Closed kaizu closed 4 years ago
The following might be also useful:
>>> s = Session(10, model=m, y0={'C': 60}, return_type='array')
>>> s.update(t=0, y={'X': 0})
>>> s.update(t=10, y={'X': 100})
>>> s.run()
A duration for the simulation might be better to be an argument of run
function:
>>> s = Session(model=m, y0={'C': 60}, return_type='array')
>>> s.update(t=0, y={'X': 0})
>>> s.update(t=10, y={'X': 100})
>>> s.run(duration=30)
An idea about "operation list":
[
{'$set': {'model': m}, '$add': {'value': {'C': 60}}},
{'$run': {'duration': 10, 'observer': [obs1]}},
{'$set': {'value': {'X': 100}}},
{'$run': {'duration': 20, 'observer': [obs1]}}
]
# {'$set': {'model': m}, '$add': {'value.C': 60}}
Or simply,
run_simulation([
{'$bind_to': m, '$add_molecules': {'C': 60}},
{'$run': 10},
{'$set_value': {'X': 100}},
{'$run': 10}
],
return_type='array')
>>> s = Session(model=m)
>>> s.update({'C': 60, 'X': 60})
>>> s.run(10)
>>> s.update({'X': 100})
>>> s.run(30)
>>> print(s.todict())
>>> ret = s.solve('ode')
>>> print(ret.asarray())
>>> ret.plot()
run_simulation
could be implemented as follows:
def run_simulation(t, m, y0, solver):
s = Session(model=m)
s.update(y0)
s.run(t[-1])
obs = NumberObserver(t) #???
ret = s.solve(solver, [obs]) #???
return ret.asarray()
This has been done partially in the new interface.
session = Session(model=m, y0=y0)
ret = session.run(10.0, solver='gillespie')
print(ret.as_array())
ret.plot()
run_simulation
provides an easy way to run a single simulation.This should be also written like:
And
Session
object will allow to update the settings.