Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using vector user variable in HYSYS

Status
Not open for further replies.

Zsolt Ulbert

Chemical
Mar 3, 2024
2
Hi!
I would like to use a vector user variable in Hysys V14. For example, I prepared the following code to create a vector user variable using stream temperature:

Sub PostExecute()
Dim hysysuv As HYSYS.InternalRealFlexVariable
Dim varVals As Variant
Dim Count As Integer
Dim myFluid As Object
On Error GoTo GetOut
Set myFluid = ActiveObject.DuplicateFluid
'Linking to wrapper to hysysuv variable
Set hysysuv = ActiveVariableWrapper.Variable
'Setting the range
hysysuv.SetBounds 2,0,0
'Retrieving an array of values
varVals = hysysuv.Values
'Calculating values using stream temperature
For Count = 0 To 1
varVals(Count)= Count*myFluid.Temperature
Next
'varVals into hysysuv
hysysuv.SetValues varVals,"C"
'Retrieving values (using unit Kelvin)
varVals = hysysuv.GetValues ("K")
GetOut:
End Sub

I debugged the code and it looks working well, but in the user variable property windows only the <Multidimensional> word is displayed for my multidim user variable (see the attached picture). When I try to send this variable to a spreadsheet object <empty> is only inserted.
Does someone know how I can see the results of a vector variable variable and use its components?

Thanks,
Zsolt
 
 https://files.engineering.com/getfile.aspx?folder=c5168937-12c9-4160-962c-be48ca050c8a&file=vector_user_variable_Hysys.png
Status
Not open for further replies.

Part and Inventory Search

Sponsor