# Section L2.3: A Simple Dynamic Modelling System

This section describes a tool for creating models of dynamic systems. It is very similar to the aalgebraic equation modelling system discussed above.

The system allows the creation of differential-algebraic equation (DAE) models, although the solution facilities for algebraic equations are somewhat limited.

Its be described using a simple example.

## Example

A system is described by the following set of DAEs.

dx1/dt = (-Ay-x1) / T1
dx/dt = (x1-y) / T2
y = x²

The initial conditions are: x = 0 , x1=1 at t=0

As with the algebraic system it is convenient to consider the model as consisting of sections:

• variables
• parameters
• equations, of which there are here two kinds:
• algebraic equations
• differential equations
• initial conditions for differential equations
• a housekeeping or schedule section

Each of these sections will be described briefly.

### Variable Section

In this example these are:
``` x1, x,  y
```
The variables are the unknowns in the model. As discussed elsewhere, there are two sorts of variables in DAEs, those which may appear as derivatives in the differential equations, and the `algebraic' variables which do not. This distinction is not made in this section, which serves mainly to define the names to be used for variables.

### Parameter Section

These are:
``` A=1 ;  T1=1
T2 = 2
```
`Parameters' as distinct from `unknowns' in a mathematical problem are quantities which the user knows, but which might be changed at some point to see their effect. It is convenient to give them symbols rather than simply numbers.

A parameter may often be a physical property, e.g. a heat capacity, which can appear several times in a set of equations. If the parameter is defined in one place, then making one change will result in the new parameter value being used throughout the model.

This section of the model enables parameters to be defined and given values if required. If no values are given the parameter defaults to zero. New values can be given when the spreadsheet has been generated.

### Equation Sections

This is an algebraic equation:
``` y =  x*x
```
These are differential equations:
``` x1.dt = (-A*y-x1)/T1
x.dt = (x1-x)/T2
```
This is the main part of the model and contains the differential and algebraic equations which describe the model. Note the following:
• Differential quations may be written in any order.
• There must be as many equations as variables.
• Each variable must appear once, and only once, on the left hand side on an `=' sign.
• The LHS variable will appear as a derivative for a differential equation, and as a simple variable for an AE.
• The dot `.dt' following a variable name indicates its derivative w.r.t. time. These may only appear on the left hand side on an `=' sign.
• The LHS must be a single variable or its derivative, it may not be an expression.
• Differential quations may be written in any order.
• Algebraic equations, as in the algebraic equation solver, must appear in an order such that no algebraic variable appears on the RHS of an `=' sign before it has previously appeared on the LHS.
All normal algebraic operators and functions may be used in equations.

### Initial Conditions Section

```x=0 ; x1=0
```
This section provides another place where initial values may be given for variables. If no initial values is set for a variable which requires it, then it defaults to zero.

### Schedule Section

This section describes how the model is to be run. At present this must specify:
• the timestep for the simulation, here 0.5 time units
• length of the simulation time, here 25 units.

### General

When you click the Solve button the solution, a list of the variable values at each timestep, will appear in a new window. There will also be a separate window with these plotted. You can copy and paste the results from the text window. It is not possible to save the graph window unless you have screen `snapshot' saver.

Clicking Show Model Data will provide a listing of the complete model. This can be copied and pasted into a text file, e.g. in Windows a Notepad .txt file, save and used to recreate your model.

Course Organiser