[SciPy-User] Help!!!!!! having problems with ODEINT

Laura Matrajt matrajt at gmail.com
Fri Jul 22 01:11:43 EDT 2011


Hi Warren,
 thanks for your fast reply.
As I said in my email, 90% of the time this runs perfectly well.
Is 'mxstep' a number that will be computed at each iteration or is it just
there in case of more steps are needed? I am worried that by increasing it I
will make my code slower...
Also, would increasing my tspan solve the issue?
If the answer is yes, which of the two solutions would be better?
Also, I am not passing the Jacobian to my function. Do you think that it
will make a difference, both in terms of speed and in terms of this error to
pass the Jacobian?

THank you very very much! I was really worried about this!


On Thu, Jul 21, 2011 at 6:08 PM, Warren Weckesser <
warren.weckesser at enthought.com> wrote:

>
>
> On Thu, Jul 21, 2011 at 6:22 PM, Laura Matrajt <matrajt at gmail.com> wrote:
>
>> Hi all,
>>  I am working with a system of 16 differential equations that simulates an
>> epidemic in a city.  Because there are many cities interacting with each
>> other, I need to run my ode's for a single day, stop them, modify the
>> initial conditions and run them again.  Because the ode is running only for
>> a day, I defined my tspan to have only two points, like this:
>>
>> tspan = tspan = linspace(day, day+1, 2)
>>
>> I wrote my equations in Python and I am using scipy.odeint to solve it.
>>
>> Here is my code:
>> def advanceODEoneDay(self,day):
>>
>>         #rename variables for convenience
>>         N0, N1 = self.children, self.adults
>>         S0,S1,A0,A1,I0,I1,RA0,RA1,RI0,RI1 =
>> self.S0,self.S1,self.A0,self.A1,self.I0,self.I1,self.RA0,self.RA1,self.RI0,self.RI1
>>
>>
>>
>>         #create a vector of times for integration:
>>         tspan = linspace(day, day+1, 2)
>>
>>
>>         #set initial conditions. To do this, I need to look in the array
>> in the day
>>         initCond = [S0[day,0], S0[day,1],
>>                     S1[day,0], S1[day,1],
>>                     A0[day,0], A0[day,1], A1[day,0], A1[day,1],
>>                     I0[day,0], I0[day,1], I1[day,0], I1[day,1],
>>                     RA0[day,0], RA1[day,0], RI0[day,0], RI1[day,0] ]
>>
>>
>>         #run the ode:
>>         sir_sol = odeint(sir2groups,initCond, tspan,
>> args=(self.p,self.C,self.m,self.VEs,self.VEi,self.VEp,N0,N1))#,self.gamma,self.rho))
>>
>>
>> Most of the time, it works just fine. However, there are some times where
>> the following message appears:
>>
>> Excess work done on this call (perhaps wrong Dfun type).
>> Run with full_output = 1 to get quantitative information.
>>  lsoda--  at current t (=r1), mxstep (=i1) steps
>>        taken on this call before reaching tout
>>       In above message,  I1 =       500
>>       In above message,  R1 =  0.1170754095027E+03
>>
>> I should mention that it is NOT only a warning. This is repeated over and
>> over (thousands of times) and then it will break the rest of my code
>> Ok, after searching in this mailing list, someone else posted a similar
>> warning message and it was suggested to him that "
>>
>> *In your case, you might simply be computing for to coarse a mesh in t,** so "too much work" has to be done for each step. "
>>
>>
>> *Is this what is happening to me? the problem is that I don't get this error every single time, so I don't even know how to run it with full_output = 1 to get the info...
>>
>>
>>
>> I really don't know what to do. Any help will be very very very very appreciated!
>> thank you very *
>> *
>>
>>
> The function odeint has the keyword argument 'mxstep' that determines the
> maximum number of internal steps allowed between requested time values.  The
> default is 500.  It is not unusual to have to increase this, especially in a
> case like yours where you simply want the value at the end of a long time
> interval.  Try increasing it to, say, mxstep=5000.
>
> Warren
>
> *
>> *
>>
>>
>>
>>
>> --
>> Laura
>>
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


-- 
Laura
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110721/2d2b5e6f/attachment.html>


More information about the SciPy-User mailing list