You are on page 1of 53

MODELS

IN
ATP

LANGUAGE MANUAL

February 1996
TABLE OF CONTENTS

1. INTRODUCTION ............................................................................................................1
1.1 THE MODELS LANGUAGE......................................................................................1
1.2 MAIN FEATURES.....................................................................................................1
2. MODEL DESCRIPTION .................................................................................................2
2.1 SYSTEM REPRESENTATION .................................................................................2
2.2 MODEL REPRESENTATION ...................................................................................3
2.2.1 MODEL DECOMPOSITION ...............................................................................3
2.2.2 MODEL DEFINITION .........................................................................................4
2.2.3 FOREIGN MODELS ...........................................................................................5
2.2.4 EXTERNAL MODELS ........................................................................................6
2.3 STATEMENTS..........................................................................................................6
2.3.1 ASSIGNMENT STATEMENTS...........................................................................6
2.3.1.1 VALUE ASSIGNMENT ................................................................................6
2.3.1.2 DIFFERENTIAL EQUATION........................................................................7
2.3.1.3 LAPLACE TRANSFER FUNCTION.............................................................8
2.3.1.3 Z TRANSFER FUNCTION...........................................................................9
2.3.2 ALGORITHM CONTROL STATEMENTS ........................................................11
2.3.2.1 IF................................................................................................................11
2.3.2.2 WHILE .......................................................................................................11
2.3.2.3 FOR ...........................................................................................................11
2.3.2.4 DO .............................................................................................................12
2.3.2.5 REDO.........................................................................................................12
2.3.2.6 COMBINE ..................................................................................................13
2.3.2.7 SEQUENCE...............................................................................................14
2.3.2.8 USE ...........................................................................................................14
2.3.3 SIMULATION DIRECTIVE STATEMENTS ......................................................15
2.3.3.1 WRITE .......................................................................................................15
2.3.3.2 ERROR ......................................................................................................15
2.3.3.3 DEPOSIT ...................................................................................................15
2.4 VALUE-HOLDING ELEMENTS ..............................................................................16
2.4.1 ARRAYS...........................................................................................................16
2.4.2 CONSTANTS ...................................................................................................16
2.4.3 RESIDENT CONSTANTS ................................................................................17
2.4.4 DATA................................................................................................................17
2.4.5 VARIABLES .....................................................................................................18
2.4.6 RESIDENT VARIABLES ..................................................................................19
2.5 MODEL INTERFACE..............................................................................................20
2.5.1 INPUT...............................................................................................................20
2.5.2 OUTPUT...........................................................................................................21
2.6 FUNCTIONS ...........................................................................................................21
2.6.1 FUNCTIONS IN A MODEL...............................................................................21
2.6.2 STATEMENT FUNCTION ................................................................................21
2.6.3 POINTLIST FUNCTION ...................................................................................22
2.6.4 FOREIGN FUNCTIONS ...................................................................................23
2.6.5 RESIDENT FUNCTIONS .................................................................................23
2.6.6 RESIDENT SIMULATION FUNCTIONS ...........................................................25
2.7 NAMES ...................................................................................................................26
2.7.1 NAME DEFINITION..........................................................................................26
2.7.2 USE PATHNAMES...........................................................................................26
2.8 VALUES..................................................................................................................27
2.8.1 VALUE TYPES.................................................................................................27
2.8.2 VALUE REFERENCE.......................................................................................27
2.8.3 VALUE LIMITS .................................................................................................28
2.9 EXPRESSIONS ......................................................................................................28
2.9.1 EXPRESSIONS IN A MODEL ..........................................................................28
2.9.2 REGULAR EXPRESSIONS .............................................................................29
2.9.3 SUM EXPRESSIONS.......................................................................................31
2.9.4 DERIVATIVE EXPRESSIONS .........................................................................32
2.9.5 INTEGRALS .....................................................................................................33
2.9.5.1 INTEGRAL EXPRESSION.........................................................................33
2.9.5.2 INTEGRAL VALUE RESET .......................................................................33
2.10 FORMAT...............................................................................................................34
2.10.1 DESCRIPTION FORMAT...............................................................................34
2.10.2 DELIMITERS..................................................................................................34
2.10.3 LINE INDENTATION ......................................................................................35
2.10.4 COMMENTS ..................................................................................................35
3. MODEL SIMULATION..................................................................................................35
3.1 SIMULATION DIRECTIVES ...................................................................................35
3.1.1 TIMESTEP .......................................................................................................35
3.1.2 INTERPOLATION ............................................................................................36
3.1.3 DELAY..............................................................................................................37
3.2 SIMULATION PROCESS .......................................................................................38
3.2.1 INITIALIZATION ...............................................................................................38
3.2.2 HISTORY FUNCTIONS....................................................................................38
3.2.3 INIT PROCEDURE...........................................................................................40
3.2.4 EXEC PROCEDURE........................................................................................40
3.2.5 SIMULTANEOUS VARIABLES ........................................................................41
3.2.6 SIMULTANEOUS LINEAR VARIABLES USING A LINEAR COMBINE...........41
3.2.7 SIMULTANEOUS NONLINEAR VARIABLES USING A LINEAR COMBINE...42
4. MODELS IN ATP..........................................................................................................44
4.1 MODELS SECTION IN THE DATA CASE..............................................................44
4.1.1 INPUTS FROM THE ELECTRICAL CIRCUIT TO MODELS............................45
4.1.2 OUTPUTS FROM MODELS TO THE ELECTRICAL CIRCUIT........................46
4.1.3 TOP VARIABLES OF THE MODELS SECTION..............................................46
4.1.4 RECORDED VALUES IN MODELS .................................................................47
4.2 TYPE-94 COMPONENTS IN THE CIRCUIT ..........................................................47
4.2.1 THREE TYPES: THEVENIN, ITERATED, NORTON ........................................48
4.2.2 TYPE-94 FORMAT IN ATP ..............................................................................49
4.2.3 TYPE-94 MODEL TEMPLATES.......................................................................50
4.2.3.1 THEVENIN MODEL TEMPLATE ................................................................50
4.2.3.2 ITERATED MODEL TEMPLATE ................................................................51
4.2.3.3 NON-TRANSMISSION NORTON MODEL TEMPLATE .............................51
4.2.3.4 TRANSMISSION NORTON MODEL TEMPLATE ......................................52
MODELS -- p. 1

1. INTRODUCTION

1.1 THE MODELS LANGUAGE


MODELS is a general-purpose description language supported by a set of simulation tools for the
representation and study of time-variant systems.
The MODELS language provides a format which focuses on the description of the structure of a
model and on the function of its elements.
The description of a model is intended to be self-documenting, and can therefore be used both as
the description document used for representing the system and as the data used in the actual
simulation.
A system can be described in MODELS as an arrangement of inter-related submodels,
independent from one another in their internal description (for example, in selecting the names of
their variables) and in their simulation (for example, in selecting the size of their individual
simulation time step).
There is also a clear distinction in MODELS between the description of a model, and the use of a
model. Individual models can be developed separately, grouped in one or more libraries of models,
and used in other models as independent building blocks in the construction of a system.
Finally, the description of each model uses a free-format, keyword-driven syntax of local context,
and does not require fixed formatting in its representation.
The present documentation is divided in two sections, the first covering the description of a model,
and the second describing the use of a model in a simulation.
A general overview of the model description approach in MODELS is presented in the next pages,
under the headings MAIN FEATURES, SYSTEM REPRESENTATION, MODEL
DECOMPOSITION, and MODEL DEFINITION.
________________________________________

1.2 MAIN FEATURES


The main description features of the MODELS language are the following:
- the syntax of MODELS allows the representation of a system to closely follow the system's
functional structure, supporting the explicit description of composition, sequence, concurrence,
selection, repetition, and replication;
- the description of a model can also be used as the model's documentation;
- the interface of a model with the outside world is clearly specified;
- the components of a model can be given meaningful names representative of their function;
- a system can be partitioned into individual submodels, each with a local name space;
- the models and functions used for describing the operation of a system can be constructed in
programming languages other than the MODELS language.
The main simulation features supported by the MODELS language are the following:
- distinction between the description of a model and its use, allowing multiple independent
replications of a model with individual simulation management (time step, dimensions, initial
conditions, etc.);
- hierarchical combination of three initialization methods (default, use-dependent, and built-in),
each contributing to the description of the pre-simulation history of a model by a direct
representation of the pre-simulation value of its inputs and variables as functions of time;
MODELS -- p. 2

- dynamically-controlled modification of the values of the inputs and variables of a model during
the course of a simulation;
- dynamically-controlled modification of the structure of a model (both topological composition
and algorithmic flow) during the course of a simulation.
________________________________________

2. MODEL DESCRIPTION

2.1 SYSTEM REPRESENTATION


The description blocks of the MODELS language are model definitions. Four aspects of a model
are included in its description:
- what elements are present in the model,
- how these elements interact with each other,
- how the model interacts with the environment in which it operates,
- how the operation of the model is to be simulated.
A model is composed of elements of two types:
- value-holding elements (constants, data parameters, inputs, and variables),
- submodels (local groups of value-holding elements).
The internal interaction of the elements of a model is described by specifying the structure in which
the elements are assembled, using:
- composition, where the joined operation of a group of statements is assembled into a
submodel;
- replication, where several independent uses of a model are specified in the description of a
system (see USE statement);
- selection, where different groups of statements are active depending on a specified set of
conditions (see IF statement);
- association, where some statements are explicitly identified as belonging to a common group
(see DO statement);
- repetition, where the action of a group of statements is repeated according to directives
internal to the description of the group (see REDO statement);
- conditional repetition, where the action of a group of statements is repeated according to a
specified external condition (see WHILE statement);
- indexed repetition, where the action of a group of statements is repeated using a list specifying
the values of one or more parameters (see FOR statement);
- concurrence, where the statements of a group are active simultaneously with each other (see
COMBINE statement);
- sequence, where the statements of a group are active consecutively, in the order in which they
are described (see SEQUENCE statement).
The external interaction of a model with its immediate surrounding environment is described by
specifying how information is carried to and from the model, through:
- its input connections (see INPUT);
- its output connections (see OUTPUT).
MODELS -- p. 3

The operation directives that are specific to the individual uses of a model are specified in each
USE statement, in the form of local DATA and HISTORY assignments, and of local simulation
directives (see USE).
________________________________________

2.2 MODEL REPRESENTATION

2.2.1 MODEL DECOMPOSITION


Although it is generally possible to represent the operation of a model without defining any
submodels, there are many advantages to dividing a larger model into groups of elements each
performing a more simple function.
Each composite group is represented as a separate model in the overall description of a system,
describing the interaction of the group's elements among each other and the interaction of the
group itself with the environment in which it operates, with the following advantages:
- explicit interface: the interaction of a model with its environment takes place exclusively
through its specified interface;
- local operation: the elements contained in a model operate independently from the
environment in which the model itself is used;
- local naming: all names used as identifiers in a model can be selected without
concern for the possible duplication of names used outside that model;
- replication: once defined, a model can be used in many separate applications,
each application being used independently from other applications of
the same model;
- simulation control: the directives controlling the simulation of a model can be specified
individually for different uses of the same model;
- state history: state information is retained for each separate use of a model, in the
form of the present and past values assigned to its variables;
- local development: being a self-contained description, a model can be developed and
tested separately from the larger context in which it may eventually be
used;
- local maintenance: the internal implementation of a model can be modified without
affecting the rest of a system description, provided that the original
specifications of the model's interface remain unchanged;
- model library: an assortment of models can be gathered in a library of models, to be
utilized individually as required;
- rough-modeling: when developing the description of a large system, a model of the
overall system can be prototyped early, by temporarily approximating
the internal operation of unfinished submodels with simplified
equivalent representations using the same model interfaces as the final
product.
________________________________________

2.2.2 MODEL DEFINITION


A model written in the MODELS language includes declarations, simulation directives, and
operation procedures. The syntax used for a model definition is the following:
MODELS -- p. 4

