Lotka-Volterra 2D

The Original Model in Ordinary Differential Equations

%matplotlib inline
from ecell4 import *
alpha = 1

with reaction_rules():
    ~u > u | u * (1 - v)
    ~v > v | alpha * v * (u - 1)

m = get_model()
run_simulation(15, {'u': 1.25, 'v': 0.66}, model=m)
../_images/example7_4_0.png

The Modified Model Decomposed into Elementary Reactions

alpha = 1

with species_attributes():
    u | {'D': '0.1'}
    v | {'D': '0.1'}

with reaction_rules():
    u > u + u | 1.0
    u + v > v | 1.0

    u + v > u + v2 | alpha
    v2 > v + v | alpha * 10000.0
    v > ~v | alpha

m = get_model()
run_simulation(40, {'u': 1.25 * 1600, 'v': 0.66 * 1600}, volume=1600, model=m)
../_images/example7_7_0.png
run_simulation(40, {'u': 1.25 * 1600, 'v': 0.66 * 1600}, volume=1600, model=m, solver='gillespie')
../_images/example7_8_0.png

A Lotka-Volterra-like Model in 2D

rng = GSLRandomNumberGenerator()
rng.seed(0)
w = meso.MesoscopicWorld(Real3(40, 40, 1), Integer3(160, 160, 1), rng)
w.bind_to(m)
V = w.volume()
print(V)
1600.0
w.add_molecules(Species("u"), int(1.25 * V))
w.add_molecules(Species("v"), int(0.66 * V))
sim = meso.MesoscopicSimulator(w)
obs1 = FixedIntervalNumberObserver(0.1, ('u', 'v', 'v2'))
obs2 = FixedIntervalHDF5Observer(2, "test%03d.h5")
sim.run(100, (obs1, obs2))
viz.plot_number_observer(obs1)
../_images/example7_16_0.png
viz.plot_world(w, radius=0.2)
viz.plot_movie_with_attractive_mpl(
    obs2, linewidth=0, noaxis=True, figsize=6, whratio=1.4,
    angle=(-90, 90, 6), bitrate='10M')