My question is with respect to the current scipy ode solver. From the scipy doc page, their usage is:
# A problem to integrate and the corresponding jacobian:
from scipy.integrate import ode
y0, t0 = [1.0j, 2.0], 0
def f(t, y, arg1):
return [1j*arg1*y[0] + y[1], -arg1*y[1]**2]
def jac(t, y, arg1):
return [[1j*arg1, 1], [0, -arg1*2*y[1]]]
# The integration:
r = ode(f, jac).set_integrator('zvode', method='bdf', with_jacobian=True)
r.set_initial_value(y0, t0).set_f_params(2.0).set_jac_params(2.0)
t1 = 10
dt = 1
while r.successful() and r.t < t1:
r.integrate(r.t+dt)
print("%g %g" % (r.t, r.y))
My problem is: it is using a lot of the python loops (the while-loop) which essentially slows the program down. I can try to write a C code and use ctypes to make it faster, but I won't be able to access the nice algorithms like dopri5 in scipy (unless I implement it myself).
Is there any vectorized way of coding to make this faster?
Thank you!