declarations:
- CONST declarations specify the name, array range, and value of the constants of the model
(the internally-assigned constant value-holding elements);
- DATA declarations specify the name, array range, and optional default value of the data
parameters of the model (the externally-assigned constant value-holding elements);
- VAR declarations specify the name and array range of the variables of the model (the
internally-assigned variable value-holding elements);
- INPUT declarations specify the name, array range, and optional default value of the inputs of
the model (the externally-assigned variable value-holding elements);
- OUTPUT declarations specify which of the model's elements may be used as outputs of the
model;
- FUNCTION declarations specify the description of functions used in the model;
- MODEL declarations specify the description of submodels used in the model;
simulation directives:
- TIMESTEP directives specify the optional default value of time step minimum and maximum
limits for the model;
- INTERPOLATION directives specify the default interpolation degree to be applied to the inputs
of the model if the model is used at sub-steps of the external time step;
- DELAY directives specify the default size of value storage associated with usage of the delay()
function in the model;
- HISTORY declarations specify the name of the model's variables for which a history function
must be defined when using the model; they may optionally be used to assign default history
functions to any of the model's inputs and variables;
operation procedures:
- the EXEC procedure describes the execution algorithm of the model;
- the INIT procedure describes the initialization algorithm of the model.
Once defined, a model can be used independently in as many separate uses as required. Each
use of a model is introduced in a separate USE statement specifying the inputs and outputs of the
used model, and stating the local directives controlling its simulation (see USE).
The names chosen for identifying the constants, data, variables, inputs, functions, and submodels
defined in a model are local to the model. They are not visible outside the model, and can be
selected without concern for the possible duplication of names already used outside the model.
________________________________________
MODELS -- p. 5

2.2.3 FOREIGN MODELS


In addition to using the MODELS language for describing the operation of a model, it is also
possible to use procedures written in other programming languages. MODELS provides a pre-
defined interface that can be used by the user to connect "foreign" programs to a simulation. The
interface is defined as four arrays carrying the values of data, input, output, and history variables
between MODELS and the foreign procedure. Each foreign model must provide both an execution
procedure and an initialization procedure, with a function corresponding to the EXEC procedure
and the INIT procedure of a model. For example, a Fortran model would be written as:
SUBROUTINE execsub(xdata, xin, xout, xvar)
DIMENSION xdata(*), xin(*), xout(*), xvar(*)
... execution procedure ...
RETURN
ENTRY inisub(xdata, xin, xout, xvar)
... initialization procedure ...
END
where
- execsub: arbitrary name of the execution section of the foreign model;
- inisub: arbitrary name of the initialization section of the foreign model;
- xdata: array of the DATA values of the model;
- xin: array of the INPUT values of the model;
- xout: array of the OUTPUT values of the model;
- xvar: array of the history variables of the model (initial and ongoing) with storage
managed by MODELS.
In order to be recognized as a model, a foreign model is declared in the model where it is used.
The declaration format is as follows:

where:
- name: local name by which the foreign model can be referenced in the model;
- idname: arbitrary name used in the connection table of the foreign interface subroutine of
MODELS to recognize calls to this model;
and where the following pre-defined names must be used to identify the size of the four arrays
used to interface this model with the rest of the simulation:
- ixdata: number of elements in the array xdata
- ixin: number of elements in the array xin
- ixout: number of elements in the array xout
- ixvar: number of elements in the array xvar
A foreign program must be compiled and linked to the simulation program before it can be called
by MODELS. Any source language may be used, provided that the compiled object code is
compatible with the linker available on the computer platform used to run the simulation. The
interface routine of MODELS (in file mod001.for) is where the user registers the correspondence
between the idname used in the foreign model declarations, and the actual names of the foreign
subroutines and functions linked with the program.
Once declared and named, a foreign model can be used independently in as many separate uses
as required. The inputs and outputs of the foreign model, along with the directives controlling its
MODELS -- p. 6

simulation, are specified in a regular USE statement (see USE). The following simulation directives
apply:
- DATA directives specify the value of the elements of the xdata array;
- INPUT directives specify values to be assigned to elements of the xin array at model
execution;
- OUTPUT directives specify usage of the values of elements of the xout array at model
execution;
- HISTORY directives specify history functions used for assigning pre-simulation history to
elements of xvar and xin;
- TIMESTEP and INTERPOLATION directives can be specified as in a regular USE statement.
All local variables of a foreign model are considered to be under memory management defined
locally in the foreign procedure. Storage for the elements of the arrays xdata, xin, xout, and xvar is
provided automatically by MODELS. The array xvar can be used by the foreign procedure for
storage by MODELS, between calls to the procedure, of the state variables of the procedure.
Storage of these values is provided and managed by MODELS, automatically taking into account
the possibly many separate uses of the same model.
________________________________________

2.2.4 EXTERNAL MODELS


No model can be used in a model without being first declared in that model. If the definition of a
model is not included in a model in which it is used, it must be declared as EXTERNAL to that
model, as follows:
MODEL name EXTERNAL
The implied search algorithm for the location of the definition of an external model inspects the
model structure from the local model upward. All models defined at the same level as the model
containing the external declaration are candidates (including the host model itself, which permits a
model to use itself). This search is carried to the top of the model structure, one level at a time.
________________________________________

2.3 STATEMENTS
Three categories of statements are available for describing the operation of a model's procedures:
assignment statements, algorithm control statements, and simulation directive statements.
________________________________________

2.3.1 ASSIGNMENT STATEMENTS

2.3.1.1 VALUE ASSIGNMENT


Value assignment statements are used for assigning or modifying the values of a model's variables
(see VARIABLES).
Explicit values are specified on the right-hand side of an assignment in the form of a regular
expression (see REGULAR EXPRESSIONS), a linear sum of variables (see SUM
EXPRESSIONS), a linear polynomial of the derivatives of a variable (see DERIVATIVE
EXPRESSIONS), or the integral of a variable (see INTEGRALS).
Implicit value assignments in the form of differential equations and Laplace or Z transfer functions
are also available for specifying the value of a variable (see DIFFERENTIAL EQUATION,
LAPLACE TRANSFER FUNCTION, Z TRANSFER FUNCTION).
MODELS -- p. 7

A single value can be assigned to a single variable, to a single element of a variable array, or to a
group of elements of a variable array sharing the same value, by using a single-value assignment
as follows:

and an array of values can be assigned to a group of elements of a variable array, using an array-
value assignment as follows:
name [ expr .. expr ] := array-value expr
Minimum and maximum limits can be attached to the value of a variable or array of variables inside
the expression describing the value (see EXPRESSIONS).
________________________________________

2.3.1.2 DIFFERENTIAL EQUATION


A differential equation of the form
2
( a0 + a1 D + a2 D + ...) y = x
can be used for expressing the value of a variable "y", where "D" is the time derivative operator
d/dt.
A differential equation is specified in MODELS as follows:
DIFFEQ ( D-polynomial ) | y := x
where "y" can refer to any variable of the model, and "x" to any variable or input of the model,
specified using a simple name or a reference to an element of an array as follows:

i
The D-polynomial describes the terms "aiD " of the equation, written as follows:

where each coefficient can be represented as an arbitrary expression (linear or nonlinear, constant
or time-varying), and is separated from the D operator by a vertical bar, which is the "applies to"
i
operator of MODELS, with the meaning of "expression applied to D " (see DERIVATIVE
EXPRESSIONS for examples). Minimum and maximum limits can be specified for any of the
coefficients (see EXPRESSIONS).
The keyword CDIFFEQ can be used instead of DIFFEQ, as follows:
CDIFFEQ ( D-polynomial ) | y := x
to indicate a constant-coefficients differential equation. The expressions specifying the value of the
coefficients in CDIFFEQ are not re-evaluated during the execution, regardless of the variation of
the values of any input or variable possibly referred to in these expressions. Using CDIFFEQ
instead of DIFFEQ when the coefficients are constant will increase the simulation speed of the
solution by avoiding needless re-evaluation of the coefficients at each step.
MODELS -- p. 8

Dynamic minimum and maximum limits can be imposed on the value of "y". The limits are specified
in the statement as follows:
DIFFEQ ( D-polynomial ) | y { limits } := x
or
CDIFFEQ ( D-polynomial ) | y { limits } := x
where the limits are expressed using the following syntax:

The limit applied to a variable expressed by means of a differential equation is a "dynamic limit".
While an external static limit would simply clip the value of the variable outside of the procedure by
which the value of the variable is calculated, a dynamic limit modifies the calculation procedure
itself by recognizing that the values of the derivatives of the variable held at a constant limit are
zero.
In a case in which the value of the variable calculated by means of a differential equation is
subsequently reassigned by other means during the same time step, the action of any dynamic
limit previously applied to that variable at that time step is ignored.
When the driving variable "x" of a differential equation of "y" is itself a function of "y", the differential
equation should be solved simultaneously with the equation of "x" in a COMBINE group or in an
explicitly-defined iteration structure, because both are together defining the value of "y"
concurrently with the value of the derivatives of "y".
________________________________________

2.3.1.3 LAPLACE TRANSFER FUNCTION


A Laplace transfer function of the form
Y N(s ) b0 + b1s + b2s 2 +...
= =
X D(s ) a0 + a1s + a2s 2 +...

can be used for expressing the value of a variable "y", where "s" is the Laplace operator.
A Laplace transfer function is specified in MODELS as follows:
LAPLACE ( y / x ) := ( S-polynomial ) / ( S-polynomial )
where "y" can refer to any variable of the model, and "x" to any variable or input of the model,
specified using a simple name or a reference to an element of an array as follows:

i i
The s-polynomials describe the terms "ais " and "bis " of the Laplace function, with each polynomial
written as follows:

where each coefficient can be represented as an arbitrary expression (linear or nonlinear, constant
or time-varying), and is separated from the "s" operator by a vertical bar, which is the "applies to"
i
operator of MODELS, with the meaning of "expression applied to s " (see DERIVATIVE
EXPRESSIONS for examples). Minimum and maximum limits can be specified for any of the
coefficients (see EXPRESSIONS).
The keyword CLAPLACE can be used instead of LAPLACE, as follows:
CLAPLACE ( y / x ) := ( S-polynomial ) / (S-polynomial )
MODELS -- p. 9

to indicate a constant-coefficients Laplace function. The expressions specifying the value of the
coefficients in CLAPLACE are not re-evaluated during the execution, regardless of the variation of
the values of any input or variable possibly referred to in these expressions. Using CLAPLACE
instead of LAPLACE when the coefficients are constant will increase the simulation speed of the
solution by avoiding needless re-evaluation of the coefficients at each step.
Dynamic minimum and maximum limits can be imposed on the value of "y". The limits are specified
in the statement as follows:
LAPLACE ( y / x ) { limits } := ( S-polynomial ) / (S-polynomial )
or
CLAPLACE ( y / x ) { limits } := ( S-polynomial ) / (S-polynomial )
where the limits are expressed using the following syntax:

The limit applied to a variable expressed by means of a Laplace function is a "dynamic limit". While
an external static limit would simply clip the value of the variable outside of the procedure by which
the value of the variable is calculated, a dynamic limit modifies the calculation procedure itself by
recognizing that the values of the derivatives of the variable held at a constant limit are zero.
In a case in which the value of the variable calculated by means of a Laplace function is
subsequently reassigned by other means during the same time step, the action of any dynamic
limit previously applied to that variable at that time step is ignored.
When the driving variable "x" of a Laplace function of "y" is itself a function of "y", the Laplace
function should be solved simultaneously with the equation of "x" in a COMBINE group or in an
explicitly-defined iteration structure, because both are together defining the value of "y"
concurrently with the value of the derivatives of "y".
The operator "p" may be used equivalently to "s" when describing the polynomials of the Laplace
function.
________________________________________

2.3.1.3 Z TRANSFER FUNCTION


A Z transfer function of the form
Y N(z −1) b0 + b1z −1 + b2z −2 +...
= =
X D(z −1) a0 + a1z −1 + a2z −2 +...

can be used for expressing the value of a variable "y", where "z" is the z-transform operator.
A z transfer function is specified in MODELS as follows:
ZFUN ( y / x ) := ( Z-polynomial ) / ( Z-polynomial )
where "y" can refer to any variable of the model, and "x" to any variable or input of the model,
specified using a simple name or a reference to an element of an array as follows:

-i -i
The z-polynomials describe the terms "aiz " and "biz " of the Z function, with each polynomial
written as follows:
MODELS -- p. 10

where each coefficient can be represented as an arbitrary expression (linear or nonlinear, constant
or time-varying), and is separated from the "z" operator by a vertical bar, which is the "applies to"
-i
operator of MODELS, with the meaning of "expression applied to z " (see DERIVATIVE
EXPRESSIONS for examples). Minimum and maximum limits can be specified for any of the
coefficients (see EXPRESSIONS).
The keyword CZFUN can be used instead of ZFUN, as follows:
CZFUN ( y / x ) := ( Z-polynomial ) / (Z-polynomial )
to indicate a constant-coefficients Z function. The expressions specifying the value of the
coefficients in CZFUN are not re-evaluated during the execution, regardless of the variation of the
values of any input or variable possibly referred to in these expressions. Using CZFUN instead of
ZFUN when the coefficients are constant will increase the simulation speed of the solution by
avoiding needless re-evaluation of the coefficients at each step.
Dynamic minimum and maximum limits can be imposed on the value of "y". The limits are specified
in the statement as follows:
ZFUN ( y / x ) { limits } := ( Z-polynomial ) / (Z-polynomial )
or
CZFUN ( y / x ) { limits } := ( Z-polynomial ) / (Z-polynomial )
where the limits are expressed using the following syntax:

