split 2 I
ashow y/rurp show
yr
y/nowupashow upr/wup show upr/nowup mark
a 2.5
Omark "Time
t markall
mark
v "Control variable
umark
a t
7.5mark
v "output y
andyref
END
Notice that lower case letters may be used to get a more readable code, although Simnon does not distinguish them from upper case letters. Macros
for
generatingall figures
for
this report are given in Appendix D.Macros are useful
for
documentation. They are also convenientfor
simplificationof a
dialogue. Command sequences, that are commonly used, may be defined asmacros.
A
simple macro callwill
then activatea
whole sequenceof
commands.Macros may also be used to generate new commands.
The
usefulnessof
macrosmay be
extended considerablyby
introducing commands to control the program flow in a macro, facilitiesfor
handling local and global variables and by allowing macros to have arguments. By having commandsfor
reading the keyboard andfor
writingon
the terminalit is
also possible to implement menu driven dialogues using macros.Even
a
casual useris
strongly recommendedto
learn simple usesof
the macro facility.INTEGRATIONALGORITHMS f ,
r, lt I
Differential equations are solved
in
Simnon using numeric integration routines. A predictorcorector
formula by Hamming with auto¡natic step length adjustment isnormally used. The initial value of the' step length is chosen as one hundredth of the integration interval.
A
differ¡ífrt firitial step size may be chosen by an optionall¡n '|
argument
in
the command SIMU1lh
tde algorithm the step lengthis
reduced until the difference between the prediction and the correction is sufficiently small. The tolerance may by theIt
is also possible to choose other integration algorithms by the command ALGoR {r{AHPc I RK I RKFrx I DAS}where HAMPC
is
Hammings predictor corrector method, RKis a fourth
order Runge-Kutta algorithmwith
automatic steplength adjustment. RKFIXis
also afourth order
Runge-Kutta algorithmbut it
hasa
fixed step length. DASis
analgorithm
for
integrationof stiff
equations,i.e.
differential equationswith
both slow and fast modes. Further details on the different algorithms are givenin
the Simnon manual.FORTRAN SYSTEMS
The Simnon language
is
simple, easyto use
and reliable becauseof all
the diagnostics thatis built
intoit.
The language has howevera
limited expression power. There are no possibilitiesto
control program flow, there are no arraysor
other data types and there are no procedures. For models whose descriptions require a more powerful languageit is
possibleto
interface Fortran routines to Simnon. This also makesit
possibleto
uselibrary
subroutineslike
Eispac and Linpac in the simulations. The Simnon manual describes in detail how to do this"STANDARD SYSTEMS
There are several standard systems
in
Simnon.A
listof
the available systems isnormally displayed
on the
screen when.*the systemis
started.A few of
the systems are listed below.-
timedelay \ ' ' -
nonlinearity defintáUf
"
t"ut"-
logging of stored variables-
white gaussian noise generator-
optimizer-
discrete system which reads output variables from fileDELAY FUNCl LOGGER NOISEl OPTA IFILE
There are also more
sontris¡iÉaÉg systemstike linear
quadratic gaussianregulators, self-tuning regulatoÉs
in
some implementations.A
descriptionof
the standard systems is givenin
the manual. The command HELP SYSTEMS also givesinformation about the systems. The standard systems are often implemented as
Fortran systems.
GLOBAL VARIABLES
All
variablesin
Simnon systemsare
local. When usingFortran
systems or standard systemsit
may, however, be necessaryto
transfer global data. Globalvariables
are
usedfor this
purpose. The global variablesare set by a
LETcommand.
An
example illustratesthe use of
global variablesand
standard systems.Example 6.1
-
Use of standard systemsAssume that we want to include a function defined by a table in a simulation. This
is
conveniently doneby
the function FUNCI. This function has one inputu
andone output
y.
The function has one global parameter N.FUNCI which gives thenumber
of entries in the
table.The
argumentsare
specifiedby the
local parametersuit,
ui?,... .
The corresponding function values are specifiedby
the arguments gil,giZ,...
. The local parameter ORDER specifies staircase (order = 0)or
linear (order=
1) interpolation.The following dialogue illustrates how the function may be used.
Iet n.funcl =
4syst
FUNC1 FUNCPLOTpar uil:
-3par gi1:
-1par ui2:
-1par gi2: -2.8 par
ui3:par
gi3:par
ui4:par
gi4:par order:
1The global parameter
n.funcl
must, be assigneda
value beforethe
system is activatedby
the SYST command. The local parameters may be changedby
the PAR command as parameters inf4inary
Simnon systems.frn Í,
Itt
I
I
1.54 2
\
, l'
f (x)
3
2
-1
-3
1
0
-2
0 2 4
-4 2 x
Fisure 10. Graph
of a
function definedby a
table generated usingthe
Simnonfunction FUNCI.
with
connecting system FUNCPLOT
time
xuIFUNCl]=x yp=yIFUNCl]
END
the commands
axesh-44v-33 plot
ypsimu
-4
4I
, ì'
Ithen generates a graph of the function, see Fig. 10'
t
,11, 1,.
ORGANIZATION OF LARGE SIMULATIONS
There are several facilities which are useful when working with large systems or
with
large amountsof
data. System descriptions and macros are stored as textfiles.
Thesefiles have the file
extension.T on the
VAX/VMS system. The subsystems also have a name which is the identifier given on thefirst
line of thesystem description. See Appendix
B.
Notice thatthe file
name andthe
system name may be different. This isvery
useful when simulating different versions of a model because the same macros and the same connecting systems may be used.The selection of a particular model is done when the systems are activated by the command SYST.
An
illustrationis
givenin
the macro FIG9 whichis
listedin
the appendix.A
PI regulator with the name REG is storedin
a file called PIREG and asystem with the name PROC
is
storedin a file
called INTEGR. The systems are activated by the commandSYST INTEGR PIREG CON
The variables
of
the system are labeledby
[REG] and [PROC] respectively. This makesit
possible to use a standard connecting systemfor
different processes and regulators.SAVING AND RETRIEVING PARAMETERS AND INITIAL VALUES
The command SAVE stores parameters and initial values in a file. The values may
be
retrievedby the
command GET. These commandsare very
useful whenworking with large
models, because parametersand initial
valuesare
notintroduced manually. Assume
for
example,that the systems FUNC1 and FUNCPLOT have been activated as in bcample 6.1 by the commandSYST FUNcI
FUNcPLoT 1 ' ,t
The command SAVE FUNCPAR
then generates a file FUNCPAR.T,,pf the form (.t
t',
IFUNC1]
UIl: -3.
UL2:
-1.
UI3: 1.
UI4:4.
GI1:
-1.
GT.2:
-2.8
GI3: 1.5 GIA:2.
order: 1.
IFUNcPLor]
It is
convenientto
edit filesof
this typefor
parameters and initial values when simulating large systems.DOCUMENTATION
It is often useful to keep a running log of an interactive session. The command SY{ITCH LOG ON
generates a file of all commands in a session.
The scale factors in the graphs are computed by an algorithm. The same axes are obtained
in
horizontalor
vertical directionif
the horizontal rangeis
divisible byfour
and the verticalby
3.It is
possible to get scale factors 1,2
and 5 only by the commandTURN 5125 ON
It is
possibleto
add text to the axes by the command MARK. Thisis
usedin
the macros which generate the curves in the report.It is
also usefulto
have access to operating system commands under Simnon. Inthe Vax implementation this is done]gimply'
I
bV typing$
followed by any operatingsystem command.