SciELO - Scientific Electronic Library Online

 
vol.30 número3Metodología para priorizar la inversión en irrigación en zonas rurales deprimidasFuentes convencionales y no convencionales de energía: estado actual y perspectivas índice de autoresíndice de materiabúsqueda de artículos
Home Pagelista alfabética de revistas  

Servicios Personalizados

Revista

Articulo

Indicadores

Links relacionados

  • En proceso de indezaciónCitado por Google
  • No hay articulos similaresSimilares en SciELO
  • En proceso de indezaciónSimilares en Google

Compartir


Ingeniería e Investigación

versión impresa ISSN 0120-5609

Ing. Investig. v.30 n.3 Bogotá sep./dic. 2010

 

System Solver: an open source tool for mathematically modelling dynamical systems

Efraín Domínguez1, Felipe Ardila2 y Santiago Bustamante3

1 Hydrologist Engineer. M.Sc., in ecology Hydrometeorology. Ph.D., in technical sciences. Universidad Javeriana, Bogotá, Colombia.e.dominguez@javeriana.edu.co

2 Systems Engineering, Universidad Distrital. M.Sc., student in Hydrosystems, Universidad Javeriana, Bogotá, Colombia. Geophysical Institute. felipeardilac@ gmail.com.

3Undergraduate, Universidad Javeriana, Bogotá, Colombia. santiagobus@gmail.com


ABSTRACT

The following paper presents a freeware modelling tool simulating dynamic systems that can be represented by either an ordinary differential equation (ODE) or a set of differential equations of different orders. The main idea leading to this software development is related to the fact that many physiccal, biological, ecological, economical, chemical, social and engineering problems can be expressed in this way. Furthermore, the solution to these problems requires some expertise in numerical methods and programming. Such knowledge is uncommon in some of the experts in such scientific domains. A tool to fill in this knowledge gap, increase productivity within modelling-related research and support the teaching of mathematical modelling topics is thus needed. This paper introduces System Solver, a computer application that facilitates the formulation of initial value problems for ODE systems, numerically solves these problems and provides a user with not only the solution but also debugged Visual Basic source code for the application. The obtained code can be easily shared among researchers, which facilitates the replication of numerical experiments even across different operating systems. This software's introduction is accompanied by examples from different domains, including one example from stochastic modelling.

Keywords: ODE solver, computational differentiation, modelling, dynamical system.


Received: june 23th 2009

Accepted: november 15th 2010

Introduction

Several real world problems can be studied using mathematical modelling methods. The differential operator is a widely-used operator for describing physical, biological, ecological and other types of processes. These processes are usually described through either an ODE of a different order r or a set of ODEs. Resolving these equations or sets of equations is often done by using numerical methods. For researchers interested in numerical solutions to their mathematical models, one has to be familiar with both numerical and programming techniques; however, this requirement delays research unless a specialist in numerical methods becomes available).

Automatic integration of ODE systems has been of interest for a long time. In fact, computational differentiation development (Tolsma and Barton, 1998) has been happening since the 1970s (Moore, 1979). Tolsma and Barton (1998) suggested five approaches to the computation of derivatives: hand-coding, finite-difference approximation, symbolic differentiation, evaluation using Reverse Polish Notation(RPN) (Bardsley and Prasad, 1997) and automatic differentiation. Iri (1991) described some prerequisites for a good differentiation method; it should be fast, free of truncation error and preferably performed automatically. Perhaps, however, an additional prerequisite should be considered. The method must allow generalisation to systems of any complexity. The second and fifth methods almost fulfil all of the mentioned requirements. Truncation errors are still present in the second method, however, and the fifth method requires high user intervention for providing a starting subroutine for calculating a given ODE system. Automatic differentiation could require some adaptation for solving problem sets in a discrete (tabular) manner. All of the above-mentioned techniques are used for solving modelling problems in different science domains and all of them are usually studied within the standard programme of a mathematical modelling course. There is a significant amount of specialised software on the market for solving ODE systems; most of this software is not available free of charge, however, and not all of the algorithms used are known as clearly as the researchers wish. The available applications do not provide the source code for the ODE system being investigated.

This paper presents the theoretical foundations, methods, algorithms and implementation of an automatic programmer and numerical solver for ODE Systems. This modelling system uses both Euler and Runge-Kutta explicit methods and export numerical solutions for visualisation within Scilab or Matlab packages. This application represents the first version of a modelling system implementing automatic code generation for solving differential equations when studying complex systems.