The limit applied to a variable expressed by means of a Z function is a "dynamic limit". While an
external static limit would simply clip the value of the variable outside of the procedure by which the
value of the variable is calculated, a dynamic limit modifies the calculation procedure itself by
recognizing that the values of the derivatives of the variable held at a constant limit are zero.
In a case in which the value of the variable calculated by means of a Z function is subsequently
reassigned by other means during the same time step, the action of any dynamic limit previously
applied to that variable at that time step is ignored.
When the driving variable "x" of a Z function of "y" is itself a function of "y", the Z function should be
solved simultaneously with the equation of "x" in a COMBINE group or in an explicitly-defined
iteration structure, because both are together defining the value of "y" concurrently with the value
of the derivatives of "y".
________________________________________

2.3.2 ALGORITHM CONTROL STATEMENTS

2.3.2.1 IF
The use of an IF statement allows the conditions applying to the selective operation of groups of
statements to be stated explicitly. An IF statement is specified as follows:

in which the conditions are expressed as logical expressions, and the statement lists can include
any arrangement of MODELS statements.
MODELS -- p. 11

Only one option among the IF, ELSIF, and ELSE options of an IF statement is operative at a time:
it is the first option for which the logical expression describing the condition associated with the
option is evaluated as true (see EXPRESSIONS). All remaining options are ignored at that time.
________________________________________

2.3.2.2 WHILE
The use of a WHILE statement allows the conditions applying to the repetition of a group of
statements to be stated explicitly. A WHILE statement is specified as follows:
WHILE expr DO statement-list ENDWHILE
in which the condition is expressed as a logical expression, and the statement list can include any
arrangement of MODELS statements.
The entire statement list placed in a WHILE statement is considered to be looped onto itself as a
repetition. The condition expressed in the associated logical expression is evaluated every time the
decision to enter or re-enter the list of statements must be made. The group is entered only if the
condition is true. The group is then re-entered as many times as required at the same simulation
time as long as the condition continues to be evaluated as true (see EXPRESSIONS).
________________________________________

2.3.2.3 FOR
The use of a FOR statement allows the value of the parameters controlling the repetition of a group
of statements to be stated explicitly. One or more parameters can be specified in the same FOR
statement, as follows:

in which the statement list can include any arrangement of MODELS statements.
The values of each parameter can be specified as a list of values, a range of values, and a
combination of the two, as follows:

The entire statement list placed in a FOR statement is considered to be looped onto itself as a
repetition. The list of statements is entered and re-entered as many times as required until all the
parameters have been assigned all combinations of their specified values.
The names chosen for representing the parameters are local to the FOR statement. They are not
visible outside the FOR statement, and can be selected without concern for the possible
duplication of names of variables already defined in the model. They may not, however, duplicate
the names of the resident variables and constants and of the model's constants, data, and inputs.
When a parameter of a FOR statement is used as an array index, and the expression defining its
value yields a non-integer value, a value rounded to the nearest integer is implied and used.
When the size of the "BY" interval used for covering a range of values is not specified, a default
value of +1 is implied.
________________________________________
MODELS -- p. 12

2.3.2.4 DO
The use of a DO statement allows the association of a group of statements to be stated explicitly.
An DO list of statement is specified as follows:
DO statement-list ENDDO
in which the statement list can include any arrangement of MODELS statements.
The use of the DO...ENDDO statement is equivalent to the use of parentheses marking association
in an algebraic expression. It defines the boundaries of a group of statements to which a common
operation applies (see REDO).
________________________________________

2.3.2.5 REDO
The use of a REDO statement allows internal conditions controlling the repetition of a
DO...ENDDO group of statements to be stated explicitly.
The indication that the operation of a DO...ENDDO group of statements is to be repeated is
specified within the group by the use of one or more REDO statements. The boundaries of
application of the REDO directive are determined by the extent of the DO...ENDDO statement
enclosing the group that is to be repeated (see DO).
The REDO statement sets a repetition flag if it is encountered during the execution of the
DO...ENDDO group of statements. At the start of each repeated execution of the group, the
repetition flag is reset. At the end of each execution of the group, the status of the flag determines
whether the group will be repeated or not.
The REDO directive has no qualifiers, and is specified by the simple use of the "REDO" statement
anywhere in a DO...ENDDO group.
The simple DO repetition structure differs from the conditional (see WHILE) and indexed (see
FOR) repetition structures as follows:
- the directives controlling the repetition are internal to the group of statements forming the
DO...ENDDO repetition group;
- the execution of the DO...ENDDO group of statements is conducted at least once.
________________________________________

2.3.2.6 COMBINE
A group of variables can be solved simultaneously by placing their assignment statements inside a
COMBINE group of linear statements of the form:
COMBINE AS identifier statement-list ENDCOMBINE
or a COMBINE group of nonlinear statements of the form:
COMBINE ITERATE AS identifier statement-list ENDCOMBINE
or COMBINE ITERATE { max-iter } AS identifier statement-list ENDCOMBINE
where the identifier is a name or an indexed name uniquely identifying the group in the model, and
"max-iter" is the maximum allowed number of iterations to convergence, defaulted to 10.
The first form is used for groups of linear variables, and is solved in matrix form using Gaussian
elimination. The statement list of a linear COMBINE can include any of the following value
assignments:
- differential equations
- Laplace functions
- Z functions
MODELS -- p. 13

- linear value assignment of a variable or of an array element of a variable, using:


- linear sum of variables (sum expression)
- polynomial of derivatives of a variable (derivative expression)
- integral of a variable (integral function)
- first and second derivative of a variable (derivative function)
- no regular expression (considered as possibly nonlinear)
- one set of static or dynamic min/max limits in one of the group's assignments (allowed by the
Gaussian elimination method)
The second form is used for groups of nonlinear variables, and is solved by iteration using the
Newton method. The statement list of an iterated COMBINE can include a combination of any type
of assignments, at the cost of possibly-longer execution times and possible non-convergence of
the solution, or convergence to a local (non-global) solution point. Accuracy of initial history and
size of time step are determining factors in attaining correct solution points.
All assignments statements placed in a COMBINE group are evaluated simultaneously. Examples
of simultaneous groups include:
- a group of value assignments in a tightly-coupled (non-delayed) feedback loop,
- a set of interdependent variables operating concurrently,
- a procedure described as a set of simultaneous equations.
Each statement in a COMBINE statement list specifies how to calculate the value of each
simultaneous variable. The value of each simultaneous variable cannot be specified in more than
one statement.
The simultaneous variables of a COMBINE group are considered to be evaluated concurrently with
each other. For this reason, any reference to the value of these variables within the COMBINE
group is considered to be a reference to the present value of the variable, not to its previous value.
It is however possible to refer to the previous value of a simultaneous variable by defining, outside
of the COMBINE group, a separate variable carrying that previous value. Note that this distinction
is not required in ordinary sequences of statements.
The configuration of a COMBINE group is considered to remain unchanged throughout a
simulation. The array index values identifying the group's simultaneous variables are therefore
considered to remain constant throughout the simulation.
Both the linear and the nonlinear COMBINE groups accept the coefficients used in the statements
to be time-dependent as well as nonlinear expressions. However, in the linear COMBINE solution,
the value of each coefficient, whether linear or not, is calculated every time step before finding the
solution point of the group. As a consequence, in cases where the value of a coefficient is
dependent on the value of a simultaneous variable, the coefficient is pre-evaluated using the
variable's value from the preceding time step. This allows the solution to remain linear by inserting
one-step delays in these dependency loops. This is discussed in more detail in the section on
model simulation below.
________________________________________

2.3.2.7 SEQUENCE
When no other form of structure is specified, the statements describing the operation of a model
are considered to be assembled in a sequence form. The sequence structure can also be specified
explicitly in a SEQUENCE statement as follows:
SEQUENCE statement-list ENDSEQUENCE
in which the statement list can include any arrangement of MODELS statements.
MODELS -- p. 14

The statements assembled in a sequence are considered to operate consecutively from the first
statement to the last.
________________________________________

2.3.2.8 USE
Once defined, a model can be used in as many instances as needed in the model in which it is
defined. Each instance is introduced by its own USE statement specifying the defined model name,
the usename of the instance, and the directives controlling its simulation. The syntax for a USE
statement is the following:

where:
- modelname is the name of the used model;
- usename is a unique local identifier of each instance of the used model, in the form of a single
name or an indexed name, as follows:

- ITERATE is a keyword indicating that this instance may be re-used


more than once at each time step;
- INPUT directives are used to assign values to the inputs of the model;
- OUTPUT directives are used to assign the values of the outputs of the model to variables of
the calling model;
- DATA directives are used to assign values to the data of the model;
- HISTORY directives are used to assign history functions to variables and inputs of the model;
- TIMESTEP directives are used to assign minimum and maximum limits to the execution time
step of the model;
- INTERPOLATION directives are used to specify the interpolation degrees to be applied to the
inputs of the model if the model is used at sub-steps of the external time step;
- DELAY directives are used to specify the size of storage associated with usage of the delay()
function in the model.
A model can be used only where its name is visible. The name of a model is only visible in the
model in which it is declared (see MODEL DEFINITION, FOREIGN MODEL, EXTERNAL MODEL).
________________________________________

2.3.3 SIMULATION DIRECTIVE STATEMENTS

2.3.3.1 WRITE
Individual lines of text can be written to the computer's standard output during a simulation, as
specified in a model description in one or more WRITE statements as follows:
WRITE ( write-list )
MODELS -- p. 15

where the write-list is specified as follows:

The statement keywords WRITE1 and WRITE2 can be used instead of WRITE, to send the
respective lines of text to the files named models.1 and models.2 .
________________________________________

2.3.3.2 ERROR
Predicted error situations related to the simulation of a model can be stated explicitly in the model,
using an ERROR...STOP structure to specify the pre-termination procedure to be followed before
the simulation is halted in a well-ordered manner.
An ERROR statement is specified as follows:
ERROR statement-list STOP
where the statement list can include any arrangement of MODELS statements.
On completion of the execution of the statement list specified in an ERROR statement, the
simulation is immediately terminated.
________________________________________

2.3.3.3 DEPOSIT
The DEPOSIT statement allows a model to modify the value of any numerical program variable of
ATP that can be changed using ATP's SPY command DEPOSIT. The ATP documentation of the
SPY commands describes what variables can be modified.
The DEPOSIT statement is used as follows:
DEPOSIT( name, value )
DEPOSIT( name[ expr ] , value )
DEPOSIT( name[ expr .. expr ] , value )
where 'name' is the name of a program variable accessible from SPY;
and where a single value can be assigned to a single variable, to a single element of an array
variable, or to a group of elements of an array variable.
________________________________________

2.4 VALUE-HOLDING ELEMENTS

2.4.1 ARRAYS
The value-holding elements of a model can be specified singly or as elements of unidimensional
arrays, with the following advantages:
- the symmetry or similarity of a group of elements can be made more explicit when an array
form is used (for example in identifying similar inputs to a model)
- the possibility of referring to many instances of a variable or constant under the same name
simplifies the use of repetition structures (WHILE, FOR, DO).
The total index range of an array is inferred from one or more declarations of the elements of the
array in the model definition (see DATA, INPUT, CONSTANTS, VARIABLES). The default index
range is one.
MODELS -- p. 16

A non-array element is identified by simply indicating its name:


name
A single array element is identified by indicating the name of the array and, within square brackets,
a numerical expression specifying the value of the array index:
name [ expr ]
A group of array elements is identified by indicating the name of the array and, within square
brackets, the two numerical expressions specifying the index range of the group:
name [ expr .. expr ]
When the evaluation of an expression defining the value of an array index yields a non-integer
value, a value rounded to the nearest integer is automatically implied and used.
________________________________________

2.4.2 CONSTANTS
The constants of a model are named value-holders carrying constant values. Their name, optional
array range, and value are declared in one or more CONST declarations in a model definition as
follows:

- where each constant element can be specified as a single name, a single array element, or a
group of array elements, as follows:

- where a single value can be assigned to a single constant, to a single element of a constant
array, or to a group of elements of a constant array sharing the same value;
- and where an array of values can be assigned directly to a group of elements of a constant
array by using an array-value expression to describe the assigned value.
The constants of a model are used as follows:
- their name, array range, and value are declared in one or more CONST declarations in the
model definition;
- their value cannot be modified in the model;
- their value can be used in any expression in the model.
________________________________________

2.4.3 RESIDENT CONSTANTS


