UniSim Design Customization Guide
UniSim Design Customization Guide
Customization Guide
Copyright
June 2005 R350 Release
The information in this help file is subject to change over time. Honeywell may make
changes to the requirements described. Future revisions will incorporate changes,
including corrections of typographical errors and technical inaccuracies.
Honeywell
300-250 York Street
London, Ontario
N6A 6K2
Telephone: (519) 679-6570
Facsimile: (519) 679-3977
Prepared in Canada.
Table of Contents
1 Introduction ......................................................... 1-1
1.1 Customization.................................................. 1-2
1.2 Automation & Extensibility................................. 1-3
1.3 Customizing UniSim Design ............................... 1-7
2 Automation........................................................... 2-1
2.1 Introduction .................................................... 2-2
2.2 Objects........................................................... 2-2
2.3 Automation Syntax........................................... 2-9
2.4 Key UniSim Design Objects...............................2-19
2.5 Example 1: The Macro Language Editor..............2-46
2.6 Example 2: Automation in Visual Basic...............2-52
iii
5 User Variables ...................................................... 5-1
5.1 Introduction .................................................... 5-2
5.2 Adding a User Variable...................................... 5-2
5.3 Importing/Exporting User Variables .................... 5-6
5.4 User Variable View ........................................... 5-8
5.5 Data Types.....................................................5-10
5.6 User Variables Tabs .........................................5-13
5.7 Code Editor ....................................................5-21
5.8 User Variable Examples....................................5-22
Index.................................................................... I-1
iv
Introduction 1-1
1 Introduction
1-1
1-2 Customization
1.1 Customization
Unlike its accompanying volumes, the Customization Guide does
not discuss exact procedures for accomplishing tasks within
UniSim Design. The purpose of this volume is to demonstrate
the possible simulation technologies that can be created both
within UniSim Design and also in addition to the application.
UniSim Design incorporates an advanced software architecture
and OLE Technology to provide a component-based framework
that can be easily customized, updated and maintained to meet
changing user requirements.
Method Description
Automation The use of third party tools such as Visual Basic or the
UniSim Design Macro Language Editor to programmatically
run UniSim Design.
Extensibility The creation of custom unit operations, property packages
and kinetic reactions which become part of the simulation
and function as built in UniSim Design objects.
1-2
Introduction 1-3
Tool Description
The Macro Language An interactive design environment for developing,
Editor testing and executing WinWrap basic scripts.
For more information on User Variables and the Allow you to increase the functionality of UniSim
User Variables and User User Unit Operation Design by creating your own variables or unit
Unit Ops see Chapter 5 operations.
- User Variables and
Chapter 6 - User Unit
Operation.
1.2 Automation &
Extensibility
1.2.1 Automation
Automation allows programmers to expose objects within a
program for use by other applications. The exposed objects
provide the means by which different applications can interact
with each other and the operating system. Automation is a
standard based on Microsoft's Component Object Model (COM).
It is not necessary to understand all the intricacies of
Automation or COM in order to utilize the functionality they
provide.
1-3
1-4 Automation & Extensibility
1.2.2 Extensions
The UniSim Design architecture allows direct extensibility for
unit operations, kinetic reactions, and property packages.
Extensibility can be described as the ability to augment existing
functionality in a direct and seamless manner. Unit operation
extensions look and feel like the existing operations in UniSim
Design but the algorithms used by the extension reside in a
1-4
Introduction 1-5
The EDF file acts as the interface view within UniSim Design as
well as the point for variable declaration and storage. It is
created through the Extension View Editor which is included with
your copy of UniSim Design. The View Editor is similar to the
tool used by Honeywell Developers when creating the views for
UniSim Design.
1-5
1-6 Automation & Extensibility
Once you find the appropriate extension, you can select it and
begin using it as though it were a built-in UniSim Design object.
1-6
Introduction 1-7
1-7
1-8 Customizing UniSim Design
1-8
Introduction 1-9
Figure 1.2
Figure 1.3
1-9
1-10 Customizing UniSim Design
Once the Application and Case objects have been created, other
UniSim Design objects can be accessed through them. For
example, from the Case's flowsheet object (accessed through
the flowsheet property of the Case), you can create new Process
Streams and Unit Operations.
1-10
Introduction 1-11
VBA
Microsoft Excel and related products make use of Visual Basic
for Applications (VBA). VBA is a high level programming
language that is oriented around an object framework and event
driven execution. Visual Basic is termed “visual” because most
applications are created around a graphical interface and Visual
Basic is designed to allow code associated with the interface to
be added easily and intuitively.
1-11
1-12 Customizing UniSim Design
1-12
Automation 2-1
2 Automation
2.1 Introduction................................................................................... 2
2-1
2-2 Introduction
2.1 Introduction
Automation, defined in its simplest terms, is the ability to drive
one application from another. For example, the developers of
Product A have decided in the design phase that it would make
their product more usable if they exposed Product A’s objects,
thereby making it accessible to Automation. Since Products B, C
and D all have the ability to connect to applications that have
exposed objects, each can programmatically interact with
Product A.
2.2 Objects
The key to understanding Automation lies in the concept of
objects. An object is a container that holds a set of related
functions and variables. In Automation terminology, the
functions of an object are called methods and the variables are
called properties.
2-2
Automation 2-3
Figure 2.1
Object: Car
2-3
2-4 Objects
The UniSim Design type library reveals over 340 objects that
contain over 5000 combined properties and methods. For every
object, the type library shows its associated properties and
methods. For every property, the type library shows its return
type. For every method, the type library shows what type of
arguments are required and what type of value might be
returned.
2-4
Automation 2-5
2-5
2-6 Objects
The first step is to begin with one of the starting objects. The
Application and SimulationCase objects are the starting points in
UniSim Design. You can visualize what is available from the
Application object by picturing the UniSim Design application
view when the program is first started. You can do the same
with the SimulationCase object by thinking of all the information
contained within a case. Nearly all the objects of interest are
accessed from the SimulationCase object.
Figure 2.2
2-6
Automation 2-7
Figure 2.3
2-7
2-8 Objects
Figure 2.4
Figure 2.5
2-8
Automation 2-9
SimulationCase.Flowsheet.Streams.
Item(“Feed_Stream”).TemperatureValue
Early Binding:
Dim|Public|Private objectvar As ObjectName as
specified in the type library
Late Binding:
Dim|Public|Private objectvar As Object
2-9
2-10 Automation Syntax
Set Keyword
Connections or references to object variables are made by using
the Set keyword.
Syntax:
Set objectvar = object.[object…].object | Nothing
Example: Set
Dim hyStream As ProcessStream
Set hyStream =
hyCase.Flowsheet.MaterialStreams.Item(0)
GetObject, CreateObject
In order to begin communication between the client and server
applications, an initial link to the server application must be
established. In UniSim Design this is accomplished through the
starting objects: Application or SimulationCase. The typical
ActiveX object structure supplies a starting object to access the
application interface and another to access the documents
within the application.
GetObject([pathname] [, class])
where:
2-10
Automation 2-11
2-11
2-12 Automation Syntax
2-12
Automation 2-13
Sub-routine Method
object.method argument1, argument2
2-13
2-14 Automation Syntax
2-14
Automation 2-15
Collection Objects
A collection object is an object that contains a set of other
objects. This is similar to an array of objects. The difference
between an array of objects and a collection object is that a
collection object contains a set of properties and methods for
navigating and manipulating the objects in the collection.
2-15
2-16 Automation Syntax
2-16
Automation 2-17
Variants
A property can return a variety of variable types. Values such as
temperature and pressure are returned as doubles or 32-bit
floating-point values. The stream name property returns a string
value. Visual Basic provides an additional variable called a
variant. A variant is a variable that can take on the form of any
type of variable including, Integers, Double, String, Array, and
Objects.
2-17
2-18 Automation Syntax
2-18
Automation 2-19
2-19
2-20 Key UniSim Design Objects
2-20
Automation 2-21
Flowsheet(s)
The main flowsheet object is accessed through the
SimulationCase object. The flowsheet object is a container of all
the ProcessStream and Operations objects as well as a link to
the FluidPackage object associated with that flowsheet. Each
flowsheet and sub-flowsheet can have its own fluid package and
likewise its own property package and set of components. Sub-
flowsheets can be accessed from the main flowsheet object
through the flowsheet collection object.
2-21
2-22 Key UniSim Design Objects
2-22
Automation 2-23
FluidPackage(s)
Although both examples of syntax shown below lead you to a
FluidPackage object, there are differences that exist which are
only apparent when attempting to use the fluid package.
Example: FluidPackage
Dim hyFluidPackages As FluidPackages
Dim hyFluidPackage As FluidPackage
Set hyFluidPackages =
hyCase.BasisManager.FluidPackages
MsgBox “Number of Fluid Packages = “ &
hyFluidPackages.Count
Set hyFluidPackage = hyFluidPackages.Item(0)
2-23
2-24 Key UniSim Design Objects
PropPackage (PropertyPackage)
The PropPackage object is accessed through the FluidPackage
object. Each FluidPackage object can have a single PropPackage
object. The type of property package can be determined through
the PropPackage TypeName property or through the
PropertyPackageName property of the FluidPackage object. Each
property package has a set of unique properties and methods
along with the common ones shared among all property
packages.
2-24
Automation 2-25
Component(s)
The Components object is accessed through the FluidPackage
object. Each FluidPackage can have its own unique set of
Components.
Example: Components
Dim numComp As Integer
Dim hyFluidPackage As FluidPackage
Dim hyBasis As BasisManager
Dim hyComponents As Components
Dim hyComponent As Component
Set hyBasis = hyCase.BasisManager
Set hyFluidPackage = hyBasis.FluidPackages.Item(0)
Set hyComponents = hyFluidPackage.Components
numComp = 0
For Each hyComponent In hyComponents
If hyComponent.NormalBoilingPointValue < 0 Then
numComp = numComp + 1
End If
Next hyComponent
MsgBox numComp & “ components have NBP below 0"
2-25
2-26 Key UniSim Design Objects
Hypotheticals
The HypoGroups collection object is accessed from the
BasisManager. This object contains a collection of HypoGroup
objects, each of which provides access to a HypoComponents
object. A HypoComponent can be entirely specified through
Automation and added to a UniSim Design simulation case.
Methods for the HypoComponent object are used to estimate
properties based on the minimum data requirement.
Syntax: Hypotheticals
SimulationCase.BasisManager.HypoGroups.Item(0).HypoCo
mponents.Item(0)
Hypotheticals have a '*' The example below, adds a hypothetical component and sets its
appended to the name
once they are created.
boiling point value in order to estimate the remaining properties.
The StartBasisChange and EndBasisChange methods are
invoked prior to adding this hypothetical to the case.
Example: HypoComponent
Dim hypGroups As HypoGroups
Dim hypoComp As Object
hyCase.BasisManager.StartBasisChange
Set hypGroups = hyCase.BasisManager.HypoGroups
hypGroups.Add “myhypo”
hypGroups.Item(“myhypo”).HypoComponents.Add
“mycomponent”, “userhypo”
Set hypoComp =
hypGroups.Item(“myhypo”).HypoComponents.Item(“mycompo
nent*”)
hypoComp.NormalBoilingPointValue = 300
hypoComp.Estimate
MsgBox hypoComp.NormalBoilingPointValue
hyCase.BasisManager.EndBasisChange
2-26
Automation 2-27
OilManager
Assays and Blends are not Set through the BasisManager, the OilManager object provides
estimated until the
EndOilChange method is
access to the oils environment. Like changes made to the
invoked. objects accessed through the BasisManager, notification to the
simulation environment is required when modifying assays or
blends. This is accomplished by calling the StartOilChange and
EndOilChange methods. Calling the StartOilChange method
before calling the StartBasisChange method by default causes
the StartBasisChange method to be invoked.
2-27
2-28 Key UniSim Design Objects
Syntax: Assays
Referencing a Collection
Set hyAssays = hyCase.BasisManager.OilManager.Assays
Referencing a Member
Set hyAssay =
hyCase.BasisManager.OilManager.Assays.Item(“name”)
Adding an Assay
hyCase.BasisManager.OilManager.Assays.Add “name”,
AssayType
2-28
Automation 2-29
Blend(s)
Blends are created through the BasisManager and can be
completed by specifying at least one assay. Multiple assays can
be used in a blend as long as flow rates for each of the assays is
specified. A large number of blend properties for the
2-29
2-30 Key UniSim Design Objects
Referencing a Member
Set hyBlend =
hyCase.BasisManager.OilManager.Blend.Item(“blendname”
)
Installing to a ProcessStream
hyBlend.InstallIntoStream “StreamName”
Example: Blends
Dim hyBlend As Blend
'//create blend and assign assay
Set hyBlend =
hyBasis.OilManager.Blends.Add(“BlendName”)
hyBlend.AddAssay “AssayName”
'//print out some properties
Dim hyVar As Variant
hyvar = hyBlend.TrueBPTemperatureValue
For i = 0 To UBound(hyVar)
Debug.Print hyVar(i)
Next i
hyBlend.InstallIntoStream “Blend_Stream”
2-30
Automation 2-31
ProcessStream
The Streams object is a collection object returned by the
flowsheet. The Streams collection contains one or more
ProcessStream objects. There are approximately 124 properties
associated with the ProcessStream, including attributes such as
temperature, pressure, density, and viscosity. These properties
return values of type Double. The ProcessStream object also
returns arrays as variants for properties such as
ComponentMassFraction. The Fluid object contains a similar set
of properties and methods.
By Index
SimulationCase.Flowsheet.MaterialStreams.Item(j)
2-31
2-32 Key UniSim Design Objects
Example 1: ProcessStream
Dim hyFlowsheet As Object
Dim hyStream As Object
Set hyFlowsheet = hyCase.Flowsheet
Set hyStream = hyFlowsheet.MaterialStreams.Item(0)
MsgBox “Stream Temperature = “ &
hyStream.TemperatureValue
Example 2: ProcessStream
Dim hyFlowsheet As Flowsheet
Dim hyStream As ProcessStream
Dim hyComponents As Components
Dim hyCompFrac As Variant
Set hyFlowsheet = hyCase.Flowsheet
Set hyComponents =
hyCase.BasisManager.FluidPackages.Item(0).Components
Set hyStream = hyFlowsheet.MaterialStreams.Item(2)
hyCompFrac = hyStream.ComponentMassFractionValue
For j = 0 To UBound(hyCompFrac)
MsgBox “Component “ & hyComponents.Item(j) & “ Mass
Fraction = “ & hyCompFrac(j)
Next j
2-32
Automation 2-33
Fluid
A Fluid object is derived from a single ProcessStream through
the DuplicateFluid method. A Fluid object is essentially an
internal copy of the ProcessStream that can be manipulated for
property calculation purposes. The ProcessStream and Fluid
share many of the same properties. A Fluid however can be
flashed without interfering with the simulation case.
Example: Fluid
Public Sub FluidExample(pressureval As Double)
Dim hyFluid As Fluid
Dim hyStream As ProcessStream
Set hyStream =
hyCase.Flowsheet.MaterialStreams.Item(0)
Set hyFluid = hyStream.DuplicateFluid
hyFluid.PVFlash pressureval, 0
MsgBox “Bubble Point Temperature = “ &
hyFluid.TemperatureValue
End Sub
2-33
2-34 Key UniSim Design Objects
FluidPhase(s)
PhaseTypes (constants): The FluidPhases collection object is derived from the Fluid
• ptUnknownPhase object. Each FluidPhase in the collection contains a set of
• ptCombinedLiquidPhase
properties and methods that are similar to the Fluid itself except
• ptCombinedPhase
• ptLiquid2Phase that the properties correspond to a specific phase of the Fluid.
• ptLiquidPhase The PhaseType property of the FluidPhase objects can be
• ptPolymerPhase
accessed to determine the type of phase.
• ptSolidPhase
• ptVapourPhase
Syntax: FluidPhase(s)
Through Collection
Set hyFluidPhase = hyFluid.FluidPhases.Item(0)
HeavyLiquidPhase
Set hyFluidPhase = hyFluid.HeavyLiquidPhase
LightLiquidPhase
Set hyFluidPhase = hyFluid.LightLiquidPhase
VapourPhase
Set hyFluidPhase = hyFluid.VapourPhase
Example: FluidPhase
Dim i As Integer
Dim hyCase As SimulationCase
Dim hyfluid As Fluid
Dim hystream As ProcessStream
Dim hyPhase As FluidPhase
Dim hyPhases As FluidPhases
Set hystream =
hyCase.Flowsheet.MaterialStreams.Item(0)
Set hyfluid = hystream.DuplicateFluid
Set hyPhases = hyfluid.FluidPhases
i = 1
For Each hyPhase In hyPhases
If hyPhase.PhaseType = ptVapourPhase Then
MsgBox “Phase “ & i & “ is the vapour phase”
i = i + 1
End If
Next
2-34
Automation 2-35
Operations
All operations have a few properties and methods in common.
Operation objects contain properties for determining the feeds,
products, and additional objects connected to the operation. The
operation objects also contain methods for adding and removing
the operations from the flowsheet and the UniSim Design case.
2-35
2-36 Key UniSim Design Objects
Example: Operation
Dim i As Integer
Dim hyOperations As Operations
Set hyOperations = hyCase.Flowsheet.Operations
For i = 0 To hyOperations.Count - 1
MsgBox “Operation “ & hyOperations.Item(i).name & “
is unit type - & hyOperations.Item(i).TypeName
Next i
2-36
Automation 2-37
ColumnSpecification(s)
A column is solved based on matching specifications related to
the available degrees of freedom. The ColumnSpecifications
collection object is accessed through the ColumnFlowsheet. The
ColumnSpecification contains information such as the goal
value, current value, and status.
Syntax: ColumnSpecification
Set hyColumn =
hyCase.Flowsheet.Operations(“ColumnOp”).Item(0)
Set hyColumnFlowsheet = hyColumn.ColumnFlowsheet
By Index:
Set hyColumnSpec = hyColumnFlowsheet.
Specifications.Item(0)
By name:
Set hyColumnSpec =
hyColumnFlowsheet.Specifications.Item(“specname”)
2-37
2-38 Key UniSim Design Objects
Example: ColumnSpecification
Dim hyColumnSpec As ColumnSpecification
Dim hyColumnSpecs As ColumnSpecifications
Dim hyColumn As ColumnOp
Dim hyColumnFlowsheet As ColumnFlowsheet
Set hyColumn =
hyCase.Flowsheet.Operations(“ColumnOp”).Item(1)
Set hyColumnFlowsheet = hyColumn.ColumnFlowsheet
Set hyColumnSpecs = hyColumnFlowsheet.Specifications
For Each hyColumnSpec In hyColumnSpecs
If hyColumnSpec.IsActive Then
MsgBox “Column spec '" & hyColumnSpec & “' is
active.”
Else
MsgBox “Column spec '" & hyColumnSpec & “' is an
estimate.”
End If
Next hyColumnSpec
Syntax: ColumnStage(s)
By Index:
Set hyColumnStage =
hyColumnFlowsheet.ColumnStages.Item(0)
By Name:
Set hyColumnStage =
hyColumnFlowsheet.ColumnStages.Item(“1_Main TS”)
Syntax: SeparationStage
Set hySepStage = hyColumnStage.SeparationStage
2-38
Automation 2-39
The example below, loops through each feed stage and displays
in the Debug view its molar liquid flows.
Example: ColumnStage
Dim hyColumn As ColumnOp
Dim hyColumnFlowsheet As ColumnFlowsheet
Dim hyFeedStage As Object
Dim hySepStage As SeparationStage
Set hyColumn =
hyCase.Flowsheet.Operations(“ColumnOp”).Item(0)
With hyColumn.ColumnFlowsheet
For Each hyFeedStage In .FeedStages
Debug.Print “Stage “
&.ColumnStages(hyFeedStage.name)
StageNumberValue & “ Molar Liquid Flow (kgmole/hr)
is “ &.ColumnStages(hyFeedStage.name).
SeparationStage.MolarLiquidFlowValue
Next hyFeedStage
End With
2-39
2-40 Key UniSim Design Objects
RealVariable/RealFlexVariable
The RealVariable object provides additional information about a
particular variable such as its units and whether it is calculated
or set. UniSim Design performs all calculations in SI units
regardless of how the user preference settings are set. By
default, the values returned through Automation are also in SI
units. It becomes your responsibility to handle how units are
handled when writing applications. A RealVariable contains a
property called GetValue and SetValue which allows one to
specify the units that are to be used when returning or setting
the value.
The presence of “Flex” in The RealVariable object also contains a property called Value.
the object name
The Value property returns the actual value in SI units within
indicates the possibility
of a dynamic array (i.e., the UniSim Design case. Many of the objects that return a
has a “variable” size, RealVariable for a given property also have a similarly named
depending on what is
being returned.) property with the word value concatenated to it. The alternative
property allows direct access to the actual variable in SI units
with one less function call. An example for the ProcessStream
object would be the Temperature property that returns a
RealVariable and the TemperatureValue property, that returns a
value in °C.
2-40
Automation 2-41
Example 1: RealVariable
Dim hyStream As ProcessStream
Dim TemperatureVal As Double
Set hyStream =
hyCase.Flowsheet.MaterialStreams.Item(0)
TemperatureVal = hyStream.Temperature.GetValue(“F”)
MsgBox hyStream.name & “ temperature(F) = “ &
TemperatureVal
Example 2: RealVariable
Dim hyStream As ProcessStream
Dim TemperatureVal As Double
Set hyStream =
hyCase.Flowsheet.MaterialStreams.Item(0)
TemperatureVal = 150
hyStream.Temperature.SetValue 150, “F”
Example 3: RealVariable
Dim hystream As ProcessStream
Set hystream =
hyCase.Flowsheet.MaterialStreams.Item(0)
Select Case hystream.Temperature.State
Case vsCalculated
MsgBox “Temperature value is calculated.”
Case vsSpecified
MsgBox “Temperature value is specified.”
Case vsDefaultedValue
MsgBox “Temperature value is default.”
End Select
2-41
2-42 Key UniSim Design Objects
Fixed Attachments
The FixedAttachments object is a collection object accessed
from Operations or Stream objects. The FixedAttachments
collection object contains a set of objects related to the feeds,
products, or connected operations.
AttachedFeeds - ProcessStream
AttachedProducts - ProcessStream
AttachedLogicalOps - UnitOperation
AttachedOpers - UnitOperation
Examples: FixedAttachments
Dim hyFeeds As FixedAttachments
Dim hyOp As ColumnOp
Set hyOp =
hyCase.Flowsheet.Operations(“ColumnOp”).Item(0)
Set hyFeeds = hyOp.AttachedFeeds
For j = 0 To hyFeeds.Count - 1
MsgBox “FeedStream “ & j & “ Name = “ &
hyFeeds.Item(j).name
Next j
2-42
Automation 2-43
Integrator
SimulationCase.Solver.Integrator.Active = True
SimulationCase.Solver.Integrator.Active = False
2-43
2-44 Key UniSim Design Objects
SpreadsheetOp &
SpreadsheetCell(s)
The SpreadsheetCells object is a collection of SpreadsheetCell
objects. The cell properties allow access to information related
to the UniSim Design variable being imported or exported, the
formulas associated with the cell, and the value within the cell.
2-44
Automation 2-45
2-45
2-46 Example 1: The Macro Language
Figure 2.6
Code Explanation
Function SelectStream(simcase As Object) As Object Signifies the beginning of the
SelectStream function. This
function takes a SimulationCase
object and prompts the user to
select a Stream from a list of
streams in the case, returning
an interface to the Stream.
Set FS = simcase.Flowsheet Acquire the case flowsheet.
2-46
Automation 2-47
Code Explanation
Set Strms = FS.MaterialStreams Acquire the collection of Streams
from the flowsheet.
Dim strmnames() Build a string array of the
strmnames = Strms.Names Stream names.
Figure 2.7
2-47
2-48 Example 1: The Macro Language
4. You can now begin defining the Main sub-routine. Enter the
following code:
Code Explanation
Sub Main Signifies the beginning main
sub-routine.
pipeSizes(1) = 2 Defines an array of pipe sizes (in
pipeSizes(2) = 3 inches).
pipeSizes(3) = 4
pipeSizes(4) = 6
pipeSizes(5) = 8
pipeSizes(6) = 10
pipeSizes(7) = 12
pipeSizes(8) = 16
Dim simcase As Object Looks for an open active case. If
Set simcase = ActiveCase there is no active case, it alerts
the user and terminates.
If simcase Is Nothing Then
MsgBox “No UniSim Design case is open.”
End
End If
Dim strm As Object Calls the SelectStream function
Set strm = SelectStream(simcase) to select a stream in the
simcase.
Set flow = strm.MassFlow Check to see if the selected
If flow.IsKnown Then stream has a defined mass flow
rate. If the flow rate is known,
flowValue = flow.GetValue(“lb/hr”) convert the flow rate in to “lb/s”.
flowValue = flowValue / 3600
Else
GoTo NoFlow
End If
Set rho = strm.MassDensity Checks to see if the stream’s
If rho.IsKnown Then mass density has been
calculated.
rhoValue = rho.GetValue(“lb/ft3”)
Else
GoTo NoRho
End If
flowValue = flowValue / rhoValue Calculates volumetric flow rate.
On Error GoTo NoCv Proceeds to an error trap if the
Cv = strm.MolarHeatCapacityValue / Cv value of the stream has not
been calculated.
strm.CpCvValue
On Error GoTo NoZ Proceeds to an error trap if the
Z = strm.CompressibilityValue compressibility of the stream
has not been calculated.
On Error GoTo NoTemp Proceeds to an error trap if the
T = strm.TemperatureValue + 273.15 absolute temperature of the
stream cannot be calculated.
2-48
Automation 2-49
Code Explanation
On Error GoTo NoMolWt Proceeds to an error trap if the
MolWt = strm.MolecularWeightValue / 1000.0 molecular weight of the stream
cannot be calculated.
soundVel = Sqr(Z*R*T/MolWt*(1.0+Z*R/Cv)) Calculates the Speed of Sound
soundVel = soundVel / 0.3048 of the stream and converts it
from m/s to ft/s.
soundVelTxt = Format(soundVel,
“###,###,###.###”)
Dim DispText() As String Declares an array of String
ReDim DispText(nPipes + 2) types. The “+2” leaves room for
a two line header. The two
DispText(0) = “Pipe Size (in) Mach header lines are assigned.
Number “
Please note there are eighteen
DispText(1) = “--------------------------------- spaces between “(in)” and
------------------------------” “Mach” and four spaces after
“Number”. There are
approximately seventy dashes in
the line DispText(1) = “---...”
For num = 1 To nPipes For each pipe size, the Mach
rSquared = pipeSizes(num) * pipeSizes(num)/ number is calculated, formatted
and stored in the previously
144.0/4.0 created array of strings.
Mach = flowValue / pi / rSquared / soundVel
Please notice that there are
sizetxt = Format(pipeSizes(num), eighteen spaces between the
"###,###,###.###") quotation marks in the sixth line
Machtxt = Format(Mach, "###,###,###.#####") of code (ninth line displayed).
DispText(num + 1) = Format$(sizetxt,
"@@@@@@@@@@@@@@@") + " " +
Format$(Machtxt, "@@@@@@@@@@@@@@@")
Next num
Begin Dialog UserDialog 360,217 Create a user view that displays
ListBox 10,49,340,133,DispText(),.Field5 the Speed of Sound value as
well as the Mach number for
OKButton 250,189,90,21 each of the pipe sizes.
Text 30,14,150,14,"Speed of Sound (ft/s):",
Use the Language Help option
.Field2 provided in the Help menu to
TextBox 190,14,90,21,.Field1 explore the use of UserDialogs.
End Dialog
Dim dlg2 As UserDialog
dlg2.Field1 = soundVelTxt
Dialog dlg2
End
2-49
2-50 Example 1: The Macro Language
Code Explanation
NoFlow: This is where you define the
MsgBox "Unknown mass flow in stream " + error trap instances.
strm.name
End
NoRho:
MsgBox "Unknown density in stream " +
strm.name
End
NoCv:
MsgBox "Unknown heat capacity in stream " +
strm.name
End
NoZ:
MsgBox "Unknown compressibility in stream " +
strm.name
End
NoTemp:
MsgBox "Unknown temperature in stream " +
strm.name
End
NoMolWt:
MsgBox "Unknown molecular weight in stream " +
strm.name
End
End Sub Signifies the end of the method.
Start/Resume icon
2-50
Automation 2-51
Figure 2.8
6. Select a stream from the list and click the OK button. This
should result in a view similar to the one shown below.
Figure 2.9
Save icon
2-51
2-52 Example 2: Automation in Visual
2.6 Example 2:
Automation in Visual
Basic
This complete example In this example UniSim Design is used as the Automation server
has also been pre-built
and is located in the
for a unit conversion program. More specifically, you are
UniSim accessing an object called the UnitConversionManager which
Design\Samples\OLE\vb\ manages unit conversion within UniSim Design.
ucsm directory.
1. Open a new project in Visual Basic 6.0® and from the New
tab of the New Project view select the Standard EXE icon
and click the Open button.
2-52
Automation 2-53
Figure 2.10
2-53
2-54 Example 2: Automation in Visual
5. From the toolbox select the Combo Box icon and create a
combo box on the form as shown below.
Figure 2.11
Combo Box icon
6. Ensure that the combo box is the active control. This can be
done in one of two ways:
• Select the combo box on the form so that the object
guides appear around the object.
• From the drop-down list found at the top of the
Properties tiled view select the name of the combo box
you have just created.
7. In Properties tiled view, set the name of the Combo Box as
ddUnitSet in the Name field. If you want, you can also
change the default text that appears inside the combo box
by entering a new name in the Text field.
8. You can add a Label to the form (i.e., to identify the object
from others), by clicking the Label icon and drawing a label
on the form just above the combo box you have just created.
Label icon
Figure 2.12
2-54
Automation 2-55
10. Now add an Text Box next to the Combo Box you created.
Use the method described in Steps #6 - #7 to name this
Text Box ebFromValue. Repeat Steps #8 - #9 to add a
Label above the ebFromValue Text Box that reads From
Value.
Figure 2.13
11. Add the following objects to the view using the previously
described methods.
Figure 2.14
Object Type - Combo Box Object Type - Label Object Type - Combo Box
Name - ddFromUnit Name - lbToValue Name - ddToUnit
Text - ddFromUnit Caption - lbToValue Text - ddToUnit
2-55
2-56 Example 2: Automation in Visual
12. Only two more objects are required on the form. Select the
Command icon control from the toolbox and add two
buttons to the view as shown below.
Command icon
Figure 2.15
13. You are now ready to begin defining the events behind the
form and objects. You can enter the code environment using
a number of methods:
• Click the View Code icon in the Project tiled view.
• Select the Code command from the View menu.
View Code icon • Double-click the frmUCSM form.
2-56
Automation 2-57
Figure 2.16
If you attempt to use an 14. Begin by declaring the following variables under the Option
undeclared variable, an Explicit declaration.
error occurs at compile
time.
Figure 2.17
2-57
2-58 Example 2: Automation in Visual
Code Explanation
Private Sub Form_Load() Signifies the Start of the form load sub-routine. You do
not have to add it as it should already be there.
ddUnitSet.Clear Clear the default text found inside the ddUnitSet,
ddFromUnit.Clear ddFromUnit and ddToUnit combo boxes.
ddToUnit.Clear
Set hyApp = Connects to UniSim Design and the UniSim Design Unit
CreateObject("UniSimDesign.Application") Conversion Set Manager.
Set UCSM = hyApp.UnitConversionSetManager
For Each UCS In UCSM For each Unit Conversion Set found in the Unit
ddUnitSet.AddItem UCS.Name Conversion Set Manager add the Unit Set to
Next UCS ddUnitSet combo box list.
Indicates no item is currently selected in the ddUnitSet
ddUnitSet.ListIndex = -1
combo box.
ebFromValue.Text = "" Clears the text that appears in the ebFromValue text
lbToValue.Caption = "" box and the lbToValue label.
End Sub Signifies the end of the initialization sub-routine. This
line does not need to be added.
16. The next section of code to be added tells the program what
is to occur when an option is selected in the ddUnitSet
combo box.
Code Explanation
Private Sub ddUnitSet_Click() Signifies the Start of the sub-routine.
ddFromUnit.Clear Clears any list entries in the ddFromUnit and
ddToUnit.Clear ddToUnit combo boxes.
Set hyApp = Connects to UniSim Design and the UniSim Design Unit
CreateObject("UniSimDesign.Application") Conversion Set Manager.
Set UCSM = hyApp.UnitConversionSetManager
Once the selection is made in the ddUnitSet combo
UCSNumber = ddUnitSet.ListIndex box, the UCSNumber variable holds the internal
UniSim Design index number of the selected Unit Set.
Find the selected Unit Conversion Set in Unit
Set UCS = UCSM.Item(UCSNumber)
Conversion Manager.
For Each UC In UCS For each Unit Conversion type (UC) in the Unit
ddFromUnit.AddItem UC.Name
Conversion Set, add the Unit type to both the
ddFromUnit combo box (the unit type the program is
ddToUnit.AddItem UC.Name
converting from) and the ddToUnit (the unit type the
Next UC program is converting to).
ddFromUnit.ListIndex = -1 Indicates no items are currently selected in the
ddToUnit.ListIndex = -1 ddFromUnit and ddToUnit combo box.
2-58
Automation 2-59
Code Explanation
lbToValue.Caption = "" Clears any text that appears in the lbToValue label.
End Sub Signifies the end of the sub-routine. This line does not
need to be added.
Code Explanation
Private Sub Signifies the Start of the sub-routine.
ddFromUnit_Click()
lbToValue.Caption = "" Clears any text that appears in the lbToValue label.
End Sub Signifies the end of the sub-routine. This line does not need to
be added.
Code Explanation
Private Sub ddToUnit_Click() Signifies the Start of the sub-routine.
lbToValue.Caption = "" Clears any text that appears in the lbToValue label.
End Sub Signifies the end of the sub-routine. This line does not need to
be added.
18. The final two sub-routines define the actions of the two
buttons: btConvert and btExit.
Code Explanation
Private Sub btConvert_Click() Signifies the Start of the sub-routine.
Set hyApp = Connects to UniSim Design and the UniSim Design
CreateObject("UniSimDesign.Application") Unit Conversion Set Manager.
Set UCSM = hyApp.UnitConversionSetManager
Takes the value entered in the ebFromValue text
FromValue = CDbl(Val(ebFromValue.Text))
box and converts in to a numerical variable type.
Set ebFromValue text box text equal to
ebFromValue.Text = CStr(FromValue)
FromValue double.
UCSNumber = ddUnitSet.ListIndex Gets current selection in the three drop-down lists
FromNumber = ddFromUnit.ListIndex (combo boxes).
ToNumber = ddToUnit.ListIndex
If FromNumber < 0 Or ToNumber < 0 Then If no selection is made in either the ddFromUnit
lbToValue.Caption = "" or ddToUnit combo boxes, exit the sub-routine.
Exit Sub
End If
Set UCS = UCSM.Item(UCSNumber) Chooses a specific UCS from UCSM. It takes the
Unit conversion type you want to change from,
Set FromUC = UCS.Item(FromNumber)
and the Unit Conversion type you want to change
Set ToUC = UCS.Item(ToNumber)
to.
2-59
2-60 Example 2: Automation in Visual
Code Explanation
Converts the contents of the ddFromValue
Intermediate = FromUC.ToCalculationUnit(FromValue) combo box from the FromUC units to UniSim
Design internal units (Intermediate). It then
ToValue = ToUC.FromCalculationUnit(Intermediate)
converts the Intermediate value from internal
lbToValue.Caption = CStr(ToValue)
units to the ToUC units. It then displays the
converted value in the lbToValue label.
End Sub Signifies the end of the sub-routine. This line does
not need to be added.
Code Explanation
Private Sub btExit_Click() Signifies the Start of the sub-routine.
Unload Me Unloads the form and ends the program.
End
End Sub Signifies the end of the sub-routine. This line does
not need to be added.
19. You are now ready to compile and run the program. Before
you begin, please ensure that you have a copy of UniSim
Design on the computer.
20. To compile the program do one of the following:
• Click the Start icon in the toolbar.
• Select Start command from the Run menu.
Start icon • Press F5 from the keyboard.
VB informs you of any errors that occur during compile time.
2-60
Extensibility 3-1
3 Extensibility
3.1 Introduction................................................................................... 3
3-1
3-2 Extensibility
3.11 References..................................................................................76
3-2
Extensibility 3-3
3.1 Introduction
UniSim Design provides the unique capability of enhancing its
functionality through the addition of custom objects to a
simulation. With its open concept, the functionality of UniSim
Design can be extended to include your unique or proprietary
calculations. Currently, you can add:
• Extension Unit Operations
• Extension Reaction Kinetics
• Extension Property Packages
3-3
3-4 Introduction
Figure 3.1
UniSim Extension
Design Container Code
3-4
Extensibility 3-5
3.2 Implementing
Interfaces
An extension implements an interface if it supports the methods
in that interface. There are two different ways of implementing
an interface.
3.2.1 Implementing an
Interface Through a
Dispatch Interface
An extension can implement interfaces through Dispatch
interfaces. This can be done in Visual Basic if the extension is
implemented as a Visual Basic Class.
3-5
3-6 Data Types
3.2.2 Implementing an
Interface Through a
Custom Interface
An extension can also be implemented by overloading the
Custom interfaces defined for the extension. For example, an
extension Unit Operation can be created by overloading the
ExtensionObject interface and the ExtnUnitOperation interface.
3-6
Extensibility 3-7
3.4 Extension
Development Kit
A number of tools are provided in the UniSim Design Extension
Development Kit. These tools are not required to build
extensions for UniSim Design, but they make the job much
easier. Included in the kit are the following:
File Description
UniSim The UniSim Design Type Library, that contains definitions
Design.tlb for all objects exposed by UniSim Design, as well as
definitions for interfaces required by UniSim Design
Extensions. Programming languages such as Visual Basic
use this file to determine what a particular object contains.
Many programs provide browsers to look at the contents of
this file. For example, Excel provides an Object Browser
that can be used to view the properties of methods of each
object and to help navigate the object model. Unlike the
other files in the table, the UniSim Design Type Library is
always installed, even when you do not install the
Extension Development Kit.
extsdk.bas Contains constants defined by UniSim Design in a format
that can easily be included in a Visual Basic project. This
allows the extension developer to refer to UniSim Design
constants through Const definitions, rather than through
numbers. This information can also be read from the
UniSim Design Type Library, if your programming language
supports this.
extsdk.cpp Contain support code that can be included in a C++
and project. They implement a ClassFactory for any extensions
extsdk.hpp in the project and also implement the DllRegisterServer and
DllUnregisterServer methods. These files compile in both
Microsoft Visual C++ and Borland C++.
UniSimDesig Contains definitions of all the interfaces and enumerations
n.hh found in the UniSim Design Type Library. Including this file
in your C++ source allows you to call methods on UniSim
Design interfaces.
UniSimDesig Instantiates all of the GUIDs defined by UniSim Design. It
niid.cc can be included as part of a C++ project to allow reference
to UniSim Design GUIDs.
The UniSim Allows you to:
Design View • Define extension information for the registration
Editor program.
• Define Variables for UniSim Design to create and
manage on behalf of an extension.
• Create Views for an extension.
3-7
3-8 Creating an Extension
It is possible to create For each extension, you must provide either a CLSID or a
an EDF with 0 views.
ProgID. Other information that can be provided at this point
includes: the extension description, from which you identify the
extension within UniSim Design, the extension type and the
number of views. For extensions written in Visual Basic, you
must specify a ProgID. The selection of the ProgID is explained
in the following sub-section entitled: Register the Extension.
3-8
Extensibility 3-9
For more information on Once the preliminary definition information is provided, you
the View Editor see specify the variables that the object owns and that are visible to
Chapter 4 - Extension
View Editor. the user. These variables are of the following types:
A widget is an equivalent Views are created by adding widgets to the DefaultView form.
term for a Visual Basic
Select a widget with the secondary mouse button, drag it on to
control.
the DefaultView form, and drop it. You can then position the
widget to your liking. Double-click the widget to access its
Properties view, from which you can specify detailed information
for the widget. If necessary, you can associate a variable with
the widget.
3-9
3-10 Creating an Extension
ProjectName.ClassName
where:
For more information on You can register extensions on the Extensions tab of the Session
extension registration Preferences property view.
see Section 3.6 -
Registering
Extensions.
3-10
Extensibility 3-11
You can also use the Debug object in Visual Basic to print
information to the Debug view while the extension runs.
To distribute your extension, you must provide the DLL file, the
EDF file, and any other files required by your extension (i.e., a
separate FORTRAN DLL called from your extension). You must
register your extension on each individual machine that uses the
extension calculations. You can use the registration tool found
on the Extensions tab of the Session Preferences property view
for this, or you can include this step in your own setup program.
3-11
3-12 Creating an Extension
3.5.2 In C++
The following six steps provide a framework for creating an
extension in C++:
1. Create the Extension Definition.
2. Implement the Required Interfaces.
3. Implement the ClassFactory.
4. Create and Register the DLL.
5. Debug the Extension.
6. Distribute the Extension.
It is possible to create For each extension, you must provide either a CLSID or a
an EDF with 0 views.
ProgID. Other information that can be provided at this point
includes: the extension description, from which you identify the
extension within UniSim Design, the extension type and the
number of views. The selection of the ProgID is explained in the
following sub-section entitled: Register the Extension.
3-12
Extensibility 3-13
For more information on Once the preliminary definition information is provided, you
the View Editor see specify the variables that the object owns and that is visible to
Chapter 4 - Extension
View Editor. the user. These variables are of the following types:
3-13
3-14 Creating an Extension
where:
You must implement this macro once for every extension in your
DLL.
3-14
Extensibility 3-15
For more information on You can register your DLL on the Extensions tab of the Session
extension registration
see Section 3.6 - Preferences property view.
Registering
Extensions.
Debug the Extension
You can debug your extension by putting a call to the Win32
function DebugBreak in your code. When UniSim Design
executes this part of your code, you are allowed to start your
debugger and debug the code from there. You are then able to
inspect variables, and trace the execution of your extension's
code. You can also debug your extension in MS DevStudio by
setting breakpoints in the code. Specifying the path of the
UniSim Design executable file in the Executable for debug
session field on the Debug tab of the Project Settings view and
launch VC++ auto debug.
3-15
3-16 Creating an Extension
To distribute your extension, you must provide the DLL file, the
EDF file, and any other files required by your extension (i.e., a
separate FORTRAN DLL called from you extension). You must
register your extension on each individual machine that uses the
extension calculations. You can use the registration tool found
on the Extensions tab of the Session Preferences property view
for this, or you can include this step in your own setup program.
3-16
Extensibility 3-17
See Chapter 4 - All this information is provided when the EDF is created in the
Extension View Editor
for more information on
View Editor.
creating an EDF.
Extensions can be registered with either a CLSID (Class
Only one of the ProgID
or CLSID values can be Identifier) or a ProgID (Program Identifier). It is recommended
used. that ProgID be used for extensions created in Visual Basic, and
CLSID be used for all other extensions.
3-17
3-18 Registering Extensions
Ensure that the EDF and To register an extension written in C++, simply use the
extension DLL are in the
following procedure:
same directory.
1. Start UniSim Design. From the Tools menu, select
Preferences command. The Session Preferences view
opens.
2. Go to the Extensions tab and click the Register an
Extension button. This opens the Select an Extension to
be Registered view.
3. Use the File Path group to find the directory in which the
DLL file is saved. Once you find the DLL file, select it and
click the OK button.
Figure 3.2
3-18
Extensibility 3-19
Figure 3.3
3-19
3-20 Registering Extensions
UniSim Design loads the DLL file and registers it, and then it
takes the name of the DLL file and looks for an Extension
Definition File with the same name in the same directory to
complete the registration.
3-20
Extensibility 3-21
3-21
3-22 Extension Reaction Kinetics
3.7.2 ExtensionObject
Interface
Every extension must implement the ExtensionObject interface.
This interface defines methods that are common to all UniSim
Design extensions. No methods in this interface are mandatory;
that is, all methods may be ignored if the extension does not
implement them.
Derived from Properties Methods
IDispatch none OnHelp
Save
StatusQuery
Terminate
VariableChanged
VariableChanging
Interface Description
ExtensionObject Called when reaction extension is added to the
simulation.
ExtnKineticReaction Called when the reaction extension is used.
3-22
Extensibility 3-23
3-23
3-24 Extension Reaction Kinetics
Figure 3.4
3.8.1 ExtnKineticReaction
Interface
The ExtnKineticReaction interface must be implemented by all
extension kinetic reactions. In addition to the Initialize and
Reaction Rate methods which are mandatory, the interface also
has the following associated properties and methods:
3-24
Extensibility 3-25
3.8.2 ExtnKineticReactionCont
ainer Interface
The ExtnKineticReactionContainer interface is passed to an
extension Kinetic Reaction in its Initialize method.
3-25
3-26 Extension Reaction Kinetics
Figure 3.5
Properties view
3-26
Extensibility 3-27
6. You are now ready to define the class. Begin by defining the
global variables in the Project VinylAc Code view:
Code Explanation
Option Explicit Used to force explicit declaration of
all variables in that module.
Dim hyContainer As Object Declare the global UniSim Design
Dim hyBulkDens As Object objects. The hy prefix is a
convention to identify variables
which come from UniSim Design.
Code Explanation
Public Function Initialize(ByVal Container As Initialize is called when the extension is
Object, ByVal IsRecalling As Boolean) As Long 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 UniSim Design
version
Set hyContainer = Container This reference lets the extension interact
with UniSim Design through the
extension container, the
ExtnKineticReactionContainer object.
Methods from the ExtensionObject object
are also available.
Set hyBulkDens = Set an object reference to the BulkDens
hyContainer.FindVariable("BulkDens").Variabl variable, which is created in the EDF file.
e
If IsRecalling = False Then The variable IsRecalling is only False
hyBulkDens.Value = 2700 when the extension is first added to the
simulation. This sets a default for
BulkDens (2700 kg catalyst/m3 reactor
volume).
hyContainer.Phase = ptVapourPhase Setting the remaining reaction properties
hyContainer.ReactionBasis = (usually found on the Basis tab of the
Reaction view). The Phase of the
rbPartialPressBasis 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.
3-27
3-28 Extension Reaction Kinetics
Code Explanation
Set hyReactant = Adds the component Ethylene as a
hyContainer.Reactants.Add("Ethylene") Reactant. It sets the stoichiometric
coefficient of ethylene as -1 (i.e., 1 mole
hyReactant.StoichiometricCoefficientValue of ethylene being consumed). You are
= -1 also specifying ethylene to be the base
hyContainer.BaseReactant = hyReactant reactant.
Set hyReactant = Adds the remaining components and
hyContainer.Reactants.Add("AceticAcid") specifies their stoichiometric coefficients.
hyReactant.StoichiometricCoefficientValue
= -1
Set hyReactant =
hyContainer.Reactants.Add("Oxygen")
hyReactant.StoichiometricCoefficientValue
= -0.5
Set hyReactant =
hyContainer.Reactants.Add("VinylAcetate")
hyReactant.StoichiometricCoefficientValue
= 1
Set hyReactant =
hyContainer.Reactants.Add("H2O")
hyReactant.StoichiometricCoefficientValue
= 1
hyContainer.BasisConversion = "psia" Sets the Basis Conversion units to psia.
The Rate Conversion units is left in
UniSim Design internal units of kg mole/
m3-s.
With hyContainer Sets the property states as Calculated so
.SetReactionPropertyState rpReactants, that they cannot be modified.
vsCalculated The With statement is used for efficiency
.SetReactionPropertyState since each line uses the
SetReactionPropertyState method of
rpStoichiometricCoefficients, vsCalculated the hyContainer object.
.SetReactionPropertyState
rpMinTemperature, vsCalculated
.SetReactionPropertyState
rpMaxTemperature, vsCalculated
.SetReactionPropertyState
rpReactionBasis, vsCalculated
.SetReactionPropertyState
rpReactionPhase, vsCalculated
.SetReactionPropertyState
rpBaseReactant, vsCalculated
.SetReactionPropertyState
rpBasisConversion, vsCalculated
.SetReactionPropertyState
rpRateConversion, vsCalculated
End With
End If
3-28
Extensibility 3-29
Code Explanation
ErrorTrap: Line to which the On Error statement
branches if an error occurs
End Function Signifies the end of the function. This line
does not need to be added.
Code Explanation
Public Function ReactionRate(ByVal Fluid As This function is called whenever the
Object, ByVal RxnTemperatureInC As Double, extension is executed.
ByVal RxnVolumeInKmolPerM3 As Double, rate As
Double) As Boolean
On Error GoTo ErrorTrap Enable Error trapping.
Dim TotalPressure As Double Declare local variables.
Dim RxnTemperatureinK As Double
Dim EthyleneIndex As Integer
Dim AceticAcidIndex As Integer
Dim OxygenIndex As Integer
Dim WaterIndex As Integer
Dim ComponentFracs As Variant
Dim EthylenePP As Double
Dim AceticAcidPP As Double
Dim OxygenPP As Double
Dim WaterPP As Double
If hyBulkDens.Value <= 0 Then Check to see if the value of hyBulkDens >
hyBulkDens.Value = 2700 0. If not, then sets it to the default value
of 2700 kg catalyst/m3 reactor volume.
TotalPressure = Gets the overall pressure of the reaction
Fluid.Pressure.GetValue("psia") in psia.
3-29
3-30 Extension Reaction Kinetics
Code Explanation
EthylenePP = ComponentFracs(EthyleneIndex) * Get partial pressure of components in
TotalPressure psia by multiplying component mole
fraction by total pressure (Smith and Van
AceticAcidPP = Ness, p. 300).
ComponentFracs(AceticAcidIndex) *
TotalPressure
OxygenPP = ComponentFracs(OxygenIndex) *
TotalPressure
WaterPP = ComponentFracs(WaterIndex) *
TotalPressure
rate = 0.1036 * Exp(-3674 / Calculate the reaction rate1. The rate is in
RxnTemperatureinK) * OxygenPP * EthylenePP * g mol AceticAcid consumed/min-g
catalyst. hyBulkDens.Value is
AceticAcidPP * (1 + 1.7 * WaterPP) / ((1 + multiplied by 1000 to convert it to g
0.583 * OxygenPP * (1 + 1.7 * WaterPP)) * (1 + catalyst/m3 reactor volume.
6.8 * AceticAcidPP)) * hyBulkDens.Value *
1000
rate = rate / 1000 / 60 Since the units required by UniSim
Design are kg mole/m3-s, divide by 1000
g mol/kg mol and divide by 60 s/min.
ReactionRate = True Tell UniSim Design that the calculation
worked as expected.
ErrorTrap: Line to which the On Error statement
branches if an error occurs.
End Function Signifies the end of the function. This line
does not need to be added.
Figure 3.6
3-30
Extensibility 3-31
10. Select the folder you want to save the VinylAc.dll file in, and
click the OK button.
3-31
3-32 Extension Reaction Kinetics
Figure 3.8
3-32
Extensibility 3-33
Figure 3.9
8. From the Existing Views list, select the DefaultView and click
the Edit button. The DefaultView form appears. It consists of
several default objects that are not used in this example.
These objects have to be deleted.
3-33
3-34 Extension Reaction Kinetics
Figure 3.10
Static
Text
Text
Entry
Page
Tabs
10. Delete the Name Static Text widget and the Object Name
Text Entry widget using the method described in the step
above.
11. Resize the DefaultView form into a smaller view, as shown
below.
Figure 3.11
3-34
Extensibility 3-35
Figure 3.12
Figure 3.13
3-35
3-36 Extension Reaction Kinetics
Figure 3.14
The Target Moniker field 6. For the Numerical Input widget specify properties as shown
is specified by clicking
the Ellipsis icon
below. When you are finished click the OK button.
associated with the field
and selecting Bulk Figure 3.15
Density from the Select
Number Variable view.
Ellipsis icon
3-36
Extensibility 3-37
10. Click the Insert button on the Edit Messages view. The
Select Message view appears. Select the Close the View
message from the list.
Figure 3.16
11. Click the OK button to add this message to this button. The
Edit Messages view appears as shown below.
Figure 3.17
12. Click the OK button on the Edit Messages view to close this
view and return to the Button Properties view.
3-37
3-38 Extension Reaction Kinetics
13. Specify the Name field as shown below. When you are
finished click the OK button.
Figure 3.18
Figure 3.19
14. Select Save command from the File menu and save the EDF
file as “VinylAc.edf” in the same directory as the DLL file.
3-38
Extensibility 3-39
Figure 3.20
3-39
3-40 Extension Reaction Kinetics
Figure 3.21
Figure 3.22
3-40
Extensibility 3-41
Interface Description
ExtensionObject Called when the property package extension
is added to the simulation.
ExtnPropertyPackage Called when the property package extension
is used.
3-41
3-42 Extension Property Packages
Initialization
When an Extension Property Package is initialized, it must fill in
the ExtensionPPkgInit structure passed to it by its container.
This structure lets the container know which features the
extension supports, such as requirements for a component slate
and whether or not the property package can handle changes to
the component slate order.
Component Slates
If the Extension Property Packages has a fixed component slate,
UniSim Design pre-selects those components, and does not
allow the user to remove them or add other components. The
extension lets its container know of this restriction by setting
the NumberOfPreselectedComponents member of the
ExtensionPPkgInit structure to a non-zero value. UniSim Design
then calls the extension's GetPreselectedCompIDs method at a
later point. If zero is passed for the
NumberOfPreselectedComponents member, UniSim Design
allows you to select whatever components are available.
3-42
Extensibility 3-43
ExtensionPPkgInit structure
This structure is passed to an Extension Property Packages in its
Initialize method. The extension must fill in the structure
according to its capabilities.
typedef struct
{
long StructSize;
long Version;
long NumberOfPreselectedComponents;
enum DynamicPropertyMethod DynPropMethod;
VARIANT_BOOL IsActivityModelType;
VARIANT_BOOL CanExchangeComponents;
VARIANT_BOOL CanCalculateFugacity;
VARIANT_BOOL CanCalculateLLE;
VARIANT_BOOL CanHandleOilHypos;
VARIANT_BOOL UseGFlashInDynamics;
VARIANT_BOOL CanHandleInsideOutPHFlash;
} ExtensionPPkgInit;
3-43
3-44 Extension Property Packages
3.9.1 ExtnPPkgContainer
Interface
The ExtnPPkgContainer interface is passed to an Extension
3-44
Extensibility 3-45
3.9.2 ExtnPropertyPackage
Interface
The ExtnPropertyPackage interface must be implemented by all
Extension Property Packages. Only the Initialize method must
be supported, all others could return E_NOTIMPL.
3-45
3-46 Extension Property Packages
3-46
Extensibility 3-47
Interface Description
ExtensionObject Called when unit operation extension is added to
the simulation.
ExtnUnitOperation Called when the unit operation extension is used.
Method Description
Initialize The Initialize method is called whenever the extension is first
added or whenever a case containing the extension is reopened.
The Initialize method is a function that expects the current build
value of UniSim Design to be returned. By referencing the
UniSim Design Type Library it is possible to use the constant
extnCurrentVersion to return the proper build value.
The Initialize method passes two arguments when it is called.
The first argument is the extension container object. With the
extension container object, all the variables declared in the EDF
can be accessed. The second argument “IsRecalling” is used to
determine if the extension is being added for the first time or if
the case already contained the extension. This flag can be used
to set default values or to assure that the values specified by
the user are not overwritten by the default values.
3-47
3-48 Extension Unit Operations
Method Description
Execute Extension Unit Operations perform their calculations within their
Execute method. This method is called by the Steady State
Solver during the Execute Passes; it must not be called directly
by the extension.
The Execute method is called whenever a stream connected to
the extension is changed or when any of the variables marked
as trigger solve in the EDF are changed. UniSim Design
automatically calls the Execute method and pass the Forgetting
argument. The Forgetting argument relates to how UniSim
Design solves based on the degrees of freedom approach.
Whenever a variable is changed within UniSim Design, all the
values associated or utilizing that value as a basis for
calculation must be forgotten. This Forget process propagates
throughout the simulation model. It is a good idea to check the
Forgetting argument prior to executing code. Especially if values
that are forgotten are used in the calculation. A forgotten value
is set to the empty state, which, for UniSim Design is the
number -32767.
3.10.1 ExtnUnitOperationCont
ainer Interface
The ExtnUnitOperationContainer interface is passed to an
extension Unit Operation in its Initialize method.
3-48
Extensibility 3-49
3.10.2 ExtnUnitOperation
Interface
The ExtnUnitOperation interface must be implemented by all
Extension Unit Operations. Only two methods (the Initialize
method and the Execute method) are mandatory.
3.10.3 Passes
Execute Passes
The Solver performs steady state calculations in two passes: the
Forget Pass and the Calculate Pass. Normally, extension Unit
Operations need not know which pass is underway, but an
IsForgetting parameter is passed to the extension's Execute
method so the extension can optimize calculations if necessary.
3-49
3-50 Extension Unit Operations
Forget Pass
When the value of a variable changes, the Solver first does one
Solve Pass on the flowsheet with the value marked as unknown.
Each object that is linked to the object with the changed variable
has its Execute method called, and the object must perform as
many calculations as it can with the remaining known
information.
Calculate Pass
After all information based on the previous value of a variable
has been forgotten, the new value is set in to the variable and
the second Solver pass (the Calculate Pass) is started. In this
pass, each object affected by the change in the variable has its
Execute method called. Any changes these objects make are
propagated through the flowsheet as the variables in other
objects are touched.
3-50
Extensibility 3-51
Figure 3.23
3-51
3-52 Extension Unit Operations
Figure 3.24
3-52
Extensibility 3-53
Code Explanation
Option Explicit Used to force explicit declaration of all variables in
that module.
Declare the global UniSim Design objects. The hy
prefix is a convention to identify variables which
come from UniSim Design.
Dim hyContainer As • The extension unit operation container
ExtnUnitOperationContainer object.
3-53
3-54 Extension Unit Operations
Code Explanation
Public Function Initialize(ByVal Container As Initialize is called when the extension is
Object, ByVal IsRecalling As Boolean) As Long first added to the simulation or when a
simulation case containing the extension
is loaded.
On Error GoTo ErrorTrap Enable Error trapping.
CalcError(0) = False Initialize variables.
CalcError(1) = False
Initialize = extnCurrentVersion Reference the current UniSim Design
version.
Set hyContainer = Container This reference lets the extension interact
Set myOp = hyContainer.ExtensionInterface with UniSim Design through the
extension container, the
ExtnUnitOperationContainer object.
Methods from the ExtensionObject
object are also available.
Set Components = Get the list of components that are
hyContainer.Flowsheet.FluidPackage.Component currently attached to the fluid package.
For each component in the list, determine
s if water is one of the components.
WaterPresent = False
If water is present, determine the
For Each Component In Components internal index number of water.
If Component.Name = "H2O" Then
WaterPresent = True
Next
If WaterPresent Then H2O =
Components.Index("H2O")
Set hyFeedStrm = Set an object reference to the Feed,
hyContainer.FindVariable("FeedStream").Varia Product and Water stream attachment
objects in the EDF.
ble.object
Set hyProdStrm =
hyContainer.FindVariable("ProductStream").Va
riable.object
Set hyWatStrm =
hyContainer.FindVariable("WaterStream").Vari
able.object
If IsRecalling = False Then IsRecalling is False when the extension
End If is first added to the simulation,
IsRecalling is True when a saved
simulation case containing the extension
is loaded. The If statement uses
IsRecalling to set defaults. Saturate has
no default values, so none are set here.
3-54
Extensibility 3-55
Code Explanation
ErrorTrap: Line to which the On Error statement
branches if an error occurs.
End Function Signifies the end of the function. This line
does not need to be added.
Code Explanation
Public Sub Execute(ByVal Forgetting As Boolean) This sub-routine is called whenever the
extension is executed.
On Error GoTo ErrorTrap Enable Error trapping.
If Not Forgetting Then When a change is made to a variable
which affects the extension, UniSim
Design performs a Forgetting pass and
two Calculation Passes. The Forgetting
pass is used to identify the streams, unit
operations, etc. affected by the change.
The first Calculation pass is used to allow
the extension to complete its internal
calculations. The second Calculation pass
is made so that external references made
by the extension use correct values. If
the extension makes no external
references, then the second pass can be
bypassed using the SolveComplete
method of the Container object. This
command is included later in the code.
For efficiency, no calculations are made
during the Forgetting pass.
Set Components = Determine if water is present (ensure it
hyContainer.Flowsheet.FluidPackage.Component hasn't been removed).
s
WaterPresent = False
For Each Component In Components
If Component.Name = "H2O" Then
WaterPresent = True
Next Component
If Not WaterPresent Then GoTo ErrorTrap
H2O = Components.Index("H2O") Get the index for water.
3-55
3-56 Extension Unit Operations
Code Explanation
Set hyFeedStrm = Set an object reference to the Feed,
hyContainer.FindVariable("FeedStream").Varia Product and Water stream attachment
objects in the EDF.
ble.object
Set hyProdStrm =
hyContainer.FindVariable("ProductStream").Va
riable.object
Set hyWatStrm =
hyContainer.FindVariable("WaterStream").Vari
able.object
If hyFeedStrm Is Nothing Then GoTo If the streams are not attached, then
ErrorTrap exit.
If hyWatStrm Is Nothing Then GoTo ErrorTrap
If hyProdStrm Is Nothing Then GoTo
ErrorTrap
If hyFeedStrm.TemperatureValue = conEmpty Determine if the feed stream has the
Then GoTo ErrorTrap information required.
If hyFeedStrm.PressureValue = conEmpty
Then GoTo ErrorTrap
If hyFeedStrm.MolarFlowValue = conEmpty
Then GoTo ErrorTrap
Temp = hyFeedStrm.ComponentMolarFraction
If (Temp(0) = conEmpty) Then GoTo ErrorTrap
Set WorkFluid = hyFeedStrm.DuplicateFluid Create a duplicate fluid object of
MoleFl = WorkFluid.MolarFractionsValue hyFeedStrm and creates an array
containing the mole fraction of each
component in the fluid.
For i = 0 To Components.Count - 1 For every component in the fluid, divide
MoleFl(i) = MoleFl(i) / 10 the mole fraction by a factor of 10. This
means that the current composition of
Next the stream now only make up 10% of the
MoleFl(H2O) = 0.9 + MoleFl(H2O) fluid composition. Make the remaining
WorkFluid.MolarFractionsValue = MoleFl 90% water.
WorkFluid.TPFlash Do a TP Flash on the fluid at the
hyFeedStrm.TemperatureValue, temperature and pressure of the stream
hyFeedStrm. If there is a second phase
hyFeedStrm.PressureValue then an error has occurred.
If WorkFluid.FluidPhases.Count = 1 Then
CalcError(0) = True
GoTo ErrorTrap
End If
Temp = hyWatStrm.ComponentMolarFraction Creates a temporary array containing the
If Temp(0) = conEmpty Then component molar fraction values of the
stream object hyWatStrm (the water
MoleFl = stream).
hyWatStrm.ComponentMolarFraction
If the mole fraction of the first component
in the stream is not specified, then do the
following:
3-56
Extensibility 3-57
Code Explanation
For i = 0 To Components.Count - 1 Set the mole fraction of every component
MoleFl(i) = 0 in the temporary array to be zero. Then
set the mole fraction of water to be 1.
Next i
MoleFl(H2O) = 1
hyWatStrm.ComponentMolarFraction.Erase Deletes the current component molar
hyWatStrm.ComponentMolarFraction.Calculate fraction values of the stream
hyWatStrm. It then sets the component
MoleFl fraction of the stream to the contents of
the temporary array MoleFl.
ElseIf Temp(H2O) = 0 Then Else if the mole fraction of water in the
CalcError(1) = True stream hyWatStrm is zero then an error
has occurred.
GoTo ErrorTrap
End If
With hyWatStrm Resets the water stream temperature and
.Pressure.Erase pressure at the new molar composition.
.Pressure.Calculate
hyFeedStrm.PressureValue
.Temperature.Erase
.Temperature.Calculate
hyFeedStrm.TemperatureValue
End With
If hyFeedStrm.MolarFlowValue = 0 Then If the feed stream molar flow is 0 then
hyWatStrm.MolarFlow.Calculate 0 exit.
GoTo EndCalcs
End If
Set WorkFluid = hyFeedStrm.DuplicateFluid Creates a duplicate fluid of the feed and
Set WatFluid = hyWatStrm.DuplicateFluid water streams and sets the counter
variable Count to zero.
Count = 0
If WorkFluid.FluidPhases.Count > 1 Then If the number of phases in the feed
hyWatStrm.MolarFlow.Calculate 0 stream fluid is greater than 1, then set
the molar flow of the water stream to
GoTo EndCalcs zero.
End If
Do While WorkFluid.FluidPhases.Count = 1 Determine water stream flow required to
Count = Count + 1 saturate feed stream.
Set WorkFluid = While the number of phases in the feed
hyFeedStrm.DuplicateFluid stream is still one, increase the molar
flow of the water stream. Add the feed
WatFluid.MolarFlowValue = and water streams and reflash the
WorkFluid.MolarFlowValue * (Count / 20) stream at the feed stream’s temperature
WorkFluid.AddFluid WatFluid and pressure.
WorkFluid.TPFlash
hyFeedStrm.TemperatureValue,
hyFeedStrm.PressureValue
Loop
MoleFl = Set MoleFl to the values of the
WorkFluid.HeavyLiquidPhase.MolarFlowsValue component molar flows of the heavy
liquid phase of the fluid object WorkFluid.
3-57
3-58 Extension Unit Operations
Code Explanation
Temp = WatFluid.MolarFlowValue - Set the variable Temp to be the difference
MoleFl(H2O) between the flow rate of the water
stream and component molar flow rate of
If Temp < 0 Then Temp = 0 water in the heavy liquid phase of the
hyWatStrm.MolarFlow.Calculate Temp saturated stream. If the difference is
negative (i.e., no water is required), set
the molar flow rate of the water fluid to
zero.
EndCalcs: Begin the end calculations procedure.
WorkFluid.Erase Erase contents of the fluid.
WatFluid.Erase
With hyProdStrm Set product stream temperature and
.Pressure.Erase pressure values.
.Pressure.Calculate
hyFeedStrm.PressureValue
.Temperature.Erase
.Temperature.Calculate
hyFeedStrm.TemperatureValue
End With
If hyFeedStrm.MolarFlowValue = 0 Then If feed stream molar flow is 0 then
calculate product stream as feed stream.
hyProdStrm.ComponentMolarFraction.Calculate
hyFeedStrm.ComponentMolarFractionValue
hyProdStrm.MolarFlow.Calculate
hyFeedStrm.MolarFlowValue
Else If feed stream molar flow is not 0, then
Set Streams(0) = hyFeedStrm perform a mole balance.
Set Streams(1) = hyWatStrm
Set Streams(2) = hyProdStrm
hyContainer.Balance btMoleBalance, 2,
Streams
End If
hyContainer.SolveComplete This line prevents a second Calculation
pass, because it is not required. See the
comment associated with the If Not
Forgetting Then line of code at the
beginning of the code. Read the section
on the SolveComplete method in
Extending UniSim Design Help file for
more information.
CalcError(0) = False Reset error flags.
CalcError(1) = False
End If
ErrorTrap: Line to which the On Error statement
branches if an error occurs.
End Sub Signifies the end of the sub-routine. This
line does not need to be added.
3-58
Extensibility 3-59
9. While the Initialize and Execute methods are required for the
implementation of the unit operation extension, it is strongly
recommended you also include a Status Query method that
accurately assesses how the extension is performing.
Code Explanation
Public Sub StatusQuery(hyStatus As ObjectStatus) The StatusQuery sub-routine of the
extension is used to display appropriate
messages on the extension view (EDF
file) in UniSim Design. This sub-routine is
called whenever some change is made to
the extension, whether it is a result of a
solver pass or user interaction.
Dim OK As Boolean Declare and initialize the OK flag.
OK = True
If WaterPresent = False Then If there is no water present in the fluid
Call package, an error message appears
telling you water is required.
hyStatus.AddStatusCondition(slMissingRequire
dInformation, 1, "Water is Required as a
Component")
OK = False
End If
If hyFeedStrm Is Nothing Then If there is no feed stream attached to the
Call unit op, an error message appears telling
you that a feed stream is required.
hyStatus.AddStatusCondition(slMissingRequire
dInformation, 2, "Feed Stream Required")
OK = False
End If
If hyWatStrm Is Nothing Then If there is no water stream attached to
Call the unit op, an error message appears
telling you that a water stream is
hyStatus.AddStatusCondition(slMissingRequire required.
dInformation, 4, "Water Stream Required")
OK = False
End If
If hyProdStrm Is Nothing Then If there is no product stream attached to
Call the unit op, an error message appears
telling you that a product stream is
hyStatus.AddStatusCondition(slMissingRequire required.
dInformation, 3, "Product Stream Required")
OK = False
End If
If myOp.IsIgnored = True Then If the Ignored checkbox is checked then
Call send an Ignored message to the status
bar.
hyStatus.AddStatusCondition(slWarning, 11,
"Ignored")
OK = False
End If
3-59
3-60 Extension Unit Operations
Code Explanation
If OK = False Then Exit Sub These next message can wait until the
connections are made so skip them.
If Not hyFeedStrm.Temperature.IsKnown Then If the feed stream temperature is not
Call known, then send an Unknown Feed
Temperature message to the status bar.
hyStatus.AddStatusCondition(slMissingOptiona
lInformation, 5, "Unknown Feed Temperature")
OK = False
End If
If Not hyFeedStrm.Pressure.IsKnown Then If the feed stream pressure is not known,
Call then send an Unknown Feed Pressure
message to the status bar.
hyStatus.AddStatusCondition(slMissingOptiona
lInformation, 6, "Unknown Feed Pressure")
OK = False
End If
If Not hyFeedStrm.MolarFlow.IsKnown Then If the feed stream molar flow rate is not
Call known, then send an Unknown Feed Flow
message to the status bar.
hyStatus.AddStatusCondition(slMissingOptiona
lInformation, 7, "Unknown Feed Flow")
OK = False
End If
IsKnownFeedArray = Check to see if the feed stream’s
hyFeedStrm.ComponentMolarFraction.IsKnown composition has been set. If it has not,
an error message is sent to the status bar
If Not IsKnownFeedArray(0) Then indicating an Unknown Feed Composition.
Call
hyStatus.AddStatusCondition(slMissingOptiona
lInformation, 8, "Unknown Feed Composition")
OK = False
End If
If CalcError(0) Then If the first error flag has been tripped, it
Call hyStatus.AddStatusCondition(slError, sends a message to the status bar
indicating that the Feed Cannot be
9, "Feed Cannot be Saturated with Water") Saturated with Water.
OK = False
End If
If CalcError(1) Then If the second error flag has been tripped,
Call hyStatus.AddStatusCondition(slError, it sends a message to the status bar
indicating that Water is Required in the
10, "Water is required in Water Stream") Water Stream.
OK = False
End If
End Sub Signifies the end of the sub-routine. This
line does not need to be added.
3-60
Extensibility 3-61
3-61
3-62 Extension Unit Operations
Attachment Flow N
Tag Description Type Persistent
Type Direction Dimensions
FeedStream FeedStrm Attachment Active Material Feed None
Stream
ProductStream ProductStrm Attachment Active Material Product None
Stream
WaterStream WaterStrm Attachment Active Material Feed None
Stream
Figure 3.26
3-62
Extensibility 3-63
Figure 3.27
Figure 3.28
3-63
3-64 Extension Unit Operations
Figure 3.29
3-64
Extensibility 3-65
4. In the Label field of the Static Tabs group change the two
entries Page1 and Page2 to Connections and
Worksheet, respectively.
Figure 3.30
3-65
3-66 Extension Unit Operations
Figure 3.31
The names of the two 9. Click the OK button to return to the Visibility Manager view.
radio buttons that
appear in the
PageController group
have changed to the Adding Widgets to Connections Tab
names of the two page
tabs.
You are now ready to add widgets to the Connections tab on the
DefaultView form.
1. From the Widgets Palette select the Attachment Name
widget. Right-click, hold, and drag the widget on to the
DefaultView form. Move the widget to the left side of the
view.
2. Add two more Attachment Name widgets to the view using
the drag and drop method described in the step above.
Stagger the two widgets in the upper and lower corners of
the right side as shown in Figure 3.32.
3-66
Extensibility 3-67
Figure 3.32
4. First the Feed widgets (i.e., the Attachment Name and Static
Text widget on the left) is defined. For the Feed Static Text
widget specify properties as shown below. When you are
finished click the OK button.
Figure 3.33
3-67
3-68 Extension Unit Operations
Figure 3.34
Ellipsis icon
6. For the Water Stream (i.e., upper right) Static Text widget
specify properties as shown below. When you are finished
click the OK button.
Figure 3.35
3-68
Extensibility 3-69
Figure 3.36
Ellipsis icon
8. For the Product Stream (i.e., lower right) Static Text widget
specify properties as shown below. When you are finished
click the OK button.
Figure 3.37
3-69
3-70 Extension Unit Operations
Figure 3.38
The Target Moniker field
is specified by clicking
the Ellipsis icon
associated with the field
and selecting
ProductStrm from the
Select Attachment view.
Ellipsis icon
Figure 3.39
3-70
Extensibility 3-71
3-71
3-72 Extension Unit Operations
Figure 3.41
7. The Data Set list should contain a default data set. Click the
Insert button to open the Select a Data Type view and add a
new data set to the list.
8. On the Select a Data Type view, select Text as the data type
and click the OK button.
Figure 3.42
3-72
Extensibility 3-73
12. From the list select Object Name as shown in the figure
below and click the OK button.
Figure 3.43
13. The Select Text Variable view closes, and you are returned to
the Text Data Set Properties view.
14. In the Label group enter Name as the label associated with
field and click the OK button to close the Data Set Properties
view.
Figure 3.44
3-73
3-74 Extension Unit Operations
19. From the list select Molar Flow and click the OK button.
The Select Number Variable view closes, and you are
returned to the Numeric Data Set Properties view.
20. In the Label group enter Molar Flow as the label associated
with field and click the OK button to close the Numeric Data
Set Properties view.
Figure 3.45
Other data sets can be 21. Click the OK button on the Matrix Properties view to close
added for other streams
and other stream
the view. The DefaultView form appears similar to the figure
properties, however for shown below.
the sake of brevity,
these are the only two
Figure 3.46
cells defined.
22. Select Save command from the File menu and save the EDF
as Saturate.edf in the same directory as the DLL file.
3-74
Extensibility 3-75
Figure 3.47
3-75
3-76 References
Figure 3.48
3.11 References
1 "An Industrial Design/Control Study for the Vinyl Acetate Monomer
Process", Luyben & Tyreus, p.4.
3-76
Extension View Editor 4-1
4.1 Introduction................................................................................... 3
4.1.1 Accessing the View Editor.......................................................... 4
4.1.2 Creating a New EDF File ............................................................ 5
4.1.3 Editing an Existing EDF File........................................................ 8
4-1
4-2 Extension View Editor
4-2
Extension View Editor 4-3
4.1 Introduction
The View Editor can be used to create or modify Extension
Definition Files (*.edf). Users that are accessing the automation
and extension capabilities of UniSim Design generally make use
of EDF files. The extension definition file acts as the interface
view within UniSim Design as well as the point for variable
declaration and storage.
Figure 4.1
4-3
4-4 Introduction
Figure 4.2
4-4
Extension View Editor 4-5
Figure 4.3
You can now either open an existing EDF or create a new EDF.
4-5
4-6 Introduction
Figure 4.4
4-6
Extension View Editor 4-7
2. Assuming, at this time, that only one view exists for this EDF
file, click the Edit button to open the DefaultView form.
Figure 4.5
4-7
4-8 Using the View Editor
4-8
Extension View Editor 4-9
Alternate Approach
An alternate approach to the above steps #2 through #3 is to
check the Lock checkbox found at the bottom of the Widgets
Palette. Once checked, the mouse cursor changes in to a cross-
hair cursor whenever the mouse cursor is placed over the
DefaultView form. You can then use the cross-hair cursor to
draw the currently selected widget in the Widget Palette by
clicking and dragging the cursor in the DefaultView form.
With the Lock checkbox checked, you can add multiple widgets
of the same type simply by clicking on the DefaultView form
multiple times.
Figure 4.6
4-9
4-10 Using the View Editor
Deleting a Widget
To delete a widget simply select the widget and do one of the
following:
• Press the DELETE key.
• Right-click the widget and from the resulting Object
Inspect menu, select the Delete <Widget Type>
command.
Re-sizing a Widget
To re-size the widget using the mouse:
1. Select the widget.
Notice the cursor
2. Place the cursor over one of the re-sizing handles.
changes to a double-
headed arrow. 3. Hold down the primary mouse button and drag in one of the
directions indicated by the double-headed arrow.
Figure 4.7
4-10
Extension View Editor 4-11
Figure 4.8
Moving a Widget
You can also select To move a widget:
multiple widgets by
dragging a frame 1. Select a widget.
around the widgets of
2. Hold down the primary mouse button and drag the widget to
choice or by selecting
individual widgets while a new location.
holding down the CTRL
Toolbar
When you are creating a new view or editing an existing view,
there is a toolbar containing buttons on the DefaultView form.
These buttons can be used to access some of the widget
properties without opening the particular widget property view.
4-11
4-12 Using the View Editor
Figure 4.9
The tab order is indicated by the integer values in the black dots
covering the widgets. From the Name field (#6), pressing TAB
moves the focus to the Ignored checkbox (#7), then to the
Delete button (#8) and so on.
Notice that static text widgets such as Name, Inlet and Outlet
also receive tab order values. These values should always be
one below the value on the widget with which the static text is
associated. This enables the associated widget to get the focus
when the static text hot key is pressed. For example, when the
user presses ALT N, the focus should be in the text entry cell
where the name can be input. Since the static text Name widget
(#5) cannot accept the focus, the next integer value is used
(#6).
There are two approaches to changing the tab order. You can
click either the Select #1 or the Select Sequentially button. The
4-12
Extension View Editor 4-13
Select #1 Button
When you click this button, the View Editor allows you to select
a different widget to carry the value #1 in the tab order. When a
new #1 is selected, the tab order remains the same, but the
integer values are rotated to accommodate the new #1
selection.
For example, if you clicked the Select #1 button for the valve
view shown previously, and then selected the Text Entry Outlet
widget (current #3), this widget would become #1. All other
widgets would have their integer values increase by 1 with the
old #1, the Static Text Inlet widget, becoming #8 (as shown in
the figure below).
Figure 4.10
If this new order was not what you wanted, you could continue
with a user selected order. Notice the Select Sequentially button
has changed to a selected Select #2 button. So you can select
the widget that you would like to be #2 in the tab order. After
you select a widget to by #2, the Select #2 button changes to
Select #3 button. So you can choose the #3 widget in the tab
order. The sequence number button increase with each selection
until the highest number has been designated to a widget.
4-13
4-14 Using the View Editor
When the highest number (like number 9 from the figure above)
has been designated, the sequence number goes back to #1
and you can resequence the view again. You can keep
resequencing the tab order until the Tab Order icon is clicked
again or the view is closed.
Sizing Icons
Stretch Width
Clicking the Stretch Width icon toggles the X-direction Stretch
checkbox (found in the widget’s Properties view) for the selected
Stretch Width icon widget. When the Stretch checkbox is checked, the width of the
widget increases as the DefaultView form is expanded
horizontally. Stretching is related to the Tie To Corner and the
Tie Reference properties.
Stretch Height
Clicking the Stretch Height icon toggles the Y-direction Stretch
checkbox (found in the widget’s Properties view) for the selected
Stretch Height icon widget. This icon is disabled for those widgets that are not
designed to stretch vertically (vertically-challenged widgets).
4-14
Extension View Editor 4-15
Alignment Icons
These icons are disabled unless you select multiple widgets on a
DefaultView form. The icons that become available depends on
the orientation of the widgets that you have selected.
For instance, if you select two static text widgets, one being
below the other, the icons that become available allow you to
choose a left, centre or right alignment according to the widget
that is chosen as the anchor widget.
Figure 4.11
The anchor widget is the widget that serves as the basis for
alignment and is identified by the resizing handles around its
outline. The other widgets in the group selection become the
widgets that are moved. To change the anchor widget, simply
select another of the selected widgets. This changes the
selected widget’s outline from the solid black line to a thinner
outline with resizing handles.
4-15
4-16 Using the View Editor
4-16
Extension View Editor 4-17
For instance, many UniSim Design views have tabs along the
lower part of the view which enable different information to be
grouped and shown at different times. When the second tab on
a view is selected, the information from the first tab is typically
hidden and the information specific to the second tab is shown.
Figure 4.12
Figure 4.13
4-17
4-18 Using the View Editor
Visibility Manager view Clicking the Edit button opens the Visibility Controller Properties
view.
Figure 4.14
Object Description
Name The controller name. The name entered in to this field is
the name of that appears in the Visibility Manager.
Moniker Clicking the Ellipsis icon associated with this field, opens
the Select Number Variable view. You can select the
moniker type you want to associate to the controller using
Ellipsis icon the Select Number Variable view. See Moniker
Specification sub-section from Section 4.3 - Widget
Properties for more information.
4-18
Extension View Editor 4-19
Object Description
States This group has three different fields that require
specification:
• Name. The name of the state. This appears as a radio
button in the controller group on the Visibility Manager
view.
• Low. The low value for the state.
• High. The high value for the state.
Insert State Click this button to add a new state to the list.
Delete State Select a state and click this button to delete the currently
selected state.
Apply Click this button to apply any changes made on the
Properties view to the Visibility Manager view.
Select Click this button to open the Visibility Controller Widget
Widgets Selections view which allows you to associate widgets with
the state.
Activation Click this button to open the Visibility Controller Activation
view which allows you to create a hierarchy of visibility
states.
Using Tabs
A view created through the View Editor can contain multiple
tabbed sections within the same view. Double-clicking on the
tabs of a view opens the tab Properties view. Labels are added
for each new tab to be displayed.
1. To add a tab to a view, right-click, hold, and drag the Page
Tab widget from the Widget Palette into the DefaultView
form.
2. Resize the tab size to your specifications.
Figure 4.15
4-19
4-20 Using the View Editor
Figure 4.17
4-20
Extension View Editor 4-21
Figure 4.18
9. Enter a name for the first tab in the Name column of the
States group.
10. Enter an integer value in the Low and High cells beside the
Name cell from the above step. The integer value for both
Low and High cells have to be the same.
If the values entered for the Low and High cells is not for the
first tab, increment the values by one for each tabbed sheet
(i.e., High and Low for first tab is 0, High and Low for second
tab is 1).
Figure 4.19
4-21
4-22 Using the View Editor
Figure 4.20
4-22
Extension View Editor 4-23
Figure 4.21
4-23
4-24 Using the View Editor
Column Description
ProgID/ The entry in this cell identifies the name of the object that
CLSID owns the views shown in the Existing Views group of the
Views Manager view. This information must match what is
in the registry and is used by UniSim Design to access the
proper DLL file.
Description This is the text that appears in the appropriate location
within UniSim Design in order to select the extension.
Type This specifies the type of extension. The choices include:
• Unit Operation
• Property Package
• Kinetic Reaction
• Exchanger Design, Base
• Exchanger Design, End Point
• Exchanger Design, Simple
• Exchanger Design, Weighted
• DeltaP (Pressure Drop) Correlation
• Sim Case Translator
• ExternalAddIn
• Pipe Deposition Correlation
• Property Balance
• Mixing Rule
This selection impacts the list of internal Honeywell
variables that are visible when the Ellipsis icon is clicked on
a widget Properties view.
Ellipsis icon Views The number of views associated with this extension.
4-24
Extension View Editor 4-25
Column Description
Tag Represents the internal name of the variable that is stored to
disk (usually input as the same as Name). You cannot have 2
identical tags for the same object.
Name Represents the variable name which is visible on views in the
program (usually the same as Tag). This name should be
unique such that you can identify it in the program. Unlike the
Tag, spaces are allowed in this text string.
Type Variable types include:
• Real Number. Numeric variable for which you can
specify the dimensions and unit type.
• Enumeration. A related set of identifiers, each of which
is associated with an integer value; you can specify the
dimensions and create the enumeration through the
Enumeration Values button.
• Text. A string variable for which you can specify the
dimensions.
• Attachment. Represents a variable associated with an
object that is attached to another object (i.e., a feed
stream is attached to the inlet of a pump, so the feed
stream name is of type Attachment); allows you to
specify the dimensions, attachment type and flow
direction.
• Message. A variable holding information passed when a
button is clicked.
Object Description
Persistent Check this checkbox if you want this variable value to be
saved with the simulation case. Pertains to all variables
except Message variables.
Triggers Check this checkbox if you want changes in the variable to
Solve set off a smart solve (solve whatever needs to be solved).
The checkbox is enabled for all variables ONLY when the
object in question is a Unit Operation. For Real Number and
Enumeration types, this checkbox is checked by default.
4-25
4-26 Using the View Editor
Object Description
Attachment For Attachment variables, you can specify the attachment
Type type as one of the following:
• Stream. Generic specification, implying that the
stream can be either material or energy.
• Material Stream. The attachment is a material
stream and cannot be an energy stream.
• Energy Stream. The attachment is an energy stream
and cannot be a material stream.
Flow The choice for Flow Direction impacts the PFD in its
Direction presentation of nozzles for unit operations in Attach Mode.
For Attachment variables, you can specify the flow direction
as one of the following:
• Unknown. The PFD does not know until run-time if
the attachment is a feed or product; depends if the
attachment is already attached to something.
• Feed. Only feed nozzles are presented by the PFD.
• Product. Only product nozzles are presented by the
PFD.
Numeric For variables of type Real Number, a unit type can be
Type specified. This guarantees that the appropriate value
appears by the view according to the user specified unit
set.
N For all variable types except Message, the variable
Dimensions dimensions can be specified as one of the following:
• None. Single value.
• Vector. One dimensional array.
• Matrix. Two dimensional array.
• Cube. Three dimensional array.
Only the Real Number variable type has access to all
dimension types. The other variable types have access to
only None and Vector.
Enumeration When you click the Enumeration Values button, the
Values Enumeration Values view appears (as shown in Figure
Button 4.22), on which you can create your enumeration. Simply
enter the labels and the integer values with which the
labels are associated.
Figure 4.22
4-26
Extension View Editor 4-27
Figure 4.23
4-27
4-28 Widget Properties
From the Views Manager view, you can click any of the buttons
that pertain to the Existing Views list:
Button Description
Edit Opens the selected view and the Widget Palette.
Test Allows you to test the view.
Add Adds a new view to the object.
Copy Creates a copy of the selected view.
Remove Removes the selected view from the object.
4-28
Extension View Editor 4-29
Moniker Specification
Moniker (or variable) specification is usually done via the Ellipsis
icon that is usually associated with the moniker field. There are
Ellipsis icon usually three types of monikers specified:
4-29
4-30 Widget Properties
The Select Number Variable and Select Text Variable view are
very similar in their appearance and operation. Both consist of a
list that displays the available variables in the variables set (or
sub-set) selected in the Base Object drop-down list.
Figure 4.24
The Base Object drop-down list contains variable sets and sub-
sets. The drop-down list acts as a path to object and object sub-
sets. The default option is the <Form’s Base Object>.
Notice the angle brackets around the Form’s Base Object. This
indicates that the options appearing below it in the drop-down
list are all variable sub-sets. For example, the options that
appear below the Form’s Base Object option are all variable sub-
sets of the DefaultView form. If such a tributary option is
selected, the drop-down list hierarchy immediately changes.
While the selected option appears in the field, when the drop-
down list appear, the selected variable sub-set appears just
below the Form’s Base Object option surrounded by square
brackets. Drop-down list options that appear above the current
selection allow you to return to a higher level of the variable
hierarchy. The options that appear below are in turn sub-sets of
that selection. The display field that appears above the list
displays the variable set path.
4-30
Extension View Editor 4-31
Figure 4.25
The list above the Base Object drop-down list displays all
variables that belong to this sub-set. Selecting the drop-down
list shows that the list has changed. The <Form’s Base Object>
option is placed at the top of the list. If you wanted to return to
a higher level of the object hierarchy you would select this
option. Below it is the current selection in the field, FeedStrm, in
square brackets. The options that appear below the Feedstrm
option are all variable sub-sets of the material stream variable
set.
4-31
4-32 Widget Properties
Figure 4.26
Object Description
Name Each widget is named automatically when it is placed on
the DefaultView form. You can replace the default name
with one that is more descriptive or meaningful.
Fly By Place text in this field to have a message appear in the
UniSim Design status bar and/or as a tool tip when the
cursor is placed over the widget. The ‘\n’ (newline
sequence) is used to differentiate status bar output and
tool tips. Multiple newlines allow for multi-line tool tips.
For example, with the Fly By input of “Performs an
action.\nThe sky is blue”, the message to the left of the
newline sequence, “Performs an action”, would appear in
the status bar and the message to the right of the newline
sequence, “The sky is blue” would appear as a tool tip. If
the newline sequence is not used, the whole message
appears in the status bar.
Position The X and Y values represent the co-ordinate values of the
top left corner of the widget with the reference point being
the top left corner of the DefaultView form. Co-ordinate
units are 1/8 of a character for the Y direction or height and
1/4 of a character for the X direction or width, where the
character in question is of the size seen on a button widget.
Size The X and Y values represent, respectively, the horizontal
and vertical size of the widget. Co-ordinate units are 1/8 of
a character for the Y direction or height and 1/4 of a
character for the X direction or width, where the character
in question is of the size seen on a button widget.
4-32
Extension View Editor 4-33
Object Description
Stretch When the X-direction Stretch checkbox is checked, the
width of the widget increases as the DefaultView form is
expanded horizontally. When the Y-direction Stretch
checkbox is checked, the height of the widget increases as
the DefaultView form is expanded vertically.
Stretching is related to the Tie To Corner and the Tie
Reference properties.
Background Double-click the field to opens the Select A Colour view.
Colour The Select A Colour view allows you to select the
background colour of the widget from all listed internal
widget colours.
Enable Allows you to provide or select a variable that allows you to
Moniker control whether or not the widget is disabled/enabled
(greyed out or normal) at certain times. When the variable
is true, the widget is enabled.
On False Check this checkbox to force a reverse effect for the Enable
Moniker variable. The widget is enabled when the selected
variable is false.
Tie To Corner Select one of the radio buttons, which represents the
corner to which the widget is bound. If the DefaultView
form is stretched, you may want the widget to remain
stationary relative to a certain corner of the DefaultView
form. For example, a button that is placed near the lower
right corner of the DefaultView form can have the lower
right radio button selected. So the button is always the
same distance from the lower right corner of the
DefaultView form if the DefaultView form is stretched
vertically or horizontally.
This property is dependent on the selection for the Tie
Reference property as well as the Stretch properties.
Tie From this drop-down list, you can choose another widget to
Reference which the currently selected widget is bound. This can be
useful when you do not want to have stretching widgets
overlap on a DefaultView form. Otherwise, use the default
selection, which is the DefaultView form.
OK Click this button to close the widget’s Properties view and
accept the properties setting in the Properties view for the
widget.
Cancel Click this button to close the widget’s Properties view
without accepting any current changes made to the
properties setting on the Properties view.
Apply Click this button to apply changes to the widget without
closing the widget’s Properties view. This button is only
available after you made at least one change to the
properties setting.
Visibility The Visibility button opens the Widget Visibility Control
view, which is similar to the Visibility Controller Properties
view. Refer to the Section 4.2.3 - Visibility Manager.
4-33
4-34 Widget Properties
Figure 4.27
Right-click
anywhere on
the
DefaultView
form to access
the Object
Inspect menu.
4-34
Extension View Editor 4-35
Figure 4.28
Object Description
Form Title The text entered in this field, appears in the title bar of the
DefaultView form. The default is a format string (%s) that
simply uses the object name.
Name Source Allows you to choose from a list of sources for the
DefaultView form name. By default, the object name is the
source.
Help Panel This entry provides a link between the view and the help
system, such that a certain help topic appears when F1 is
pressed and the particular view has focus. For extensions,
this is normally left blank.
Form Icon The choice of icon appears in the upper left corner of the
DefaultView form. Double-clicking on the icon brings up a
view from which you can choose an icon from a list of
internal UniSim Design icons.
Background Double-clicking on the associated cell brings up a view from
Colour which you can choose a DefaultView form background
colour from a list of UniSim Design colours.
4-35
4-36 Widget Properties
Object Description
Form Style In this group, you can choose one of the radio buttons that
assigns characteristics to the DefaultView form:
• Normal. A DefaultView form similar to most property
view in UniSim Design.
• Modal. A DefaultView form that always stays on top
of others and does not allow access to other views
until it is closed or de-pegged; can be pegged or not,
depending on the Peggable checkbox selection.
• Floating. A DefaultView form similar to the object
palette, that remains on top but does not restrict
access to other views.
The following checkboxes are also within the Form Style
group:
• Small Caption. Activating this checkbox reduces the
height of the caption area to that of a UniSim Design
face plate or the object palette. The checkbox is
available as a choice only to Normal style views. The
checkbox is checked by default for Floating style
views.
• Peggable. Activating this checkbox allows a modal
DefaultView form to become non-modal by placing a
peg in the upper right corner of the view. The
checkbox is available to Modal style views only.
• Cached Data. Activating this checkbox allows
changes to be made on the DefaultView form without
the object below knowing it until the time when:
FlushCache is called; this allows a user to make
changes to the DefaultView form and then click Cancel
without having the changes accepted; an example of
using this is on the New Object Type form, which can
be accessed from the Setup view of the Workbook.
The OK button sends both the FlushCache and
CloseView messages. The checkbox is available to
Modal style views only.
Action Allows you to specify a message to be sent, much like when
Messages a button is clicked, but in this case, when the user double-
clicks the background of the DefaultView form (Double
Ellipsis icon Click), opens the DefaultView form (Form Open) or closes
the DefaultView form (Form Close). Clicking the Ellipsis icon
brings up a view on which you can add, edit or delete the
messages.
Form Default Select a button name from either the Enter or Escape drop-
Buttons down list to have the button display its message when
either the ENTER key or ESC key is pressed, respectively.
Normal use is having the ENTER key associated with a Close
button and having the ESC key associated with a Cancel
button.
The Enter drop-down list is available with Normal and Modal
DefaultView forms, while the Escape drop-down list is only
available for Modal DefaultView forms.
File/Print The Widget to Print drop-down list allows the selection of a
Override particular widget on the DefaultView form to be printed
instead of the whole DefaultView form. The drop-down list
changes the way Print command under the File menu
works. An example of its use is on the PFD. When the PFD
is printed, all you get is the PFD, not its toolbar, tabs or the
DefaultView form surrounding the PFD.
4-36
Extension View Editor 4-37
Object Description
Borders Allows you to specify the distance that the top, bottom, left,
and right edges of the DefaultView form are from the
outermost widgets. The minimum size of the DefaultView
form is dictated by the placement of the widgets on the
DefaultView form.
Units of measure are 1/8 of a character for the height and
1/4 of a character for the width, where the character in
question is of the size seen on a Button widget.
4-37
4-38 Widget Properties
Object Description
Advanced When you click the Advanced button, the Advanced Form
Properties view appears.
4-38
Extension View Editor 4-39
To access the Button The Button Properties view appears as shown in the figure
Properties view do one
of the following: below.
• Double-click the
button widget. Figure 4.29
• Right-click the
button widget, and
select the Button
Properties
command from the
Object Inspect
menu.
Button Properties
The properties available for a Button widget are described in the
table below:
Object Description
Label Whatever is entered in this field, is shown on the face of the
button. Place an ampersand (&) before the character that
gets the hot key (underscore) designation.
Message This is the command(s) that will be executed/fired when the
button is clicked. Common examples include: Delete and
CloseView. You can click the Ellipsis icon to access the Edit
Ellipsis icon Messages view, which provides a list of the current
messages that are being used for the particular button.
From this view, you can add new messages, delete existing
ones, edit the list or re-arrange the order in which the
messages are fired. If you have created variables of type
Message in the Objects Manager, these are available for
addition to the Edit Messages view.
4-39
4-40 Widget Properties
Object Description
Source Allows you to choose a widget that provides required
Widget information when the button is clicked. It is used to
‘populate’ the arguments for the Message.
For example, the Simulation Basis Manager view shows a list
of fluid packages in the Current Fluid Packages group. The
View button opens a fluid package according to the selection
made in the Current Fluid Packages group. Thus the text list
widget (list of fluid packages) acts as a source widget for the
View button.
Target Allows you to choose a widget which holds a collection of
Widget objects. The selected object or multiple selected objects will
be affected by the clicking of the button.
This is illustrated by the Delete button. This button has the
attachments list widget, which displays all of the column
specifications, as its target widget. By clicking the Delete
button, you are indirectly affecting the attachments list
widget by passing the: Delete message to a particular
Specification object. The target widget is not deleted, but is
updated after the selected Specification object is deleted.
Requires Activating this checkbox limits selection in the source widget
Single to a single item. Continuing the example cited in the Source
Source Widget discussion, activating this checkbox allows you to
select only a single fluid package in the list.
Requires Activating this checkbox limits selection in the target widget
Single to a single item. If the button deletes items from a list, you
Target may want to limit the user to only a single deletion per
button click.
Figure 4.30
4-40
Extension View Editor 4-41
Object Description
Type of Select one of the radio buttons to specify the type of static
Text text widget:
• Fixed. Makes the Fixed Text field available. An example
of the use of this radio button is the descriptive text seen
beside a numerical input field.
• Source. Makes the Source Moniker field and Source
Widget drop-down list available. An example of the use
of this radio button is the status text seen at the bottom
of each unit operation property view.
There is also a Framed checkbox that you can checked if you
want the static text widget to have a frame. Unframed static
text widgets can usually be seen next to numerical or text
input widgets. An example of a framed version is the status
text for each unit operation.
Fixed Text This is available only when the Fixed radio button is selected.
Allows you to enter a string in the Fixed Text input field that
does not change at run-time.
Source This is available only when the Source radio button is
Moniker selected. Allows you to select a text variable that provides the
string for the static text widget. Any variables of type Text
Ellipsis icon that you have set up in the Objects Manager are available
when you click the Ellipsis icon. For a UniSim Design property
view status bar, the usual selection is Description of Highest
Status Condition.
Source Available only when the Source radio button is selected. This
Widget is rarely used in UniSim Design, but it allows you to choose a
widget that supplies the static text with information. For
example, you could select the tabs widget and have the tab
label appear in the static text widget.
Alignment Select a radio button to determine the justification of the text
in the static text widget. Choose Left, Centre, or Right.
4-41
4-42 Widget Properties
Object Description
Colour Allows you to select a variable that determines the
Variable background colour of the static text widget at run time. Click
the Ellipsis icon for current options. For a UniSim Design
Ellipsis icon property view status bar, the usual selection is Colour for
Current Status.
Ellipsis The selection in this drop-down list instructs the static text
Style widget how to show its information when the text is too long
to be fully shown. This should only apply to Source text, not
Fixed text, since you know the length of fixed text and can
adjust the size of the widget to accommodate it. You can
choose from three available options:
• None. The text is cropped according to the widget size.
• Path. Applies to file names; as much of the path name
as possible is shown; for instance, the path c:\program
files\UniSim Design\cases\ed.usc may be shown as
c:\,...\cases\ed.usc.
• End. As much as possible is shown with an ending … if
the text cannot fit.
Figure 4.31
4-42
Extension View Editor 4-43
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Text that you have created in the Object Manager.
Message This is the command(s) that will be executed/fired when
the ENTER key is pressed or the space bar is pressed,
depending on the radio button selection in the Send
Message After group.
Send Select the Enter Key radio button to send the command
Message specified in the Message input after the ENTER key has been
After pressed, or select the Token radio button to send the
Message command after the space bar has been pressed.
Multi-Line Check this checkbox if you would like the text entry widget
to hold more than a single line of text. Scroll bars are
added automatically. For more than a single line to be
shown at a time, you must resize the widget accordingly.
Word Wrap Available only when the Multi-Line checkbox is checked.
Check this checkbox if you would like the widget to start a
new line of text when the width of the widget has been
reached. If this checkbox is unchecked, you must use the
ENTER key to proceed to the next line.
4-43
4-44 Widget Properties
Object Description
Mono Space Check this checkbox to have characters line up perfectly in
Font the vertical direction when using the Multi-Line
functionality.
This is equivalent to selecting Mono Space as a font in the
Session Preferences (Tools-Preferences).
Target By making a selection from this drop-down list, you are
Widget instructing the text entry widget to receive its information
from the Target Widget. When a target widget is selected,
the target moniker must correspond to a variable
associated with the target widget.
For example, you could select an attachment list (i.e., a list
of product streams) as the target widget and have the
selected item in the list, an object, appear in the text entry
widget. You would then have to link the Target Moniker to
the object variable type associated with the attachment list.
Figure 4.32
4-44
Extension View Editor 4-45
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Text that you have created in the Object Manager.
Get/Set As Check this checkbox if you would like all input to the widget
Text to be treated as text. This is useful if you will be passing the
moniker to a method that requires a text parameter. The
entered text loses any formatting that might bet attached to
it (i.e., strips RTF).
Hide Toolbar Checking this checkbox hides the toolbar that accompanies
the rich text entry widget.
Figure 4.33
4-45
4-46 Widget Properties
Object Description
Target This is the variable to which you put your widget data and/or
Moniker from which you get your widget data. It is the variable that is
associated with the widget. Clicking the Ellipsis icon gives a list
Ellipsis icon of available options, including any applicable variables that you
have created in the Object Manager.
Format This is the variable that represents the default format for the
Moniker widget. It is called when the user presses either the DELETE key
in the widget or the Use Default button on the Real Format
Editor view.
Figure 4.34
4-46
Extension View Editor 4-47
Object Description
Target This is the variable to which you put your widget data and/or
Moniker from which you get your widget data. It is the variable that is
associated with the widget. Clicking the Ellipsis icon gives a list
Ellipsis icon of available options, including any variables of type Real
Number or Enumeration that you have created in the Object
Manager.
Format Specify the format for the value in the numerical input widget.
Clicking the Ellipsis icon brings up the Real Format Editor view.
Empty If the value held in the widget becomes -32767, whatever is
Text input in the Empty Text field is shown.
View Only Check this checkbox to make the widget read-only.
Hidden If the value held in the widget becomes -32768, whatever is
Text input in the Hidden Text field is shown.
Time If using a target moniker with time units, specify the format to
Format be shown.
Units There are three particulars in the Units group:
• Var Type Moniker. This is for historical purposes only
and is no longer relevant (the method GetEDVarType is
used internally).
• Show Unit. Check this checkbox if you want to show the
unit associated with the moniker with the value in the
widget.
For information • Fixed Unit Type. Enter a unit here if you want to force
concerning the format of the value in the widget to remain as this unit type
entries in this field, refer regardless of the unit set selection in the Session
to Section 12.3.1 - Preferences. For a temperature moniker, you could enter
Units Page from the ‘C’ and have the value always in Celsius.
UniSim Design User Target By making a selection from this drop-down list, you are
Guide. Widget instructing the Numerical Input widget to receive its
information from the Target Widget. When a target widget is
selected, the target moniker must correspond to a variable
associated with the target widget.
For an example, see the Target Widget property for the text
entry widget.
Use Popup Check this checkbox if you want the edit bar to pop up beside
Edit Bar the numerical input widget as opposed to below the view’s title
bar.
Disable Check this checkbox if you want to disable the fly by
Fly By description that appears when the cursor is over the Numerical
Input widget.
4-47
4-48 Widget Properties
Figure 4.35
4-48
Extension View Editor 4-49
Matrix Properties
The properties available for a Matrix widget are described in the
table below:
Object Properties
Data Sets In this list, you can Edit or Delete a selected data set or
Insert a new data set by clicking the appropriate button.
The View Editor requires a minimum of one data set at all
times for the matrix widget.
When the Insert button is clicked, you must choose the
type of data set from the Select a Data Type view. Each
type has its own set of properties. Only the most frequently
used data set types are described:
• Attachment. For objects such as streams, pump
curves, etc.
• Boolean. Shows a checkbox (or other designated
symbol) for true/false type situations.
• Enumeration. Shows the enumeration label for the
given enumeration value.
• Numeric. For any numeric value, real or integer.
• Text. For text values or labels.
• Unit. Used to show and specify the unit being used
(i.e. for time units, choose between seconds, minutes,
hours, etc.) for other data in the matrix; provides a
link for overriding the Session Preferences unit set for
other matrix data.
Vertical If this checkbox is checked, data sets are added one below
Direction the next (vertical direction).
Multi- If this checkbox is checked, you are able to select multiple
Selectable cells in the matrix, horizontally, vertically, and diagonally.
Sticky Last If this checkbox is checked, placing the focus on the last
Entry entry will keep the focus on the last entry in the matrix
even when additions are being made to the matrix. For
instance, while the solver is performing iterations, run time
data can enter a matrix. If you always wanted to see the
last entry in the list, you would check the Sticky Last Entry
checkbox and place the focus on the last entry in the
matrix. Placing the focus anywhere but on the last entry
will keep the focus on that particular entry, which is also
the behaviour which is exhibited if the checkbox is
unchecked.
Position Allows you to assign different monikers to the x and y
Track locations in the matrix so you can keep track of the exact
Monikers location of the focus. An example of this functionality is in
the Workbook. The Show Name Only button compresses all
the stream information to show only the names of the
streams. The current focus can be on any of the stream
properties (i.e., name, temperature, molar flow) when
uncompressed information is shown. When the Show Name
Only button is clicked the focus moves to the name of the
stream that held the focus, which would be a different row
number.
4-49
4-50 Widget Properties
Object Properties
Labels The Labels group has two drop-down lists, a numerical
entry cell and a cell for a label moniker:
• Unnamed. The first drop-down list is unnamed, but
allows you to choose where you would like labels
shown in the matrix. Your options are None, Row
(place the labels in the left column on each row),
Column (place the labels along the top row on each
column) and Both.
• Show Units. A drop-down list from which you can
choose to display units along with the label on the
Row, in the Column, or on Both, or choose None. This
will likely coincide with your choice of whether or not
to display units.
• Left Width. Enter a value for the leftmost column
when labels are present.
• Moniker. Assign a variable for the labels. An example
of its use is the assignment of labels to a matrix at run
time, when you could have a variety of names in a
matrix. If you are adding column specifications to the
column property view, you will have no idea what
specs will be added until run time, so by retrieving the
spec names through a running label moniker at run
time, you can perform this action.
Cells In this group, you can set global Width, Height and Wrap
values for the matrix widget. The cell width can be
overridden in the individual data set properties. The cell
height of 9 is the standard that is used in all UniSim Design
views. The value for Wrap allows you to force a particular
number of columns of data to be displayed in the matrix.
After this value is reached the next column of data starts at
the far left. An example of this behaviour is on the
Worksheet tab of the Column unit operation (its value is set
to 5).
4-50
Extension View Editor 4-51
Object Properties
Enter Motion Select a direction for the focus movement when the ENTER
key has been pressed in the matrix. The options include:
• None. Stay in the same cell.
• Right. Move to the cell to the right.
• Down. Move to the cell directly below.
• Complement. Move to the complementary matrix cell
(i.e., if focus is in row 2, column 4 move to row 4,
column 2). An example of this behaviour is in the
binary coefficients matrix for the Chien Null activity
model.
• Right Wrap. Use this option in conjunction with the
Wrap cell. When data in the last cell of the rightmost
column has been input, the focus moves to the next
line in the leftmost column. This is used in the view for
molecular weight/density/viscosity assay data input.
• Right if Empty. If the value in the cell was <Empty>
before input, then move to the right; if it held a value
and the user is simply editing, then stay in that cell.
• Down if Empty. If the value in the cell was <Empty>
before input, then move down one cell; if it held a
value and the user is simply editing, then stay in that
cell.
• Complement if Empty. If the value in the cell was
<Empty> before input, then move to the
complementary matrix cell; if it held a value and the
user is simply editing, then stay in that cell.
Grids Specify whether you want the matrix grid shown for each
Column, each Row, Both rows and columns or None at all.
Target By making a selection from this drop-down list, you are
Widget instructing the matrix widget to receive its information from
the Target Widget. When a target widget is selected, the
target moniker must correspond to a variable associated
with the target widget.
For an example, see the Target Widget property for the Text
Entry widget.
DataSet Properties
All data set types have the following common properties:
Figure 4.36
4-51
4-52 Widget Properties
Object Description
Name Retain the default name or input a more descriptive name
for the data set, which appears in the Data Sets list on the
Matrix Properties view.
Fly By Place text in this cell to have a message appear in the
UniSim Design status bar and/or as a tool tip when the
mouse is placed over the data set. This overrides any Fly By
that has been input for the matrix widget. The ‘\n’ (newline
sequence) is used to differentiate status bar output and
tool tips.
For example, with the Fly By input of “Performs an
action.\nThe sky is blue”, the message to the left of the
newline sequence, “Performs an action”, would appear in
the status bar and the message to the right of the newline
sequence, “The sky is blue” would appear as a tool tip. If
the newline sequence is not used, the whole message
appears in the status bar.
Moniker This is the variable to which you put your data and/or from
which you get your data. It is the variable that is associated
with the data set. Clicking the Ellipsis icon gives a list of
Ellipsis icon available options, including any appropriate variables that
you have created in the Object Manager.
Message This is the command(s) that will be executed/fired when
the ENTER key is pressed.
Label Select either the Fixed or Moniker radio button and then
either specify a static label or associate a moniker with the
data set label.
Cell Width Enter a width for the data set cell that overrides the value
Override in the Width cell of the Cells group on the Matrix Properties
view.
View Only Check this checkbox to make the data set read-only.
Attachment
Figure 4.37
Object Description
Drop List Assign a type of sorting for the list of attachments that
Sorting appears in the drop-down list: Ascending (alphabetical),
Descending (reverse alphabetical) or None.
4-52
Extension View Editor 4-53
Object Description
Expand Style This is the recommended way, by controlling through the
widget instead of through code, to control how the matrix
expands.
There are three selections in this drop-down list:
• Always. Adds another field to the matrix when the
current boundary is exceeded. The default setting for
Empty Text is <Empty>.
An example of this behaviour is found for unit
operations that can handle multiple feeds or products.
You are first presented with something like <New
Feed>. As you add feeds, the matrix is expanded and
<New Feed> is added to the bottom of the list. When
the physical size of the matrix is exceeded, scroll bars
appear and another field is added to the bottom of the
list. In this case, the.edf file has been modified
through a text editor to change the Empty Text from
<Empty> to <New Feed>.
• Never. The matrix is limited to the physical size of the
widget.
• Limit. Supply a limit for the maximum size that is
allowed for the data set.
Allow Check this checkbox if you want the user to be able to type
Creation in a name and have a new object (of the particular type) be
created and added to the list if the name does not already
exist.
Show Tag If this checkbox is checked, you will see the flowsheet
Names name attached to the object name if you are currently not
in the flowsheet where the object resides (i.e., from the
column environment, you might see Feed@Main if the
stream Feed was created in the main environment).
Boolean
Figure 4.38
Object Description
True Icon Double-click on this cell to select an icon that represents
the true value of the Boolean, which is the value 1.
False Icon Double-click on this cell to select an icon that represents
the false value of the Boolean, which is the value 0.
Third State Double-click on this cell to select an icon that represents
Icon the (often misunderstood) other state of the Boolean,
which is any value other that 0 or 1.
4-53
4-54 Widget Properties
Enumeration
Figure 4.39
Object Description
Specify EMPTY Check this checkbox if you want -32767 to be set in
on Delete the variable when the user presses DELETE.
Numeric
Figure 4.40
Object Description
Format Specify the format for the value in the data set. Clicking the
Ellipsis icon brings up the Real Format Editor view.
Empty Text If the value held in the matrix cell becomes -32767,
Ellipsis icon whatever is input in the Empty Text field is shown.
Hidden Text If the value held in the matrix cell becomes -32768,
whatever is input in the Hidden Text field is shown.
Variable type This is for historical purposes only and is no longer relevant
override (the method GetEDVarType is now used internally).
moniker
Auto Assigns the appropriate unit according to the specified
Moniker and the chosen Unit Set in the Session
Preferences.
Moniker This choice allows you to override the selection in the
Session Preferences, but also gives the opportunity for the
user to make the unit selection at run time. You must
specify a moniker to be used when this radio button is
selected. This is usually used in conjunction with a Unit
data set, which specifies the unit moniker. The same
moniker is then used in this unit moniker cell, forming a
link between the two cells.
A good example is on the Integrator view, where the user
can select a time unit for the integrator step size. The step
size, minimum and maximum are then shown in that
selected time unit regardless of the choice in the Session
Preferences.
4-54
Extension View Editor 4-55
Object Description
Fixed Allows you to hard code a particular unit type which
overrides the selection in the Session Preferences; for a
temperature moniker, you could enter ‘C’ and have the
value always in Celsius; for the format of entries in this
field, refer to the unit representations as shown in the
Display Units group on the Units page of the Session
Preferences view.
Show Unit in Check this checkbox if you want to show the unit associated
Cell with the data set Moniker along with the value in the cell.
Hide Units in Check this checkbox if you want to hide the unit in the data
Label set label.
Spreadsheet
Figure 4.41
Object Description
Unit System Optional setting. When set it allows the unit set used for
Moniker the held data to differ from the default “Unit Set”
configured in preferences.
Variable This is for historical purposes only and is no longer
Type relevant.
Moniker
Is Formula? Opens the Select Number Variable view. This allows you
Moniker to set whether the moniker will be used to get or set either:
text (a formula) or numbers (non-formula).
Formula Must return an error code form that indicates what type of
Error mathematical error has occurred or when all is well.
Moniker
4-55
4-56 Widget Properties
Unit
Figure 4.42
Object Description
Variable Type This is for historical purposes only and is no longer
Moniker relevant.
Worksheet Attach
Figure 4.43
Object Description
Expand There are three options for this drop-down list:
Style • Always. The default setting. It allows you to
automatically expand the worksheet data set to include
new entries.
• Never. This option does not allow you to expand the
number of variable entries.
• Limit. This option allows you to explicitly set the
number of entries you can expand to.
Numerical Format
Figure 4.44
Object Description
Default This is the variable that represents the default format for
Format the widget. It is called when the user presses either the
DELETE key in the widget or the Use Default button on the
Real Format Editor view.
4-56
Extension View Editor 4-57
Figure 4.45
Checkbox Properties
The properties available for a Checkbox widget are described in
the table below:
Object Description
Label Whatever is entered here is shown as the text next to the
checkbox. Place an ampersand (&) before the character
that gets the hot key (underscore) designation.
Label Select a radio button to place the label text to the left or to
Placement the right of the checkbox.
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Real or Enum that you have created in the Object
Manager.
Target By making a selection from this drop-down list, you are
Widget instructing the checkbox widget to receive its information
from the Target Widget. When a target widget is selected,
the target moniker must correspond to a variable
associated with the target widget.
For an example, see the Target Widget property for the Text
Entry widget.
4-57
4-58 Widget Properties
Figure 4.46
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Real or Enum that you have created in the Object
Manager.
Target By making a selection from this drop-down list, you are
Widget instructing the radio buttons widget to receive its
information from the Target Widget. When a target widget
is selected, the target moniker must correspond to a
variable associated with the target widget.
For an example, see the Target Widget property for the text
entry widget.
4-58
Extension View Editor 4-59
Object Description
Insert Adds another entry in to the radio button details matrix
wherever the focus happens to be, but the entry will not be
named and will have no assigned value. The symbol +++ is
shown in the label cell.
Delete Deletes the entry from the radio button details matrix
wherever the focus happens to be.
Use This is not functional.
Template
Radio Button There are six columns in the matrix in which you can
Details specify details for the radio button widget:
Matrix • Label. Whatever is entered here will be shown as the
text next to the radio button. Place an ampersand (&)
before the character that will get the hot key
(underscore) designation.
• Value. Each radio button must have a unique value,
such that it can be used in code, if need be. The value
can be integer or real, it simply needs to be unique
within the scope of the particular widget.
• X. X coordinate of the particular radio button on the
DefaultView form. For information concerning the
units used, refer to the Position section under
Common Widget Properties.
• Y. Y coordinate of the particular radio button on the
DefaultView form. For information concerning the
units used, refer to the Position section under
Common Widget Properties.
• Width. Width of the widget. If you input different
values for each radio button, the largest value will be
honoured. For information concerning the units used,
refer to the Position section under Common Widget
Properties.
• Placement. Choice for where you want to place the
label, in reference to the radio button. Either On Left
or On Right.
4-59
4-60 Widget Properties
Figure 4.47
Object Description
Main Icon Double-click on this cell to make a choice for the icon that
will appear on the button.
Focus Icon Double-click on this cell to make a choice for the icon that
will appear with the Main Icon on the button when the
button has focus. The default for Focus Icon is the regular
dotted outline that appears with most Windows programs.
4-60
Extension View Editor 4-61
Object Description
Message This is the command(s) that will be executed/fired when
the button is pressed. For the button shown above, the
property view of the upstream unit operation will be shown.
You can click the Ellipsis icon to access the Edit Messages
view, which provides a list of the current messages that are
being used for the particular button. From this view, you
can add new messages, delete existing ones, edit the list or
re-arrange the order in which the messages are fired. If
you have created variables of type Message in the Objects
Manager, these will be available for addition to the Edit
Messages view.
Source Allows you to choose a widget that will provide required
Widget information when the button is fired. It is used to ‘populate’
the arguments for the Message. For example, the index
value of an object in a list could be provided to the button
so the button can perform some action on the particular
object. You can use placement holder type syntax (i.e.,%d
for an integer).
Target Allows you to choose a widget which holds a collection of
Widget objects. The selected object or multiple selected objects will
be affected by the firing of the button. For an example,
refer to the Target Widget section for the Button widget.
Value Type Allows you to choose what type of data is held or passed
when the button is pressed. You can choose one of the
following:
• None. The button’s only purpose is to fire its message
when it is pressed. The View Next Downstream
Operation button is an example of the use of this
option.
• Number. A numeric value is held when the button has
been pressed. The Colour Scheme button on the PFD
is an example of the use of this option.
• Object Type. An object type string is held when the
button is pressed. All unit operation and stream
buttons on the Object Palette use this option.
Repeat In these two fields, Initial and Fast, you can enter values
Delays that respectively represent the time that elapses before the
first message is sent and the time interval that will pass
before the sending of each subsequent message if the
button is held down. The units used for the time entries are
milliseconds.
This is used for the rotation of plots, where the user
presses and holds a button down to continually rotate the
plot until the desired view is attained.
4-61
4-62 Widget Properties
Object Description
Sticky These options allow you to set whether or not the button
Options will remain in its pressed state (Stuck) when it is pressed
and also if it is in its pressed state, whether or not pressing
the button again will remove it from its pressed state
(Released).
You can assign a variable (normally of type Boolean) in the
Variable cell to the option, which will allow you to monitor
the state of the button (Stuck or Released).
By providing values in the Stuck and Released cells, you
can assign one of two behaviours for the button:
• Pressing a Stuck button releases the button - provide a
unique value in each cell (i.e. 50 and 65)
• A Stuck button is released by another object - provide
the same value in each cell. This behaviour is exhibited
by the unit operation and stream buttons on the
Objects Palette. For instance, pressing a Cooler
operation button will make it stuck. You cannot release
the button by pressing it again. You must click the
Cancel button (the red X), click the Add button (the
green +), click another unit operation or stream button
in the palette or click on the PFD to add the operation.
Requires Activating this checkbox limits selection in the source
Single widget to a single item. Continuing the example cited in the
Source Source Widget discussion, activating this checkbox will
allow the user to select only a single fluid package in the
list.
Requires Activating this checkbox limits selection in the target
Single Target widget to a single item. If the button deletes items from a
list, you may want to limit the user to only a single deletion
per button click.
Accepts Check this checkbox if you want the button to take away
Focus the focus when it is pressed or to have the ability to accept
the focus when its tab order number is selected by pressing
the TAB key.
For instance, none of the buttons in the PFD toolbar have
this checkbox checked, and as such, do not accept the
focus when they are pressed. Focus remains with whatever
was selected in the PFD. Also, you cannot access the
buttons by pressing the TAB key.
Support Drag Check this checkbox if the button widget will be drag and
drop compliant. All unit operation and stream buttons in the
Object Palette have this checkbox checked, and thus, when
a button is selected with the secondary mouse button and
dragged, the value can be dropped onto another widget
(i.e. the PFD).
4-62
Extension View Editor 4-63
Figure 4.48
Group Properties
The properties available for a Group widget are described in the
table below:
Object Description
Title Enter a title for the group. Use the ampersand (&) before the
character that is the accelerator key or hot key.
4-63
4-64 Widget Properties
Figure 4.49
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Real or Enum that you have created in the Object
Manager.
Static Tabs In this group, supply a Label and a unique Value for each
tab that will appear in this widget.
The unique Value that is supplied for each tab should match
the High/Low values that you provide in the Visibility
Controller Properties view. Refer to the Section 4.2.3 -
Visibility Manager for more information.
4-64
Extension View Editor 4-65
Object Description
Draw Border check this checkbox if would like a rectangular area around
the tabs to have a three-dimensional sunken effect. The
tabs in UniSim Design do not have this option enabled.
Dynamic There are three areas in this group, each of which deals with
Tabs the changing of the tabs at run-time:
• Label Moniker. Supply a variable in this cell if you
have to adapt the view according to user input at run-
time. For instance, the results view for the case study
tool in UniSim Design has a Label moniker (variable)
since the user can create as many case studies as
required in the simulation. The view must show one
tab per case study created.
• First Value. Provide a unique value in this cell such
that the first tab added at run-time does not conflict
with any of the values for the static tabs. This value
should be greater than the largest unique value that
you are using in the Static Tabs group.
• Move Tab Message. Allows you to input a custom
message, which will be defined in your code, to enable
the movement/re-ordering of the tabs at run-time by
the user. This functionality is found in the Workbook,
where you can select a tab, drag down below the tab
and then drag to the side where you would like to
move the tab. All tab contents are moved with the tab.
Controlled The widget selected in this drop-down list will receive the
Widget focus when a tab is selected. This functionality provides
visual appeal in that the tab seems to be part of the
controlled widget. The user does not have to click within the
controlled widget after selecting a tab. Normal use of this
option occurs when the selected widget is the only other
widget on the DefaultView form or when there is a clearly
dominant widget that will be the main focus of the user.
This functionality is used in the Workbook and in the PFD, in
which you can select a particular tab and the focus is
automatically placed within the particular Workbook sheet
or PFD pane.
Target By making a selection from this drop-down list, you are
Widget instructing the tabs widget to receive its information from
the Target Widget. When a target widget is selected, the
target moniker must correspond to a variable associated
with the target widget.
For an example, see the Target Widget property for the text
entry widget.
4-65
4-66 Widget Properties
Figure 4.50
4-66
Extension View Editor 4-67
Object Description
Title In this group you can provide a title for the ply picker
Options widget. Refer to the example widget shown previously,
which has the title Design, to see where the title is placed.
You see a different input cell in this group depending on the
radio button selection. The radio button selections are:
• Fixed. Choose this option if you want to supply a static
title, and then supply the text in the Title input cell.
• Dynamic. If you would like the title to be dynamic (i.e.
ability to change at run-time), select this option and
then associate the title with a variable in the Title
Moniker cell. Any variables of type Text that you have
created in the Object Manager will be shown when you
click the Ellipsis icon.
• Other Widget. Select this option if you want to choose
a widget that will supply the ply picker title with
information. You can then select a widget from the
Source Widget drop-down list. For example, you could
select the tabs widget and have the tab label appear as
the ply picker title widget. This is how the ply picker
widget on the UniSim Design unit operation property
views are configured.
Enum Allows you to associate an enumeration variable to the
Moniker widget so that the name of each individual ‘ply’ can appear
on the widget. For example, the widget shown previously,
the enumeration contains the names Connections,
Parameters, User Variables and Notes.
Target This is the variable to which you put your widget data and/or
Moniker from which you get your widget data. It is the variable that
is associated with the widget. Clicking the Ellipsis icon gives
Ellipsis icon a list of available options, including any variables of type
Real or Enum that you have created in the Object Manager.
Target By making a selection from this drop-down list, you are
Widget instructing the ply picker widget to receive its information
from the Target Widget. When a target widget is selected,
the target moniker must correspond to a variable associated
with the target widget.
For an example, see the Target Widget property for the Text
Entry widget.
4-67
4-68 Widget Properties
Figure 4.51
Object Description
Number of In this cell, you specify the size of the list that is shown
Entries when the drop-down list is accessed. If more objects
exist than the value specified, a scroll bar is
automatically added to the drop-down list.
Target Moniker This is the variable to which you put your widget data
and/or from which you get your widget data. It is the
variable that is associated with the widget.Clicking the
Ellipsis icon Ellipsis icon gives a list of available options, including
any variables of type Attachment that you have
created in the Object Manager.
Target Widget By making a selection from this drop-down list, you are
instructing the attachment name widget to receive its
information from the Target Widget. When a target
widget is selected, the target moniker must correspond
to a variable associated with the target widget.
For an example, see the Target Widget property for the
Text Entry widget.
4-68
Extension View Editor 4-69
Object Description
Attach Message Allows you to specify a command(s) that will be
executed/fired when a choice is made in the
attachment name widget. All variables of type Message
that you created in the Objects Manager will be
available if you click the Ellipsis and then click the
Insert button on the Edit Messages view.
Allow creation Check this checkbox if you want the user to be able to
type directly in the attachment name widget and have
the application create a new object of type Attachment
with the user input name.
Most unit operation views that have attachment name
widgets will allow the creation of a new attached
stream when the user types a name directly in the
widget.
Use drop list Check this checkbox if you want the widget to show its
drop-down list when checked. If this checkbox is
unchecked, the widget appears as though it is a text
entry widget.
Match using Check this checkbox if you want the focus in the drop-
abbreviations down list to move to the first occurrence of the letter or
letter combination that the user types.
This checkbox is available only when the Use drop list
checkbox is checked.
Drop List Sorting Select one of the radio buttons to instruct the widget
on how you would like the items in the drop-down list
shown:
• Ascending. Items are shown alphabetically.
• Descending. Items are shown in reverse
alphabetical order.
• None. Items are shown in the order in which they
are added to the application.
4-69
4-70 Widget Properties
Figure 4.52
Enumeration Properties
The properties available for a Enumeration widget are described
in the table below:
Object Description
Number of In this cell, you specify the size of the list that is shown
Entries when the drop-down list is accessed. If more objects
exist than the value specified, a scroll bar is
automatically added to the drop-down list.
Target Moniker This is the variable to which you put your widget data
and/or from which you get your widget data. It is the
variable that is associated with the widget. Clicking the
Ellipsis icon Ellipsis icon gives a list of available options, including
any variables of type Enumeration that you have
created in the Object Manager.
Target Widget By making a selection from this drop-down list, you are
instructing the enumeration widget to receive its
information from the Target Widget. When a target
widget is selected, the target moniker must correspond
to a variable associated with the target widget.
For an example, see the Target Widget property for the
Text Entry widget.
4-70
Extension View Editor 4-71
Object Description
Match using Check this checkbox if you want the focus in the drop-
abbreviations down list to move to the first occurrence of the letter or
letter combination that the user types.
Drop List Sorting Select one of the radio buttons to instruct the widget
on how you would like the items in the drop-down list
shown:
• Ascending. Items are shown alphabetically.
• Descending. Items are shown in reverse
alphabetical order.
• None. Items are shown in the order in which they
are added to the application.
Figure 4.53
4-71
4-72 Widget Properties
Object Description
Number of In this cell, you specify the size of the list that is shown
Entries when the drop-down list is accessed. If more objects exist
than the value specified, a scroll bar is automatically added
to the drop-down list.
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Text that you have created in the Object Manager.
Target By making a selection from this drop-down list, you are
Widget instructing the unit enumeration widget to receive its
information from the Target Widget. When a target widget
is selected, the target moniker must correspond to a
variable associated with the target widget.
For an example, see the Target Widget property for the
text entry widget.
Unit Type/ This cell along with its corresponding radio buttons (Fixed
Unit Type and Source) are for historical purposes only.
Moniker
Match using Check this checkbox if you want the focus in the drop-
abbreviations down list to move to the first occurrence of the letter or
letter combination that the user types.
Drop List Select one of the radio buttons to instruct the widget on
Sorting how you would like the items in the drop-down list shown:
• Ascending. Items are shown alphabetically.
• Descending. Items are shown in reverse
alphabetical order.
• None. Items are shown in the order in which they are
added to the application.
4-72
Extension View Editor 4-73
Figure 4.54
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Text that you created in the Objects Manager. Any
variables of type Text that you create must have Vector
selected in the N Dimensions drop-down list.
Message This is the message that is executed/sent when the user
presses ENTER or double-clicks on the selection in the
widget. Normal use would have the object’s property view
open.
Delete This is the message that will be executed/fired when the
Message user presses DELETE on the selection in the widget. Normal
use would have the object being deleted.
Insert This is the message that will be executed/fired when the
Message user presses INSERT while the focus is within the widget.
4-73
4-74 Widget Properties
Object Description
Track Supply a variable in this cell which will allow you to keep a
Moniker record of the selected object in the list or set the selected
object in the list, depending on how it is used in your code.
When there is multiple selection in the list, the first
(topmost) object in the selection will be accessed through
the track moniker. The track moniker will not correspond to
the object that has focus when multiple selection is made
from the top down, as the bottom most object will have the
dotted outline or focus.
Sorting Select one of the options in the drop-down list to instruct
the widget on how you would like the items in the widget
to be shown:
• Ascending. Items are shown alphabetically.
• Descending. Items are shown in reverse
alphabetical order.
• None. Items are shown in the order in which they are
added to the application.
Multi- Check this checkbox if you want to allow more than a
Selectable single selection in the widget.
Sticky Last If this checkbox is checked, placing the focus on the last
Entry entry will keep the focus on the last entry in the widget
even when additions are being made to the widget. Refer
to this option in the Matrix widget for an example.
Append Extra Check this checkbox if you want a blank row to always be
Blank present at the end of the list. This is useful when the user
is able to select the position of new entrants to the list. By
placing the focus on the blank row at the end, the new list
entrant will added to the end of the list. Placing the focus
on an existing list entry will have the new list entrant
added above this selection. This behaviour is exhibited in
the Current Component List on the Components tab of the
Fluid Package view.
Initially Check this checkbox if you want to have an item selected
Selected in the widget when the view is re-opened. This option
retrieves the list item identified in the track moniker and
tries to match this information to an item that you may
have coded (i.e. by name). If no match is found, the first
item in the list becomes the selected item and this
information is sent to the track moniker. A selected item
does not necessarily have the focus.
Source Allows you to choose a widget that will provide required
Widget information when any message is fired. It is used to
‘populate’ the arguments for a message.
Target By making a selection from this drop-down list, you are
Widget instructing the text list widget to receive its information
from the Target Widget. When a target widget is selected,
the target moniker must correspond to a variable
associated with the target widget.
For an example, see the Target Widget property for the
text entry widget.
Abbrev Keys Check this checkbox if you want the focus in the list to
move to the first occurrence of the letter or letter
combination that the user types.
4-74
Extension View Editor 4-75
Object Description
Draw Border Check this checkbox if you would like a rectangular area
around the text list to have a three-dimensional sunken
effect.
Tab Stops Add values here which correspond to the use of ‘\t’, the tab
character, in the text strings that will populate the text list
widget.
If there are two occurrences of the tab character in the
text strings that will fill the widget, there should be two tab
stops, indicating the position to start the string after the
tab. With 2 tab stops, it will seem as though there are
three columns of information in the text list widget.
Column If you provide a value (the width of each column) in this
Width cell, list entries will wrap to the right in to a new column
when the current widget size has been reached. If no value
is provided, the list will keep expanding in a single column
with the appearance of scroll bars when the widget height
has been reached.
Figure 4.55
4-75
4-76 Widget Properties
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget.Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Enumeration that you created in the Objects Manager.
Message This is the message that is executed/sent when the user
presses ENTER or double-clicks on the selection in the
widget. Normal use would have the object’s property view
open.
Delete This is the message that will be executed/fired when the
Message user presses DELETE on the selection in the widget. Normal
use would have the object being deleted.
Insert This is the message that will be executed/fired when the
Message user presses INSERT while the focus is within the widget.
Track Supply a variable in this cell which will allow you to keep a
Moniker record of the selected object in the list or set the selected
object in the list, depending on how it is used in your code.
When there is multiple selection in the list, the first (top
most) object in the selection will be accessed through the
track moniker. The track moniker will not correspond to the
object that has focus when multiple selection is made from
the top down, as the bottommost object will have the
dotted outline or focus.
Sorting Select one of the options in the drop-down list to instruct
the widget on how you would like the items in the widget to
be shown:
• Ascending. Items are shown alphabetically.
• Descending. Items are shown in reverse alphabetical
order.
• None. Items are shown in the order in which they are
added to the application.
Multi- Check this checkbox if you want to allow more than a
Selectable single selection in the widget.
Sticky Last If this checkbox is checked, placing the focus on the last
Entry entry will keep the focus on the last entry in the widget
even when additions are being made to the widget. Refer
to this option in the Matrix widget for an example.
Append Extra Check this checkbox if you want a blank row to always be
Blank present at the end of the list. This is useful when the user
is able to select the position of new entrants to the list. By
placing the focus on the blank row at the end, the new list
entrant will be added to the end of the list. Placing the
focus on an existing list entry will have the new list entrant
added above this selection. This behaviour is exhibited in
the Current Component List on the Components tab of the
Fluid Package view.
4-76
Extension View Editor 4-77
Object Description
Initially Check this checkbox if you want to have an item selected in
Selected the widget when the view is re-opened. This option
retrieves the list item identified in the track moniker and
tries to match this information to an item that you may
have coded (i.e. by name). If no match is found, the first
item in the list becomes the selected item and this
information is sent to the track moniker. A selected item
does not necessarily have the focus.
Source Allows you to choose a widget that will provide required
Widget information when any message is fired. It is used to
‘populate’ the arguments for a message.
Target By making a selection from this drop-down list, you are
Widget instructing the enumeration list widget to receive its
information from the Target Widget. When a target
widget is selected, the target moniker must correspond to
a variable associated with the target widget.
For an example, see the Target Widget property for the
text entry widget.
Abbrev Keys Check this checkbox if you want the focus in the list to
move to the first occurrence of the letter or letter
combination that the user types.
Draw Border Check this checkbox if you would like a rectangular area
around the enumeration list to have a three-dimensional
sunken effect.
Tab Stops Add values here which correspond to the use of ‘\t’, the tab
character, in the enumeration labels that will populate the
enumeration list widget.
If there are two occurrences of the tab character in the
enumeration labels that will fill the widget, there should be
two tab stops, indicating the position to start the label after
the tab. With 2 tab stops, it will seem as though there are
three columns of information in the enumeration list
widget.
Column If you provide a value (the width of each column) in this
Width cell, list entries will wrap to the right in to a new column
when the current widget size has been reached. If no value
is provided, the list will keep expanding in a single column
with the appearance of scroll bars when the widget height
has been reached.
4-77
4-78 Widget Properties
Figure 4.56
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Attachment that you created in the Objects Manager.
Any variables of type Attachment that you create must
have Vector selected in the N Dimensions drop-down list.
Message This is the message that is executed/sent when the user
presses ENTER or double-clicks on the selection in the
widget. Normal use would have the object’s property view
open.
Delete This is the message that will be executed/fired when the
Message user presses DELETE on the selection in the widget. Normal
use would have the object being deleted.
Insert This is the message that will be executed/fired when the
Message user presses INSERT while the focus is within the widget.
4-78
Extension View Editor 4-79
Object Description
Track Supply a variable in this cell which will allow you to keep a
Moniker record of the selected object in the list or set the selected
object in the list, depending on how it is used in your code.
When there is multiple selection in the list, the first
(topmost) object in the selection will be accessed through
the track moniker. The track moniker will not correspond to
the object that has focus when multiple selection is made
from the top down, as the bottommost object will have the
dotted outline or focus.
Sorting Select one of the options in the drop-down list to instruct
the widget on how you would like the items in the widget to
be shown:
• Ascending. Items are shown alphabetically.
• Descending. Items are shown in reverse alphabetical
order.
• None. Items are shown in the order in which they are
added to the application.
Multi- Check this checkbox if you want to allow more than a single
Selectable selection in the widget.
Sticky Last If this checkbox is checked, placing the focus on the last
Entry entry will keep the focus on the last entry in the widget
even when additions are being made to the widget. Refer to
this option in the Matrix widget for an example.
Append Check this checkbox if you want a blank row to always be
Extra Blank present at the end of the list. This is useful when the user is
able to select the position of new entrants to the list. By
placing the focus on the blank row at the end, the new list
entrant will be added to the end of the list. Placing the
focus on an existing list entry will have the new list entrant
added above this selection. This behaviour is exhibited in
the Current Component List on the Components tab of the
Fluid Package view.
Initially Check this checkbox if you want to have an item selected in
Selected the widget when the view is re-opened. This option
retrieves the list item identified in the track moniker and
tries to match this information to an item that you may
have coded (i.e. by name). If no match is found, the first
item in the list becomes the selected item and this
information is sent to the track moniker. A selected item
does not necessarily have the focus.
Source Allows you to choose a widget that will provide required
Widget information when any message is fired. It is used to
‘populate’ the arguments for a message.
Target By making a selection from this drop-down list, you are
Widget instructing the attachment list widget to receive its
information from the Target Widget. When a target widget
is selected, the target moniker must correspond to a
variable associated with the target widget.
For an example, see the Target Widget property for the text
entry widget.
Abbrev Keys Check this checkbox if you want the focus in the list to
move to the first occurrence of the letter or letter
combination that the user types.
4-79
4-80 Widget Properties
Object Description
Hide Tags Check this checkbox if you do not want to show name of
the flowsheet with the name of the object in the list. The
flowsheet name will only appear when the object is being
shown outside its home flowsheet.
For instance, in a list of material streams, a stream
representing the reflux to a column, which is internal to the
column environment, may appear in a list in the main
flowsheet as Reflux@COL1 if the Hide Tags checkbox is
unchecked. With this checkbox checked, the user would
only see Reflux.
Draw Border Check this checkbox if you would like a rectangular area
around the attachment list to have a three-dimensional
sunken effect.
Allow Detach Check this checkbox if you want the object pointer to be
replaced by NULL when the attachment is deleted. If this
option is used, the code must account for this scenario. The
Allow Detach option is only valid when the Delete Message
is not being used.
Column If you provide a value (the width of each column) in this
Width cell, list entries will wrap to the right in to a new column
when the current widget size has been reached. If no value
is provided, the list will keep expanding in a single column
with the appearance of scroll bars when the widget height
has been reached.
4-80
Extension View Editor 4-81
Figure 4.57
Level Properties
The properties available for a Level widget are described in the
table below:
Object Description
Format Specify the format for the value in the widget. Clicking the
Ellipsis icon brings up the Real Format Editor view.
Fixed Units Enter a unit here if you want to force the value in the
Ellipsis icon widget to remain as this unit type regardless of the unit set
selection in the Session Preferences. For a temperature
moniker, you could enter ‘C’ and have the value always in
Celsius.
For information concerning the format of entries in this
field, refer to Section 12.3.1 - Units Page from the
UniSim Design User Guide.
Variable This is for historical purposes only and is no longer relevant
Type (the method GetEDVarType is used internally).
Moniker
4-81
4-82 Widget Properties
Object Description
Target This is the variable to which you put your widget data and/
Moniker or from which you get your widget data. It is the variable
that is associated with the widget. Clicking the Ellipsis icon
Ellipsis icon gives a list of available options, including any variables of
type Real Number or Enumeration that you have created in
the Object Manager.
Orientation The radio button selection in this group provides
instructions on how to draw the graphical portion of the
widget. The choices are:
• Horizontal. The line representing the current value in
the range will be vertical. The use of Horizontal stems
from the fact that the ‘used’ portion and ‘unused’
portion of the range are seen one beside the other.
• Vertical. The line representing the current value in
the range will be horizontal. The use of Vertical stems
from the fact that the ‘used’ portion and ‘unused’
portion of the range are seen one above the other.
Increment Enter a value here which is used as the incremental step
size when the current value pointer is dragged in the level
widget. For the OP cell in a face plate, you can click on the
current value (when the controller is in Manual) with the
mouse and drag the line to a new output value. The
increment value for the OP cell is 0.01.
Minimum The Minimum cell as shown has no relevance. Both the
Minimum and Maximum values in the target moniker range
should be determined through monikers or through the
code.
Maximum The Maximum cell as shown has no relevance. Both the
Minimum and Maximum values in the target moniker range
should be determined through monikers or through the
code.
Show Unit Check this checkbox if you want to show the unit associated
with the moniker with the value in the widget.
View Only Check this checkbox to make the widget read-only.
Target By making a selection from this drop-down list, you are
Widget instructing the level widget to receive its information from
the Target Widget. When a target widget is selected, the
target moniker must correspond to a variable associated
with the target widget.
For an example, see the Target Widget property for the Text
Entry widget.
4-82
Extension View Editor 4-83
Object Description
Display Mode The display mode represents the graphical portion of the
widget. Select either radio button:
• Percent. The graphical bar representing the current
value in the level widget will be shown at the
percentage value in the range. If you are monitoring a
temperature between 0 and 200°C, and the current
value is 20°C, the bar shows up at the 10% point in
the range.
• Actual. The graphical bar representing the current
value in the level widget will be shown at the current
value in the range. If you are monitoring a
temperature between 0 and 200°C, and the current
value is 20°C, the bar shows up at the 20°C point in
the range.
It is recommended that you select the same radio button
choice in both the Display Mode and the Value groups.
Value The value represents the numeric value shown in the
widget. Select either radio button:
• Percent. The numeric value in the level widget is
shown as the percentage value in the range. If you are
monitoring a temperature between 0 and 200°C, and
the current value is 20°C, you see 10 in the widget
representing 10% of the range.
• Actual. The numeric value in the level widget is
shown as the actual value in the range. If you are
monitoring a temperature between 0 and 200°C, and
the current value is 20°C, you see 20°C in the widget.
It is recommended that you select the same radio button
choice in both the Display Mode and the Value groups.
4-83
4-84 Widget Properties
Figure 4.58
Plot Properties
The properties available for a Plot widget are described in the
table below:
Object Description
Draw Check this checkbox if you would like a rectangular area
Border around the plot to have a three-dimensional sunken effect.
Plot Enter a description (with no spaces in the name) here such
Description that you can access the widget through code.
Target This is the variable to which you put your widget data and/or
Moniker from which you get your widget data. It is the variable that is
associated with the widget. Clicking the Ellipsis icon gives a
Ellipsis icon list of available options, including any variables of type Real
Number or Enumeration that you have created in the Object
Manager.
4-84
Extension View Editor 4-85
4-85
4-86 Widget Properties
Object Description
For more information on Data Sets In this list, you can Edit or Delete a selected data set or
the data set type Insert a new data set by clicking the appropriate button.
properties see DataSet The View Editor requires a minimum of one data set at all
Properties found in times for the worksheet matrix widget.
Section 4.3.9 - Matrix
When the Insert button is clicked, you must choose the
Widget.
type of data set from the Select a Data Type view. Each
type has its own set of properties. Only the most frequently
used data set types are described:
• Attachment. For objects such as streams, pump
curves, etc.
• Boolean. Shows a checkbox (or other designated
symbol) for true/false type situations.
• Enumeration. Shows the enumeration label for the
given enumeration value.
• Numeric. For any numeric value, real or integer.
• Text. For text values or labels.
• Unit. Used to show and specify the unit being used
(i.e., for time units, choose between seconds,
minutes, hours, etc.) for other data in the matrix;
provides a link for overriding the Session Preferences
unit set for other matrix data.
Vertical If this checkbox is checked, data sets are added one below
Direction the next (vertical direction).
Multi- If this checkbox is checked, you are able to select multiple
Selectable cells in the matrix, horizontally, vertically and diagonally.
Sticky Last If this checkbox is checked, placing the focus on the last
Entry entry will keep the focus on the last entry in the matrix
even when additions are being made to the matrix. For
instance, while the solver is performing iterations, run time
data can enter a matrix. If you always wanted to see the
last entry in the list, you would check the Sticky Last Entry
checkbox and place the focus on the last entry in the
matrix. Placing the focus anywhere but on the last entry
will keep the focus on that particular entry, which is also
the behaviour which will be exhibited if the checkbox is
unchecked.
Position Allows you to assign different monikers to the x and y
Track locations in the matrix so you can keep track of the exact
Monikers location of the focus. An example of this functionality is in
the Workbook. The Show Name Only button compresses all
the stream information to show only the names of the
streams. The current focus can be on any of the stream
properties (i.e. name, temperature, molar flow) when
uncompressed information is shown. When the Show Name
Only button is clicked the focus moves to the name of the
stream that held the focus, which would be a different row
number.
4-86
Extension View Editor 4-87
Object Description
Labels The Labels group has two drop-down lists, a numerical
entry cell and a cell for a label moniker:
• Unnamed. The first option is unnamed, but allows
you to choose where you would like labels shown in
the matrix. Your options are None, Row (place the
labels in the left column of each row), Column (place
the labels along the top row on each column) and
Both.
• Show Units. A drop-down list which you can choose
to display units along with label on the Row, in the
Column or on Both or choose None. This will likely
coincide with your choice of whether or not to display
units.
Cells In this group, you can set global Width, Height and Wrap
values for the worksheet matrix widget. The cell width can
be overridden in the individual data set properties. The cell
height of 9 is the standard that is used in all UniSim Design
views. The value for Wrap allows you to force a particular
number of columns of data to be displayed in the matrix.
After this value is reached the next column of data will start
at the far left. An example of this behaviour is on the
Worksheet tab of the Column unit operation (its value is set
to 5).
Enter Motion Select a direction for the focus movement when the ENTER
key has been pressed in the matrix. The options include:
• None. Stay in the same cell.
• Right. Move to the cell to the right.
• Down. Move to the cell directly below.
• Complement. Move to the complementary matrix cell
(i.e. if focus is in row 2, column 4 move to row 4,
column 2). An example of this behaviour is in the
binary coefficients matrix for the Chien Null activity
model.
• Right Wrap. Use this option in conjunction with the
Wrap cell. When data in the last cell of the rightmost
column has been input, the focus moves to the next
line in the leftmost column. This is used in the view for
molecular weight/density/viscosity assay data input.
• Right if Empty. If the value in the cell was <empty>
before input, then move to the right; if it held a value
and the user is simply editing, then stay in that cell.
• Down if Empty. If the value in the cell was <empty>
before input, then move down one cell; if it held a
value and the user is simply editing, then stay in that
cell.
• Complement if Empty. If the value in the cell was
<empty> before input, then move to the
complementary matrix cell; if it held a value and the
user is simply editing, then stay in that cell.
4-87
4-88 Widget Properties
Object Description
Grids Specify whether you want the matrix grid shown for each
Column, each Row, Both rows and columns or None at all.
Target By making a selection from this drop-down list, you are
Widget instructing the worksheet matrix widget to receive its
information from the Target Widget. When a target widget
is selected, the target moniker must correspond to a
variable associated with the target widget.
For an example, see the Target Widget property for the Text
Entry widget.
Figure 4.60
4-88
Extension View Editor 4-89
Object Description
Control CLSID Clicking the Ellipsis icon opens the Select an ActiveX
Control view which displays a list of ActiveX Controls.
Selecting a control inserts the Class Identity currently
Ellipsis icon available on your computer.
Custom Clicking this button displays the custom properties
Properties associated with the ActiveX Control.
The Control CLSID field must first be selected before this
button can be used.
Associations Opens the Set Associations with ActiveX Properties and
Events that allows you to tie the control to an event or the
custom properties to a variable.
The Control CLSID field must first be selected before this
button can be used.
Unique Tag This the internal designation of the control.
Caption Text The text associated with the control.
Menu Title The text label that appears in the menu bar when the
control has focus.
Draw Border Draws a border around the ActiveX Control.
Container can This checkbox is for internal use only and should not go
alter extent unchecked.
4-89
4-90 Widget Properties
4-90
User Variables 5-1
5 User Variables
5.1 Introduction................................................................................... 2
5-1
5-2 Introduction
5.1 Introduction
For example, you could User Variables help you to increase the internal functionality of
attach a User Variable to UniSim Design objects, such as streams and unit operations, by
a stream to ensure that
the flow rate is specified dynamically attaching variables and code to those objects from
lower than a certain within UniSim Design itself. User Variables are indistinguishable
value. Or, you could
have a view appear from the variables built into UniSim Design objects and, as such,
when a vessel can be added to spreadsheets, targeted by logic controllers,
temperature exceeds a have their values specified by your input, etc.
certain value.
Figure 5.1
Regardless of where the
User Variables matrix is
located, the matrix is
the same as the one
shown in the figure on
the right.
5-2
User Variables 5-3
Figure 5.2
Figure 5.3
The User Variables view contains all the User Variables currently
attached to the object. There is a drop-down list that serves as a
filter to sort the displayed User Variables by Data Type.
The User Variables matrix lists the User Variables of the object
owning the view. The name of the variable appears in the left
column, and the value appears in the right. Un-initialized values
5-3
5-4 Adding a User Variable
The User Variables are listed in their execution order. You can
change the execution order using the icons in the toolbar.
Before you add the first The toolbar above the matrix lets you create, edit, and delete
User Variable to an
object, only the Create
variables as well as filtering and ordering the list. Until one or
a New User Variable and more User Variables are added to an object, some of the icons
the Sort Alphabetically at the top of the view are disabled. The drop-down list, on the
and Sort by Execution
Order buttons are left side of the icons, filters the matrix by data type and
active. customer user type.
You can also open the Edit the Selected Select an existing User Variable and click this
edit view of a User User Variable icon to open the view of the existing User
Variable by double- Variable for editing.
clicking on its name in
Delete the Select the User Variable you want to delete
the matrix.
Selected User and click this icon.
Variable UniSim Design requires confirmation before
proceeding with the deletion. If a password
has been assigned to the User Variable, the
password is requested before proceeding with
the deletion.
Sort Click this icon to sort the User Variable list
Alphabetically alphabetically.
Sorting by execution Sort by Click this icon to sort the User Variable list
order is important if Execution Order according to the order by which they are
your User Variables executed by UniSim Design.
have order
Move Selected Click this icon to move the selected User
dependencies in their
Variable Up In Variable up in execution order.
macro code. Normally, Execution Order
you should try and
avoid these types of Move Selected Click this icon to move the selected User
dependencies. Variable Down In Variable down in the execution order.
Execution Order
Show/Hide Shows or hides the Variable Enabling
Variable checkboxes associated with each User
Enabling Variable. By default, the checkboxes are not
Checkbox displayed.
5-4
User Variables 5-5
Figure 5.4
Code field
Allows you to
add password
security to the
User Variable.
5-5
5-6 Importing/Exporting User
5.3 Importing/Exporting
User Variables
You may import and export User Variables between cases via
the Import Export User Variables view.
Figure 5.5
5-6
User Variables 5-7
Figure 5.6
Figure 5.7
5-7
5-8 User Variable View
5. In the File name field type the name of the file you want to
save the User Variables to and click the Save button.
The file is saved with *.huv file extension.
The file name you selected should now appear in the User
Variables In Export File group under the Current Export
File: text. A list of user variables in the file should appear in
the list in this group.
4. Select the variable you want to import and click the Import
button.
5-8
User Variables 5-9
Figure 5.8
For more information on The only entry fields common to all user variable data types are
using security
passwords, see Section the Name and Tag fields. The Name specified is the visible name
5.6.4 - Security Tab. of the variable used throughout UniSim Design. The Tag is the
unique identifier used to access this user variable
programmatically. These two strings are often identical and the
variable tag automatically defaults to be the same as the
variable Name, if not specified. You are prompted to provide an
alternate Name or Tag if they are not unique among all User
Variables attached to the object. You are also prompted to
provide a cryptic tag if the User Variable uses a security
password.
5-9
5-10 Data Types
Figure 5.9
The drop-down list at the top of the User Variables view can
change, depending on the additional requirements for the
specified data type.
5-10
User Variables 5-11
Figure 5.10
From this drop-down list you can select one of the existing
variable types built into UniSim Design in order to determine
units and valid numeric range for the new variable. For example,
selecting Temperature results in a User Variable displaying units
of temperature that accepts input in Celsius, Kelvin, Rankin or
Fahrenheit. That same variable would also automatically
disallow out of range input such as a negative Kelvin value or a
Celsius value less than -273.15.
5-11
5-12 Data Types
Figure 5.11
Figure 5.12
5-12
User Variables 5-13
5-13
5-14 User Variables Tabs
Object Macros
Flowsheet PreExecuted. Invoked when the Steady State solver is
Object about to execute the flowsheet object that owns this
variable.
PostExecuted. Invoked immediately after the Steady
State solver executes the flowsheet object that owns this
variable.
Flowsheets PreSolve. Invoked before the Steady State solver begins
solving the flowsheet.
PostSolve. Invoked after the Steady State solver
completes the flowsheet solution.
Simulation Run. Explicitly invoked when the Run button on the
Case Simulation Case User Variables view is clicked.
Figure 5.13
5-14
User Variables 5-15
The sub-routines that are added to the User Variable when the
checkboxes, in the Variable group, are checked include:
Sub-routine Initialization
Variable Called when an attempt is made to specify a new value for
Changing the User Variable from any source other than the variable’s
own macro code.The new value is available for inspection
using the ActiveVariableWrapper macro keyword. If the
Variable Changing code chooses to disallow the change, it
must set the AllowThisChange property to false.
Variable Invoked immediately after a new value has been assigned
Changed to the variable.
Variable Invoked whenever the value for a User Variable is about to
Query be read.
Code Example
Sub VariableChanging()
If ActiveVariableWrapper.NewRealValue > 100 Or
ActiveVariableWrapper.NewRealValue < 1 Then
AllowThisChange = False
MsgBox "Valid values are in the range 1-100", vbOkOnly,
"User Variable"
End If
End Sub
If you disable a macro with its code still present and then
type or paste in the Code Editor, the macro is automatically
re-enabled.
5-15
5-16 User Variables Tabs
Activation Group
The Activation group refers to the scope of the variable. A User
Variable is defined for an entire class of objects but can be
optionally enabled only in specific instances of these objects or
made to appear automatically in all instances. Specify the
activation by choosing from either the Automatic or User
Enabled radio button.
Figure 5.14
5-16
User Variables 5-17
Figure 5.15
Enabling
column
checkboxes
5-17
5-18 User Variables Tabs
Solver Group
The Solver group of the Attributes tab contains a single
checkbox labelled Trigger Solve. This checkbox is only available
Solver group for Real and Enumeration data types. When enabled, the User
Variable causes the object instance that owns it to recalculate
whenever the value of the variable is changed. This is analogous
to the UniSim Design Process Variable.
Figure 5.16
To add a new filter type, click the Edit button. The Filter Names
view opens:
Figure 5.17
From this view you can create new filter names. Once the new
filter names have been specified, click the OK button to return to
the User Variable view. If you do not want to keep the filter
names you specified, click the Cancel button. New filter names
appear in the list on the right of the Filters tab.
5-18
User Variables 5-19
The native data type (Real, Text, etc.) is always included in the
list of active filters. It cannot be deleted. To include a newly
created filter name with the active filters, highlight the filter
name on the right and click the Add button. To remove a filter
from the active list, click the Remove button.
Figure 5.18
5-19
5-20 User Variables Tabs
Variable
The second level of security is the Calculate Only setting. Check
this checkbox to ensure that only the User Variable’s macro code
can change its value.
Figure 5.19
To assign a default
value, check the
Assign Default Value
checkbox and enter
the desired value in
the field.
5-20
User Variables 5-21
Figure 5.20
Break Point
5-21
5-22 User Variable Examples
Figure 5.21
2. Click the New User Variable icon at the top of the user
variable matrix. The Create New User Variable view opens.
New User Variable icon
5-22
User Variables 5-23
Field Input
When you specify a Name DewPt Temp
Name, it is
Type Real
automatically copied to
the Tag field. Units Temperature
Figure 5.22
5-23
5-24 User Variable Examples
This step is a 5. On the Security tab, check the Calculate Only checkbox.
convenience and not a This ensures that no one attempts to specify a value for this
requirement for macro
User Variable other than its macro.
execution.
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
5-24
User Variables 5-25
The figure below shows two streams views with the calculated
values:
Figure 5.24
5-25
5-26 User Variable Examples
Field Input
Name QStream
Type Enumeration
5-26
User Variables 5-27
Figure 5.26
The Label names are not important, but the numeric values
of the two must match the NotYetRun and HasRun constants
used in the associated code.
5-27
5-28 User Variable Examples
Macro Code
' Automatically add and connect an energy stream once feed and product
' streams are connected.
' The process will not repeat unless this variable is reset to NotYetRun.
' Global constants matching the enumeration values of this user variable.
' Note that only constant values are useful here. Non-constant global
' variables will lose their values
' between invocations of this macro code. Create user variables when
' storing persistent 'information.
Const NotYetRun = 0
Const HasRun = 1
' The use of both late and early binding are demonstrated here.
' Late binding should be used during development and testing since it is
' more robust and produces more useful error messages.
' Early binding should be used where performance is an issue as it is
' slightly faster. Or when an explicit 'cast' to a certain interface of
' an object is required.
Sub PostExecute()
' Error handling minimized for clarity.
On Error GoTo UnknownError
5-28
User Variables 5-29
Macro Code
'Late binding of Streams collection and Stream object.
Dim strs As Object
Dim newstr As Object
Set strs = ActiveCase.Flowsheet.MaterialStreams
Dim strName As String
strName = Pump.name + "_W"
Set newstr = strs.Add(strName)
newstr.IsEnergyStream = True
Pump.EnergyStream = newstr
thisvar.Value = HasRun
Else
thisvar.Value = HasRun
End If
Exit Sub
AlreadyAdded:
Exit Sub
UnknownError:
End Sub
For the pump and streams shown on the left of the figure below,
once the inlet and outlet streams are connected, the stream
PUMP_W is automatically created, as shown to the right:
Figure 5.27
5-29
5-30 User Variable Examples
The first three lines of comment in your code appear as tool tip
fly by when the cursor hovers over the variable in on the User
Variables page:
Figure 5.28
Toggling the setting back The User Variable enumeration can be explicitly toggled for any
to Not Run Yet would
allow the macro to once pump instance by changing its value in the User Variable Matrix
again add and connect a on the User Variables page. Select the value in the right column
new Energy stream
of the matrix and then access the drop-down list (see the figure
during a steady state
execution of the pump below). You can select Not Yet Run from the list.
when inlet and outlet
streams are connected.
Figure 5.29
5-30
User Unit Operation 6-1
6.1 Introduction................................................................................... 2
6-1
6-2 Introduction
6.1 Introduction
The User Unit Operation is a UniSim Design unit operation much
like any other, except that its behaviour is defined entirely with
Visual Basic® compatible code that you provide. It allows you to
create additional unit operation types without the complexity
involved in creating an Extension Unit Operation.
If you use the User Ops filter on the UnitOps view, the left
side of the view changes to include the same buttons that
appear in the view on Figure 6.1.
6-2
User Unit Operation 6-3
2. When the User Unit Operation has been added, the following
view appears:
Figure 6.1
The view shown above lists the available User Unit Operation
types, lets you add new operations of existing types, and
lets you create or delete operation types.
3. Click the Create Type button to add a new type to the list.
The following view opens:
Figure 6.2
6-3
6-4 Adding a User Unit Operation
Figure 6.3
6-4
User Unit Operation 6-5
Figure 6.4
6-5
6-6 User Unit Op Property View
Connections Page
On the Connections page you can specify the Name of the
operation, and attach Feed, Product, and Energy streams.
Figure 6.5
The first feed and first product nozzles are always active, but the
other four nozzles can be activated or deactivated depending on
the type of requirements of your User Unit Operation. Attach
6-6
User Unit Operation 6-7
Code Page
On the Code page, you add the Visual Basic® compatible code
that defines the behaviour of your User Unit Operation.
Figure 6.6
6-7
6-8 User Unit Op Property View
Code can be added by clicking the Edit button. This opens the
Edit Existing Code view. The view in the figure below shows the
three empty sub-routines that appear before you begin adding
code in the view.
Figure 6.7
6-8
User Unit Operation 6-9
Sub-routine Action
Initialize() Called immediately before the first time Execute is
called. This sub-routine should be used to set up the
unit operation. Decide which nozzles are valid and
name them; create any variables that will be needed
and give them initial values, etc.
Execute() Called whenever a trigger solve variable of the unit
operation is changed, and whenever any of its attached
streams re-calculates. This sub-routine should perform
all of the unit operation’s calculations. In this sub-
routine only, it is permissible (and recommended) to
use the Calculate method to write data to variables of
the operations attached streams. These variables are
then displayed in black in UniSim Design, and cause an
inconsistency error if any other object attempts to
calculate their values.
StatusQuery() Called whenever UniSim Design wants to update the
status information for its objects. This sub-routine
should be used to provide warning and error messages
for any missing connections, missing variable values,
etc. These messages will be displayed in the UniSim
Design status bar, as well as at the bottom of the User
Unit Operation’s view.
The left border of the Code page is a development tool for you to
use as you add code to your operation. You may add break
points in this border thereby allowing you to step through your
code. Simply click the primary mouse button in the margin on
the left side of the code pane next to the line you want to insert
the break for.
6-9
6-10 User Unit Op Property View
Figure 6.8
Variables Page
User Variables do not You can attach User Variables to the User Unit Operation, as you
have the PreExecute and
PostExecute macro
can to any flowsheet object, to further customize your
options. simulation case.
The Execute macro of
the User Unit Operation User Unit Operation User Variables can be used to store
itself is intended to
perform all calculations calculation results, persistent state information, etc. These
required to implement variables can be created manually from the Variables page, or
the operation and its programmatically using the CreateUserVariable method of the
variable values.
Active Object interface.
6-10
User Unit Operation 6-11
Notes Page
The Notes page provides a text editor where you can record any
comments or information regarding the User Unit Operation, or
pertaining to your simulation in general.
Export Page
The Export page allows you to export the User Unit Operation,
by clicking the Export button and entering the file name and file
path for the User Unit Operation. The file is saved with *.huo file
extension.
You can also add a description about the User Unit Operation in
the Type Description group.
6-11
6-12 Dehumidifier Example
6-12
User Unit Operation 6-13
Figure 6.9
Figure 6.10
6-13
6-14 Dehumidifier Example
8. To add code, switch to the Code page and click the Edit
button. This opens the Edit Existing Code view where you
can enter the following code:
Dehumidifier Code
Sub Initialize()
' Of the four optional nozzles, we only want the second products:
ActiveObject.Feeds1Name = "Feed"
ActiveObject.Products1Name = "Dry Product"
ActiveObject.Feeds2Name = "Inactive Feed"
ActiveObject.Feeds2Active = False
ActiveObject.Products2Name = "Water Product"
ActiveObject.Products2Active = True
ActiveObject.EnergyFeedsName = "Inactive Energy In"
ActiveObject.EnergyFeedsActive = False
ActiveObject.EnergyProductsName = "Inactive Energy Out"
ActiveObject.EnergyProductsActive = False
End Sub
Sub Execute()
On Error GoTo EarlyExit
' get the feed stream
Dim feed As Object
Set feed = ActiveObject.Feeds1.Item(0)
If feed Is Nothing Then GoTo EarlyExit
' get the dry product stream
Dim prod As Object
Set prod = ActiveObject.Products1.Item(0)
If prod Is Nothing Then GoTo EarlyExit
' get the water product stream
Dim wtr As Object
Set wtr = ActiveObject.Products2.Item(0)
If wtr Is Nothing Then GoTo EarlyExit
' find the position of water in the current Fluid Package's component
list
Dim theComps As Object
Set theComps = ActiveObject.Flowsheet.FluidPackage.Components
waterPosn = theComps.index("H2O")
' get the array of component molar flows from the feed stream
Dim CMFs As Variant
CMFs = feed.ComponentMolarFlowValue
WaterFlow = CMFs(waterPosn)
DryFlow = Feed.MolarFlowValue - WaterFlow
' calculate the Temperature, Pressure, and Flow of the water product
6-14
User Unit Operation 6-15
Dehumidifier Code
stream
wtr.Pressure.Calculate(feed.PressureValue)
wtr.Temperature.Calculate(feed.TemperatureValue)
wtr.MolarFlow.Calculate(WaterFlow)
' remove the water from the CMF array
CMFs(waterPosn) = 0.0
' calculate Temperature, Pressure, and ComponentMolarFlows of the dry
stream
prod.Pressure.Calculate(feed.PressureValue)
prod.Temperature.Calculate(feed.TemperatureValue)
prod.MolarFlow.Calculate(DryFlow)
' calculate the composition of the dry stream
For i = 0 To theComps.Count - 1
CMFs(i) = CMFS(i) / DryFlow
Next i
prod.ComponentMolarFraction.Calculate(CMFs)
' calculate the composition of the water stream (pure water)
For i = 0 To theComps.Count - 1
CMFs(i) = 0.0
Next i
CMFs(waterPosn) = 1.0
wtr.ComponentMolarFraction.Calculate(CMFs)
' tell the Solver we're done
' (this will remove the "Not Solved" status message)
ActiveObject.SolveComplete
Exit Sub
EarlyExit:
' not enough info to calculate
End Sub
Sub StatusQuery()
On Error GoTo ThatsAll
Dim GotOne As Boolean
GotOne = False
If ActiveObject.Feeds1.Count = 0 Then
GotOne = True
ActiveObject.AddStatusCondition(slMissingRequiredInformation, 1,
"Feed Stream Required")
End If
If ActiveObject.Products1.Count = 0 Then
GotOne = True
ActiveObject.AddStatusCondition(slMissingRequiredInformation, 2,
"Dry Product Stream Required")
End If
6-15
6-16 Dehumidifier Example
Dehumidifier Code
If ActiveObject.Products2.Count = 0 Then
GotOne = True
ActiveObject.AddStatusCondition(slMissingRequiredInformation, 3,
"Water Product Stream Required")
End If
' If we're missing an attachment, don't bother checking for any other
problems
If GotOne = True Then GoTo ThatsAll
On Error GoTo NoWater
waterPosn =
ActiveObject.Flowsheet.FluidPackage.Components.index("H2O")
GoTo AfterWaterCheck
NoWater:
GotOne = True
ActiveObject.AddStatusCondition(slError, 11, "No Water in Current Fluid
Package")
AfterWaterCheck:
On Error GoTo ThatsAll
Dim feed As Object
Set feed = ActiveObject.Feeds1.Item(0)
If Not feed.Temperature.IsKnownThen
ActiveObject.AddStatusCondition(slMissingOptionalInformation, 12,
"Feed Temperature Unknown")
GotOne = True
End If
If Not feed.Pressure.IsKnownThen
ActiveObject.AddStatusCondition(slMissingOptionalInformation, 13,
"Feed Pressure Unknown")
GotOne = True
End If
If Not feed.MolarFlow.IsKnown Then
ActiveObject.AddStatusCondition(slMissingOptionalInformation, 14,
"Feed Flow Unknown")
GotOne = True
End If
' The composition's IsKnown will return a Variant containing an array of
Booleans.
' We must make a variable containing the array before we attempt to
access a data
' member.
' (i.e., "feed.ComponentMolarFraction.IsKnown(0)" will probably not
work)
CMFsKnown = feed.ComponentMolarFraction.IsKnown
6-16
User Unit Operation 6-17
Dehumidifier Code
If Not CMFsKnown(0) Then
ActiveObject.AddStatusCondition(slMissingOptionalInformation, 15,
"Feed Composition Unknown")
GotOne = True
End If
If GotOne = True Then GoTo ThatsAll
If ActiveObject.Feeds1.Count > 1 Then
GotOne = True
ActiveObject.AddStatusCondition(slWarning, 20, "Additional Feed
Stream(s) Ignored")
End If
If ActiveObject.Feeds1.Count > 1 Then
GotOne = True
ActiveObject.AddStatusCondition(slWarning, 20, "Additional Feed
Stream(s) Ignored")
End If
If ActiveObject.Products1.Count > 1 Then
GotOne = True
ActiveObject.AddStatusCondition(slWarning, 21, "Additional Dry
Product Stream(s) Ignored")
End If
If ActiveObject.Products2.Count > 1 Then
GotOne = True
ActiveObject.AddStatusCondition(slWarning, 22, "Additional Water
Product Stream(s) Ignored")
End If
Dim BogusCnxn As Boolean
BogusCnxn = False
If ActiveObject.Feeds2.Count > 0 Then
BogusCnxn = True
ElseIf ActiveObject.EnergyFeeds.Count > 0 Then
BogusCnxn = True
ElseIf ActiveObject.EnergyProducts.Count > 0 Then
BogusCnxn = True
End If
If BogusCnxn = True Then
GotOne = True
ActiveObject.AddStatusCondition(slWarning, 7, "Connection(s) to
Inactive Nozzles")
End If
ThatsAll:
End Sub
6-17
6-18 Dehumidifier Example
Figure 6.11
The original instance of The Initialize sub-routine code automatically configures the
the Dehumidifier may
invoke Initialize before nozzles appropriately.
you have entered the 10. Click the Initialize button in the Manual Invoke group to
example code.
ensure that the nozzles are reconfigured.
Any future instances of Dehumidifier will not require this
explicitly extra Initialize once the macro code has been
entered and debugged.
6-18
User Unit Operation 6-19
Deactivate the extra 11. Complete the Connections page by attaching streams as
nozzles by clearing the shown in the figure below:
checkboxes to the right
of the nozzle names.
Figure 6.12
6-19
6-20 Dehumidifier Example
The PFD for the solved case, along with an attached stream
table, is shown in the figure below:
Figure 6.13
6-20
Customization FAQ A-1
A Customization FAQ
A-1
A-2 Automation FAQ
hyCase.Solver.CanSolve = False
hyCase.BasisManager.StartBasisChange
{make Basis changes}
hyCase.BasisManager.EndBasisChange
hyCase.Solver.CanSolve = True
A-2
Customization FAQ A-3
Sub Main
Set hyApp = Application
Set hyCase =
hyApp.SimulationCases.Add("C:\Temp.USC")
Set hyBasis = hyCase.BasisManager
Set hyFldPkgs = hyBasis.FluidPackages
Set hyFldPkg = hyFldPkgs.Item(0)
Set hyPropPkg = hyFldpkg.PropertyPackage
hyFldPkgs.Add "Steam"
Set hyFldPkg = hyFldPkgs.Item("Steam")
hyFldPkg.PropertyPackageName = "asme steam"
End Sub
A-3
A-4 Automation FAQ
hyMix.Feeds.Add hyFeed1
hyMix.Feeds.Add hyFeed2
hyMix.Products.Add hyProduct1
hyMix.Products.Add hyProduct2
Sub Main
' This macro assume an active sheet which has the
following Streams: Feed1, Feed2, Product
Set hyCase = ActiveCase
Set hyFS = hyCase.Flowsheet
Set hyOpers = hyFS.Operations
Set hyFeed1 = hyFS.MaterialStreams("Feed1")
Set hyFeed2 = hyFS.MaterialStreams("Feed2")
Set hyProduct = hyFS.MaterialStreams("Product")
' Add a Mixer named Mix-100
hyOpers.Add ("Mix-100", "MixerOp")
' Set an Object reference To the Mixer
Set hyMix = hyOpers.Item("Mix-100")
' **Add feed Streams To the Mix-100 (must be added
one at a Time, can’t use an Array of Streams)
hyMix.Feeds.Add hyFeed1
hyMix.Feeds.Add hyFeed2
hyMix.Product = hyProduct
End Sub
A-4
Customization FAQ A-5
Stream_Name = "2"
hyStream = Streams.Item(Stream_Name)
Stream = Streams.Item(CStr(Stream_Name))
hyViscosity = hyFluid.HeavyLiquidPhase.ViscosityValue
where:
A-5
A-6 Automation FAQ
A-6
Customization FAQ A-7
A-7
A-8 Automation FAQ
Set SS = hyCase.Flowsheet.Operations.Item("SSName")
A1Value = SS.Cell("A1").CellValue
A-8
Customization FAQ A-9
hyCase.Visible = True
where:
A-9
A-10 Extensibility FAQ
A-10
Customization FAQ A-11
Set hyFeed =
hyContainer.FindVariable("Feed").Variable.Object
Set hyProdTemp =
hyContainer.FindVariable("PrdTmp").Variable
A-11
A-12 Extensibility FAQ
A-12
Customization FAQ A-13
hyContainer.SolveComplete
where:
A-13
A-14 Extensibility FAQ
problems.
4. How do I set default values for numeric input or text boxes?
Ans: Use the following procedure:
Make object references to the numeric input boxes in the
Initialize function and then set their defaults using the Value
property. For example,
A-14
Customization FAQ A-15
A-15
A-16 Extensibility FAQ
Code Description
Dim hyRef as Object Dimension hyRef as an
object in the declaration
section.
Set hyRef = Use hyRef to set a reference
hyContainer.FindVariable("Ref").Variable to the Status object in the
extension definition file
(EDF).
Set hyRef = The Initialization function
hyContainer.FindVariable("Ref").Variable in the extension code is
used to set the default value
If IsRecalling = False Then for the Radio Buttons.
hyRef.Value = 0
A-16
Customization FAQ A-17
Controlled OK Error
OK X X
Error X X
A-17
A-18 Extensibility FAQ
Set hyStatus =
hyContainer.FindVariable("Status").Variable
A-18
Customization FAQ A-19
Code Description
Dim hyList as Object Dimension hyList as an
object in the declaration
section.
Set hyList = Use hyList to set a reference
hyContainer.FindVariable("List").Variable to the Status object in the
extension definition file
(EDF).
A-19
A-20 Extensibility FAQ
A-20
Customization FAQ A-21
A-21
A-22 Extensibility FAQ
Tag Name which is used to access the object from Visual Basic.
Name Alternate name used in the extension view editor (used to
be more descriptive).
Type The object type.
A-22
Customization FAQ A-23
A-23
A-24 Extensibility FAQ
Code
Set ComponentNames = hyContainer.FindVariable("ComponentNames").Variable
Set MatrixData = hyContainer.FindVariable("MatrixData").Variable
' IsRecalling Is only False when the extension Is first added To the
simulation.
If IsRecalling = False Then
Set hyComponents = hyContainer.Flowsheet.FluidPackage.Components
ComponentNames.SetBounds hyComponents.Count, 0, 0
ComponentNames.Values = hyComponents.Names
DummyMatrix = MatrixData.Values
ReDim DummyMatrix(hyComponents.Count, hyComponents.Count)
' This Is used To Set default values For the matrix. Note that the
diagonal Is Set To -32768, which makes it uneditable
For i = 0 To hyComponents.Count - 1
For j = 0 To hyComponents.Count - 1
If i = j Then
DummyMatrix(i, j) = -32768
Else
DummyMatrix(i, j) = 0
End If
Next j
Next i
MatrixData.SetBounds hyComponents.Count, hyComponents.Count, 0
MatrixData.Values = DummyMatrix
End If
A-24
Customization FAQ A-25
DummyMatrix = MatrixData.Values
For i = 0 To hyComponents.Count - 1
For j = 0 To hyComponents.Count - 1
if i = j Then DummyMatrix(i, j) = -32768
Next j
Next i
MatrixData.Values = DummyMatrix
A-25
A-26 Extensibility FAQ
where:
A-26
Customization FAQ A-27
hyContainer.FindVariable("EDFVariable").Variable =
ExtnVariable
where:
A-27
A-28 Extensibility FAQ
where:
A-28
Customization FAQ A-29
A-29
A-30 Extensibility FAQ
A-30
Customization FAQ A-31
would not match the new specified value. Often, the problem
is subtler, and results in the two values being calculated,
each thinking that the other is a specification. To avoid this,
the Cooler must check that it is not a variable’s “CalcBy”
object, before using that variable’s value to calculate other
variables.
20. Why do I get Three Execute calls?
First-time extension writers are almost always surprised to
receive a second non-Forgetting Execute call from UniSim
Design. In fact, non-Extension unit operations only receive
two Execute passes. An additional Execute is necessary for
some extensions that need to see the results of the Balance
calls they make during their Execute.
When a unit operation calculates a value to a stream’s
variable, the unit operation cannot then “see” the value until
the stream has recalculated. If the unit operation calculates
a stream’s temperature during its Execute, and needs to use
the stream’s temperature later in the Execute, it will not be
able to ask the stream for the value. When the unit
operation’s Execute knows the value (as in this case), it can
simply keep the value itself as long as it needs to.
A problem arises when the unit operation uses a “Balance”
call to calculate the compositions and flow of its streams.
The “Balance” performs all the logic to detect which values
are specified and which need to be calculated, combines
multiple feeds to produce a single product, etc., all without
the unit operation needing to be aware of the calculations.
Unfortunately, the results of these calculations will be
unavailable to the unit operation until after the streams have
had their Executes. If the unit operation wants to display,
e.g., the flow of a key component in each of its attached
streams, these values will be unavailable. However, the unit
operation will receive a third Execute, after the streams have
had theirs, during which the values “Balance” had calculated
will be available. Proper use of the third Execute for this
purpose is tricky, as the unit operation must avoid repeating
the work of the previous Execute.
A-31
A-32 Extensibility FAQ
A-32
Customization FAQ A-33
Code Description
hyContainer.Phase = ptCombinedPhase Set the Phase property to
ptCombinedPhase.
Temp = Fluid.HeavyLiquidPhase.MolarDensityValue Access the Liquid phase for your
rate calculations (make sure to
identify it as
HeavyLiquidPhase or
LightLiquidPhase).
rate = rate * (1 - Fluid.VapourFractionValue) Multiply the rate you calculate
by (1 -
Fluid.VapourFractionValue)
A-33
A-34 Extensibility FAQ
A-34
Index
EDF H
creating a new 4-5 Hypotheticals Object 2-26
Examples
I-1
I-2 Index
I S
Index 2-15 Security
Integrator 2-43 See User Variables.
Interfaces SeparationStage Object 2-38
implementing 3-5 Set 2-10
Item 2-15 SetValue 2-40
Solver 2-43
K
SpreadsheetCell(s) 2-44
Kinetic Reaction SpreadsheetOp 2-44
example 3-26 Stream Objects 2-30
extension definition files 3-22 Support Objects 2-39
M T
Macros 5-14 Tab Order 4-11
Matrix 4-48 Tabs 4-19
Methods 2-2, 2-13 Tool Tip Text 5-21
Moniker Specification 4-29 Type Library 2-4
navigating 2-6
O
U
Object
hierarchy 2-3, 2-13 Unit Operation Extension
Object Browser 2-4 example 3-51
accessing 2-5 User Unit Operation
Object Definition Matrix 4-24 adding 6-2
Objects code page 6-7
collection 2-15 dehumidifier example 6-12
declaring 2-9 sub-routines 6-9
definition 2-2 variables page 6-10
UniSim Design 2-19 User Variable
Objects Manager View 4-23 example 5-22
Oil Manager Object 2-27 User Variable Tabs 5-13
Oils Objects 2-27 User Variable View 5-8
Operation Objects 2-35 User Variables 5-2
Operations Object 2-35 buttons 5-4
filters 5-18
P security 5-19
Passes 3-49 V
calculate 3-50
Process Stream Object 2-31 Variants 2-17
ProgID 3-17 View Editor
Properties 2-2, 2-13 accessing 4-4
Property Package using 4-8
extensions 3-41 Views Manage 4-27
Property Package Object 2-24 Visibility Manager 4-16
R W
RealFlexVariable 2-40 Widgets
RealVariable 2-40 ActiveX Container 4-88
I-2
Index I-3
aligning 4-15
attachment name 4-68
button 4-35, 4-39
format entry 4-45
level 4-81
manipulating 4-8
numerical input 4-46, 4-48
plot 4-84
properties 4-28, 4-29
rich text 4-44
static text 4-40
text entry 4-42
I-3
I-4 Index
I-4