System Solver is open source software. It is a good tool for people who like to solve ODE although they are not programmers. This application is easier to use than programmes like Matlab because it only uses a few commands and it is specifically designed to solve ODE. System Solver is high-quality pedagogical software for an introduction to the world of mathematical modelling. The advantage of using System Solver instead of known programmes such as MatLab, Scilab or Octave is the teaching-orientated design aimed at developping modelling and programming skills at the same time. Another potential advantage is the possibility of choosing the language programme that users want to learn for modelled systems share code; such ability will be implemented in the next version of the package.

System Solver was developed in Java script and uses a special library named "Qt Jambi." It is an officially-supported technology aimed at all programmers who want to write rich GUI clients using Java language.

Compared to conceptual modelling tools like Stella, Powersim, Simile or Vensim, System Solver shows better explanatory power for basic modelling concepts. System Solver users can see the ODE behind the system they are simulating and they also have total control over a numerical code being used for solving the ODE system being studied. The design of n-dimensional problems in conceptual modelling systems can be troublesome because of the visual representation of the problem diagram. System Solver structure has been designed to allow a friendly setup of n-dimensional systems and the assimilation of partial differential equations to model distributed systems.

System-Solver structure

Using the following notation:

System (1) suggests a cyclical algorithm that applies a numerical method (Euler or Runge-Kutta in this case) n -times to find vector y (Боглаев, 1990). System Solver uses the Euler explicit finite differences scheme as follows:

It is also possible to select a fourth order Runge-Kutta explicit scheme in the form:

In both equations [(2) and (3)], nij  represents an induced error due to the truncation of high order Taylor series derivatives during the deduction of finite differences for the ODE j . In fact,ni→0 si Δx→0. Schemes (1) and (2) are both explicit and their performance depends heavily on the size of steps Δx. Index i fixes the x node that is being evaluated.

An experienced programmer will easily to recognise generic behaviour in equations (1), (2), and (3) for solving an ODE system. There must be a routine for evaluating yji+1 (procedure 3 in Figure 1) and the right side of eq. (1) has to be solved using an external procedure (2 in Figure 1). The initial conditions, solution interval, ODE coefficients and integration step (Δx  ) must be setup. This can be done at the beginning of the calculations (procedure 1 in Figure 1). To solve the right side of functions, a parser procedure has been implemented leading to the identification of required variables and ODE parameters; ODE parameters can also be a function of time and/or the state variables of the system (1)

The basic System Solver structure is shown in Figure 2. This structure provides an interface for setting both the quantity of ODE in the studied system and also the fields for expressions defining right parts of the functions. A method called "Solve" activates the translation from algebraic notation to reverse Poland notation (RPN). The parameters, independent variables and state variables are classified from the RPN strings and used in previously-prepared code templates. The first template (RPEvaluator) evaluates the right parts of the expressions.

Once the RPEvaluator template is filled with the correct number of variables and the required ODE parameters, another template (EDOSystem) is completed with discretisation intervals, initial condition vectors and number of time steps. The EDOSystem is the implementation of the flow scheme presented in Figure 1. This procedure is the main procedure invoking a RPEvaluator instance that returns a solution vector for right parts of the equation required by the Runge- Kutta or Euler procedures and creates a new evaluation yji+1  for every time node x .

Some dynamic systems are examined and their hand-code and System Solver solutions compared as an example. Consider a predator-prey system of the type:

Here, r and q are growth coefficients and a and b are the predator's attack rate and its reproductive efficiency, respectively.

Given initial conditions,

An experienced modeller would find the numerical solution of (4) using the Euler methods.

Following the structure shown in Figure 1, the ODE_Euler system is equivalent to Procedure 1 in Figure 1, the sub right(.) is the equivalent of Procedure 2, and the sub Euler(.) evaluates xt+1  and   yt+1  y (procedure 3 in Figure 1).

The ODE system must be set up to solve the same problem within the System Solver application by adding each equation at once using the common notation used in spreadsheet applications to define mathematical expressions. The order of the ODE system is only restricted by the hardware specifications. Figure 2 describes the main System Solver window. This application is user-friendly, even for scientists having minimal knowledge of modelling, numerical methods, and programming. A model setup requires no more than a couple of minutes to complete. The researcher expends time in finding the required equations, defining the numerical values of parameters and interpreting results instead of designing, coding and debugging a numerical algorithm.

For the case of the predator-prey model (Equation 4), System Solver provides the Visual Basic code shown in http://www.mathmodelling.org/home/System Solver-1

