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. When defining a Script, therefore, the first step is to define the attributes (units, type, order) of this primary output.

The Display Units determine the dimensions 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, a vector or a matrix. 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. 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 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 identifying the element’s name, type (i.e., Script), the number of times it was updated, and the total CPU time used.

Related Topics…

Learn more about: