I was wondering about the odeint function in scipy.
While I was solving the Van der pol equations, I found the function odeint
is not suitable. I know there are some differences between Runge-kutta method and RKF method, and only the RKF method can be used to solve the Van der Pol system.
But what should I do by the scipy function 'odeint'?
Thanks a lot!
The python program is given as follow,
Expand|Select|Wrap|Line Numbers
- #! /usr/bin/python
- # Filename:vaderpol.py
- from scipy import *
- from pylab import *
- u=0.1
- deriv= lambda y,t :array([y[1],y[0]-u*(y[0]**2-1)*y[1]])
- start=0
- end=20000
- numsteps=100000
- time=linspace(start,end,numsteps)
- from scipy import integrate
- y0=array([0.01,0.0])
- y=integrate.odeint(deriv,y0,time,hmax=0.2,hmin=0.001)
- plot(time,y[:,0])
- show()