I am trying to calculate pipe thickness by coding in hysys using user variable option. I am using pipe segment where the user variable is available. To calculate pipe thickness I need some parameters given below.
1. Temperature(T) and Pressure(P) of inlet stream of pipe segment.
2. Diameter and thickness selected inside the pipe segment.
The problem is I can read T,P from the stream easily by using my code.
===========================
Sub PostExecute()
On Error GoTo ErrorHandler
Dim myFluid As Object
Dim T ,P, Thk,OD,S,E,Y,CA As Double
Set myFluid = ActiveObject.DuplicateFluid
'initial variable---------------------------
S=20*10^3 'strength
Y=0.4 '(API 14E)
CA=0.118 'inch (Corrosion Allowance)
OD=1.939 'inch Outer Diameter
E=1.0 'joint efficiency
'-------------------------------------------
T=myFluid.Temperature.GetValue("F")
P=myFluid.Pressure.GetValue("Psig")
P=P*1.2 'design pressure
Thk=P*OD/2.0/(S*E+P*Y)+CA
'thickness
ActiveVariableWrapper.Variable.SetValue Thk,"in"
ErrorHandler:
Exit Sub
End Sub
=======================================
This code is working when I write it inside the Stream User Variable code window.
But I want to read these data (T,P, OD) from Pipe Segment User Variable code window.
Can anyone help me. Is there any document where I can get code sample regarding Pipe Segment User Variable Coding?
Regards