I am using scikits.odes.odeint
to solve a relatively large system of ODEs (40 variables, 100 kinetic parameters). I want to speed up the process by supplying a jacobian to the solver. However, I do not know how to best define the jacobian for this purpose and supply it to the solver.
This is a very basic symbolic Jacobion but it works for most ODE solvers.
import sympy as sp
def rhs(t, y):
return [y[0],2*y[1]]
def jacob(t, y):
ydot = rhs(t,y)
J = sp.Matrix(ydot).jacobian(y)
J_func = sp.lambdify((t, y) , J)
return J_func
There is a more in depth guide here.