[SciPy-user] integrate.odeint and simultaniuos equations

Scott Askey scotta_2002@yahoo....
Tue Jan 20 06:34:01 CST 2009


Do ode and odeint work in multiple dimensions?

I could not any examples with more than one degree of freedom.  And from the doc string it how to solve simultaneous  ode's was not obvious.  The code for modelling a 2d simple harmonic oscillator or spherical pendulum would give me the insight I need.

I found and understand the following 1 D harmonic oscillator model from the scipy cookbook.

V/R

Scott



from scipy import *
from pylab import *
deriv = lambda y,t : array([y[1],-y[0]-.1*y[1]])#xdot,x2dot
# Integration parameters
start=0
end=10
numsteps=10000
time=linspace(start,end,numsteps)
from scipy import integrate
y0=array([0.0005,0.2]) #x,x_dot
y=integrate.odeint(deriv,y0,time)
plot(time,y[:,0])#x,xdot
show()




      


More information about the SciPy-user mailing list