The System Solver Visual Basic code can be pasted directly to a Microsoft Excel Visual Basic module. It can then be used as a Macro to obtain model results placed directly into a sheet in the current Workbook. The generated code can also be prepared for the MS Visual Basic stand alone compiler. This compiler can be downloaded from the Microsoft web site: http://www.microsoft.com. The open source "Mono" project sponsored by Novell has included a Visual Basic compiler in its integrated development environment. This compiler allows MS Visual Basic code to run in different operating systems, including Linux, Mac OS X, Sun Solaris, BSD - OpenBSD, FreeBSD, NetBSD and Microsoft Windows. More information about the "Mono" project can be obtained from: http://www.monoproject.com.

If the System Solver code is generated for a stand-alone Visual Basic compiler, it is necessary to edit the output code to permit post-processing. Independently of the platform for which the code is generated, the Scilab or Matlab packages offer one post-processing option. System Solver can save numerical results to an ASCII formatted text file and generate the required script to provide rapid graphic output in Scilab or Matlab environments.

Solving a third order ODE system and exporting the results to the Scilab and Matlab packages

Many modelling problems include three or more ODEs in the system to describe a phenomenon being studied. Such multidimensional systems require 3D graphic abilities during post-processing. In the System Solver case, such abilities are provided by the export option which prepares the results to be processed with the Scilab or Matlab packages. The discrete solution is exported to a text file and an import script that imports the resulting data to the selected package (Scilab or Matlab) is provided. A three-dimensional competition model given by the system can be solved to examine this ability (Saez et al., 2007):

with initial conditions:

using the following parameters: a=1.5, b=5.0, c=8.0,q=1.0, f=0.16, g=0.1, w=1.1 , l=2.0, m=0.16, Δt=0.1, tmin=0, and. Entering this setup into System Solver provides us with the Visual Basic code listed in Figure 2.

The Solver System "export" function saves the resulting data and a Scilab script within a user-selected location. The script is presented in Figure 3.

Loading and executing the Script in the Scilab environment produces the graphing shown in Figure 4.

Conclusions

The examples presented show that the System Solver prototype is able to handle ODE and PDE problems of differing complexities. This version can write efficient numerical code and provides tools for exporting the numerical results to Scilab and Matlab programmes enabling 3D graphical presentation of problem output. The application presented here offers a helpful tool for modelling systems represented by sets of ODEs. All of these abilities accelerate research when dealing with ODE systems and they also support teaching efforts in programming, mathematical modelling and numerical methods courses. Using System Solver closes the cycle of defining a mathematical model, building a numerical algorithm and coding a programmeto simulate a dynamic system (Samarsky and Mikhailov, 1997).

System Solver's ability to switch between the Euler and fourth order Runge-Kutta methods allows exploring their properties for each ODE system investigated.

System Solver has been thought to act as a cross platform system. It is projected that future System Solver versions will provide source code for several compilers, such as C#, C++, Java, object-oriented Pascal, component Pascal and Fortran compilers. At the moment,output source code is written for Visual Basic compilers and Visual Basic for applications interpreters (like the one included in MS Office applications). A Visual Basic compiler is also available for the Mono project so the produced code can also be executed in Linux and other UNIX-like systems. A beta version of System Solver can be downloaded from the website: http://www.mathmodelling.org/home/System Solver-1

It is envisioned that several numerical algorithms for solving ODE systems, including algorithms for stiff (rigid) equations, will be provided by System Solver in the near future; algorithms for solving stochastic differential equations will also be implemented. Suggestions regarding user requirements from System Solver users are welcome.

Bardsley, W.G., Prasad, N., Using ASCII text files in post-fix notation (reverse Polish) to define mathematical models and systems of differential equations for simulation and non-linear regression., Computers & Chemistry, 21(2), 1997, pp. 71-82.        [ Links ]

Iri, M., History of automatic differentiation and rounding error estimation., Automatic differentiation of algorithms: Theory, implementation and application. SIAM, Philadelphia, PA., 1991.        [ Links ]

Moore, R.E., Methods and applications of interval analysis., SIAM Publications, Philadelphia, 1979.        [ Links ]

Saez, E., Stange, E., Szanto, I., Chaotic Dynamics and Coexistence in an Interaction Model Between Three Species., Universidad Técnica Federico Santa María - Departamento de Matemáticas, 2007, pp. 5.        [ Links ]

Samarsky, A., Mikhailov, A., P., Matematicheskoie modelirovanie: Idei, metodi, primieri., Nauka, Moscow, 1997, 316 pp.        [ Links ]

Tolsma, J.E., Barton, P.I., On computational differentiation., Computers & Chemical Engineering, 22(4-5), 1998, pp. 475-490.        [ Links ]

Creative Commons License Todo el contenido de esta revista, excepto dónde está identificado, está bajo una Licencia Creative Commons