[SciPy-user] Coupled ODEs

Lou Pecora lou_boog2000 at yahoo.com
Tue Apr 22 13:14:10 EDT 2008


You use arrays (2-dimensional in your example) for
initial conditions and define f to be a function from
R^2 to R^2 (i.e. it returns a 2D array of function
values - called the vector field of the ODE- using the
input 2D array (y,z) ).  SciPy.odeint is set up to
handle arrays, not just scalars.  You should get the
tutorial on SciPy by Travis Oliphant at 

http://www.scipy.org/Wiki/Documentation?action=AttachFile&do=get&target=scipy_tutorial.pdf

the above URL should be all on one line. Search for
ODEINT and all is explained.

-- Lou Pecora

--- Colin Gillespie wrote:

Hi,

How do I solve coupled ODEs using scipy?

For the ODE

dz/dt = z2

I have

from scipy import *
def f(t,z):
    return z**2
t = [0,1]
z0 = array([0])

z = integrate.odeint(f, z0, t)
print z

But how do I handle:

dy/dt = y*z
dz/dt = z2+y

Thanks

Colin






      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



More information about the SciPy-User mailing list