Class ODESolver

  • All Implemented Interfaces:
    java.io.Serializable

    public class ODESolver
    extends java.lang.Object
    implements java.io.Serializable
    use this class to solve any ODE system. the integrator and state array size can be changed at any time currently Euler and Runge-Kutta 4 can be used as fixed-step-size integrators currently Runge-Kutta Fehlberg 4,5 exists as an adaptive-step-size integrator
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ODESolver()  
    • Method Summary

      Modifier and Type Method Description
      void Euler​(Derivative Derivative, double[] state, double[] out, double t, double dt)
      runs 1 round of Euler integration, putting the result in the out array
      void Euler​(Derivative Derivative, double[] state, double[] out, double t0, double tf, double dt)
      runs Euler integration from t0 to tf in increments of dt
      void Euler​(Derivative Derivative, double[] state, double t, double dt)
      runs 1 round of Euler integration, putting the result in the state array
      void Euler​(Derivative Derivative, java.util.ArrayList<double[]> states, java.util.ArrayList<java.lang.Double> ts, double tf, double dt, int startStateIndex)
      runs Euler integration from t0 to tf in increments of dt, puts the resulting states in the states array, and the resulting ts in the ts array
      void Runge4​(Derivative Derivative, double[] state, double[] out, double t, double dt)
      runs 1 round of Runge-Kutta 4 integration, putting the result in the out array
      void Runge4​(Derivative Derivative, double[] state, double t, double dt)
      runs 1 round of Runge-Kutta 4 integration, putting the result in the state array
      void Runge4​(Derivative Derivative, double[] state, double t0, double tf, double dt)
      runs Runge-Kutta 4 integration from t0 to tf in increments of dt
      void Runge4​(Derivative Derivative, java.util.ArrayList<double[]> states, java.util.ArrayList<java.lang.Double> ts, double tf, double dt, int startStateIndex)
      runs Runge-Kutta 4,5 integration from t0 to tf in increments of dt, puts the resulting states in the states array, and the resulting ts in the ts array
      double Runge45​(Derivative Derivative, double[] state, double[] out, double t0, double tf, double dtStart, double errorTolerance)
      calls runge kutta 4,5 iteratively, updating the state array until tf.
      double Runge45​(Derivative Derivative, double[] state, double[] out, double t0, double tf, double dtStart, double errorTolerance, double dtMin, double dtMax)
      calls runge kutta 4,5 iteratively, updating the state array until tf.
      double Runge45​(Derivative Derivative, double[] state, double t0, double tf, double dtStart, double errorTolerance)  
      double Runge45​(Derivative Derivative, double[] state, double t0, double tf, double dtStart, double errorTolerance, double dtMin, double dtMax)  
      int Runge45​(Derivative Derivative, java.util.ArrayList<double[]> states, java.util.ArrayList<java.lang.Double> ts, double tf, double dtStart, double errorTolerance, int startStateIndex)
      calls runge kutta 4,5 iteratively, putting new states and the times for which those states were computed into the states and ts arraylists.
      int Runge45​(Derivative Derivative, java.util.ArrayList<double[]> states, java.util.ArrayList<java.lang.Double> ts, double tf, double dtStart, double errorTolerance, int startStateIndex, double dtMin, double dtMax)
      calls runge kutta 4,5 iteratively, putting new states and the times for which those states were computed into the states and ts arraylists.
      • Methods inherited from class java.lang.Object

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

      • ODESolver

        public ODESolver()
    • Method Detail

      • Euler

        public void Euler​(Derivative Derivative,
                          double[] state,
                          double[] out,
                          double t,
                          double dt)
        runs 1 round of Euler integration, putting the result in the out array
      • Euler

        public void Euler​(Derivative Derivative,
                          double[] state,
                          double t,
                          double dt)
        runs 1 round of Euler integration, putting the result in the state array
      • Euler

        public void Euler​(Derivative Derivative,
                          double[] state,
                          double[] out,
                          double t0,
                          double tf,
                          double dt)
        runs Euler integration from t0 to tf in increments of dt
      • Euler

        public void Euler​(Derivative Derivative,
                          java.util.ArrayList<double[]> states,
                          java.util.ArrayList<java.lang.Double> ts,
                          double tf,
                          double dt,
                          int startStateIndex)
        runs Euler integration from t0 to tf in increments of dt, puts the resulting states in the states array, and the resulting ts in the ts array
      • Runge4

        public void Runge4​(Derivative Derivative,
                           double[] state,
                           double[] out,
                           double t,
                           double dt)
        runs 1 round of Runge-Kutta 4 integration, putting the result in the out array
      • Runge4

        public void Runge4​(Derivative Derivative,
                           double[] state,
                           double t,
                           double dt)
        runs 1 round of Runge-Kutta 4 integration, putting the result in the state array
      • Runge4

        public void Runge4​(Derivative Derivative,
                           double[] state,
                           double t0,
                           double tf,
                           double dt)
        runs Runge-Kutta 4 integration from t0 to tf in increments of dt
      • Runge4

        public void Runge4​(Derivative Derivative,
                           java.util.ArrayList<double[]> states,
                           java.util.ArrayList<java.lang.Double> ts,
                           double tf,
                           double dt,
                           int startStateIndex)
        runs Runge-Kutta 4,5 integration from t0 to tf in increments of dt, puts the resulting states in the states array, and the resulting ts in the ts array
      • Runge45

        public double Runge45​(Derivative Derivative,
                              double[] state,
                              double[] out,
                              double t0,
                              double tf,
                              double dtStart,
                              double errorTolerance)
        calls runge kutta 4,5 iteratively, updating the state array until tf. returns the final dt that works for the provided tolerance. dtStart is the starting stepsize
      • Runge45

        public double Runge45​(Derivative Derivative,
                              double[] state,
                              double[] out,
                              double t0,
                              double tf,
                              double dtStart,
                              double errorTolerance,
                              double dtMin,
                              double dtMax)
        calls runge kutta 4,5 iteratively, updating the state array until tf. returns the final dt that works for the provided tolerance. dtStart is the starting stepsize
      • Runge45

        public double Runge45​(Derivative Derivative,
                              double[] state,
                              double t0,
                              double tf,
                              double dtStart,
                              double errorTolerance)
      • Runge45

        public double Runge45​(Derivative Derivative,
                              double[] state,
                              double t0,
                              double tf,
                              double dtStart,
                              double errorTolerance,
                              double dtMin,
                              double dtMax)
      • Runge45

        public int Runge45​(Derivative Derivative,
                           java.util.ArrayList<double[]> states,
                           java.util.ArrayList<java.lang.Double> ts,
                           double tf,
                           double dtStart,
                           double errorTolerance,
                           int startStateIndex)
        calls runge kutta 4,5 iteratively, putting new states and the times for which those states were computed into the states and ts arraylists. dtStart is the starting stepsize
      • Runge45

        public int Runge45​(Derivative Derivative,
                           java.util.ArrayList<double[]> states,
                           java.util.ArrayList<java.lang.Double> ts,
                           double tf,
                           double dtStart,
                           double errorTolerance,
                           int startStateIndex,
                           double dtMin,
                           double dtMax)
        calls runge kutta 4,5 iteratively, putting new states and the times for which those states were computed into the states and ts arraylists. dtStart is the starting stepsize