[SciPy-user] Runge-Kutta ODE integrator in SciPy, odepack problems on SciPy Superpack for OSX?
Gabriel Gellner
ggellner@uoguelph...
Thu Mar 13 11:27:05 CDT 2008
On Wed, Mar 12, 2008 at 08:07:27PM -0700, Zane Selvans wrote:
> I'm looking for a Python Runge-Kutta diffeq integrator, and I've found
> conflicting information online as to whether this is included within SciPy
> (the SciPy to Matlab comparison says it's included in Matlab, and not in
> SciPy, but some mailing list commentary says it's part of the odepack).
>
Odepack is the name of the fortran code that the scipy odeint wraps. It is a
addaptive linear multistep algroithm and not in the runge kutta familiy. It
works well, and depending on your problem can be very efficient. Is there any
reason you need runge kutta specifically?
I imagine you want a Dormand Prince pair as you mention matlab. In this case
your only option at this stage is to use PyDSTool, which has its own model
syntax (not normal python functions). Or you could try out Sage which has an
experimental wrapper for the GSL codes (which include a range of runge kutta
algorithms).
> Does anyone know for sure? I don't actually know a whole lot about how
> numerical ode solvers work (and truthfully, I don't want to learn, which is
> why I'm hoping I can just find an open source solver...)
>
If you don't have specific needs, I would just use odeint
(scipy.integrate.odeint), check out my example in the cookbook:
http://www.scipy.org/Cookbook/Theoretical_Ecology/Hastings_and_Powell
I use a fortran callback for speed, but using a normal python function is the
same. If is still confusing I can send you an easier example.
I don't have a mac . . . but can you do:
import scipy.integrate.odeint
What does scipy.test() do, looks like a broken installation.
Gabriel
> The reason I'm asking instead of just playing with scipy.integrate.ode is
> for some reason my SciPy installation seems to be having problems loading
> the ode module. I'm using Chris Fonnesbeck's "SciPy Superpack"
> installation.
>
> I get this:
>
> In [170]: from scipy.integrate import ode
> ---------------------------------------------------------------------------
> ImportError Traceback (most recent call last)
>
> /Users/zane/svn/stress/pySatStress/<ipython console> in <module>()
>
> /Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/integrate/__init__.py
> in <module>()
> 7 from info import __doc__
> 8
> ----> 9 from quadrature import *
> 10 from odepack import *
> 11 from quadpack import *
>
> /Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/integrate/quadrature.py
> in <module>()
> 3 'cumtrapz','newton_cotes','composite']
> 4
> ----> 5 from scipy.special.orthogonal import p_roots
> 6 from scipy.special import gammaln
> 7 from numpy import sum, ones, add, diff, isinf, isscalar, \
>
> /Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/special/__init__.py
> in <module>()
> 6 #from special_version import special_version as __version__
> 7
> ----> 8 from basic import *
> 9 import specfun
> 10 import orthogonal
>
> /Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/special/basic.py
> in <module>()
> 6
> 7 from numpy import *
> ----> 8 from _cephes import *
> 9 import types
> 10 import specfun
>
> ImportError:
> dlopen(/Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/special/_cephes.so,
> 2): Library not loaded: /usr/local/lib/libgfortran.2.dylib
> Referenced from:
> /Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/special/_cephes.so
> Reason: image not found
>
> And lo, it turns out I don't have libgfortran.2.dylib on my system. I do
> have libgfortran.3.dylib though. If I create a symbolic link from 3 to 2,
> and then try the import I get a different error:
>
> ImportError:
> dlopen(/Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/special/_cephes.so,
> 2): Symbol not found: __gfortran_pow_r4_i4
> Referenced from:
> /Library/Python/2.5/site-packages/scipy-0.7.0.dev3998-py2.5-macosx-10.5-i386.egg/scipy/special/_cephes.so
> Expected in: /usr/local/lib/libgfortran.2.dylib
>
> It turns out there was a libgfortran.2.0.0.dylib included with the
> superpack, but it's for the Mach-0 architecture, not Intel, which is what
> I've got (MacBook Pro).
>
> Any insight appreciated,
> Thanks!
>
> Zane
>
> --
> Zane Selvans
> Amateur Human
> zane@ideotrope.org
> 303/815-6866
> PGP Key: 55E0815F
> begin:vcard
> fn:Zane Selvans
> n:Selvans;Zane
> org:Earthlings
> adr:;;200 S. Parkwood Ave.;Pasadena;CA;91107;USA
> email;internet:zane@ideotrope.org
> title:Amateur Human
> tel;cell:(303) 815-6866
> x-mozilla-html:TRUE
> url:https://ideotrope.org
> version:2.1
> end:vcard
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-user
mailing list