User:Fccoelho/Model-Builder

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Model-Builder
Developer(s) Flávio Codeço Coelho, Cláudia Torres Codeço, Antônio Pacheco
Stable release 0.4.0 / March. 26, 2007
Operating system Cross-platform
Type Ordinary differential equations,mathematical modeling
License GPL
Website home-page

Model-Builder is an application written in Python programming language, designed to provide a simple graphical interface for writing simulating and analyzing mathematical models based on ordinary differential equations.

Graphical User Interface[edit]

Model-Builder GUI

Model-builder's GUI is a very simple one designed to be as unobstrusive as possible. Models are written in standard mathematical language (with operator syntax from Python). The design principle is: If you can write your equations on paper, you can write implement them in Model-Builder.

The menus[edit]

The first menu is the file menu. It contains the standard open, save, save as, close and exit options. These are pretty much self-explanatory.

The second menu is the analysis menu. This menu contains two options: The uncertainty analysis (UA) and State-space Diagram . This first option opens the uncertainty analysis panel, and makes ModelBuilder go into UA mode. The second allow the creation of state-space plot of up to two variables.

The third and last is the help menu with its usual functionality

The Toolbar[edit]

The toolbar contains three buttons. The first one is the run button, which starts the simulation.

The second button shows a typeset version of the differential equations in the model (this feature requires the latest version of matplotlib).

The third button shows the results of a simulation on a spreadsheet. From there you can select variables to plot separately and save the results to a csv(comma separated values) file.

Installation Guide[edit]

Since Model-builder is written entirely in Python, it is distributed as a source package. However, it needs a Python installation (>=2.4) and utilizes other libraries that need to be installed in your system so that Model-Builder can be started.

Dependencies[edit]

  1. wxPython: wxpython is the GUI toolkit used by Model-Builder
  2. NumPy: Python package with many number crunching functions, written in C and Fortran.
  3. SciPy: Is another Python library that provides the Numerical integration code used by Model-Builder.
  4. Matplotlib: This is a python plotting library which is used to produce all the graphical output.

For Linux and Mac users those dependencies are all available as packages ready for easy installation. For windows users, those packages are also available but the best optio is to install the Python Enthought Edition. which already comes bundled with all the above packages.

Once all of the pre-requisites are installed the best way to get the latest Model-Builder is by means of the Python setuptools package (which also needs to be installed). If you have setuptools installed, all you have to do is type the following command on the command prompt:

easy_install Model-Builder

Then setuptools with fetch Model-builder's most recent package from Sourceforge and install it on you machine. If you are a linux user, you will need to have root privileges to do this.

Quick-start Tutorial[edit]

Simple Lotka-Volterra predator-prey model.

If you've gone through the installation process withou problems, you should be able to start Model-Builder from the console with a simple command:

PyMB

On some Linux distros, an entry for Model-Builder will show up on the programs menu under Science & Math.

if you have also Downloaded the examples package from the sourceforge site, you can open the lotka-volterra2.ode model file.

Now, just press the little stopwatch button on toobar, the start button, to start the simulation. On completion, a line plot will pop-up with the result.

Output of the Lotka-Voterra model

The results can also be opened in a spreadsheet wher it can be further analyzed, graphed and exported to a csv file.

Spreadsheet with simulation results

to write a model from scratch in Model-builder, a little knowledge about acceptable syntax is required.

Equations are written on the equations box which is situated on the top left part of the GUI. Equations may include symbols defined in the parameter box, as well as the time t symbol, available automatically, since the model equations are considered as derivatives with respect to time.

General form of equations[edit]

The general form of a differential equation is, for instance: \frac{dx}{dt}=ax(t).

In Model Builder, to simplify notaion, on the LHS of the equation we can put only the symbol of the State variable. So the equation above would become: x=ax. It is obvious that this equation is not mathematically equivalent to the real differential equation we are trying to calculate. But Model-Builder only uses the LHS of equations as a labels for the state variables. Only what is on the RHS of the equations is included in calculations. So make sure all you equations conform to these rules before entering them in the equation box. Note also that x(t) on the RHS of the equation became simply x. Whenever state variables appear on the RHS, they are assumed to be functions of time, so no explicit notation is necessary, or allowed. Equations may include symbols defined in the parameter box, locate on the right side of the GUI. Thus, in our simple example, the parameter a must be defined like this (for instance): a=2.3 in the parameter box. Parameter expressions may not reference state space variables.

Both Equations and parameter expressions may also include the symbol t (time) as well as any mathematical function defined in numerical python, like for example sin(t).

Equations are to be entered according to Python's syntax for mathematical expressions. This means that basic arithmetic operators become:

Operation Symbol
Sum +
Subtraction -
Product *
Division /
Power **
Etc. See Python's documentation

Category:Mathematical software