The Script Element
Dialog
The properties dialog for a Script element looks like this:
Like all elements, you first specify an Element ID and a Description.
By default, all Script elements have a single primary output For an element with multiple outputs, the output that has the same name as the element.. When defining a Script, therefore, the first step is to define the attributes (units, type, order) of this primary output.
The Display Units The units (e.g., m, g, $/day) in which an output is displayed within GoldSim. determine the dimensions An output attribute for an element that defines the dimensionality (in terms of Length, Time and other fundamental dimensions) of the output. of the output. You can specify the type and order by pressing the Type... button. The output can be defined as either a value or a condition, and can be specified as a scalar An output consisting of a single value or condition., a vector A one-dimensional array. or a matrix A two-dimensional array.. By default, the primary output of a new Script element is a scalar, dimensionless value.
Note: It is also possible to define additional outputs for the element (with their own dimensions) when defining local variables within a script.
The primary output of a Script element is a state variable The output of an element in GoldSim whose value is computed based on the historical value of the element’s inputs (as opposed to only being a function of the current value of the element’s inputs). State variables have well-defined initial conditions. Feedback loops can only be created if they contain at least one state variable.. A state variable provides inertia or "memory" to a system because its value is computed based on the historical value of the element's inputs (as opposed to only being a function of the current value of the element's inputs). All state variables have, by definition, an initial value. This allows the output to be computed when there are no historical inputs available (e.g., at the start of simulation).
The Initial Value input to the Script must have the same attributes (order and dimensions) as the primary output.
Note: The Initial Value must be a number or a link from a static variable (e.g., a constant Data element An input element intended to represent constant inputs in a model. or a Stochastic).
Buttons at the bottom of the dialog are used to insert, delete, move and edit statements in your script. You can also print the entire script.
If you check the Record CPU times in the run log box, if the element uses more than 1 CPU seconds, a message will be written to the GoldSim run log Text that is stored with a GoldSim model once it has been run. It contains basic information regarding the simulation, and any warning or error messages that were generated. identifying the element's name, type (i.e., Script), the number of times it was updated, and the total CPU time used.