Skip to content

Instantly share code, notes, and snippets.

@kaizu
Last active November 1, 2018 05:53
Show Gist options
  • Save kaizu/d7e2cdae68a8413882e127eeadcc4935 to your computer and use it in GitHub Desktop.
Save kaizu/d7e2cdae68a8413882e127eeadcc4935 to your computer and use it in GitHub Desktop.
from ecell4 import *
# with reaction_rules():
# ~A == A | (Parameter(1.0), Parameter(1.0)) #<= Parameterize
def generate_model(k1=1.0, k2=1.0):
with reaction_rules():
~A == A | (k1, k2)
return get_model()
m1 = generate_model() #<= Apply a value to each parameter
m2 = generate_model(0.0)
f = gillespie.Factory() #<= A shorter name
w = f.world(100) #<= A shorter name & enable to set a volume rather than sizes
w.bind_to(m1)
# w.add_molecules({"A": 60, "B": 60}) #<= Convenient interface
obs = number_observer(0.1) #<= A shorter name for [FixedInterval/Timing]NumberObserver
f.simulator(m1, w).run(10.0, obs) #<= A shorter name
f.simulator(m2, w).run(10.0, obs)
show(obs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment