Programa Hoja de Calculo Tubería
Programa Hoja de Calculo Tubería
Programa Hoja de Calculo Tubería
IDcol = 11
If Target.Row = 8 And Target.Column = IDcol Then
If ActiveSheet.Cells(8, IDcol) = "[in]" And Sheets(SNAcc).Cells(8, 40) = "[mm]" Then
Sheets(SNAcc).Cells(8, 40) = "[in]"
For i = 1 To 2000
If ActiveSheet.Cells(i + 8, IDcol) <> "" Then ActiveSheet.Cells(i + 8, IDcol) = Round(Act
iveSheet.Cells(i + 8, IDcol) / 25.4, 3):
ActiveSheet.Cells(i + 8, IDcol).NumberFormat = "0.00"
Next i
ElseIf ActiveSheet.Cells(8, IDcol) = "[mm]" And Sheets(SNAcc).Cells(8, 40) = "[in]" Then
Sheets(SNAcc).Cells(8, 40) = "[mm]"
For i = 1 To 2000
If ActiveSheet.Cells(i + 8, IDcol) <> "" Then ActiveSheet.Cells(i + 8, IDcol) = Round(Act
iveSheet.Cells(i + 8, IDcol) * 25.4, 2):
ActiveSheet.Cells(i + 8, IDcol).NumberFormat = "0.0"
Next i
ElseIf ActiveSheet.Cells(8, IDcol) = "" Then ActiveSheet.Cells(8, IDcol) = Sheets(SNAcc).Cell
s(8, 40)
End If
End If
AccCol = 15
If Target.Row > 8 And Target.Column = AccCol Then
If Sheets(SNPD).Cells(Target.Row, AccCol) <> Sheets(SNAcc).Cells(Target.Row, 44) Then Sheets(SN
Acc).Cells(Target.Row, 43) = False
End If
Columns(20).EntireColumn.Hidden = 1
Columns(21).EntireColumn.Hidden = 1
End Select
End If
End Sub
IDcol = 11
If Target.Column = IDcol And Target.Row > 8 Then
If Target.Value <> "" Then Call FormDiamGen
Target.Offset(1).Select
End If
RugCol = 12
If Target.Column = RugCol And Target.Row > 8 Then
If Target.Value <> "" Then FormRugos.Show
End If
AccCol = 15
If Target.Column = AccCol And Target.Row > 8 Then
If Target.Value <> "" Then Call FormAccGen
Target.Offset(1).Select
End If
MachCol = 25
If Target.Column = MachCol And Target.Row > 8 And ActiveSheet.Cells(Target.Row, 2) > 0.999 Then
If Target.Value <> "" Then Call FormChokeGen
FormChoke.Show
Target.Offset(1).Select
End If
End Sub
IDcol = 11
If Target.Row = 8 And Target.Column = IDcol Then Sheets(SNAcc).Cells(8, 40) = Sheets(SNPD).Cells(
8, IDcol) Else Sheets(SNAcc).Cells(8, 40) = "[mm]"
End Sub
Hoja2 - 1
AccCol = 15
If Target.Row > 8 And Sheets(SNAcc).Cells(Target.Row, 43) Then Sheets(SNPD).Cells(Target.Row, Acc
Col) = Sheets(SNAcc).Cells(Target.Row, 44)
End Sub
ThisWorkbook - 1
'PressDrop
'Sheets(1).Cells(9, 16).FormulaArray = "=PTD(B9,C9,D9,E9,F9,fanning(Re,L9/ID),H9,I9,J9,ID,M9,N9,O9)
"
'Sheets(1).Cells(9, 17).FormulaArray = "=PTD(B9,C9,D9,E9,F9,fanning(Re,L9/ID),H9,I9,J9,ID,M9,N9,O9)
"
'Sheets(1).Cells(9, 18).FormulaArray = "=PTD(B9,C9,D9,E9,F9,fanning(Re,L9/ID),H9,I9,J9,ID,M9,N9,O9)
"
'Sheets(1).Cells(9, 20) = "=-SI(B9=0,(P9-D9)/F9/9.81,((D9+1.013)/F9/9.81)*SI(I9=""Isothrm"",LN((P9+
1.013)/(D9+1.013)),(((P9+1.013)/(D9+1.013))^(1-1/k)-1)/(1-1/k)))*100000"
'Sheets(1).Cells(9, 22) = "=(C9/3600/(PI()*(ID/1000)^2/4))/MIN(F9,R9)"
'Sheets(1).Cells(9, 25) = "=SI(B9<0.999,""na"",(C9/3600/(PI()*(ID/1000)^2/4))/(SI(I9=""Isothrm"",1,
k)*MIN(F9*(D9+1.013),R9*(P9+1.013))*100000)^0.5)"
'PDropAcc
'Sheets(2).Cells(9, 1) = "=Stream"
'Sheets(2).Cells(9, 41) = "=Re"
'Sheets(2).Cells(9, 42) = "=ID"
''Sheets(2).Cells(9, 44).FormulaArray = "=SUMA(B9:AG9*TRANSPONER(KData!$G$9:$G$40))/AO9+SUMA(B9:AG9
*TRANSPONER(KData!$H$9:$H$40))*(1+1/(AP9/25,4))+SUMA(AH9:AM9*TRANSPONER(KData!$G$41:$G$46))/AO9+SUM
A(AH9:AM9*TRANSPONER(KData!$H$41:$H$46))+AN9"
''Sheets(2).Cells(9, 44) = "=KCalc(FILA(A9),AO9,AP9,B9:AN9)"
'Worksheets(2).Range("AR9").FormulaArray = "=SUM(RC[-42]:RC[-11]*TRANSPOSE(KData!R9C8:R40C8))/RC[-3
]+SUM(RC[-42]:RC[-11]*TRANSPOSE(KData!R9C9:R40C9))*(1+1/(RC[-2]/25.4))+SUM(RC[-10]:RC[-5]*TRANSPOSE
(KData!R41C8:R46C8))/RC[-3]+SUM(RC[-10]:RC[-5]*TRANSPOSE(KData!R41C9:R46C9))+RC[-4]"
'Sheets(2).Cells(9, 45) = "=Lacc"
End Sub
FormAcc - 1
End Sub
Private Sub ButtonByOther_Click()
Call FormAccByOtherGen
End Sub
Private Sub ButtonReset_Click()
End Sub
Private Sub ButtonExit_Click()
FormAcc.Hide
End Sub
Private Sub LabelZP_Click()
End Sub
FormAccByOther - 1
Forig = 10 + FormAccByOther.ComboBoxStream.ListIndex
Fcopy = 10 + FormAcc.ComboBoxStream.ListIndex
For Col = 2 To 40
Sheets(SNAcc).Cells(Fcopy, Col) = Sheets(SNAcc).Cells(Forig, Col)
Next Col
FormAccByOther.Hide
End Sub
Private Sub ButtonExit_Click()
FormAccByOther.Hide
End Sub
FormChoke - 1
' FormChoke.LabelFlow.Visible = 0
' FormChoke.TextBoxFlow.Visible = 0
' FormChoke.LabelDZ1.Visible = 0
' FormChoke.LabelDiam.Visible = 0
' FormChoke.TextBoxDiam.Visible = 0
' FormChoke.LabelDZ2.Visible = 0
Call FormChokeGen
End Sub
' FormChoke.LabelFlow.Visible = 1
' FormChoke.TextBoxFlow.Visible = 1
' FormChoke.LabelDZ1.Visible = 1
' FormChoke.LabelDiam.Visible = 1
' FormChoke.TextBoxDiam.Visible = 1
' FormChoke.LabelDZ2.Visible = 1
Call FormChokeGen
End Sub
' FormChoke.LabelFlow.Visible = 1
' FormChoke.TextBoxFlow.Visible = 1
' FormChoke.LabelDZ1.Visible = 1
' FormChoke.LabelDiam.Visible = 1
' FormChoke.TextBoxDiam.Visible = 1
' FormChoke.LabelDZ2.Visible = 1
Call FormChokeGen
End Sub
FormDiam - 1
If FormDiam.MultiPage1.SelectedItem.Index = 1 Then
ID = FormDiam.TextBoxIDO.Value
Else
ID = FormDiam.TextBoxIDN.Value
End If
If ID <> "" Then ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column) = Str(ID)
End Sub
FormDiam.Hide
End Sub
Call NPSGen
End Sub
Call SCHGen
End Sub
Call IDNCalc
End Sub
Call BWGGen
End Sub
Call IDOCalc
End Sub
FormRugos - 1
Private Sub LabelRugV1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 1
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 1
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 1
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 1
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV5_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
FormRugos - 2
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 1
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV6_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 1
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV7_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 1
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV8_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 1
LabelRugV9.Font.Italic = 0
End Sub
Private Sub LabelRugV9_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single
, ByVal Y As Single)
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 1
End Sub
FormRugos - 3
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)
If Button = 0 Then
LabelRugV1.Font.Italic = 0
LabelRugV2.Font.Italic = 0
LabelRugV3.Font.Italic = 0
LabelRugV4.Font.Italic = 0
LabelRugV5.Font.Italic = 0
LabelRugV6.Font.Italic = 0
LabelRugV7.Font.Italic = 0
LabelRugV8.Font.Italic = 0
LabelRugV9.Font.Italic = 0
End If
End Sub
FormAccMod - 1
Sub FormAccGen()
FormAcc.ComboBoxStream.Clear
FormAcc.ComboBoxStream.Value = ActiveSheet.Cells(ActiveCell.Row, 1)
Call UpDate(ActiveCell.Row)
FormAcc.Show
End Sub
Sub FormAccByOtherGen()
FormAccByOther.ComboBoxStream.Clear
FormAccByOther.ComboBoxStream.Value = ActiveSheet.Cells(ActiveCell.Row, 1)
FormAccByOther.Show
End Sub
Sub UpDate(fAcc)
'Codos 90
'FormAcc.TextBoxCodo90_1.ControlSource = Worksheets("PDropAcc").Range(.Cells(fAcc, 2))
FormAcc.TextBoxCodo90_1.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 2) + format(fAcc)
FormAcc.TextBoxCodo90_2.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 3) + format(fAcc)
FormAcc.TextBoxCodo90_3.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 4) + format(fAcc)
FormAcc.TextBoxCodo90_4.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 5) + format(fAcc)
FormAcc.TextBoxCodo90_5.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 6) + format(fAcc)
FormAcc.TextBoxCodo90_6.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 7) + format(fAcc)
FormAcc.TextBoxCodo90_7.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 8) + format(fAcc)
FormAcc.TextBoxCodo90_8.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 9) + format(fAcc)
'Codos 45
FormAcc.TextBoxCodo45_1.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 10) + format(fAcc)
FormAcc.TextBoxCodo45_2.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 11) + format(fAcc)
FormAcc.TextBoxCodo45_3.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 12) + format(fAcc)
FormAcc.TextBoxCodo45_4.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 13) + format(fAcc)
'Codos 180
FormAcc.TextBoxCodo180_1.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 14) + format(fAcc)
FormAcc.TextBoxCodo180_2.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 15) + format(fAcc)
FormAcc.TextBoxCodo180_3.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 16) + format(fAcc)
'Tees
FormAcc.TextBoxTee_1.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 17) + format(fAcc)
FormAcc.TextBoxTee_2.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 18) + format(fAcc)
FormAcc.TextBoxTee_3.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 19) + format(fAcc)
FormAcc.TextBoxTee_4.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 20) + format(fAcc)
FormAcc.TextBoxTee_5.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 21) + format(fAcc)
FormAcc.TextBoxTee_6.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 22) + format(fAcc)
FormAcc.TextBoxTee_7.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 23) + format(fAcc)
'Valvulas
FormAcc.TextBoxValve_1.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 24) + format(fAcc)
FormAcc.TextBoxValve_2.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 25) + format(fAcc)
FormAcc.TextBoxValve_3.ControlSource = "'" + SNAcc + "'!" + Chr(64 + 26) + format(fAcc)
FormAcc.TextBoxValve_4.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 1) + format(fAcc)
FormAcc.TextBoxValve_5.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 2) + format(fAcc)
FormAcc.TextBoxValve_6.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 3) + format(fAcc)
FormAcc.TextBoxValve_7.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 4) + format(fAcc)
FormAcc.TextBoxValve_8.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 5) + format(fAcc)
FormAcc.TextBoxValve_9.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 6) + format(fAcc)
FormAcc.TextBoxValve_10.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 7) + format(fAcc)
'Varios
FormAcc.TextBoxVarios_1.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 8) + format(fAcc)
FormAcc.TextBoxVarios_2.ControlSource = "'" + SNAcc + "'!A" + Chr(64 + 9) + format(fAcc)
FormAccMod - 2
End Sub
Sub Reset(fAcc)
RtaReset = MsgBox("This action will DELETE charged accesories. Do you wish to continue?", vbYesNo
, "Delete Accesories")
If RtaReset = 6 Then
For C = 2 To 40
Sheets(SNAcc).Cells(fAcc, C) = ""
Next
End If
End Sub
FormChokeMod - 1
Sub FormChokeGen()
w = ActiveSheet.Cells(ActiveCell.Row, 3)
Pc = (ActiveSheet.Cells(ActiveCell.Row, 4) + 1.013) * 100000
Tc = ActiveSheet.Cells(ActiveCell.Row, 5) + 273
d = ActiveSheet.Cells(ActiveCell.Row, 6)
visc = ActiveSheet.Cells(ActiveCell.Row, 7) / 1000
Cp = ActiveSheet.Cells(ActiveCell.Row, 8)
U = ActiveSheet.Cells(ActiveCell.Row, 9)
Tamb = ActiveSheet.Cells(ActiveCell.Row, 10) + 273
If ActiveSheet.Cells(8, 11) = "[in]" Then
Dint = ActiveSheet.Cells(ActiveCell.Row, 11) * 0.0254
Else
Dint = ActiveSheet.Cells(ActiveCell.Row, 11) / 1000
End If
e = ActiveSheet.Cells(ActiveCell.Row, 12) / 1000
L = ActiveSheet.Cells(ActiveCell.Row, 13)
s = ActiveSheet.Cells(ActiveCell.Row, 14) * (3.1416 / 180)
SumK = ActiveSheet.Cells(ActiveCell.Row, 15)
R = 8314
M = d * R * Tc / Pc
Gw = (w / 3600) / (3.1416 * Dint ^ 2 / 4)
f = fanning(Gw * Dint / visc, e / Dint)
Lacc = Sgn(L) * SumK / (4 * f / Dint)
Ltot = L + Lacc
End Sub
g = 9.8
R = 8314
L = 0
Case Is = 1 'actual
If U = "Isothrm" Then
Do
d = P * M / (R * T)
v = Gw / d
vc = (P / d) ^ 0.5
If L > 10000 Then dL = 1 Else dL = 0.1
If L > 1000000 Then L = "high": Exit Do
dPdL = -(d * g * Sin(s) + d * v ^ 2 / 2 * (4 * f / Dint)) / (1 - d * v ^ 2 / P)
dTdL = 0
L = L + dL
P = P + dPdL * dL
T = T + dTdL * dL
Loop Until v >= vc
Else
Do
d = P * M / (R * T)
v = Gw / d
vc = (P / d) ^ 0.5
If L > 10000 Then dL = 1 Else dL = 0.1
If L > 1000000 Then L = "high": Exit Do
dPdL = (-Cp * (d * g * Sin(s) + d * v ^ 2 / 2 * (4 * f / Dint)) + 4 * U * v / Dint * (1 - T
amb / T)) / (Cp * (1 - d * v ^ 2 / P) + v ^ 2 / T)
dTdL = -(g * Sin(s) + v ^ 2 / 2 * (4 * f / Dint) + (1 - d * v ^ 2 / P) * (4 * U / (d * v *
Dint)) * (T - Tamb)) / (Cp * (1 - d * v ^ 2 / P) + v ^ 2 / T)
L = L + dL
P = P + dPdL * dL
T = T + dTdL * dL
Loop Until v >= vc
FormChokeMod - 2
End If
Case Is = 2 'isotermico
k = 1
If s = 0 Then
d = P * M / (R * T)
rc = (Gw ^ 2 / (k * d * P)) ^ (k / (k + 1))
L = (Log(rc ^ (2 / k)) + P / (Gw ^ 2 / (2 * d)) * (1 - rc ^ (1 + 1 / k)) / (1 + 1 / k)) / (4
* f / Dint)
P = rc * P
T = T * rc ^ (1 - 1 / k)
Else
Do
d = P * M / (R * T)
v = Gw / d
vc = (P / d) ^ 0.5
If L > 10000 Then dL = 1 Else dL = 0.1
If L > 1000000 Then L = "high": Exit Do
dPdL = -(d * g * Sin(s) + d * v ^ 2 / 2 * (4 * f / Dint)) / (1 - d * v ^ 2 / P)
dTdL = 0
L = L + dL
P = P + dPdL * dL
T = T + dTdL * dL
Loop Until v >= vc
End If
Case Is = 3 'adiabatico
k = Cp / (Cp - R / M)
If s = 0 Then
d = P * M / (R * T)
rc = (Gw ^ 2 / (k * d * P)) ^ (k / (k + 1))
L = (Log(rc ^ (2 / k)) + P / (Gw ^ 2 / (2 * d)) * (1 - rc ^ (1 + 1 / k)) / (1 + 1 / k)) / (4
* f / Dint)
P = rc * P
T = T * rc ^ (1 - 1 / k)
Else
Do
d = P * M / (R * T)
v = Gw / d
vc = (P / d) ^ 0.5
If L > 10000 Then dL = 1 Else dL = 0.1
If L > 1000000 Then L = "high": Exit Do
dPdL = (-Cp * (d * g * Sin(s) + d * v ^ 2 / 2 * (4 * f / Dint))) / (Cp * (1 - d * v ^ 2 / P)
+ v ^ 2 / T)
dTdL = -(g * Sin(s) + v ^ 2 / 2 * (4 * f / Dint)) / (Cp * (1 - d * v ^ 2 / P) + v ^ 2 / T)
L = L + dL
P = P + dPdL * dL
T = T + dTdL * dL
Loop Until v >= vc
End If
End Select
If L = "high" Then
FormChoke.TextBoxLength.Value = ">10E+6"
FormChoke.TextBoxPress.Value = "? " + format(Round(P / 100000 - 1.013, 2))
FormChoke.TextBoxTemp.Value = "? " + format(Round(T - 273, 1))
Else
FormChoke.TextBoxLength.Value = Round(L, 0)
FormChoke.TextBoxPress.Value = Round(P / 100000 - 1.013, 2)
FormChoke.TextBoxTemp.Value = Round(T - 273, 1)
End If
End Sub
R = 8314
d = P * M / (R * T)
If Ltot < 0 Then
FormChoke.TextBoxFlow.Value = "L<0"
Else
Select Case evol
Case Is = 1 'actual
Gwmax = ""
Case Is = 2 'isotermico + Dz=0
FormChokeMod - 3
k = 1
rc = 1
For i = 1 To 9
For j = 1 To 10
Gwmax = ((k * d * P) * rc ^ (1 + 1 / k)) ^ 0.5
f1 = fanning(Gwmax * Dint / visc, e / Dint)
M1 = Log(rc ^ (2 / k)) + P / (Gwmax ^ 2 / (2 * d)) * (1 - rc ^ (1 + 1 / k)) / (1 + 1 / k)
M2 = 4 * f1 * Ltot / Dint
If M1 < M2 Then rc = rc - 10 ^ (-i) Else Exit For
Next j
rc = rc + 10 ^ (-i)
Next i
Case Is = 3 'adiabatico + Dz=0
k = Cp / (Cp - R / M)
rc = 1
For i = 1 To 9
For j = 1 To 10
Gwmax = ((k * d * P) * rc ^ (1 + 1 / k)) ^ 0.5
f1 = fanning(Gwmax * Dint / visc, e / Dint)
M1 = Log(rc ^ (2 / k)) + P / (Gwmax ^ 2 / (2 * d)) * (1 - rc ^ (1 + 1 / k)) / (1 + 1 / k)
M2 = 4 * f1 * Ltot / Dint
If M1 < M2 Then rc = rc - 10 ^ (-i) Else Exit For
Next j
rc = rc + 10 ^ (-i)
Next i
End Select
If Gwmax = "" Then
FormChoke.TextBoxFlow.Value = "?"
Else
wmax = Gwmax * (3.1416 * Dint ^ 2 / 4) * 3600
FormChoke.TextBoxFlow.Value = Round(wmax, 0)
End If
End If
End Sub
R = 8314
d = P * M / (R * T)
End Sub
FormDiamMod - 1
Sub FormDiamGen()
Call NPSGen
Call ODGen
FormDiam.Show
End Sub
Sub NPSGen()
PrevNPS = FormDiam.ComboBoxNPS.Value
FormDiam.ComboBoxNPS.Clear
For i = 2 To 31
If FormDiam.CheckBoxNPS.Value Then
FormDiam.ComboBoxNPS.AddItem PipeData(i, 1)
Else
If PipeData(i, 21) <> "" Then FormDiam.ComboBoxNPS.AddItem PipeData(i, 1)
End If
Next i
FormDiam.ComboBoxNPS.Value = PrevNPS
If FormDiam.ComboBoxNPS.MatchFound = 0 Then FormDiam.ComboBoxNPS.Value = ""
End Sub
Sub SCHGen()
PrevSCH = FormDiam.ComboBoxSCH.Value
FormDiam.ComboBoxSCH.Clear
For i = 2 To 31
If format(PipeData(i, 1)) = FormDiam.ComboBoxNPS.Value Then
For j = 3 To 20
SCHP = PipeData(i, j)
If SCHP <> "" Then FormDiam.ComboBoxSCH.AddItem PipeData(1, j)
Next j
End If
Next i
FormDiam.ComboBoxSCH.Value = PrevSCH
If FormDiam.ComboBoxSCH.MatchFound = 0 Then
If FormDiam.ComboBoxNPS.Value <> "" Then FormDiam.ComboBoxSCH.Value = "STD" Else FormDiam.Combo
BoxSCH.Value = ""
End If
End Sub
Sub IDNCalc()
For i = 2 To 31
If format(PipeData(i, 1)) = FormDiam.ComboBoxNPS.Value Then
OD = PipeData(i, 2)
For j = 3 To 20
If format(PipeData(1, j)) = FormDiam.ComboBoxSCH.Value Then esp = PipeData(i, j)
Next j
End If
Next i
End Sub
Sub ODGen()
PrevOD = FormDiam.ComboBoxOD.Value
FormDiam.ComboBoxOD.Clear
For i = 2 To 12
FormDiam.ComboBoxOD.AddItem TubeData(i, 1)
Next i
FormDiam.ComboBoxOD.Value = PrevOD
If FormDiam.ComboBoxOD.MatchFound = 0 Then FormDiam.ComboBoxOD.Value = ""
End Sub
Sub BWGGen()
PrevBWG = FormDiam.ComboBoxBWG.Value
FormDiam.ComboBoxBWG.Clear
For i = 2 To 12
If format(TubeData(i, 1)) = FormDiam.ComboBoxOD.Value Then
For j = 3 To 20
BWGP = TubeData(i, j)
If BWGP <> "" Then FormDiam.ComboBoxBWG.AddItem TubeData(1, j)
Next j
End If
Next i
FormDiam.ComboBoxBWG.Value = PrevBWG
If FormDiam.ComboBoxBWG.MatchFound = 0 Then FormDiam.ComboBoxBWG.Value = ""
End Sub
Sub IDOCalc()
For i = 2 To 12
If format(TubeData(i, 1)) = FormDiam.ComboBoxOD.Value Then
OD = TubeData(i, 2)
For j = 3 To 20
If format(TubeData(1, j)) = FormDiam.ComboBoxBWG.Value Then esp = TubeData(i, j)
Next j
End If
Next i
End Sub
Friction - 1
End Function
Function Rugosidad(material)
'Rugosidad (mm)
End Function
PressDrop - 1
Function PTD(Xm, w, P0, T0, d0, f, Cp, U, Tamb, Dint, L, Slp, SumK)
Dim PTDm(1 To 3)
g = 9.81
P = (P0 + 1.013) * 100000
T = T0 + 273
d = d0
R = 8314
M = d * R * T / P
k = Cp / (Cp - R / M)
Tamb = Tamb + 273
Dint = Dint / 1000
Gw = (w / 3600) / (3.1416 * Dint ^ 2 / 4)
Lacc = Sgn(L) * SumK / (4 * f / Dint)
Ltot = L + Lacc
Ztot = L * Sin(Slp * 3.1416 / 180)
Select Case Xm
d = P * M / (R * T)
v = Gw / d
vc = (P / d) ^ 0.5
If v >= vc Then Pc = "CHOKE": Exit Do
dP1dL = -(d * g * Sin(s) + d * v ^ 2 / 2 * (4 * f / Dint)) / (1 - d * v ^ 2 / P)
dT1dL = 0
PressDrop - 2
P1 = P + dP1dL * dL
T1 = T + dT1dL * dL
d1 = P1 * M / (R * T1)
v1 = Gw / d1
vc = (P1 / d1) ^ 0.5
If v1 >= vc Then Pc = "CHOKE": Exit Do
dP2dL = -(d1 * g * Sin(s) + d1 * v1 ^ 2 / 2 * (4 * f / Dint)) / (1 - d1 * v1 ^ 2 / P1)
dT2dL = 0
P2 = P + dP2dL * dL
T2 = T + dT2dL * dL
P = (P1 + P2) / 2
T = (T1 + T2) / 2
Loop Until i = n
Else
Do
i = i + 1
dL = Ltot * (1 / n1 + (1 / n2 - 1 / n1) * ((i - 1) / (n - 1)))
Li = Li + dL
If Li > L Then s = 0 Else s = Slp * (3.1416 / 180)
d = P * M / (R * T)
v = Gw / d
vc = (k * P / d) ^ 0.5
If v >= vc Then Pc = "CHOKE": Exit Do
dP1dL = (-Cp * (d * g * Sin(s) + d * v ^ 2 / 2 * (4 * f / Dint)) + 4 * U * v / Dint * (1
- Tamb / T)) / (Cp * (1 - d * v ^ 2 / P) + v ^ 2 / T)
dT1dL = -(g * Sin(s) + v ^ 2 / 2 * (4 * f / Dint) + (1 - d * v ^ 2 / P) * (4 * U / (d * v
* Dint)) * (T - Tamb)) / (Cp * (1 - d * v ^ 2 / P) + v ^ 2 / T)
P1 = P + dP1dL * dL
T1 = T + dT1dL * dL
d1 = P1 * M / (R * T1)
v1 = Gw / d1
vc = (k * P1 / d1) ^ 0.5
If v1 >= vc Then Pc = "CHOKE": Exit Do
dP2dL = (-Cp * (d1 * g * Sin(s) + d1 * v1 ^ 2 / 2 * (4 * f / Dint)) + 4 * U * v1 / Dint *
(1 - Tamb / T1)) / (Cp * (1 - d1 * v1 ^ 2 / P1) + v1 ^ 2 / T1)
dT2dL = -(g * Sin(s) + v1 ^ 2 / 2 * (4 * f / Dint) + (1 - d1 * v1 ^ 2 / P1) * (4 * U / (d
1 * v1 * Dint)) * (T1 - Tamb)) / (Cp * (1 - d1 * v1 ^ 2 / P1) + v1 ^ 2 / T1)
P2 = P + dP2dL * dL
T2 = T + dT2dL * dL
P = (P1 + P2) / 2
T = (T1 + T2) / 2
Loop Until i = n
End If
Case Else
PTD = "ERROR"
End Select
End Function