[Tutor] Problems using odeint

Steven D'Aprano steve at pearwood.info
Wed Jan 15 01:08:51 CET 2014


Hi Grace, and welcome,

My reply is interleaved with your comments.

On Tue, Jan 14, 2014 at 06:40:03PM +0000, Grace Roberts wrote:
> Hi,
> I'm a python beginner, currently using scipy's 'odeint' to compute to 
> a set of ODEs (obtained by splitting Newton's law of gravity 
> ma=-Gm1m2r/r^3 in two ordinary differentials). The idea is that I'm 
> modelling the orbit of a satellite as it approaches Mars. 

Unfortunately, I don't think there is anyone here who is very familiar 
with scipy. Including me. I'll try my best to give some helpful 
comments, but take them with a grain of salt.


> I have two 
> problems:-For certain initial conditions the programme displays 
> impossible orbits, showing the satellite making immediate sharp turns 
> or jumping up and down in velocity.

I'm not an expert on numeric code, but my first instinct on reading this 
is to think that you're suffering numerical instability in your ODEs. 
It's been too many years since I've done ODEs to be much help to you 
here, but can you double check that the ODE you are using is 
mathematically correct and any constants are expressed to sufficient 
accuracy?


> The exact same code can also end 
> up displaying different graphs when run multiple times. For example 
> when initial conditions are set at: 
> xx0=[1000.,10000.,1000.,10000.].

If what you say is accurate, that strongly suggests that the system you 
are modelling is chaotic, and tiny changes in initial conditions lead to 
major changes in the output. This problem may be inherent in the 
physical system.


> -Often when run an error message 
> appears saying: "Excess work done on this call (perhaps wrong Dfun 
> type). Run with full_output = 1 to get quantitative information." You 
> can see that as part of the odeint function I tried to stop the excess 
> work by increasing the maxstep and I also tried to run with 
> full_output =1. It's quite possible I haven't done this right. If I 
> have, what else can I do to stop this message from appearing? I've 
> attached a quick print-screen of the code. Any help is much 
> appreciated.

Unfortunately print-screen is not so helpful here. What we really need 
is your code copy and pasted as text, if possible directly in the body 
of your email. If it is more than a hundred lines or so, it will 
probably be better to attach your .py file to the email.

I will try to find a program that will let me view your .docx file (like 
many of us here, I'm a Linux user and don't have access to Microsoft 
Office) so I can at least see the print-screen, but being able to access 
it as text rather than just a screenshot would make it much easier to 
help you.

Regards,


-- 
Steven


More information about the Tutor mailing list