
5-24 User Variable Examples
5-24
5. On the Security tab, select the Calculate Only checkbox.
This ensures that no one attempts to specify a value for this
User Variable other than its macro.
This step is a convenience and not a requirement for macro
execution.
6. On the Macros tab, select the PostExecute() checkbox. An
empty sub-routine automatically appears in the Code Editor.
Enter the PostExecute macro as follows:
The error checking is in place to so that the macro can
handle <empty> values. If the value is <empty> the
macro exits the sub-routine and continue on to the next one.
A new User Variable of type Temperature, named DewPt Temp,
now exists in all current and future instances of streams in this
case. The DewPt Temperature automatically calculates its value
during a steady state solve pass immediately after its owning
stream executes.
Figure 5.23
Macro Code
Sub PostExecute()
On Error GoTo ErrorHandler
Dim myFluid As Object
ActiveVariableWrapper.Variable.Erase
Set myFluid = ActiveObject.DuplicateFluid
FS = 0
FS = myFluid.PVFlash(ActiveObject.PressureValue, 1.0)
If FS = 0 Then ' fsFlashOK
ActiveVariableWrapper.Variable.SetValue(myFluid.Temperature.GetValue)
End If
ErrorHandler:
Exit Sub
End Sub
Komentáře k této Příručce