Sie sind auf Seite 1von 5

Introduction to Berkeley Madonna: Lab

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

Windows in the Berkeley Madonna (BM)

It uses various kinds of windows to represent your model including equation, owchart, 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 eect until your model has been recompiled. When it recompiles, all runs in memory are discarded. If BM nds 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 Integration 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 denes a set of built-in system parameters that exist in every model such as STARTTIME, STOPTIME, DT, etc.

1.3

Graph Window

When the model is run for the rst 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 o, 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 rst 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 dierent functions. 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
2.1

Running Models
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 Dene 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.3

Batch Runs

B-M can automatically run your model multiple times while optionally varying a specied 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 rst 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 Parameters 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 oating-point exception when running your model, it means some numerical operation resulted in an error. Exceptions include division by zero, numerical overow, taking the square root of a negative number, etc.

Equation Syntax

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

3.1

Basic Syntax
variable=expression

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

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 inx notation. That is, arithmetic and relational operators 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 = ... ; dene a

3.2

Dierential 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 dierential equations (known as reservoirs) are dened by two equations: an initializer equation and an integrator equation. The initializer equation determines the initial value of the reservoir. The integrator equation determines how much the reservoirs value increases or decreases during each time step (also known as the inow or out ow). 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 denes a net ow into the reservoir R denoted by ...: d / dt (R) = ... R = ... FLOW R = ...

Applications

BM can be used for Curve Fitting and estimating model parameters. The Sensitivity 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 SI = N S, dt N SI dI = ( + )I, dt N dR = I R, dt where N = S + I + R is the total population of the system.

(1) (2) (3)

1. Run the model with the parameters = 0.01, = 0.4 and = 0.3 and initial conditions S0 = 999, I0 = 1 and R0 = 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 Dene 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 Users Guide. Version 8.0. http://www.berkeleymadonna.com

Das könnte Ihnen auch gefallen