Sunteți pe pagina 1din 5

Introduction to Berkeley Madonna: Lab

What can we do with this software? Berkeley Madonna is program to numerically solve systems of ordinary differential equations (ODEs) and difference equations. NOW, OPEN AN EXAMPLE BERKELEY MADONNA FILE

1 Windows in the Berkeley Madonna (BM)

It uses various kinds of windows to represent your model including equation, flowchart, parameter, graph, datasets, sliders and notes windows.

1.1 The Equation Window

The equation window is used to edit model equations. The equation window can be displayed by choosing Model Equations.

Changes made to your equations do not take effect until your model has been recompiled. When it recompiles, all runs in memory are discarded.

If BM finds an error when compiling your equations, an error message is displayed and the suspect text will be selected in the equation window.

1.2 Parameter Window

The parameter window allows you to change the parameters in the model as well as the integration method (can also be changed by Compute Integra- tion Method) without recompiling your model. To access it from the menu:

Parameters Parameter Window.

BM displays an asterisk (*) next to the name of each parameter that has been changed from its default value. You can return them to the original value using Reset.

BM defines a set of built-in “system parameters” that exist in every model such as STARTTIME, STOPTIME, DT, etc.

1

1.3 Graph Window

When the model is run for the first time BM automatically creates a graph window. The title indicates the run number and the variables plotted on the X and Y axes.

If Overlay Plots is off, each subsequent run will replace the data from the

previous run.

If you turn it on, subsequent runs will be added to the graph

window.

You can always lock a graph by selecting the Lock button from the graph icons. With this feature the contents of a graph is preserve while you can still run your model for new graphs.

Choosing Graph Choose Variables can help you to specify which variables are plotted in the Y axis. By default, BM plots TIME on the X axis, but you can always change this in the Choose Variables dialog.

You can also create multiple graph windows by first opening an empty graph window and adding variables (use Graph menu for this).

1.4 Using Graph Buttons

The buttons in the top-left corner of the graph window perform different func- tions.

For example the Run button, runs the model once. Same as choosing Run from the Model or Compute menus.

You can print, save a graph or table by activating its window and choosing appropriate action from the File menu.

2 Running Models

2.1 Single Run

The simplest way to run your model is to click the Run button in the equation, parameter, or graph windows. Or, choose it from Model or Compute menu.

2.2 Sliders

To create sliders: Parameters Define Sliders. In the dialog, select a parameter and add it to the sliders list by clicking Add. Select linear or logarithmic scaling and adjust the minimum, maximum, and increment or multiplier for the slider.

2

2.3 Batch Runs

B-M can automatically run your model multiple times while optionally varying a spec- ified parameter. For this choose Parameters Batch Runs.

Specify the parameter you want to vary.

Specify the number of runs, betwenn 2 and 1000.

Specify the parameter to take for first and last run (Initial Value and Final Value).

Identify the series type. How the parameter should be varied, according to a arithmetic or geometric series?

How B-M should process the runs: keep runs separate (all runs), compute mean (single run) or compute mean + SD (mean, mean-SD and mean+SD).

2.4 Parameter Plot

The Parameter Plot feature enables you to plot the result of each run as a single data point over a range of parameter values.To perform a parameter plot, choose Pa- rameters Parameter Plot. The independent variable in a parameter plot is the parameter in your model rather than TIME, this is a parameter plot graph window.

2.5 Floating-Point Exceptions

If you get a floating-point exception when running your model, it means some numerical operation resulted in an error. Exceptions include division by zero, numerical overflow, taking the square root of a negative number, etc.

3 Equation Syntax

To display a summary of B-M equation syntax, choose Help Equation Help.

3.1 Basic Syntax

B-M models consist of a list of equations. Most equations are of the form:

variable=expression

Variables names consit of one or more characters. You may use letters (A-Z), digits (0-9), and underscore ( ) in variable names. However variable names must not begin with a digit. It can be anything as long as it does not clash with any B-M built-in function (see list at the end). Comparison between variable names are case-insensitive.

3

For example, the names “Mtbi”, “MTBI”, and ”mtbi” all refer to the same variable.

Expressions use standard infix notation. That is, arithmetic and relational opera- tors are placed between their two operands:

result = a + b * c result = (a + b) * c

You can place comments anywhere in the equations by enclosing them in curly brackets. For example:

{This is a sine wave} result = a * SIN(x)

B-M also recognizes single-line comments beginning with the semicolon character. For example:

a =

; define a

3.2 Differential Equations

Equation like shown above simply assign the value of the expression on the right-hand side to the variable on the left-hand side. Such equations are referred as “formulas”.

Ordinary differential equations (known as “reservoirs”) are defined by two equa- tions: an initializer equation and an integrator equation. The initializer equation determines the initial value of the reservoir. The integrator equation determines how much the reservoir’s value increases or decreases during each time step (also known as the inflow or out flow).

Form of initializer syntax; each initializes reservoir R to an initial value denoted by ”:

R(STARTTIME) = INIT R = INIT (R) =

The following three forms of integrator syntax are also functionally identical; each

defines a net flow into the reservoir R denoted by “

d / dt (R) = R’ = FLOW R =

4

”:

4

Applications

BM can be used for Curve Fitting and estimating model parameters. The Sensi- tivity feature computes the sensitivity of variables in your model to changes in one or more parameters.

Exercises

Exercise 1: A basic SIR model is give by:

dS

dt

dI

dt

dR

dt

= µN β SI µS,

N

= β SI (γ + µ)I,

N

=

γI µR,

(1)

(2)

(3)

where N = S + I + R is the total population of the system.

1. Run the model with the parameters β = 0.01, γ = 0.4 and µ = 0.3 and initial conditions S 0 = 999, I 0 = 1 and R 0 = 0. Change the Scale and Labels so you can be familiar with them.

2. Change the value of the parameters using the Parameter Window and or Define Sliders. Use 0 < β < 0.06, 0 < γ < 0.5 and 0 < µ < 1.

3. Plot a family of curves using Batch Runs. Select γ as the parameters, 6 runs with values from γ = 0 to 0.5 using the arithmetic series type and keep runs separate.

4. Plot I as a function of β and γ using the Parameter Plot. Set the values according to the previous items.

5. Calculate the Sensitivity of the parameter β and γ.

References

[1] Macey, R., Oster, G. and Zahnley, T. (2000). Berkeley Madonna User’s Guide. Version 8.0. http://www.berkeleymadonna.com

5