1

I've build a simulation template in Aspen HYSYS V9 and want to transfer the data for the column internals such as internal type, tray/packing type and end stage from an Excel sheet to HYSYS using VBA Automation. I have not found the internals in the object browser so I tried accessing the internals with a backdoor variable. To find out the moniker I recorded a script in which I opened the "internals"-page of a column and changed the type from trayed to packed and back to trayed. The script shows the following:

Message "FlowSht.1/UnitOpObject.400(Regenerator)" "view"
Message "FlowSht.1/UnitOpObject.400(Regenerator)/FlowSht.600" "MakeMeActiveColumnOp"
SpecWhileSolving Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":Enum.590.0"  0.000000000000e+000 
SpecWhileSolving Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":Enum.590.0"  0.000000000000e+000
SpecWhileSolving Message "FlowSht.1/UnitOpObject.400(Regenerator)/FlowSht.600" "MakeMeActiveColumnOp"
Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":PageNumber.0"  1.000000000000e+001
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Selection.711.0"  1.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Selection.711.0"  0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709"  0.000000000000e+000

Then I wrote the following vba code:

Dim hyfs As Flowsheet
Dim hyfsBD As BackDoor
Dim hyBDVar As RealVariable

Set hyfs = hycase.Flowsheet
Set hyfsBD = hyfs

Set hyBDVar = hyfsBD.BackDoorVariable("Utility.300(Internals-1@Main Tower@COL1)" & ":Selection.711.0").Variable

hyBDVar.SetValue 1, ""

But the return value of hyBDVar is -32767 and I get an error message: "The method "Set Value" for the object "InternalRealVariable" failed."

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
M.Cherry
  • 11
  • 3
  • Looks like a type error. Are you sure this method returns a datatype `Real`? – Ryan Wildry Jan 07 '19 at 12:31
  • @RyanWildry I am not sure but I've found a case on the Aspen TechSupport Site that suggested this syntax. They also mentioned that I could define hyBDVar as Object but the same error occurs. Do you have an alternative suggestion? Also the current value of this part : `hyfsBD.BackDoorVariable("Utility.300(Internals-1@Main Tower@COL1)" & ":Selection.711.0").Variable` during step-by-step-debugging is -32767, which is the default value when the variable has an empty value in the simulation. But I have defined a value in the simulation. – M.Cherry Jan 07 '19 at 13:02

1 Answers1

0

So I kind of found a solution myself but it brings up another question. One can specify the internals of a column by accessing through the subflowsheet of the column. I found out the monikers by using the same method as above and the script showed the following:

Message "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" "CloseViewX"
Message "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" "view"
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" ":Enum.591.1"  0.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)" ":Enum.591.1"  0.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  0.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  1.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  3.000000000000e+000
Specify "FlowSht.1/UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550" ":Selection.201"  2.000000000000e+000

The values 0,1,3 and 2 stand for the internal column types Sieve, Valve, Bubble Cap and Packed.

The following code works for that specification:

Dim hyfs As Flowsheet
Dim hyfsBD As BackDoor
Dim hyBDVar As RealVariable

Set hyfs = hycase.Flowsheet
Set hyfsBD = hyfs

Set hyBDVar = hyfsBD.BackDoorVariable("UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower)/TrayStageData.550:Selection.201").Variable

hyBDVar.SetValue 1, ""

In this case the column is specified as a valve column.

When choosing a packed column type the packing material can be chosen by using this backdoor variable:

hyBDVar = hyfsBD.BackDoorVariable("UnitOpObject.400(Absorber)/FlowSht.600/UnitOpObject.400(Main Tower):ExtraData.523.0).Variable

The other monikers for the internal specifications can be found out by recording a script and varying the the specifications in the subflowsheet.

The question that remains is how the hydraulic plots can be accessed, how the specifications for these plots can be made and why the backdoor variable mentioned in the question didn't work for that. But I'll post a new question for that.

M.Cherry
  • 11
  • 3