ecell / ecell4_base

An integrated software environment for multi-algorithm, multi-timescale, multi-spatial-representation simulation of various cellular phenomena
https://ecell4.e-cell.org/
GNU General Public License v3.0
63 stars 23 forks source link

getVelocity for ODE simulation #96

Closed kaizu closed 8 years ago

kaizu commented 8 years ago

In ecell3, an user can get the velocity of each reaction, getVelocity. In ecell4, it might be realized something like:

m = ode.ODENetworkModel()
# make a model
w = ode.ODEWorld()
# set initial conditions
print(w.evaluate(m.reaction_rules()[0]))  # return a flux of the given ode.ODEReactionRule

This is necessary for implementing metabolic control analysis tools.

kaizu commented 8 years ago

It works now as follows:

from ecell4 import *

with reaction_rules():
    A + B > C | (0.01 * A * B)
    C > A + B | (0.3 * C)
    # A + B == C | (0.01, 0.3)

m = get_model()
w = run_simulation(20, model=m, y0={'C': 60}, return_type='world')

for rr in m.reaction_rules():
    print("{:s} => {:e}".format(rr.as_string(), w.evaluate(rr)))

The above code would print:

A+B>C|(0.01*A*B) => 8.999999e+00
C>A+B|(0.3*C) => 9.000000e+00