[SciPy-user] Problems with odeint

Vinicius Lobosco vinicius.lobosco at gmail.com
Thu Jun 15 05:55:19 EDT 2006


So may have had a name conflict with another package. Sounds as a good 
strategy to import as something. Something I usually dont...

On Thursday 15 June 2006 11.41, Víctor Martínez-Moll wrote:
> Thanks Fernando!
>
> Using your script I get the right curves too. I had only to change the
> line: import pylab as P
> by
> import matplotlib.pylab as P
>
> On the other hand the debugging lines you added showed:
>
> numerix flag : Numeric
> mpl   version: 0.87.2
> scipy version: 0.4.9.1893
>
> The only thing that worries me now is to know what was wrong with my
> script (if anything). I'll try to discover when I have some time, so any
> suggestions will be welcome.
>
> Cheers,
>
> Víctor
>
> En/na Fernando Perez ha escrit:
> > On 6/9/06, Víctor Martínez-Moll <victor.martinez at uib.es> wrote:
> >> Hi all,
> >>
> >> I've been a SciLab user for some time and I'm evaluating SciPy as a
> >> development tool.
> >>
> >> The first thing I tried is to solve a simple second order diferential
> >> equation using odeint(). The problem is that depending on the function I
> >> want to integrate I get nice results, but for most of them I get simply
> >> nothing or nonsense answers. Is not a problem of the function having a
> >> strange behaviour or having singularity points. For example if I try to
> >> solve:
> >>      d2y/dt2 = 1-sin(y)
> >> either I get nothing or wrong solutions (the best thing I got was
> >> setting:hmin=0.01,atol=.001), while If I do about the same procedure in
> >> SciLab I get a nice and smooth set of curves. The strangest thing is
> >> that if I use exactly the same procedure to solve:
> >>      d2y/dt2 = 1-y
> >> then I get the right solution, which seems to indicate that I'm doing
> >> the right thing (although of course I know I'm not because I do not
> >> belive that odeint is not able to solve such a silly thing).
> >>
> >> I've only checked it with the last enthon distribution I found:
> >> enthon-python2.4-1.0.0.beta2.exe
> >>
> >> The simple procedure I wrote in Python and its equivalent in SciLab that
> >> does the right thing in are:
> >
> > I'm sorry, but I get basically the same results with both.  I'm
> > attaching a slightly modified version of the python script you wrote,
> > which prints some debug information.  On my system, this information
> > reads:
> >
> > In [7]: run odebug
> > numerix flag : Numeric
> > mpl   version: 0.87.3
> > scipy version: 0.5.0.1940
> >
> > I've attached a png of the resulting plot.
> >
> > I've never used scilab before, but just brute-pasting your example
> > into a scilab window and exporting the resulting plot gave me the
> > attached file.
> >
> >> From what I can see, both results look more or less consistent (I
> >
> > haven't done numerical accuracy checks, I'm just looking at the
> > figures).
> >
> > Cheers,
> >
> > f
> >
> >
> > ------------------------------------------------------------------------
> >
> > import math
> > import matplotlib as M
> > import pylab as P
> > import scipy as S
> > import scipy.integrate
> >
> > # debug info
> > print 'numerix flag :',P.rcParams['numerix']
> > print 'mpl   version:',M.__version__
> > print 'scipy version:',S.__version__
> >
> > def dwdt(w,t):
> >     return [w[1],1.0-math.sin(w[0])]
> >
> > t = S.arange(0.0,2.0*S.pi,.01)
> >
> > ww = S.integrate.odeint(dwdt,[0.0,0.0],t,hmin=0.01,atol=.001)
> >
> > y = ww[:,0]
> > dy =ww[:,1]
> > ddy = 1.0-S.sin(ww[:,0])
> >
> > P.figure()
> > P.plot(t,y,label='y')
> > P.plot(t,dy,label='dy')
> > P.plot(t,ddy,label='ddy')
> > P.legend()
> > P.show()
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user at scipy.net
> > http://www.scipy.net/mailman/listinfo/scipy-user




More information about the SciPy-User mailing list