User Variables
Table of Contents
Introduction
Many unit operations and streams have a user variable page where user variables can be added. Such variables can be used to store values, but can also be used to execute code scripts.

Variables in Dynamics
User variables can be created and edited exactly the same way as in steady state. However, do note the following issues which are specific to dynamics:
- User variables in unit operations and logical operation may contain code which can be set to execute. Stream user variable can be used to store values, but can not execute code.
- To have a user variable execute in dynamics mode, in the Script dialog box scroll through the list of check boxes and for check one of the following:
- DynCompositionPreStep
- DynPressureFlowPreStep
- DynExecute
- Enabling or disabling a user variable is detected when the integrator is started.
DynExecute is available for logical operations, and the other two for material transfer operations (such as a valve or a vessel). DynCompositionPreStep will result in the variable being executed less often than selecting DynPressureFlowPreStep.

Do note that user variables with scripts that execute, while optimized, may slow a simulation, especially if the script performs complex actions such as creating and flashing fluids. Script are however handy for calculating something non trivial or triggering some action or communicating with external software. If a script merely performs a simple calculation, then using the spreadsheet instead will result in better performance.
The language used by default is VBScript and there are many internet tutorial sites which explain the syntax. Scripts can also be made to use any installed active script language by changing the very first line in the script to something like: language="JavaScript". Do note that the script language of choice needs to be installed on any computer where the model will run.
User variables by default have access to the properties of the object to which they belong. For example, a user variable in a controller can have code like this:
Pressing will show a list of OLE properties for the controller.
Additional general information about user variables is available in the Petro-SIM F1 online help.
< Initialization | Index | Data Book >