www.delorie.com/gnu/docs/mcsim/mcsim_12.html   search  
Buy GNU books!

MCSim User' Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Working Through an Example

Pharmacokinetics models describe the transport and transformation of chemical compounds in the body. These models often include nonlinear first-order differential equations. The following example is taken from our own work on the kinetics of tetrachloroethylene (a solvent) in the human body (Bois et al., 1996; Bois et al., 1990) (see section Bibliographic References). Go to the `sim' directory (under Unix) or to the `Development' folder (on a Macintosh). Open the file `perc.model' with any text editor (e.g., emacs or vi under Unix). This file is distributed as an example of a model definition file (see section B.3 `perc.model': A sample model description file). You can use it as a template for your own model, but you should leave it unchanged for now. Notice that it defines:

This model definition file as a simple syntax, easy to master. It needs to be turned into a C program file before compilation and linking to the other routines (integration, file management etc.) of MCSim. You will use mod for that. First, quit the editor and return to the operating system.

To start mod under Unix just type mod perc.model. On a Macintosh, double click the `Mod' icon; Mod prompts you for the name of your model definition file; Type `perc.model'. After a few seconds, with no error messages if the model definition is syntactically correct, Mod announces that the `model.c' file has been generated. On a Macintosh you need to hit the return key to exit Mod.

The next step is to compile and link together the various C files that will constitute the simulation program for your particular model. Note that each time you want to change an equation in your model you will have to change the model definition file and repeat the steps above. However, changing just parameter values or state initial values does not require recompilation since that can be done through simulation specification files.

To start your MCSim program just type mcsim_perc (if you gave it that name) under Unix, or double click the `MCSim Perc' or whatever name you specified icon on your Macintosh. After an introductory banner (telling in particular which model file the program has been compiled with), you are prompted for an input file name: type perc.lsodes.in (see section B.4 `perc.lsodes.in', to see this file now). The program then prompts you for the output file name: type perc.lsodes.out. After a few seconds or less (depending on your machine) the program announces that it has finished and that the output file is `perc.lsodes.out' (on a Macintosh you should hit the return key to exit the program completely). You can open the output file with any text editor or word processor, you can edit it for input in graphic programs etc.

Several other models and simulation specification files are provided with the package as examples (they are in the `sim' directory. Try them and observe the output you obtain. You can then start programming you own models and doing simulations. The next sections of this manual reference the syntax for model definition and simulation specifications.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003