A number of numerical and logical constants are permanently defined and are available for use in
model descriptions. Their value can be used directly in any expression of a model (see VALUE
REFERENCE, EXPRESSIONS). Their names are visible in any model, and can be used directly
without being declared in a CONST declaration.
The following resident constants are defined:
- resident numerical constants:
pi = 3.14159...
inf = very large number fitting the computer in use
undefined = 88888.88888 (value held by any element before it is assigned a first value)
- resident logical constants:
MODELS -- p. 17

false =0
true =1
no =0
yes =1
open =0
closed =1
off =0
on =1
________________________________________

2.4.4 DATA
The data of a model are named value-holders carrying use-defined constant values. They allow a
model to be described with generic dimensions, coefficients, parameters, and flags which can be
assigned specific values at the time the model is used. Their name, optional array range, and
optional default value are declared in one or more DATA declarations in the model definition, and
they can then be assigned local values in each USE statement where the model is used.
The data elements are declared in a model definition as follows:

- where each data element can be specified as a single name, a single array element, or a
group of array elements, as follows:

- where a single default value can be assigned to a single data, to a single element of a data
array, or to a group of elements of a data array sharing the same value;
- and where an array of default values can be assigned directly to a group of elements of a data
array by using an array-value expression to describe the assigned default value.
In a USE statement, values can be assigned to the data elements of the used model as follows:

- where a single value can be assigned to a single data, to a single element of a data array, or
to a group of elements of a data array sharing the same value;
- and where an array of values can be assigned in array form to a group of elements of a data
array.
Not all data elements of a model need be assigned a value in each model use, provided that a
default value has been specified in the model's DATA declaration for each optional data
assignment.
The value of a data element is determined at the first instant each use of a model is first executed,
and remains constant throughout the rest of the simulation for that model use.
Minimum and maximum limits can be attached to the value of a data element in the expressions
describing its default and assigned values (see EXPRESSIONS).
The data of a model are used as follows:
- their name, optional array range, and optional default value are declared in one or more DATA
declarations in the model definition;
- their value is assigned in a DATA directive of a USE statement (optional for data with a default
value);
MODELS -- p. 18

- their value cannot be modified in the model;


- their value can be used in any expression in the model;
- references to data values can be used in expressions defining the dimensions of an array in
any array range declaration of a model definition; this allows the size of arrays to be
dynamically specified later when the model is used.
________________________________________

2.4.5 VARIABLES
The variables of a model are named value-holders carrying the internal variable values used in a
model. Their name and optional array range are declared in one or more VAR declarations in a
model definition as follows:

where each variable element can be specified as a single name, a single array element, or a group
of array elements, as follows:

The variables of a model are used as follows:


- their name and optional array range are declared in one or more VAR declarations in the
model definition;
- their value is assigned and can be modified in any value assignment statement in the model;
- their value can be used in any expression in the model's procedures;
- their value can be used as an output of the model.
________________________________________

2.4.6 RESIDENT VARIABLES


A number of variables are permanently defined and are available for use in a model. Their value
can be used directly in any variable expression of a model (see VALUE REFERENCE), and cannot
be modified in assignment statements in the model. Their names are visible in any model, and can
be used directly without being declared in a VAR declaration.
The following resident variables provide access to the time characteristics of the simulation of a
model. A separate set of values of these variables exists locally for each use of each model. They
are:
t the present value of the simulation time in the model;
prevtime the previous value of the simulation time in the model;
timestep the present value of the simulation interval in the model (=t-prevtime);
endtime the external simulation time to which the model is to be updated;
fullstep the total time interval over which the model is to be updated (= endtime - previous
endtime);
maxstep the calculated present maximum allowed value of the time step in the model;
minstep the calculated present minimum allowed value of the time step in the model;
MODELS -- p. 19

Three other resident variables are defined globally for a simulation. They are:
starttime the value of time at the start of the simulation;
stoptime the value of time at which the simulation will end;
startstep the value of the outermost time step at the start of the simulation.
In addition to representing the present value of the simulation time in a model, the variable t can
also be used as a regular reference to the value of time in expressions describing history functions
in a model (see HISTORY).
________________________________________

2.5 MODEL INTERFACE

2.5.1 INPUT
The inputs of a model are named value-holders carrying the external input values used in a model.
Their name, optional array range, and optional default value are declared in one or more INPUT
declarations in a model definition, and they can then be assigned local values in each USE
statement where the model is used.
The input elements are declared in a model definition as follows:

- where each input element can be a single name, a single array element, or a group of array
elements, as follows:

- where a single default value can be assigned to a single input, to a single element of an input
array, or to a group of elements of an input array sharing the same value;
- and where an array of default values can be assigned directly to a group of elements of an
input array by using an array-value expression to describe the assigned default value.
In a USE statement, values can be assigned to the input elements of the used model as follows:

- where a single value can be assigned to a single input, to a single element of an input array,
or to a group of elements of an input array sharing the same value;
- and where an array of values can be assigned in array form to a group of elements of an input
array.
Not all input elements of a model need be assigned a value in each model use, provided that a
default value has been specified in the model's INPUT declaration for each optional input
assignment.
The value of an input element is re-calculated at each call to a model use.
Minimum and maximum limits can be attached to the value of an input in the expressions
describing its default and assigned values (see EXPRESSIONS).
MODELS -- p. 20

The input variables of a model are used as follows:


- their name, optional array range, and optional default value are declared in one or more
INPUT declarations in the model definition;
- their value is assigned in an INPUT directive of the USE statement (optional for inputs with a
default value);
- their value cannot be modified in the model;
- their value can be used in any expression in the model's procedures;
- their value can be used as an output of the model.
________________________________________

2.5.2 OUTPUT
Any input or variable of a model can be used as outputs of the model. Their name and optional
array range are specified as outputs of the model in one or more OUTPUT declarations in the
model definition as follows:

where each output element can be specified as a single name, a single array element, or a group
of array elements, as follows:

In a USE statement, the value of any output of the used model can be assigned to any variable of
the calling model. The use of a model's outputs is specified in one or more OUTPUT directives of a
USE statement, as follows:

- where the value of a single output can be assigned to a single variable, to a single element of
a variable array, or to a group of elements of a variable array assigned the same output value;
- and where the value of a group of elements of an output array can be assigned in array form
to a group of elements of a variable array.
All outputs specified in a model definition are available for reference in any use of the model,
although not all outputs need be used in each model use.
________________________________________

2.6 FUNCTIONS

2.6.1 FUNCTIONS IN A MODEL


A function describes the method by which a value or an array of values is calculated, given the
values assigned to the function's arguments. When used in an expression, a function returns the
value or array of values it calculates.
Three types of functions can be declared in a model definition:
- statement functions
- pointlist functions
MODELS -- p. 21

- foreign functions
In addition, two sets of functions are pre-defined and are available for use in any model:
- resident numerical and logical functions
- resident simulation functions
________________________________________

2.6.2 STATEMENT FUNCTION


A statement function is a parametrized expression evaluated according to the values assigned to
the function's arguments. It calculates a numerical value, or an array of numerical values, and is
defined in a model as follows:

The input arguments of a function are single elements with names that are local to the function.
They are not visible outside the function, and can be selected without concern for the possible
duplication of names already defined outside the function. They may not, however, duplicate the
names of the resident variables and constants defined in MODELS.
A statement function is used by referring to the function's name and providing values for the
function's arguments in the same order as they appear in the function definition:

A statement function can be used in any expression of the model in which it is defined (see
EXPRESSIONS), except in its own definition.
Minimum and maximum limits can be attached to the value of the expression describing the
statement function in the function definition (see EXPRESSIONS). Minimum and maximum limits
can be attached to the value of the function's arguments when the function is used, in the
expressions describing their value.
________________________________________

2.6.3 POINTLIST FUNCTION


A pointlist function is a list of coordinates {(xk,yk), k=1..n}, ordered in increasing values of x. The
function is assumed to be defined over the entire range of x (from -infinity to +infinity) in one of the
two following ways:
- either as a continuous function, where the missing intermediate points (xj, yj) in
the interval xk-1 < xj < xk will be interpolated using linear of quadratic interpolation;
- or as a discontinuous function, where yj holds a constant value equal to yk-1 for each missing
intermediate point (xj, yj) in the interval xk-1 < xj < xk .
A pointlist function is defined in a model as follows:

The expressions defining the coordinates of each point are regular expressions which can refer to
the value of any value-holding element visible in the model, and which can use other functions
available in the model, including other pointlist functions (allowing the use of families of
parametrized curves defined as pointlists of pointlists).
A pointlist function is used by referring to the function's name and by providing a value for its "x"
argument and for its optional "pol" argument, in the form of f(x) or f(x,pol), as follows:
MODELS -- p. 22

- where "x" is the value at which the pointlist function f(x) is to be evaluated;
- and where "pol" is an optional argument indicating the interpolation degree 0, 1, or 2 used for
evaluating the function between its defined points (0=discontinuous, 1=linear, 2=quadratic)
(default=1).
A pointlist function can be used in any expression of the model in which it is defined.
When the variable x is considered to be holding values of time, the pointlist function can be
considered to represent a function of time f(t).
________________________________________

2.6.4 FOREIGN FUNCTIONS


In addition to defining functions using the MODELS language, it is also possible to use functions
written in other programming languages. MODELS provides a pre-defined interface that can be
used by the user to connect "foreign" functions to a simulation. The interface is defined as one
array carrying the input arguments passed to the function, and returning the output values
calculated in the function. The function itself returns the number of values it calculates. For
example, a foreign function written in C would have the form:
double cfun(double xarg[])
{ ...
xarg[0]=...
xarg[1]=...
xarg[2]=...
return 3; /* indicating it placed 3 values on xarg[] */
}
where
- cfun: arbitrary name of the foreign function
- xarg: array of values carrying the input and output values of the function
In order to be recognized as a function, a foreign function is declared in the model where it is used.
The declaration format is as follows:
FUNCTION name FOREIGN idname { IXARG : expr }
where:
- name: local name by which the foreign function can be referenced in the model;
- idname: arbitrary name used in the connection table of the foreign interface subroutine of
MODELS to recognize calls to this function;
- ixarg: pre-defined keyword that must be used to specify the size of the argument array.
A foreign function must be compiled and linked to the simulation program before it can be called by
MODELS. Any source language may be used, provided that the compiled object code is
compatible with the linker available on the computer platform used to run the simulation. The
interface routine of MODELS (in file fgnmod.for) is where the user registers the correspondence
between the idname used in the foreign function declarations, and the actual names of the foreign
functions linked with the program.
A foreign function is used by referring to the function's name and providing values for the function's
arguments in the same order as they are expected in the foreign function:

A foreign function can be used in any expression of the model in which it is defined. Minimum and
maximum limits can be attached to the value of the function's arguments when the function is
used, with each expression describing their value.
________________________________________
MODELS -- p. 23

2.6.5 RESIDENT FUNCTIONS


A number of numerical and logical functions are permanently defined and are available for use in a
model. Their names are visible in any model, and can be used directly without being declared in a
FUNCTION declaration.
A resident function is used by referring to the function's name and by providing values for the
function's arguments, as follows:

where each argument of the function is assigned a value, in the sequence expected by the
function.
The following resident functions are defined:
- numerical functions returning one value for each input argument:
abs absolute value of each argument
sqrt square root of each argument
exp exponential of each argument
ln base-e logarithm of each argument
log10 base-10 logarithm of each argument
log2 base-2 logarithm of each argument
recip 1/x for each argument x, with zero-division protection (1/0 = inf)
factorial x! for each argument x
trunc integer part of each argument
fract fractional part of each argument
round rounded value of each argument (to the nearest integer)
sign =-1 when x<0, =0 when x=0, =+1 when x>0, for each argument x
rad value conversion from degrees to radians, for each argument
deg value conversion from radians to degrees, for each argument
sin sine of each argument
cos cosine of each argument
tan tangent of each argument
asin arc sine of each argument
acos arc cosine of each argument
atan arc tangent of each argument
sinh hyperbolic sine of each argument
cosh hyperbolic cosine of each argument
tanh hyperbolic tangent of each argument
asinh arc hyperbolic sine of each argument
acosh arc hyperbolic cosine of each argument
atanh arc hyperbolic tangent of each argument
- double-argument numerical functions returning a single value:
-1
atan2(x1,x2) tan (x1/x2) with 4-quadrant range as determined by the signs of
x1 and x2
binom(n,r) C(n,r) combination of r elements in a set of n
= n!/(n-r)!r!
permut(n,r) P(n,r) permutation of r elements in a set of n
= n!/(n-r)!
- multiple-argument numerical functions returning a single value:
min(x1,x2,...) minimum value of {x1, x2, ...}
max(x1,x2,...) maximum value of {x1, x2, ...}
2 2
norm(x1,x2,...) Euclidian norm =sqrt(x1 +x2 +...)
MODELS -- p. 24

- no-argument numerical functions returning a single value:


