DEFINITION MODULE SimLib0;
(*******************************************************************
Module SimLib0 (Version 1.0)
Copyright (c) 1986-2006 by Markus Ulrich and ETH Zurich.
Purpose Basic procedures for the integration of systems of
differential or difference equations.
Remarks Three integration methods for differential
(Euler-Cauchy, Heun and Runge-Kutta 4th-order)
and one for discrete systems can be selected .
A discrete or continuous system described by
difference or differencial equations packed in a
procedure can be installed.
Programming
o Design
Markus Ulrich 15/04/1986
o Implementation
Markus Ulrich 15/04/1986
ETH Zurich
Systems Ecology
CHN E 35.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
URLs:
<mailto:RAMSES@env.ethz.ch>
<http://www.sysecol.ethz.ch>
<http://www.sysecol.ethz.ch/SimSoftware/RAMSES>
Last revision of definition: 15/04/1986 MU
*******************************************************************)
(********************************)
(* General parameters *)
(********************************)
CONST nmax = 10;
(* maximal model order*)
TYPE EquationProcedure = PROCEDURE(VAR ARRAY OF REAL, VAR ARRAY OF REAL);
VAR time: REAL;
PROCEDURE InstallModel(m:EquationProcedure);
(* This procedure installs a procedure, which must contain the
differential/difference equations of the model. All subsequent
actions performed by SimLib0, especially the procedure "Integrate",
are undertaken with these model equations.
The procedure m has to be organized in the following way:
The first parameter (x: ARRAY OF REAL) represents the state
vector (the array of all state variables). With these values, the
procedure m should calculate all deviations (dx/dt) (continuous) or
all x(k+1) (discrete) and return them as the second parameter of the
procedure (dx: ARRAY OF REAL).
Example for m:
PROCEDURE TheModel(VAR x,dx: ARRAY OF REAL);
BEGIN
dx[1]:= x[1] - 0.5 * x[2];
dx[2]:= -0.1 * x[2];
END TheModel;
...
InstallModel(TheModel);
*)
(********************************)
(* Integration *)
(********************************)
TYPE IntegrationMethod = (Euler, Heun, RungeKutta4, DiscreteTime);
PROCEDURE SetIntegrationMethod(m:IntegrationMethod);
PROCEDURE GetIntegrationMethod(VAR m:IntegrationMethod);
PROCEDURE SetIntegrationStep(step: REAL);
PROCEDURE GetIntegrationStep(VAR step: REAL);
TYPE IntegrationProc = PROCEDURE(VAR ARRAY OF REAL, VAR ARRAY OF REAL);
VAR Integrate: IntegrationProc;
(* a) Heun, Euler, or Runge-Kutta method installed:
Given the state vector x[time] as the first parameter, this
procedure calculates the new state vector s[time+step], and returns
it as the second parameter. Time is automatically updated
(time:= time+step;).
b) DiscreteTime method installed:
Given x[k] as the first parameter, this procedure calculates the
new state vector x[k+1] and returns it as the second parameter.
Time, representing k, is incremented by 1.
Integration step procedures have no effect on that method.
"Integrate" acts on the currently installed model.
*)
END SimLib0.