Package jline.lib.ode

Class RKF45

  • All Implemented Interfaces:

    
    public final class RKF45
    
                        

    Runge-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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      RKF45(Integer neqn)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit reset() Reset internal state so the next call is treated as a fresh start.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • reset

         final Unit reset()

        Reset internal state so the next call is treated as a fresh start.

      • 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 function
        yIn - current solution vector (length neqn); not modified
        ypIn - current derivative vector (length neqn); not modified
        tIn - current value of the independent variable
        tout - desired output time
        relerr - relative error tolerance (may be increased on return)
        abserr - absolute error tolerance
        flag - status flag (+1 or -1 for first call, +2/-2 for continuation)
        Returns:

        RKF45Result with updated y, yp, t, flag, and relerr