forall
07-12-2002, 05:01 AM
Hi,
I'm after some general advice on selecting an appropriate ODE solver for a single nonlinear ODE, say dy/dx=f(y,x,B). the ODE solution is inside a Monte Carlo loop and is solved a zillion times with different parameters B in the RHS (that is fairly simple), so efficiency is quite important. Since the ODE itself is approximate, I would be happy with accuracy of the order of <5%.
Runge-Kutta schemes was my first guess, until I considered the possibility of stiffness due to RHS terms such as (-B2*y^B3), so an implicit or semi-implicit solver seemed more appropriate. However, since {B} is a parameter, the stiffness may vary depending on the current trial B (and may not even occur). But since the ODE solver is inside the loop, there would seem to be a need to switch the solver at runtime. Code-wise this is no problem if I knew when to switch solvers. Is there some cheap way to determine when would an explicit Runge-Kutta start to fall over itself due to stiffness?
I had 2 ideas:
1. Look at the stepsizes - if they are too small change to implicit. This requires setting some threshold time step size.
2. Run with an implicit code at all times: this has the obvious robustness advantage but likely far slower for nonstiff cases, plus need for Jacobians (which are analytically available).
I would appreciate if somebody could share some insights into such problem.
thank you in advance,
Dmitri
I'm after some general advice on selecting an appropriate ODE solver for a single nonlinear ODE, say dy/dx=f(y,x,B). the ODE solution is inside a Monte Carlo loop and is solved a zillion times with different parameters B in the RHS (that is fairly simple), so efficiency is quite important. Since the ODE itself is approximate, I would be happy with accuracy of the order of <5%.
Runge-Kutta schemes was my first guess, until I considered the possibility of stiffness due to RHS terms such as (-B2*y^B3), so an implicit or semi-implicit solver seemed more appropriate. However, since {B} is a parameter, the stiffness may vary depending on the current trial B (and may not even occur). But since the ODE solver is inside the loop, there would seem to be a need to switch the solver at runtime. Code-wise this is no problem if I knew when to switch solvers. Is there some cheap way to determine when would an explicit Runge-Kutta start to fall over itself due to stiffness?
I had 2 ideas:
1. Look at the stepsizes - if they are too small change to implicit. This requires setting some threshold time step size.
2. Run with an implicit code at all times: this has the obvious robustness advantage but likely far slower for nonstiff cases, plus need for Jacobians (which are analytically available).
I would appreciate if somebody could share some insights into such problem.
thank you in advance,
Dmitri