LibSBMLSim: A library for simulating SBML models

Latest release: 1.3.0, released 23rd Dec 2016 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.3.0

New features

  • Add wrapper script ( for SBML Test Runner.
  • Add -o option so that user can specify an output file. This will enable SBML Test Runner to run in parallel.
  • LibSBMLSim confirmed to pass SBML test cases from 00001 to 01185 except comp and fbc.

Bug fixes

  • Allocate including_species dynamically, so that the library can handle more than 256 species.
  • Fixed warnings (CMP0037 CMP0042) from cmake.
  • Fixed alter_tree_structure to call ASTNode_setName() in the proper order.
  • Removed unused function (mySpecies_setLocatingCompartment()) from mySpecies.
  • Add -lm to linker option.
  • Avoid a C preprocessor warning on Linux.

Please see NEWS.txt on github for further information.


LibSBMLSim is distributed under the terms of LGPL. Source code is also available on github.


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.12 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
  • Takeshi Abe


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_