' Global Declarations
Dim P2StreamIn As Object, P2Strm As Object, P2StreamBulk As Object, P2StreamDec As Object
Dim szStream As String
Dim streamname As String, szData As String, Sdesc As String
Dim DoComps%, NumComps%
Dim TableRange As Object
Public ErosionVel_OUTUnit!
Public ConstraintStat!
Public ConstraintNoise!
Public GoalSeekAchv As Boolean
Public Fd!
Sub LineSizingModify(VapZ!, StndTemp!, StndPress!, temperature!, pressure!, MixedVolFlow!, VaporVolRate!, LiqVolRate!, StndVaprVol!, Col1%, Phase$, ChangeVelo!, Stati$, TwoPh$, Noise$, FlowSurge!, BulkDenstAct!, MOC$, ViscosityVap!, ViscosityLiq!, VapDens!, LiqDens!, PipeOD!, PipeThickness!, ActualVelocity!, StandardVapDen!, StandardLiqDen!, BulkViscosity!)
On Error Resume Next
Set Wf = Application.WorksheetFunction
Set UOMConvert = ActiveSheet.Range("UOMConvert")
Set TableRange = ActiveSheet.Range("UnitAttributes")
'Clear Previous Error Message, and Set Font Color to Default
ErrRow% = Application.Match("ErrorMessage", TableRange, 0)
ActiveSheet.Cells(ErrRow%, Col1%).Value = ""
ColorCells 1, Col1%
'------------------------------------------
'Pipe Line Sizing For Vapor Phase Stream
'------------------------------------------
If Phase$ = "Vapor" Then
GasSurge! = (FlowSurge! / 100) + 1
UserGasVelo! = ChangeVelo! * Application.VLookup("VELOUTINT!", UOMConvert, 2, False)
If UserGasVelo! = 0 Then
MsgBox "Velocity Cannot be Set Zero"
Exit Sub
End If
VaporVolRate! = VaporVolRate! * GasSurge! 'in m3/sec
PipeArea! = VaporVolRate! / UserGasVelo! 'get area , m3/sec divide m/sec
PipeID! = Sqr(PipeArea! * (4 / Wf.Pi)) 'get CalcID! in m
PipeIDmm! = PipeID! * 1000 'in mm
FillEqLIstWorkSheet2 Col1%, PipeID! * Application.VLookup("FINLINTOUT!", UOMConvert, 2, False), "NONE", "CalcID", 1
FillEqLIstWorkSheet2 Col1%, VapZ!, "NONE", "VapourZ", 1
FillEqLIstWorkSheet2 Col1%, StndVaprVol! * Application.VLookup("GAFINTOUT!", UOMConvert, 2, False), "NONE", "StndVaporVolRate", 1
FillEqLIstWorkSheet2 Col1%, ChangeVelo!, "NONE", "UserVelocity", 1
SearchFromPipeTable PipeIDmm!, temperature!, pressure!, MixedVolFlow!, VaporVolRate!, LiqVolRate!, Col1%, Phase$, MOC$
'Apply Velocity Constraints
RowDN% = Application.Match("DNNo", TableRange, 0)
RowActualVelo% = Application.Match("ActualVelocity", TableRange, 0)
CurrentDN! = ActiveSheet.Cells(RowDN%, Col1%).Value
ActualVelocity! = ActiveSheet.Cells(RowActualVelo%, Col1%).Value
If ActualVelocity! > ChangeVelo! Then
ErrRow% = Application.Match("ErrorMessage", TableRange, 0)
ApplyVelocityConstraint temperature!, pressure!, MixedVolFlow!, VaporVolRate!, LiqVolRate!, ActualVelocity!, CurrentDN!, Col1%, ChangeVelo!, Phase$, MOC$
End If
Constraint! = 60 * Application.VLookup("VELENGOUT!", UOMConvert, 2, False) '60ft/sec max Velo Limit for Noise
ConstraintNoise! = Constraint!
If Noise$ = "Yes" Then ApplyVelocityConstraint temperature!, pressure!, MixedVolFlow!, VaporVolRate!, LiqVolRate!, ActualVelocity!, CurrentDN!, Col1%, Constraint!, Phase$, MOC$
End If