random single random number between 0 and 1, uses no argument
- logical functions returning one value for each input argument:
bool value conversion of each argument from numerical to Boolean
value = 1 when argument > 0
value = 0 when argument <= 0
- multiple-argument logical functions returning a single value:
and(x1,x2,...) returns value of "x1 AND x2 AND ..."
=1 only when all the arguments are true
or(x1,x2,...) returns value of "x1 OR x2 OR ..."
=1 when one or more of the arguments are true
nand(x1,x2,...) returns value of "NOT(x1 AND x2 AND ...)"
=1 when one or more arguments are false
nor(x1,x2,...) returns value of "NOT(x1 OR x2 OR ...)"
=1 only when all the arguments are false
xor(x1,x2,...) returns value of "x1 XOR x2 XOR ..."
= 1 when only one of the arguments is true
________________________________________

2.6.6 RESIDENT SIMULATION FUNCTIONS


A number of functions which are related to the time simulation of a model are permanently defined
and are available for use in a model. Their names are visible in any model, and can be used
directly without being declared in a FUNCTION declaration.
A resident simulation function is used by indicating the function's name, the single element to
which the function is applied, and values of any required function arguments, as follows:

- where the element can be any input or variable element of a model, as follows:

- and where, in the case of the functions histdef and histval, the element can also be the integral
of any input or variable of the model:

For those functions requiring interpolation or extrapolation (see the list of functions below), the
interpolation degree "pol" is an optional argument indicating the interpolation degree 0, 1, or 2
used for evaluating the function between the available values of the element (0=discontinuous,
1=linear, 2=quadratic) (default=1).
The following resident simulation functions are defined:
deriv(x) the value of the first-order time derivative of x at the present simulation
time
deriv2(x) the value of the second-order time derivative of x at the present
simulation time
delay(x,d,pol) past value of x at time (t-d), including references to pre-simulation times
using the history function assigned to x
MODELS -- p. 25

prevval(x) the value of x at the previous simulation time


backval(x,t,pol) past value of x at a time t within the last time step
backtime(x,val,pol) time at which x had the value val during the last time step
= "undefined" if not possible
predval(x,t,pol) predicted value of x at time t
predtime(x,val,pol) predicted value of time at which x will reach the value val
= "undefined" if not possible
histdef(x) a reference to the definition of the history function associated with x,
used when defining the history of an element in terms of the history of
another element
histval(x,t) the value of x evaluated at time t, calculated using the history function
associated with x
atp(x) the value of a single ATP program variable or array element x accessible
by ATP's SPY command EXAMINE
________________________________________

2.7 NAMES

2.7.1 NAME DEFINITION


A name is a string of contiguous characters of arbitrary length, starting with a letter, and including
any number of letters, digits, and underscore characters "_". Names in a model are not case-
sensitive.
Names are used for identifying models, functions, and value-holding elements (constant, data,
input, variable, function argument, and FOR parameters). The reference to a named element is
direct, by simple indication of the name.
The following identifiers have a reserved interpretation and may not be assigned as names in the
description of a model. They are:
- the names of the resident models, functions, variables, and constants;
- the syntactic keywords of the MODELS language.
________________________________________

2.7.2 USE PATHNAMES


A use pathname is the unique pathname describing the location of a model use in a system. It
consists of a contiguous sequence of usenames, each separated by a period. A usename is the
local identification name assigned to a model in each use of the model, and may be a single name
or an indexed array name, as follows:

Use pathnames are used by the simulation program in the printout of warning and error messages.
________________________________________
MODELS -- p. 26

2.8 VALUES

2.8.1 VALUE TYPES


Three types of values are available: numerical values, logical values, and text values.
Numerical values are integer or real values in the interval (-inf,+inf), specified as follows:

where n is any contiguous sequence of decimal digits.


Logical values are the values true and false, and can be specified by using the resident logical
constants true/false, on/off, closed/open, and yes/no.
A text value is an arbitrary string of characters enclosed in quotes or apostrophes. A string can
include any character except the string delimiter used for enclosing the string.
Numerical values can be used directly as logical values, where they are interpreted as true when
positive, and as false when negative or zero.
Logical values can be used directly as numerical values, where they are interpreted as having the
value 1.0 when true, and 0.0 when false.
________________________________________

2.8.2 VALUE REFERENCE


The value associated with a named value-holding element can be accessed in any expression of
the model in which the name of the element is visible. The value-holding elements visible in a
model are:
- the constants, data, variables, and inputs declared in the model
- the resident constants and variables of MODELS
The names of the arguments of a statement function are visible only in the function where they are
defined.
The names of the parameters of a FOR statement are visible only in the statement list associated
with the FOR statement.
The value of an element is accessed directly by using the element's name as a reference to its
value.
The reference context of an expression is the model in which the value-holding elements referred
to in the expression are defined. The reference context of most expressions is the model in which
the expression is specified. However, the reference context of some expressions in a USE
statement also includes the model being used, as follows:
- data names of the used model can be referenced in any expression of a USE statement
defining values or array indexes of elements of the used model;
- input names of the used model can be referenced in any expression of a USE statement
defining values of elements of the used model, except values of data elements of the used
model.
________________________________________
MODELS -- p. 27

2.8.3 VALUE LIMITS


Static limits are specified in the following format:

Static limits ("clipping") can be applied to any of the following calculated values:
- a regular expression
- a sum expression
- a derivative polynomial expression
Dynamic limits are specified in the following format:

Dynamic limits can be applied to any of the following calculated value:


- integrals
- variables calculated by a differential equation
- variables calculated by a Laplace or Z transfer function
A static limit modifies the value of a variable outside and independently of the procedure by which
the variable is calculated. A dynamic limit directly affects the procedure used for the calculation of
the variable.
In control circuitry, applying a dynamic limit corresponds to modifying the value of a signal within a
component's internal feedback loop. Applying a static limit corresponds to modifying the value of a
signal externally from the component producing the signal.
The effect of applying an external static limit and an internal dynamic limit to an integral, for
instance, is demonstrated in the following example:

________________________________________

2.9 EXPRESSIONS

2.9.1 EXPRESSIONS IN A MODEL


An expression is a description of the method by which a value is determined. An expression can
refer to names of functions and of value-holding elements visible in the context where the
expression is used (see VALUE REFERENCE). An expression can be used for specifying the
value of a single element or of a group of array elements. It is implicitly an array of one or more
elements.
MODELS -- p. 28

The type of value (numerical or logical) resulting from the evaluation of an expression is
determined by the type of the operators used in the expression.
The following forms of expressions can be used in MODELS:
- regular expressions
- sum expressions
- derivative expressions
- use of integrals
________________________________________

2.9.2 REGULAR EXPRESSIONS


A regular expression is either a logical expression or a numerical expression depending on the
operators used in the expression. The value of a regular expression is either a single value or an
array of values depending on the value descriptions used in the expression.
A regular expression is defined in the following format and order of precedence:
- a regular expression consists of one or more logical terms separated by the OR operator:

- a logical term consists of one of more logical factors separated by the AND operator:

- a logical factor is a logical relation or a numerical expression:

- a logical relation consists of two numerical expressions separated by one of the six relational
operators:
numerical expr relational-op numerical expr
where the relational operators are:
> greater than
>= greater than or equal to
< less than
<= less than or equal to
= equal to
<> not equal to
- a numerical expression consists of one or more numerical terms separated by the addition or
subtraction operators + and - :

- a numerical term consists of one or more numerical factors separated by the multiplication or
division operators * and / :

- a numerical factor is an exponent relation or a value reference:


MODELS -- p. 29

- an exponent relation consists of two value references separated by the exponent operator ** :
value reference ** value reference
- a modulo relation consists of two value references separated by the modulo operator MOD :
value reference MOD value reference
- a value reference is one of the following:

where:
- a simple numerical value or an array value can be described directly
- a named value, a function value, or a sub-expression can be preceded by the unary
numerical or logical inverse operators - and NOT
- a numerical value is described in the following format:

where n is any contiguous sequence of decimal digits


- an array value is a list of regular single-value or array-value expressions enclosed in square
brackets:

a named value is:


- a reference by name to a single value-holding element,
- a reference by name and array index to a single element of an array,
- or a reference by name and array index range to a group of elements of an array
(when used, the left bracket must immediately follow the name)

- a function value is expressed as a function name followed by a list of argument values (the
left parenthesis must immediately follow the function name):

- a sub-expression is a regular expression enclosed in parentheses.


( expr )
Numerical limits can be applied to the value of a regular expression. Limits applied to an
expression are static limits. They are specified immediately following the expression, enclosed in a
pair of braces:
MODELS -- p. 30

Some examples of regular expressions follow:


a + b[i+2] sum of single element a and of element [i+2] of array b
-sin(2*omega*t) use of resident function sin( )
a AND NOT b logical expression
a>=2*b +c**(2*d) logical expression
-3.582 * 3E6 product of two numerical values
[3, 5, 9, cnt-2] array value of length 4
________________________________________

2.9.3 SUM EXPRESSIONS


A linear polynomial expression of the form
a0 + a1 x1 + a2 x2 + ...
can be used for expressing the value of a variable y.
A linear polynomial is specified in MODELS as follows:
y := sum ( polynomial )
where y can refer to any variable of the model, specified using a single name or a single element
of an array:

The polynomial describes the terms "aixi" of the equation, written as follows:

where each element can be a single name or a single element of an array:

and where each coefficient can be represented as an arbitrary expression (linear or nonlinear,
constant or time-varying), and is separated from the element by a vertical bar, which is the "applies
to" operator of MODELS, with the meaning of "expression applied to x". Minimum and maximum
limits can be specified for any of the coefficients (see EXPRESSIONS).
Minimum and maximum limits can be assigned to the value of the sum as follows:
y := sum ( polynomial ) { limits }
Limits applied to a sum expression are static limits. They are specified immediately following the
sum expression, enclosed in a pair of braces:

An expression is specified as a sum expression when it is necessary to put in evidence the


linearity of the expression with respect to the x elements. It can be used as the right-hand side of
any value assignment, but is required only in a COMBINE group of statements (see COMBINE,
SIMULTANEOUS ELEMENTS).
MODELS -- p. 31

The following are examples of sum terms:


3.0 | a coef = 3.0, x-element = a
1.0 | b[2*i-6] coef = 1.0, x-element = b[2*i-6]
6.42*a | coef = 6.42*a, no x-element
________________________________________

2.9.4 DERIVATIVE EXPRESSIONS


References to the value of the first- and second-order time derivatives of an input or variable can
be used in any expression of a model, by means of the functions deriv(x) and deriv2(x) (see
RESIDENT SIMULATION FUNCTIONS). Alternately, a linear polynomial of the time derivatives of
an element can be used, of the form:
2
( a0 + a1 D + a2 D + ... ) x
where D is the time derivative operator representing d/dt.
In MODELS, a derivative expression can be used for describing a linear polynomial of derivatives,
as follows:
y := derivpol ( D-polynomial ) | x
- where y can refer to any variable of the model, and x can refer to any input or variable of the
model, each specified using a single name or a single element of an array:

- and where the polynomial is separated from the element to which it is applied by a vertical bar,
the "applies to" operator of MODELS, with the meaning of "polynomial applied to x".
i
The D-polynomial describes the terms "aiD " of the equation, written as follows:

where each coefficient can be represented as an arbitrary expression (linear or nonlinear, constant
or time-varying), and is separated from the D operator by a vertical bar, the "applies to" operator of
MODELS, with the meaning of "expression applied to D". Minimum and maximum limits can be
specified for any of the coefficients (see EXPRESSIONS).
Minimum and maximum limit values can be assigned to a derivative polynomial as follows:
y := derivpol ( D-polynomial ) | x { limits }
Limits applied to a derivative polynomial expression are static limits. They are specified
immediately following the element to which the derivative expression is applied, as follows:

An expression is specified as a derivative expression when it is necessary to put in evidence the


linearity of the expression with respect to the derivatives of x. It can be used as the right-hand side
of any value assignment, but is required only in a COMBINE group of statements (see COMBINE,
SIMULTANEOUS ELEMENTS).
An example of a derivative polynomial is shown below, with its interpretation:
(cos(a)| +2|D +3.56*a|D2 -1|D3) | x : cos(a)×x +2×dx/dt +3.56×a×d2x/dt2 -d3x/dt3
________________________________________
MODELS -- p. 32

2.9.5 INTEGRALS

2.9.5.1 INTEGRAL EXPRESSION


The time integral of any input or variable of a model is automatically calculated during the
simulation whenever an integral expression is evaluated. The value of the integral of an element at
a given time step is a cumulative value dependent on the previous value of the integral and on the
present and previous value of the integrated element.
An integral expression is specified as follows:
y := integral ( x )
where y and x can be references to a single element or to a single array element, of the form:

