[SciPy-User] possible bug with scipy.integrate.ode

Flavio Coelho fccoelho@gmail....
Fri Nov 4 08:30:49 CDT 2011


The sad thing is... I knew about the order of arguments :-(
but moving from one to the other I forgot to swap the arguments...

Thanks, I am very relieved to hear that  there is no such bug!

Flávio

On Fri, Nov 4, 2011 at 11:01, Warren Weckesser <
warren.weckesser@enthought.com> wrote:

>
>
> On Fri, Nov 4, 2011 at 7:35 AM, Flavio Coelho <fccoelho@gmail.com> wrote:
>
>> Hi,
>>
>> I am a long time user of scipy.integrate.odeint for solving ODEs. Today I
>> decided to test the "other solver" in scipy: scipy.integrate.ode I am
>> getting strange results for model below:
>>
>> def fun(y,t):
>> """
>> Logistic model
>>  """
>> a = .5
>> k = 1000.0
>>  return a*(1-y/k)*y
>>
>> r = ode(fun).set_integrator('vode',method='bdf', with_jacobian=False)
>> r.set_initial_value(1e-6,0)
>> res = np.zeros(10000)
>> i = 0
>> while r.successful() and r.t < 100:
>> r.integrate(r.t+.01)
>> res[i] = r.y
>>  i += 1
>>
>>
>> odeint solves this correctly and returns the caracteristic logistic curve
>> which maxes out at 1000. ode, however, keeps growing beyond 1000.
>>
>> I may be doing something stupid, since I am not familiar with the usage
>> of ode. Or there maybe a bug in ode.
>>
>>
>
> Flávio,
>
> It is unfortunate, but odeint and ode use different conventions for the
> order of the arguments of the function that defines the system of
> differential equations.  If you change the signature of your definition of
> 'fun' to 'def fun(t, y):', your example works fine.
>
> Warren
>
>
>
>
>> I'll just stay away from ode for now, but I thought it might be a good
>> Idea to report this.
>>
>>
>> --
>> Flávio Codeço Coelho
>> ================
>> +55(21) 3799-5567
>> Professor
>> Escola de Matemática Aplicada
>> Fundação Getúlio Vargas
>> Rio de Janeiro - RJ
>> Brasil
>>
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


-- 
Flávio Codeço Coelho
================
+55(21) 3799-5567
Professor
Escola de Matemática Aplicada
Fundação Getúlio Vargas
Rio de Janeiro - RJ
Brasil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111104/4a5fd79b/attachment.html 


More information about the SciPy-User mailing list