|
Boost Users : |
Subject: Re: [Boost-users] odeint - solving an ODE with time-dependent parameter numerically
From: Damien Hocking (damien_at_[hidden])
Date: 2014-01-19 21:43:27
On 1/19/2014, 5:55 PM, Arijit Hazra wrote:
> Hello All,
>
> I am trying to solve an ode with time-dependent parameters by using
> boost. I have just started using boost and I think boost library's
> odeint library is the best option for my problem.
>
> Would anyone please explain me how I can solve a Initial Value Problem
> --a system of ODE --with a time-dependent parameter. e.g.
>
> | dy1/dt = a1(t) * y2 -b1(t)* y3 -c1(t) y1;
> dy2/dt = a2(t) * y1 -b2(t)* y1 -c2(t) y3;
> dy3/dt = a3(t) * y2 -b3(t)* y3 -c3(t) y1;
> |
>
> y(0)=c; My idea so far after going through the manuals and help
> files. is that for fixed time-step if I form a vector of a,b,c and
> assume a,b,c to be constant over that time-period I can solve using
> boost library.
>
> But this is mathematically less accurate and computationally
> expensive as far my understanding .For solving an ODE numerically
> /y/?(/t/)=/f/(/y/(/t/),/t/) generally the problem is all about
> function evaluation for explicit methods and Jacobian evaluation for
> Implicit methods at specific points in /t/ and /y/.
>
> e.g a step of explicit Euler is /yn/+1=/yn/+(/tn/+1-/tn/)?/f/(/yn/,/tn/).
>
> For time-dependent parameter, treating it as part of /f/, the function
> evaluation (respectively, for implicit methods, also treat it as part
> of the Jacobian evaluation) is the standard procedure. A similar
> strategy applies to more complicated methods for solving ODEs
> (multistage methods such as Runge-Kutta, implicit methods for stiff
> systems, etc.).
>
> This strategy is different and mathematically more accurate than
> assuming parameters are constant over a time step like a multistage
> method.
>
> Would anyone please help me to solve this problem using boost? Thank
> you in advance.
>
>
> With Best Regards,
>
> Arijit Hazra
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Arijit,
I'm not going to answer this from a Boost perspective (Boost mods jump
in if need be), I'm going to answer this based on you asking this
question over in SciComp at Stackexchange. I think you're looking for
maths help, not necessarily Boost help. Having seen that other question
and the answers, what are you looking for exactly? In your question,
you said "My idea so far after going through the manuals and help
files. is that for fixed time-step if I form a vector of a,b,c and
assume a,b,c to be constant over that time-period I can solve using
boost library.". That's correct, you can. If a, b and c have
widely-varying values (several orders of magnitude ratios between them)
you have a stiff system.
Different algorithms are derived to solve different ways, some assume a,
b and c are constant over the whole step, and some require that you
update a, b and c during the substeps of the calculation (e.g.
multistage). Typically, algorithms assume you are going to do the
"right thing" and that whenever they ask you to evaluate dydt, you're
evaluating that vector with the most recent information. You don't
*have* to do that in a multistage algorithm, but as the SciComp answer
suggested, if you do assume your parameters are constant, you're
effectively wasting the advantages of a multistage method.
Is this homework? Do you have to do this in C++ (which is what Boost is
written in), or can you choose any language? Do you actually have to
program it? If you just need an answer you could use Maple, for
example, and not have to program anything. You can even do it in Excel.
Damien
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net