Minimum and maximum limits can be assigned to the value of an integral as follows:
y := integral ( x ) { limits }
They are specified immediately following the integral, enclosed in a pair of braces:

The limit applied to an integral is a "dynamic limit". While an external static limit would simply clip
the value of the integral separately from the procedure by which it is calculated, a dynamic limit
modifies the calculation procedure itself by recognizing that the past value used in a later
calculation of the integral is the integral's limited value.
When more than one integral expressions affect the same element at a given time step of a
simulation, the integral is re-evaluated each time it is used, to reflect possible changes in the value
of the element to which it applies. Each new evaluation of the integral during the same time step
also releases any previously-applied limit to that integral at that time step.
________________________________________

2.9.5.2 INTEGRAL VALUE RESET


The value of an integral can be reset at any time of a simulation, using an integral value
assignment. A single value can be assigned to the integral of a single element, of a single array
element, or of a group of array elements sharing the same value, by using a single-value integral
assignment as follows:

and an array of values can be assigned to the integral of a group of array elements, using an array-
value integral assignment as follows:
integral ( name [ expr .. expr ] ) := array-value expr
Minimum and maximum limits can be attached to the value assigned to the integral, in the
expression describing the value (see EXPRESSIONS).
From the point where a reset value is assigned to an integral until the end of the execution of that
model at that simulation time, the value of the integral becomes fixed, and is not influenced
anymore by the value of the integrated variable.
________________________________________
MODELS -- p. 33

2.10 FORMAT

2.10.1 DESCRIPTION FORMAT


The syntax of MODELS allows the use of free-style formatting throughout the description of a
model. The interpretation of the description is based exclusively on the use of single keywords (for
example, DATA, INPUT, TIMESTEP) and of sets of delimiters (for example,
MODEL...ENDMODEL, USE...ENDUSE, IF...ELSE...ENDIF, "..." ), and by the local context of
interpretation defined by their use.
The interpretation of the description of a model is not sensitive to the case of the identifiers used in
the model. Uppercase letters have been used for identifying the various keywords in this
documentation, but only in order to increase their visibility.
________________________________________

2.10.2 DELIMITERS
Names, numerical values, and reserved keywords, must be written as strings of contiguous
characters.
In a name, any character other than a letter, a digit, or the underscore character, is interpreted to
indicate the end of the name (see NAME DEFINITION).
In a numerical value, any character other than a decimal digit, a plus sign, a minus sign, a period,
or the letter E, is interpreted to indicate the end of the numerical value (see VALUE TYPES).
In a reserved keyword, any character other than a letter is interpreted to indicate the end of the
keyword (see NAME DEFINITION).
Commas, semicolons, and white-space characters (spaces, tabs, carriage returns, line feeds), are
interpreted as spaces, with no additional syntactical meaning. They can be used at will to separate
keywords, names or numbers. There is one exception: a carriage return or line feed is used to
mark the end of an in-line comment.
________________________________________

2.10.3 LINE INDENTATION


Line indentation can be used in the description of a model for the purpose of facilitating the
reader's identification of the structure of the model description.
Any space or tab characters used for indenting the lines of a model description are only visual
place markers in the written presentation of the model, and carry no syntactic meaning affecting
the interpretation of the description, other than their regular use as delimiters of names and
numerical values (see DELIMITERS).
Blank lines can similarly be used freely for increasing the readability of a model description.
________________________________________

2.10.4 COMMENTS
Comments can be included anywhere in a model description, and do not affect the syntactic
interpretation of the model description.
Two types of comments can be used: in-line comments, and block comments.
An in-line comment is any text beginning with a hyphen string (two or more contiguous hyphens)
and ending at the end of the line.
A block comment is enclosed by the keywords:
COMMENT ... ENDCOMMENT
MODELS -- p. 34

or
ILLUSTRATION ... ENDILLUSTRATION
and can contain any combination of text and graphics, as follows:

or

________________________________________

3. MODEL SIMULATION

3.1 SIMULATION DIRECTIVES

3.1.1 TIMESTEP
Over the course of a simulation, the state of a model is updated at successive instants of time,
every time the model is called for execution by the environment in which it is used. The size of the
time interval between two successive instants of execution of a model is referred to as the
simulation time step of the model.
It is possible to define limits on the permitted time interval between successive executions of a
model. Variable minimum and maximum size of a model's time step can be specified in any
definition and in any USE of a model, using one or more TIMESTEP directives, as follows:

Whenever a model is called for execution after a time step that is smaller than the calculated
minimum time step, the execution request is ignored. A model can in this way be executed with a
time step larger than the time step used in the environment in which the model is used, its state
and its outputs remaining constant from one execution to the next.
Whenever a model is called for execution after a time step that is larger than the calculated
maximum time step, the model's local time step is divided into equal sub-steps of a size satisfying
the stated maximum, and the model is executed successively at each sub-step until the complete
interval is covered. A model can in this way be executed with a time step smaller than the time step
used in the environment in which the model is used (see INTERPOLATION for calculation of the
inputs to the model at each sub-step).
When no minimum and maximum values are specified for the time step, a model is executed every
time it is called by a USE statement.
The values of the minimum and maximum specified for a model's time step in a USE statement are
subject to the minimum and maximum values specified in the definition of the used model.
________________________________________

3.1.2 INTERPOLATION
When a model is executed, the values presented to its inputs by the calling model are values
calculated at the simulation time of the calling model. If the used model runs at sub-steps of the
calling model (see TIMESTEP), the values of the inputs are undefined at those intermediate times,
and must be estimated by the model, using interpolation.
MODELS -- p. 35

The inputs can be treated as continuous or discontinuous, depending on the level of interpolation
used for calculating their value for sub-step execution (0=discontinuous, 1=linear, 2=quadratic)
(default=1).
The interpolation degree to be applied to the inputs of a model for sub-step execution can be
specified for individual input elements, in the model definition and in USE statements, in
INTERPOLATION DEGREE directives of the form:

- where a different degree value can be specified for different lists of input elements;
- and where a default degree value can be specified for the remaining unlisted input elements.
Each list of elements is written in the following form:

with each element either a single input, a single element of an input array, or a group of elements
of an input array, as follows:

When unspecified, a default interpolation degree value of 1 is automatically selected.


An INTERPOLATION DEGREE directive specified in a model definition applies to all uses of the
model, and can be modified by specifying individual INTERPOLATION DEGREE directives in local
USE statements.
Interpolation on the values of an element x in an interval (x0, x1) has the following interpretation
depending on the interpolation degree:
0 uses the value x0 for any time t0 <= t < t1
uses the value x1 for time t = t1
(equivalent to considering x as a step function of time)
1 uses linear interpolation based on the two most recent values of x
2 uses quadratic interpolation based on the three most recent values of x
________________________________________

3.1.3 DELAY
The resident simulation function delay() provides access to past values of the input and variable
elements of a model. The simulation program reserves a default number of memory cells for each
element to which the function is applied. However, a different number of storage cells can be
assigned to any delay element, in the model definition and in USE statements, in DELAY CELLS
directives of the form:

- where a different number of cells can be specified for different lists of elements;
- and where a new default degree value can be specified for the remaining unlisted elements.
Each list of elements is written in the following form:
MODELS -- p. 36

with each element either a single element, a single array element, or a group of array elements, as
follows:

When unspecified, the program reserves a default number of 100 cells for each element to which
the delay function is applied.
A DELAY CELLS directive specified in a model definition applies to all uses of the model, and can
be modified by specifying individual DELAY CELLS directives in local USE statements.
Depending on how it is specified, the number of storage cells for each delay element is calculated
as follows:
- if specified in a DELAY CELLS list in the USE definition, then that number;
- else if specified in a DELAY CELLS list in the MODEL definition, then that number;
- else if there is a DELAY CELLS DFLT in the USE definition, then that number;
- else if there is a DELAY CELLS DFLT in the MODEL definition, then that number;
- else 100 cells.
This allows the developer and the user of a model to adjust the storage size that is required to
match the maximum number of storage cells necessary for lodging the largest delay value applied
to a given element (number of cells = largest delay value / smallest time step value).
________________________________________

3.2 SIMULATION PROCESS

3.2.1 INITIALIZATION
During the simulation of a system, the state of each used model is evaluated repeatedly at discrete
instants of time over a number of time intervals (the time steps of the model) covering the course of
the simulation.
Evaluating the state of a used model at a given instant of the simulation consists in calculating the
present value of the model's variables and integrals according to the execution procedure
describing the operation of the model (see EXECUTION), using the values being applied to the
model's inputs (see INPUT) and the accumulated history of some of the model's variables required
in the operation of the model.
At the first call for execution of a used model, this evaluation could not be conducted without first
knowing the history of the quantities expected to have been carried from non-existent previous
execution times.
The minimum initialization task then consists in defining the pre-simulation history of the quantities
expected to have been carried from the missing previous execution times.
A history function can be associated to any variable of a model. It can be defined as a general
function of time f(t), including references to pointlist functions and to the history functions of other
variables.
Three levels of history definition can be successively applied. The history can be first specified in
the definition of a model in the form of a default function; then in the HISTORY section of each
USE statement; and finally in the form of history assignment statements in the INIT procedure of
the model description.
________________________________________
MODELS -- p. 37

3.2.2 HISTORY FUNCTIONS


During the simulation of a model, references are made to the past values of an element in the
following situations:
- when referring to a variable for which a value has not yet been determined at the present
execution time;
- when using a variable as argument of the simulation functions delay, prevval, predval,
predtime, backval, backtime, histdef, histval, deriv, and deriv2;
- when applying a Laplace or Z function, a differential equation, an integral, or a derivative
expression to an element;
- when using interpolation on the inputs of a model during sub-step execution (see
INTERPOLATION).
These past values do not exist when a reference is for a simulation time preceding the start of the
execution of a model. However, it is possible to define history functions that describe the value of
an element for times preceding the simulation of a model. History functions can be defined for any
element of a model, as follows:
- in HISTORY directives in the definition of a model;
- in HISTORY directives in a USE statement defining the use of a model;
- in a history assignment statement inside the INIT procedure of a model.
All variables publicly requiring a history function in a model (as opposed to history functions
privately defined in the INIT section of a model) must be declared in a HISTORY directive of the
model definition. HISTORY directives in the model definition can also be used for assigning a
default history function to any input or variable element of the model. The format of a HISTORY
directive in the model definition is the following:

- where a history element can be a single name, a single array element, or a group of array
elements, as follows:

- where a history element can also be the integral of a single name or of a single array element,
as follows:

- where a single default value can be assigned to a single history element or to a group of array
elements sharing the same value;
- and where an array of default values can be assigned directly to a group of array elements
using an array-value expression to describe the assigned default value.
In a USE statement, history functions are assigned to the elements of the used model in a
HISTORY directive of the form:

In the INIT procedure of a model, history functions can be assigned privately (as opposed to
publicly in a USE statement) to elements of the model by using a history assignment statement of
the form:
histdef ( history element ) := expr
MODELS -- p. 38

where the expression can be any of the following:


- a regular expression describing an analytical function of time f(t) by using the variable "t" as a
reference to any value of time;
- a regular expression using references to pointlist functions describing the value of a variable
as a list of points { t, f(t) } describing a function of time;
- a regular expression using references to existing history functions by using the resident
simulation functions histdef() and histval().
Because Laplace and Z functions and differential equations are solved in a model by applying
trapezoidal integration to both sides of the equation, the solution implicitly uses past values of both
the driving variable and the calculated variable. History functions must therefore be defined for
both variables if these types of calculation are used in the first n time steps of the execution of a
model, given a s-polynomial or D-polynomial of order n.
Integrals are evaluated using the trapezoidal rule. Their solution implicitly uses the past value of
the integrated variable and of the integral. History functions must therefore be defined for both if
integrals are used at the first step of an execution without any previous integral value assignment.
No history function or default history function need be assigned to the inputs of a model which is
not executed at sub-steps of the applied time step at the first time step that the model is used.
________________________________________

3.2.3 INIT PROCEDURE


It is possible to define, in the model description, an initialization procedure that is different from the
regular execution procedure of the model. The INIT procedure, if present in a model description, is
executed once at the first execution of each use of the model. It can be used, typically, for
completing the history assignments required in the model, and for verifying, correcting, and
possibly rejecting the conditions under which the model is being used.
When defined, the initialization procedure is specified in the INIT section of a model definition as
follows:
INIT statement-list ENDINIT
The statement list of an INIT procedure may include any statement and function not requiring the
existence of a history for their execution, namely:
- value assignments other than differential equations and Laplace or Z functions;
- history assignment statements;
- integral assignment statements;
- algorithm control statements other than the USE statement;
- the simulation directive statements ERROR and WRITE;
- the simulation functions histdef and histval, but not the functions delay, predval, predtime,
backval, backtime, and prevval;
- and no derivatives or integrals.
________________________________________

