[SciPy-User] Problem with combining Fsolve and Integrate.Odeint
Peter Cimermančič
peter.cimermancic@gmail....
Tue Oct 13 10:43:39 CDT 2009
Thank you. That helped me a lot. I'd like to calculate steady-state
concentrations at different concentration of particular specie in my model
too. Whereas it worked perfectly up to some concentration, it raised me
this warning (Warning: The iteration is not making good progress, as
measured by the improvement from the last ten iterations.) from that
concentration on. Do you know, how could I improve that? And I will
definitely check pysces. It looks exactly what I need.
Cheers,
Peter
On Tue, Oct 13, 2009 at 4:01 AM, Johann Rohwer <jr@sun.ac.za> wrote:
> Sending again - my previous reply doesn't seem to have made it to the
> list...
>
> On Tuesday 13 October 2009, Peter Cimermančič wrote:
> > I'm trying to model system that is described with few ODEs.
> > Function, where ODEs are in, is given as def function(y,t). It
> > takes two arguments as you can see. y is an array of different
> > species in the model, whereas t is an array of time steps. Then,
> > I'd like to calculate steady state using fsolve, which takes
> > function with one argument only. When trying to solve steady state,
> > this error is raised: "TypeError: There is a mismatch between the
> > input and output shape of diff_equations.". How could I solve my
> > problem?
>
> Here is a self-contained example of 2 simple ODEs with mass action
> kinetics, that calculates a time course with odeint and then uses the
> final point of the time course as an initial estimate for a steady-
> state calculation with fsolve. As you can see, the arguments of the
> function de are handled OK between odeint and fsolve.
>
> BTW if you are interested in this problem in a more general way, you
> might want to look at our PySCeS software (http://pysces.sf.net) which
> is for simulation of (bio)chemical kinetic networks. It has high-level
> functions to calculate time courses and steady states automatically
> (amongst others) and runs on top of scipy.
>
> Regards
> Johann
>
> ---------------------8-<--------------------------------
>
> import scipy
> scipy.pkgload('optimize', 'integrate')
> import pylab
>
> k1 = 10
> k2 = 5
> k3 = 8
>
> def de(X,t):
> Xdot = scipy.zeros((2),'d')
> Xdot[0] = k1 - k2*X[0]
> Xdot[1] = k2*X[0] - k3*X[1]
> return Xdot
>
> init_val = scipy.array([10.,0.1])
> t_range = scipy.linspace(0,1,21)
>
> t_course = scipy.integrate.odeint(de, init_val, t_range)
> fin_t_course = scipy.copy(t_course[-1])
>
> ss = scipy.optimize.fsolve(de, fin_t_course, args=None)
> print ss
>
> pylab.plot(t_range, t_course[:,0], t_range, t_course[:,1])
> pylab.show()
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20091013/d531ab1d/attachment-0001.html
More information about the SciPy-User
mailing list