LibSBMLSim: A library for simulating SBML models

Latest release: 1.1.0, released 28th Jan 2013 LibSBMLSim enables you to write your own SBML capable simulator with a few lines of code.


LibSBMLSim is a library for simulating an SBML model which contains Ordinary Differential Equations (ODEs). LibSBMLSim provides simple command-line tool and several APIs to load an SBML model, perform numerical integration (simulate) and export its results. Both explicit and implicit methods are supported on libSBMLSim. LibSBMLSim is confirmed to pass all SBML Level-2 Version 4 and Level-3 Version 1 test cases ( including Events, AlgebraicRules, delays, etc. (here, we created a table of SBML test cases 2.0.2)
The libSBMLSim code is portable. It is written in C programming language (ANSI C89) and it does not depend on other third-party libraries except libSBML. The library should build and work without serious troubles on Unix based operating systems (Linux, MacOSX and FreeBSD) and on Windows (with Visual C++). LibSBMLSim also provides several language bindings like Java, C#, Python and Ruby. Perl binding is already included in the source tree, but is not able to create through the single build process (you have to manually run ``swig -perl libsbmlsim.i && perl Makefile.PL && make'').

LibSBMLSim can be used to create your own SBML capable simulator, plug-in, web based application and web services. The API is quite straight forward. You can run a simulation and generate a result file in Comma Separated Values (CSV) with a few lines of code.

  # Example Python code
  from libsbmlsim import *
  r = simulateSBMLFromFile('sbml.xml', 20, 0.1, 10, 0, MTHD_RUNGE_KUTTA, 0)
  write_csv(r, 'result.csv')

What's new in 1.1.0

New features

  • New integrators (5th order Runge-Kutta Fehlberg, 5th order Cash-Karp) are included in this release. Both new integrators support variable step size integration.
  • 5th order Runge-Kutta Fehlberg : MTHD_RUNGE_KUTTA_FEHLBERG_5
    5th order Cash-Karp : MTHD_CASH_KARP
  • C# binding functions are included in this release. Please see examples/csharp/Test.cs for the sample code.
  • Both 32bit(x86) and 64bit(x86_64) build for Windows are available.
  • Binary Installer is available for Windows, MacOSX and Linux.

Bug fixes

  • Memory leaks in free_mySBML_objects() have been fixed.

API changes

  • myResult* simulateSBMLModel() now requires 3 additional parameters for variable step integration.
  • myResult* simulateSBMLModel(Model_t *m, double sim_time, double dt,
                                    int print_interval, int print_amount,
                                    int method, int use_lazy_method,
                                    double atol, double rtol, double facmax);
    • double atol; Absolute error tolernace
    • double rtol; Relative error tolerance
    • double facmax; Maximum acceptable increasing factor
    If you don't know the right value for above 3 values, please just assign "0.0" for all 3 values, then libsbmlsim will use the default values for the integration.


LibSBMLSim is distributed under the terms of LGPL.


LibSBMLSim requires libSBML-5.x to be installed on your system. Please follow the instruction on libSBML web page to install libSBML.

Required software packages to compile libSBMLSim

CMake is required to compile libSBMLSim. Please download and install CMake-2.8.7 or above before building libSBMLSim. If you want to use language bindings of libSBMLSim, please download and install SWIG-2.0.4 or above. (Note: If you installed SWIG from MacPorts, please install swig-java, swig-python and swig-ruby which are required to compile language bindings for libSBMLSim.)

LibSBMLSim API and its language bindings

Example usage of libSBMLSim APIs are as follows.

C, C++

  /* Example C, C++ code */
  #include "libsbmlsim/libsbmlsim.h"
  int main(void) {
     * Simulate sbml.xml to time=20 with dt=0.1, print_interval=10
     * by 4th-order Runge-Kutta Method.
	myResult *r = simulateSBMLFromFile("sbml.xml", 20,
                                        0.1, 10, 0, MTHD_RUNGE_KUTTA, 0);
    write_csv(r, "result.csv"); /* Export simulation result as CSV file */
    free_myResult(r);           /* Free Result object */
	return 0;


  # Example Python code
  from libsbmlsim import *
  r = simulateSBMLFromFile('sbml.xml', 20, 0.1, 10, 0, MTHD_RUNGE_KUTTA, 0)
  write_csv(r, 'result.csv')


  # Example Ruby code
  require 'libsbmlsim'
  r = Libsbmlsim::simulateSBMLFromFile('sbml.xml', 20, 0.1, 10, 0,
                                  Libsbmlsim::MTHD_RUNGE_KUTTA, 0)
  Libsbmlsim::write_csv(r, 'result.csv')


  /* Example Java code */
  public class Test {
    public static void main(String[] args) {
      myResult r = libsbmlsim.simulateSBMLFromFile("sbml.xml", 20,
                       0.1, 10, 0, libsbmlsim.MTHD_RUNGE_KUTTA, 0);
      libsbmlsim.write_csv(r, "result.csv");


  /* Example C# code */
  using System;
  public class Test
    static void Main()
	  myResult result = libsbmlsim.simulateSBMLFromFile("sbml.xml", 20,
                            0.1, 10, 0, libsbmlsim.MTHD_RUNGE_KUTTA, 0);
      libsbmlsim.write_csv(result, "result.csv");

Please see the 'API.txt' and 'examples' directory for further information. The 'examples' directory contains sample code for test application in several programming languages (C, C++, Java, C#, Python, Ruby and Perl).

List of integrators

LibSBMLSim supports following integrators (the above example code uses 4th order Runge-Kutta as an integrator).

  • Explicit methods
    Euler : MTHD_EULER
    1st order Adams-Bashforth : MTHD_ADAMS_BASHFORTH_1
    2nd order Adams-Bashforth : MTHD_ADAMS_BASHFORTH_2
    3rd order Adams-Bashforth : MTHD_ADAMS_BASHFORTH_3
    4th order Adams-Bashforth : MTHD_ADAMS_BASHFORTH_4
    4th order Runge-Kutta : MTHD_RUNGE_KUTTA
    5th order Runge-Kutta Fehlberg (variable step size) : MTHD_RUNGE_KUTTA_FEHLBERG_5
    5th order Cash-Karp (variable step size) : MTHD_CASH_KARP

  • Implicit methods
    Backward-Euler : MTHD_BACKWARD_EULER
    Crank-Nicolson : MTHD_CRANK_NICOLSON
    2nd order Adams-Moulton : MTHD_ADAMS_MOULTON_2
    3rd order Adams-Moulton : MTHD_ADAMS_MOULTON_3
    4th order Adams-Moulton : MTHD_ADAMS_MOULTON_4
    2nd order Backward Difference : MTHD_BACKWARD_DIFFERENCE_2
    3rd order Backward Difference : MTHD_BACKWARD_DIFFERENCE_3
    4th order Backward Difference : MTHD_BACKWARD_DIFFERENCE_4


LibSBMLSim has been primary developed by

  • Hiromu Takizawa
  • Akito Tabira
  • Kazushige Nakamura
  • Yoichi Chikahara
  • Tatsuhiro Matsui
  • Noriko Hiroi
  • Akira Funahashi

with substantial contributions from

  • Kazuki Hirata
  • Keisuke Iba
  • Suguru Sakuma
  • Nobuyuki Ohta


If you have any questions / comments, please send an email to
LibSBMLSim development team: <> (please replace _at_ with @)
We appreciate your feedback!

Funding acknowledgements

This work have been supported by the following organizations: the Japanese Ministry of Education, Culture, Sports, Science and Technology (Grant-in-Aid for Scientific Research on Innovative Areas (23136513)); and Keio University (Japan).


Contact information

Funahashi Lab.
Room 516 and 417, Bld 14,
Department of Biosciences and Informatics, Keio University,
3-14-1 Hiyoshi Kouhoku-ku, Yokohama 223-8522 JAPAN

Phone: +81-45-566-1797
Email: info _at_