PyURDME includes the ADFSP (Adaptive Diffusive Finite State Projection) solver. This solver integrates the Reaction-Diffusion Master Equations using the DFSP algorithm found in [Drawert et al., J.Chem.Phys, 2010] using an adaptive timesteping schemed based on the estimating the operator splitting error using the method from [Hellander et al., J.Comp.Phys, 2013].
In [1]:
%pylab inline
from pyurdme.adfsp_solver import ADFSPSolver
from examples.cylinder_demo.cylinder_demo3D import cylinderDemo3D
import pyurdme
import time
import scipy.fftpack
import numpy
In [3]:
model = cylinderDemo3D()
sol = ADFSPSolver(model)
print "Attempting to compile"
sol.compile()
print "Beginning simulation"
t1 = time.time()
result = sol.run()
print "Simulation complete in {0}s".format(time.time()-t1)
In [4]:
print "Plotting solution"
# Plot of the time-average spatial concentration.
x_vals = model.mesh.coordinates()[:, 0]
A_vals = numpy.mean(result.get_species("A", concentration=True), axis=0)
B_vals = numpy.mean(result.get_species("B", concentration=True), axis=0)
plt.plot(x_vals,A_vals,'.r',x_vals,B_vals,'.b')
plt.legend(['A', 'B'])
Out[4]:
In [5]:
sol = ADFSPSolver(model, report_level=0)
print "Attempting to compile"
sol.compile()
N = 10
run_times = []
print "Beginning simulation:"
for n in range(N):
sys.stdout.write(str(n))
sys.stdout.flush()
t1 = time.time()
result = sol.run()
elapsed_time = time.time()-t1
run_times.append(elapsed_time)
print "Simulation of {0} trajectories: avg={1} std={2}".format(N, numpy.mean(run_times), numpy.std(run_times))
In [6]:
from pyurdme.nsmsolver import NSMSolver
nsm = NSMSolver(model, report_level=0)
print "NSM: Attempting to compile"
nsm.compile()
N = 10
nsm_times = []
print "NSM: Beginning simulation:",
for n in range(N):
sys.stdout.write(str(n))
sys.stdout.flush()
t1 = time.time()
result = nsm.run()
elapsed_time = time.time()-t1
nsm_times.append(elapsed_time)
print ""
print "NSM: Simulation of {0} trajectories: avg={1} std={2}".format(N, numpy.mean(nsm_times), numpy.std(nsm_times))
In [ ]:
In [ ]: