Simulate chemical reaction networks using ordinary differential equations.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Simulate chemical recation networks (CRNs) using ordinary differential equations (ODEs).


Using the crnsimulator executable:

Create a test file with your CRN:

File: ozzy.crn

# Oscillator Test
A + B -> B + B [k = 0.2]
B + C -> C + C [k = 0.3]
C + A -> A + A [k = 1]

And pipe it into the crnsimulator:

$ crnsimulator -o ozzy < ozzy.crn

This writes the ODE system to an executable python script:

Check the command line parameters of You have to set initial species concentrations, and choose an output-format, e.g.:

$ python ./ --p0 A=0.1 B=1e-2 C=1e-3 --t8 10000 --pyplot ozzy.pdf

This example plots a simulation on a linear-time scale (0 - 10000) to the file ozzy.pdf .

Tips and Tricks:

You can pass the command line options for directly to crnsimulator. This will automatically simulate your ODE system. Use --force to overwrite an existing script.

$ crnsimulator --p0 A=0.1 B=1e-2 C=1e-3 --t8 10000 -o ozzy --pyplot ozzy.pdf < ozzy.crn

You can specify the CRN in a single line:

$ echo "A+B->2B [k=0.2]; B+C->2C [k=0.4]; C+A->2A" | crnsimulator --p0 A=0.1 B=1e-2 C=1e-3 --t8 10000 -o ozzy --pyplot ozzy.pdf

You can specify default initial concentrations of species:

$ echo "A @i 0.1; B @i 1e-2; A+B->2B [k=0.2]; B+C->2C [k=0.4]; C+A->2A" | crnsimulator --p0 C=1e-3 --t8 10000 -o ozzy --pyplot ozzy.pdf

Using the crnsimulator library:

The easiest way to get started is by looking at the crnsimulator script itself. However, here is a small example using the above oscillating CRN.

>>> from crnsimulator import ReactionGraph
>>> crn  = [[['A', 'B'],['B','B'],0.2],
            [['B', 'C'],['C','C'],0.8],
            [['C', 'A'],['A','A'],0.9]]
>>> RG = ReactionGraph(crn)
>>> filename, odename = RG.write_ODE_lib(filename='')
>>> print 'Wrote ODE system file:', filename
Wrote ODE system file:

Then go ahead and execute

$ python ./ --p0 1=1e-6 2=2e-6 3=5e-6

... or load it as python library.

import imp
_temp = imp.load_source(odename, filename)
integrate = getattr(_temp, 'integrate')
integrate(args) # args = <argparse.ArgumentParser()>


$ python install

local installation

$ python install --user



Complete list of Python dependencies:

All dependencies are available using pip:

  • os
  • sys
  • unittest
  • imp
  • argparse
  • pyparsing
  • networkx
  • numpy
  • scipy
  • sympy
  • matplotlib
  • seaborn