3.2.4 EXEC PROCEDURE


The EXEC procedure is the main procedure of a model. It contains the algorithm describing how
the model operates at the successive instants of the simulation. It is executed each time the model
is called by a USE statement.
MODELS -- p. 39

Each time the model is used, the execution procedure updates the values of the variables of the
model for the new simulation time, taking into account the values assigned to the inputs of the
model in the USE statement.
The execution procedure is specified in the EXEC section of a model definition as follows:
EXEC statement-list ENDEXEC
The statement list of the EXEC procedure may include any type of statements except history
assignment statements (see STATEMENTS). The execution flow is directed by the algorithm
control statements used in the procedure (see ALGORITHM CONTROL STATEMENTS).
________________________________________

3.2.5 SIMULTANEOUS VARIABLES


The description of a model may include sets of interdependent variables represented by a group of
value assignments, differential equations, and transfer functions connected in a closed-loop
configuration.
The statements describing a group of simultaneous variables can be assembled in a COMBINE
statement (see COMBINE), or can be grouped inside an iterative solution algorithm defined
explicitly in the model using a WHILE or DO statement.
The distinction between linear and nonlinear groups of simultaneous variables is discussed in the
following two sections.
________________________________________

3.2.6 SIMULTANEOUS LINEAR VARIABLES USING A LINEAR COMBINE


The statements of a linear COMBINE group are considered to be linear descriptions of the value of
the simultaneous variables of the group, with the possible inclusion of one nonlinearity in the form
of a limit applied to the value of one of the group's variables.
The linearity requirement of the linear COMBINE is only with respect to the group's simultaneous
variables, and does not apply to references made to variables external to the group in the
expressions describing the coefficients used in the group's statements.
In the solution, the differential and integral equations of the group are first converted to algebraic
equations, by application of the trapezoidal rule of integration. The dependencies of the group's
simultaneous variables are then represented in matrix form, as follows:
[C] ⋅ x = b
where [C] matrix of coefficients
x vector of group's interdependent and independent variables
b vector of driving terms
During the simulation, the values of the interdependent variables in x are calculated using the two-
step procedure of, first, Gaussian elimination using Crout's algorithm of LU decomposition,
transforming [C] and b into a triangularized form [CLU] and b' which, in turn, are used for evaluating
the unknown part of x by back-substitution, in the form:
[CLU ] ⋅ x = b′
When the coefficients in [C] and b remain constant over successive execution times, re-
triangularization is not required and only back-substitution is performed, using the existing values
of [CLU] and b'.
In most instances of a change in the value of some elements of [C] or b from one execution time to
the next, only a partial re-triangularization is sufficient for reflecting the change, either because
only a subset of the equations is affected, or only elements of b are modified. These situations are
MODELS -- p. 40

automatically recognized, and after the partial re-triangularization is performed, the back-
substitution process takes place as usual.
________________________________________

3.2.7 SIMULTANEOUS NONLINEAR VARIABLES USING A LINEAR COMBINE


As described in the previous section, a set of simultaneous linear equations can be solved without
iteration by using a linear COMBINE group. Groups of nonlinear simultaneous variables, however,
must normally be solved using some iteration algorithm.
But in cases where the iteration approach would produce longer execution times or convergence
difficulties, a linearized approach may be considered. In cases where the time step is small with
respect to the group's time constants, it is often possible to insert delays inside some dependency
loops of the simultaneous nonlinear equations and still represent adequately the higher-frequency
variations of the group's variables. Under this condition, it is therefore possible to adequately solve
simultaneous groups of nonlinear equations by breaking them into a sequence of smaller linear
groups which can be represented without iteration in separate linear COMBINE groups.
As a result of this artificial sequencing, a reference within a linear sub-group to the not-yet-
calculated value of one of the outer group's nonlinear variables is in effect a reference to the value
that was calculated at the previous time step of the simulation. This is equivalent to transferring the
previous value of that variable to the sub-group of independent variables used in the solution of the
group's interdependent variables (see the example below).
This solution technique is equivalent to introducing a time delay equal to the size of the present
time step of the model and affecting how the present values of some of the group's variables are
available for the calculation of the remaining variables dependent on these values for their
evaluation.
The error introduced by this solution method is controlled by prescribing a time step size that is
small enough to ensure that the values of the variables delayed by their exclusion from the group
do not vary appreciably from one execution time to the next. It is recommended to place the
artificial delays (that is, to break a feedback loop) on the value of a more slowly varying continuous
variable, in order to minimize the approximation error.
An example consisting of a closed-loop arrangement of linear components, one nonlinear
component, and one limit is illustrated below using a block diagram representation:

where a,b,d linear interdependent variables


c linear interdependent variable with limit
nl nonlinear interdependent variable
u,v,w independent variables
Under the conditions discussed above, the diagram could be reduced to a sequence of individual
elements and of linear COMBINE groups of elements, for the purpose of avoiding the use of an
iteration method for its solution.
In this example, the loop containing the nonlinear element may be opened at one of three possible
points in the loop, as shown below, preferably at a slowly-varying continuous variable. The
variables a, c, and d are grouped in a linear COMBINE statement and are solved simultaneously
as a set. The linear COMBINE group is executed in sequence with the value assignments of the
variables b and nl, in one of the three possible ordering arrangements illustrated below.
MODELS -- p. 41

________________________________________
MODELS -- p. 42

4. MODELS IN ATP
All models used in a data case must be declared and defined in the MODELS section of the data
case. Once defined, these models can be used in a control-type connection to the circuit, or in a
circuit-type connection.
In the control-type connection, each application of a model is defined with a USE statement placed
in the MODELS section. Inputs are measurements taken from the circuit at simulation time t, and
outputs are control signals passed to the circuit at simulation time t+timestep.
In the circuit-type connection, each application of a model is introduced by defining a type-94
component in the circuit part of the data case. Inputs are voltage values at the terminals of the
component, and outputs are current values. Three types of modeling are available: Thevenin,
Norton, and iterated.

4.1 MODELS SECTION IN THE DATA CASE


The MODELS section of the data case is introduced by the keyword MODELS, and ends with the
keyword ENDMODELS. It is placed in the data case immediately before the description of the
electrical circuit.
The MODELS section contains the model definitions of all models used in a simulation. It also
contains the directives indicating use instances of the models used with a control-type connection,
for identifying the inputs and outputs used between the models and the electrical circuit, for
declaring the top variables of the MODELS section, and for recording the values of variables during
the simulation.
- Model definitions:
Each model used in a simulation must be defined in the MODELS section of the data case.
Each model provides a separate environment where names can be chosen independently
from the names existing in the other models of the data case. A model can be described using
the MODELS language, or can be defined as a "foreign" model that is written in a
programming language (for example, Fortran or C) as a subroutine or a function that is
compiled and linked to ATP prior to running the simulation.
- Using a control-connection model:
It is necessary to provide a USE statement for each instance of a control-connected model in
the simulation. Each USE statement specifies the inputs, outputs, data, and use directives
determining the operation of the model instance. For this type of model use, the USE
statements defined in the MODELS section are called in sequence by ATP in their order of
appearance in the data case, as follows:
- for a regular time simulation, these USE statements are executed at the end of each time
step of the circuit solution, with inputs received from the electrical circuit at the time step that
has just been solved, and with outputs to be used by the electrical circuit at the next time
step of the simulation;
- for a frequency-scan data case, these USE statements are executed at the end of each
frequency step of the simulation, with inputs received from the electrical circuit at the
frequency step that has just been solved, and with outputs to be used by the electrical circuit
at the next frequency step of the simulation.
- Inputs/outputs from/to the electrical circuit:
A USE statement of the MODELS section may refer to the values of inputs taken from the
electrical circuit. It may also assign values to outputs used for controlling the operation of
components of the circuit. The name of these inputs and outputs must be declared in the
INPUT and OUTPUT declarations of the MODELS section of the data case.
MODELS -- p. 43

- Top variables of the MODELS section:


Variables other than inputs and outputs can be defined in the MODELS section. These
variables may then be used for carrying values from one model to another in the MODELS
section. Their name must be declared in one or more VAR declarations in the MODELS
section of the data case.
- Specifying values to be recorded:
The value of any element of any instance of any model of a data case may be recorded during
the simulation. Each recorded element is added to the printout list and the plotting list of the
simulation. The RECORD directives identifying these elements are specified in the MODELS
section of the data case.
The MODELS section may contain any number of the above INPUT, OUTPUT, VAR, MODEL,
USE, and RECORD directives, in the following format:

________________________________________

4.1.1 INPUTS FROM THE ELECTRICAL CIRCUIT TO MODELS


The name and type of each variable passed from the electrical circuit to the MODELS section are
specified in one or more INPUT declarations as follows:

where the input names are arbitrary names given to each input;
where the identifier is a node name or a switch name, as required for each type;
and where the input types are v, imssv, i, imssi, switch, mach, tacs, pl4, and atp, used as
follows:
- v(nodename) indicates the value of the voltage measured at node "nodename";
- imssv(nodename) indicates the imaginary part of the complex steady-state value of the
voltage measured at node "nodename" at t=0;
- i(switchname) or i(nodename) indicates the value of the current measured through the switch
named "switchname", or through the first switch connected to node "nodename" (in the order
in which the case data is presented), with the direction of the current considered to be from
"left node" to "right node";
- imssi(switchname) or imssi(nodename) indicates the imaginary part of the complex steady-
state value of the current measured at t=0 through the switch named "switchname", or through
the first switch connected to node "nodename" (in the order in which the case data is
presented), with the direction of the current considered to be from "left node" to "right node".
- switch(switchname) or switch(nodename) indicates the status of the switch named
"switchname", or of the first switch connected to node "nodename" (in the order in which the
case data is presented);
= 0 when the switch is OPEN
= 1 when the switch is CLOSED
MODELS -- p. 44

- mach(varname) indicates the value of an electrical or mechanical variable internal to a


machine, as specified in the documentation of the synchronous machine and of the universal
machine for variables which can be used by TACS and MODELS;
- tacs(varname) indicates the value of a variable from the TACS section of the data case;
- pl4(number) indicates the curve number of a signal obtained from a PL4 plot file; the PL4 file is
identified in ATP using a "POSTPROCESS PLOT FILE" request;
- atp(name), or atp(name[expression]), indicates the value of a single ATP program variable or
array element accessible by ATP's SPY command EXAMINE.
The names chosen for identifying the MODELS inputs are not visible outside MODELS, and can be
selected without concern for the possible duplication of names already used in the electrical circuit.
________________________________________

4.1.2 OUTPUTS FROM MODELS TO THE ELECTRICAL CIRCUIT


Outputs from MODELS can be used in the electrical circuit:
- to control the operation of a switch
- to determine the amplitude of voltage or current sources
- to determine the value of machine variables
- to control the operation of nonlinear elements
In the electrical circuit, output variables from the MODELS section are used identically to output
variables from TACS.
The output variables passed to the electrical circuit must be declared in one or more OUTPUT
declarations as follows:

Values can be assigned to the MODELS output variables in any USE statement of the MODELS
section. Once assigned, the output values can be used as input to other USE statements of the
MODELS section as well as control variables in the electrical circuit.
The names of the MODELS outputs are limited in length to 6 characters, in order to be compatible
with the names that can be used in ATP.
The names chosen for identifying the MODELS outputs are not visible from inside the models
defined in the MODELS section. They can be selected without concern for the possible duplication
of names already used in the models.
________________________________________

4.1.3 TOP VARIABLES OF THE MODELS SECTION


Variables can be defined in the MODELS section for carrying information between the models
used in the MODELS section.
These "top" variables of the MODELS section must be declared in one or more VAR declarations
as follows:

Values can be assigned to these variables from outputs of any USE statement at the top level.
Once assigned, their value can be used as input to other USE statements at the top level.
The names of these top variables are limited in length to 6 characters, in order to be compatible
with the name storage used in ATP.
MODELS -- p. 45

The names chosen for identifying these top variables are not visible from inside the models defined
in the MODELS section. They can be selected without concern for the possible duplication of
names already used in the models.
________________________________________

4.1.4 RECORDED VALUES IN MODELS


A recording of the values of any value-holding element of a model or submodel (except arguments
of FOR statements) can be included in the ATP printout/plotting list. The recording is done at each
execution time step of the electrical model.
The values that will be included in the ATP printout/plotting list can be specified in one or more
RECORD directives, in the following format:

where each recorded element is assigned a 1- to 6-character label to be used by ATP to identify
the element in the printout/plotting list;
and where each recorded element is identified by its name, optionally preceded by an indication of
where it is used, as follows:

