[SciPy-user] Problems with odeint
Fernando Perez
fperez.net at gmail.com
Thu Jun 15 05:07:23 EDT 2006
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: odebug.py
Type: text/x-python
Size: 529 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060615/901fcc95/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: odeplot_scipy.png
Type: image/png
Size: 35304 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060615/901fcc95/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: odeplot_scilab.png
Type: image/png
Size: 3438 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060615/901fcc95/attachment-0001.png>
More information about the SciPy-User
mailing list