Specifications
Extensibility 3-33
3-33
8. The first function declared is the Initialize function. It is
called when the extension is first added to HYSYS or when a
case containing the extension is loaded.
Code Explanation
Public Function Initialize(ByVal Container As
Object, ByVal IsRecalling As Boolean) As Long
Initialize is called when the extension is
first added to the simulation or when a
simulation case containing the extension
is loaded.
On Error GoTo ErrorTrap
Enable Error trapping.
Dim hyReactant As Reactant
Declare KineticReactionContainer
variable.
Initialize = extnCurrentVersion
Reference the current HYSYS version
Set hyContainer = Container
This reference lets the extension interact
with HYSYS through the extension
container, the
ExtnKineticReactionContainer object.
Methods from the ExtensionObject object
are also available.
Set hyBulkDens =
hyContainer.FindVariable("BulkDens").Variabl
e
Set an object reference to the BulkDens
variable, which is created in the EDF file.
If IsRecalling = False Then
hyBulkDens.Value = 2700
The variable IsRecalling is only False
when the extension is first added to the
simulation. This sets a default for
BulkDens (2700 kg catalyst/m
3
reactor
volume).
hyContainer.Phase = ptVapourPhase
hyContainer.ReactionBasis =
rbPartialPressBasis
Setting the remaining reaction properties
(usually found on the Basis tab of the
Reaction property view). The Phase of
the reaction is to be Vapour and the
reaction Basis is to be Partial Pressure.
hyContainer.Reactants.RemoveAll
This initializes the reactants list by
removing any reactants that may be
specified.
Set hyReactant =
hyContainer.Reactants.Add("Ethylene")
hyReactant.StoichiometricCoefficientValue
= -1
hyContainer.BaseReactant = hyReactant
Adds the component Ethylene as a
Reactant. It sets the stoichiometric
coefficient of ethylene as -1 (i.e., 1 mole
of ethylene being consumed). You are
also specifying ethylene to be the base
reactant.