[SciPy-User] Sparse jacobian in scipy ODE solver

Per Nielsen evilper@gmail....
Sat Jan 21 07:14:49 CST 2012


Hi all

I am working with large linear system 1st order ODE systems of the form

dydt = M * y

where M is very sparse complex valued matrix. I currently use the ode class
from scipy.integrator like:

from scipy.integrate import ode
r = ode(f)
r.set_integrator('zvode', method='adams')

and calculate f = dydt as M.dot(y). I would like to make use of the
jacobian of dydt, which for my linear problem is simply M, to speed up my
simulations. However, when I supply a sparse matrix as the jacobian I get
the following error (see attached script):

rv_cb_arr is NULL
Call-back cb_jac_in_zvode__user__routines failed.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Users/per/Dropbox/DTU/python/tryouts/ode_jac_test.py in <module>()
     61
     62     while r.successful() and r.t < t1:
---> 63         r.integrate(r.t + dt)
     64         ts.append(r.t)
     65         ys.append(r.y)

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/scipy/integrate/ode.py
in integrate(self, t, step, relax)
    324         self.y,self.t = mth(self.f,self.jac or (lambda :None),
    325                             self.y,self.t,t,
--> 326                             self.f_params,self.jac_params)
    327         return self.y
    328

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/scipy/integrate/ode.py
in run(self, *args)
    684
    685     def run(self,*args):
--> 686         y1,t,istate =
self.runner(*(args[:5]+tuple(self.call_args)+args[5:]))
    687         if istate < 0:
    688             warnings.warn('zvode: ' +

TypeError: a float is required

It seems that the jacobian can not be sparse. But is this a fundamental
problem or could one somehow work around it and still use ode from scipy?

Any help or comments would be appreciated.

Best,

Per
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120121/1f68d7a0/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ode_jac_test.py
Type: application/octet-stream
Size: 1048 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20120121/1f68d7a0/attachment.obj 


More information about the SciPy-User mailing list