Class RKF45
-
- All Implemented Interfaces:
public final class RKF45Runge-Kutta-Fehlberg 4(5) adaptive ODE integrator for nonstiff and mildly stiff systems of first-order ODEs.
This class maintains internal state (step size, counters) between calls so that integration can be continued by calling integrate repeatedly with new output times.
Usage:
val solver = RKF45(neqn) var result = solver.integrate(f, y0, yp0, t0, tout, relerr, abserr, 1) // continue to next output point result = solver.integrate(f, result.y, result.yp, result.t, tout2, result.relerr, abserr, result.flag)Flag values on return:
2 normal return, integration reached tout
-2 normal return in single-step mode
3 relerr was too small and has been increased; reset flag to 2 to continue
4 more than MAXNFE (3000) derivative evaluations; call again to continue
5 solution vanished, making pure relative error test impossible; set nonzero abserr
6 requested accuracy could not be achieved with smallest step; increase tolerances
7 too much output is restricting step choice; use single-step mode
8 invalid input parameters
-
-
Method Summary
Modifier and Type Method Description final Unitreset()Reset internal state so the next call is treated as a fresh start. final RKF45Resultintegrate(OdeFunction f, DoubleArray yIn, DoubleArray ypIn, Double tIn, Double tout, Double relerr, Double abserr, Integer flag)Carry out the Runge-Kutta-Fehlberg method. -
-
Constructor Detail
-
RKF45
RKF45(Integer neqn)
-
-
Method Detail
-
integrate
final RKF45Result integrate(OdeFunction f, DoubleArray yIn, DoubleArray ypIn, Double tIn, Double tout, Double relerr, Double abserr, Integer flag)
Carry out the Runge-Kutta-Fehlberg method.
- Parameters:
f- right-hand side functionyIn- current solution vector (length neqn); not modifiedypIn- current derivative vector (length neqn); not modifiedtIn- current value of the independent variabletout- desired output timerelerr- relative error tolerance (may be increased on return)abserr- absolute error toleranceflag- status flag (+1 or -1 for first call, +2/-2 for continuation)- Returns:
RKF45Result with updated y, yp, t, flag, and relerr
-
-
-
-