When a recorded element is an input, output, or top variable of the MODELS section, no path is
required. When it belongs to a model or submodel called from a USE statement of the MODELS
section, the path is the sequence of use names of the models leading to its location, separated by
periods. A use name is the AS label given to each used instance of a model.
The path of an element belonging to a model called from a type-94 component of the ATP
simulation is an 18-character name formed using the left node name, the right node name, and the
model name. All blank characters in these three names are each replaced by underscore
characters '_', in order to form a single 18-character label, which is then followed by a period and
the name of the recorded element from inside that model.
________________________________________

4.2 TYPE-94 COMPONENTS IN THE CIRCUIT


Instead of being used in a control connection to the circuit, a model can also be used as a circuit
element in the circuit part of a data case. In this case, all inputs, outputs, data, and use directives
for that model are generated automatically by the type-94 component referring to that model. For
this type of model use, no USE statement is needed in the MODELS section of the data case,
because the model is called directly by the type-94 component during the simulation.
The type-94 component (Thevenin, iterated, or Norton) is a general nonlinear single- or multi-
phase circuit component. It allows the user to simulate arbitrary nonlinear circuit and control
elements in a circuit. The operation of the component can be described in MODELS, and also in
procedures written in other languages called from MODELS. The interaction between the model
and the rest of the circuit is defined in terms of voltage, current and impedance or admittance at
the terminals of the component.

4.2.1 THREE TYPES: THEVENIN, ITERATED, NORTON


In the Thevenin type, the component sees the rest of the linear circuit as a Thevenin equivalent.
Inputs are Thevenin voltages and resistance matrix at the terminals of the component. The model
calculates the value of the resulting current at each time step.
MODELS -- p. 46

In the iterated type, a group of nonlinear components see the rest of the linear circuit as a
Thevenin equivalent, and each calculate their current (outputs) corresponding to estimated
voltages (inputs) provided by ATP's Newton iteration algorithm.
Both of these approaches provide a solution synchronized with the rest of the circuit. In the
Thevenin type, it is the model that solves the Thevenin circuit equation. In the iterated type, that
solution is done by ATP. In cases with only one nonlinear component (which can be multi-phase),
the Thevenin type can be used, and provides a faster execution time as it avoids iteration. The
iterated type allows to connect more than one nonlinear components (type-94 and others) per
subnetwork.
For the Norton type, the circuit sees the component as a Norton equivalent, an admittance to
ground in parallel with a current source. For a multi-phase component, the admittance to ground is
a matrix, and there is a current source at each node. At each time step, the component receives
node voltage values as inputs, and calculates as outputs the admittance and current sources to be
used in the circuit solution at the next time step. No iteration is performed by ATP. Changes in
values take effect with a delay of one time step. The time step delay is not a problem for passive
components, as this is the same method already used in ATP for the representation of
inductances, capacitances, and transmission lines. The current sources typically represent past
values, and can be easily synchronized, using prediction, with the solution time at which they will
be used. The only values affected by the delay are the admittance values, with normally negligible
consequences.
In the Norton case, when admittance values change, ATP must re-triangularize the admittance
matrix of the circuit. Because of the relatively time-consuming re-triangularization, this type is best
used for infrequently-changing values of admittances. There is no execution cost in having
frequently-changing values of the current sources. Under these conditions, the Norton type-94 is
faster than the other two, because ATP is not required to calculate a Thevenin equivalent at each
time step (needed for Thevenin and iterated), and because no iteration is taking place (needed for
iterated). The Norton approach also provides the greatest flexibility in component representation,
because it allows the user to directly control values in the admittance matrix of the ATP solution.
Because the admittance or admittance matrix supplied by the Norton type-94 component is an
admittance to ground, this type is normally used with its left nodes connected to the circuit, and its
right nodes unconnected. This provides an opportunity to assign the following additional function to
this component: when the component is connected to the circuit on both sides, it is interpreted by
ATP to be operating in transmission mode, actually isolating the subnetworks on each side from
each other. Each side of the component provides its own admittance matrix and set of current
sources to the circuit. This interpretation is not possible with the Thevenin and iterated types,
because they are branch-based instead of node-based.
________________________________________

4.2.2 TYPE-94 FORMAT IN ATP


The type-94 component is seen by ATP as an electrical black box connected to the circuit. The
black box may be a one-branch component or a multi-branch component. It is specified in the data
case along with the other branches of the circuit. The model it uses is placed in the MODELS
section of the data case, and doesn't need a corresponding USE statement.
Column assignments on the first card of the type-94 component are:
cols 1- 2 '94' as the type of the nonlinear component
cols 3- 8 name of left node of the branch
cols 9- 14 name of right node of the branch
cols 15- 20 name of the model representing this component in MODELS
cols 21- 24 one of three keywords: THEV, ITER, or NORT
col 80- printout request of current, etc. as for other branches
MODELS -- p. 47

A single-branch type-94 iterated component between nodes A1 and B1 and using a model named
'm1' would be specified as follows:
94A1 B1 M1 ITER
>END

A multi-branch component is specified in a similar way, with the additional branches following the
first card, without repeating the model information:
94A1 B1 M1 ITER
94A2 B2
94A3 B3
etc...
>END

Data values can be assigned to the model used by the component, just like in a USE statement of
MODELS. Each data card specifies the name of the parameter expected by the model, and its
value, as follows:
94A1 B1 M1 ITER
94A2 B2
94A3 B3
>DATA D1 xxxxxxxxxx
>DATA D2 xxxxxxxxxx
>etc...
>END

Like other nonlinear branches in ATP, the type-94 branches are excluded from the initial linear
steady-state calculations by ATP. Typically, a user would represent a simplified operation of the
component during steady-state in a separate sub-circuit, using the 'phasor' keyword or switches to
remove this sub-circuit from the solution at t>0. Steady-state voltages and currents from such a
sub-circuit can be used to initialize the operating point of the type-94 component, using SSI and
SSV lines as follows:
94A1 B1 M1 ITER
94A2 B2
94A3 B3
>DATA D1 xxxxxxxxxx
>DATA D2 xxxxxxxxxx
>SSV KA { Voltage(t=0) at left-node #1 = voltage at node KA
>SSV { " " " " " #2 = default existing value at A2
>SSV KB { " " " " " #3 = voltage at node KB
>SSV KC { Voltage(t=0) at right-node #1 = voltage at node KC
>SSV { " " " " " #2 = default existing value at B2
>SSV KD { " " " " " #3 = voltage at node KD
>SSI KA { Current(t=0) into left-node #1 = current in switch KA
>SSI { " " " " " #2 = default value of zero
>SSI KB { " " " " " #3 = current in switch KB
>END

N-branch Thevenin and iterated types can use up to 2n SSV values and up to n SSI values. N-
phase non-transmission Norton components can use up to n SSV and n SSI values. Transmission-
mode Norton components can use up to 2n SSV and 2n SSI value, n for each side.
________________________________________

4.2.3 TYPE-94 MODEL TEMPLATES


The following are templates for building models to be used by type-94 components.

4.2.3.1 THEVENIN MODEL TEMPLATE


MODEL name
comment ----------------------------------------------------------------------
| First, declarations required for any type-94 Thevenin model |
| - these data and input values are provided to the model by ATP |
| - these output values are used by ATP |
| - these names can be changed, except 'n', but not their order |
------------------------------------------------------------------- endcomment
DATA n -- number of node pairs
n2 {dflt: n*n} -- number of matrix elements
MODELS -- p. 48

INPUT vth[1..n] -- Thev. voltage(t) across each branch


rth[1..n2] -- Thev. resistance(t) matrix, symmetrical
gth[1..n2] -- inverse of rth
v0[1..n] -- voltage(t=0) across each branch
i0[1..n] -- current(t=0) into each branch

VAR v[1..n] -- calculated voltage(t) across each branch


i[1..n] -- calculated current(t) into each branch

OUTPUT i[1..n]

comment ----------------------------------------------------------------------
| Next, declarations of user-defined data for this particular model |
| - their value is defined at the time of using the type-94 component |
------------------------------------------------------------------- endcomment
DATA ...

comment ----------------------------------------------------------------------
| Next, declarations private to the operation of this model |
------------------------------------------------------------------- endcomment
VAR ...
...
INIT
...
ENDINIT
EXEC
...
ENDEXEC
ENDMODEL

________________________________________

4.2.3.2 ITERATED MODEL TEMPLATE

MODEL name
comment ----------------------------------------------------------------------
| First, declarations required for any type-94 Thevenin model |
| - these data and input values are provided to the model by ATP |
| - these output values are used by ATP |
| - these names can be changed, except 'n', but not their order |
------------------------------------------------------------------- endcomment
DATA n -- number of node pairs
n2 {dflt: n*n} -- number of matrix elements

INPUT v[1..n] -- guessed voltage(t) across each node pair


v0[1..n] -- voltage(t=0) across each node pair
i0[1..n] -- current(t=0) into each left node

VAR i[1..n] -- calculated current(t) into each left node


didv[1..n2] -- calculated left-side nodal conductance(t) matrix
-- (formed for solving matrix equation [didv]V=I)

OUTPUT i[1..n], didv[1..n2]

comment ----------------------------------------------------------------------
| Next, declarations of user-defined data for this particular model |
| - their value is defined at the time of using the type-94 component |
------------------------------------------------------------------- endcomment
DATA ...

comment ----------------------------------------------------------------------
| Next, declarations private to the operation of this model |
------------------------------------------------------------------- endcomment
VAR ...
...
INIT
...
ENDINIT
EXEC
...
ENDEXEC
ENDMODEL

________________________________________
MODELS -- p. 49

4.2.3.3 NON-TRANSMISSION NORTON MODEL TEMPLATE

MODEL name
comment ----------------------------------------------------------------------
| First, declarations required for any type-94 Thevenin model |
| - these data and input values are provided to the model by ATP |
| - these output values are used by ATP |
| - these names can be changed, except 'n', but not their order |
------------------------------------------------------------------- endcomment
DATA n -- number of phases
ng {dflt: n*(n+1)/2} -- number of conductances

INPUT v[1..n] -- voltage(t) at each left node


v0[1..n] -- voltage(t=0) at each left node
i0[1..n] -- current(t=0) into each left node

VAR i[1..n] -- current(t) into each left node (for printout/plotting)


is[1..n] -- Norton source(t+timestep) at each left node
g[1..ng] -- conductance(t+timestep) at each left node
-- sequence is 1-gr, 1-2, 1-3..1-n, 2-gr, 2-3..2-n, ... n-gr
flag -- set to 1 whenever a conductance value is modified

OUTPUT i[1..n], is[1..n], g[1..ng], flag

comment ----------------------------------------------------------------------
| Next, declarations of user-defined data for this particular model |
| - their value is defined at the time of using the type-94 component |
------------------------------------------------------------------- endcomment
DATA ...

comment ----------------------------------------------------------------------
| Next, declarations private to the operation of this model |
------------------------------------------------------------------- endcomment
VAR ...
...
INIT
...
ENDINIT
EXEC
...
ENDEXEC
ENDMODEL

________________________________________

4.2.3.4 TRANSMISSION NORTON MODEL TEMPLATE

MODEL name
comment ----------------------------------------------------------------------
| First, declarations required for any type-94 Thevenin model |
| - these data and input values are provided to the model by ATP |
| - these output values are used by ATP |
| - these names can be changed, except 'n', but not their order |
------------------------------------------------------------------- endcomment
DATA n -- number of phases
ng {dflt: n*(n+1)/2} -- number of conductances on each side

INPUT lv[1..n] -- voltage(t) at each left node


rv[1..n] -- " " " right node
lv0[1..n] -- voltage(t=0) at each left node
rv0[1..n] -- " " " " right node
li0[1..n] -- current(t=0) into each left node
ri0[1..n] -- " " " " right node

VAR li[1..n] -- current(t) into each left node (for printout/plotting)


ri[1..n] -- " " " right node " " " "
lis[1..n] -- Norton source(t+timestep) at each left node
ris[1..n] -- " " " " " " right node
lg[1..ng] -- conductance(t+timestep) at each left node
rg[1..ng] -- " " " " " " right node
-- sequence is 1-gr, 1-2, 1-3..1-n, 2-gr, 2-3..2-n, ... n-gr
flag -- set to 1 whenever a conductance value is modified

OUTPUT li[1..n], ri[1..n], lis[1..n], ris[1..n], lg[1..ng], rg[1..ng], flag


MODELS -- p. 50

comment ----------------------------------------------------------------------
| Next, declarations of user-defined data for this particular model |
| - their value is defined at the time of using the type-94 component |
------------------------------------------------------------------- endcomment
DATA ...

comment ----------------------------------------------------------------------
| Next, declarations private to the operation of this model |
------------------------------------------------------------------- endcomment
VAR ...
...
INIT
...
ENDINIT
EXEC
...
ENDEXEC
ENDMODEL

________________________________________

You might also like