Class NumericalIntegrator

java.lang.Object
nl.tudelft.simulation.jstats.ode.integrators.NumericalIntegrator
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CachingNumericalIntegrator, Euler, Gill, Heun, RungeKutta3, RungeKutta4, RungeKuttaCashCarp, RungeKuttaFehlberg

public abstract class NumericalIntegrator extends Object implements Serializable
Provides basic methods for all numerical integration methods. They mostly include matrix computation.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Author:
Alexander Verbraeck, Peter Jacobs
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    the equation to integrate.
    protected double[]
    the calculated error of the last step.
    protected double
    the step size to use.
  • Constructor Summary

    Constructors
    Constructor
    Description
    constructs a new NumericalIntegrator.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected double[]
    add(double[] a, double[] b)
    adds two vectors.
    protected double[]
    add(double[] a, double[] b, double[] c)
    adds a number of vectors.
    protected double[]
    add(double[] a, double[] b, double[] c, double[] d)
    adds a number of vectors.
    protected double[]
    add(double[] a, double[] b, double[] c, double[] d, double[] e)
    adds a number of vectors.
    protected double[]
    add(double[] a, double[] b, double[] c, double[] d, double[] e, double[] f)
    adds a number of vectors.
    double[]
     
    double
     
    protected double[]
    multiply(double constant, double[] vector)
    multiplies a vector with a constant.
    abstract double[]
    next(double x, double[] y)
    computes the next value.
    void
    setStepSize(double stepSize)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • stepSize

      protected double stepSize
      the step size to use.
    • error

      protected double[] error
      the calculated error of the last step.
    • equation

      protected DifferentialEquationInterface equation
      the equation to integrate.
  • Constructor Details

    • NumericalIntegrator

      public NumericalIntegrator(double stepSize, DifferentialEquationInterface equation)
      constructs a new NumericalIntegrator.
      Parameters:
      stepSize - double; the stepSize
      equation - DifferentialEquationInterface; the differentialEquation
  • Method Details

    • next

      public abstract double[] next(double x, double[] y)
      computes the next value.
      Parameters:
      x - double; the x value corresponding to the last y-value computed
      y - double[]; the last y value
      Returns:
      the new value
    • multiply

      protected double[] multiply(double constant, double[] vector)
      multiplies a vector with a constant.
      Parameters:
      constant - double; the constant
      vector - double[]; the vector
      Returns:
      the new vector
    • add

      protected double[] add(double[] a, double[] b)
      adds two vectors.
      Parameters:
      a - double[]; vector a
      b - double[]; vector b
      Returns:
      the new vector
    • add

      protected double[] add(double[] a, double[] b, double[] c)
      adds a number of vectors.
      Parameters:
      a - double[]; vector a
      b - double[]; vector b
      c - double[]; vector c
      Returns:
      the new vector
    • add

      protected double[] add(double[] a, double[] b, double[] c, double[] d)
      adds a number of vectors.
      Parameters:
      a - double[]; vector a
      b - double[]; vector b
      c - double[]; vector c
      d - double[]; vector d
      Returns:
      the sum
    • add

      protected double[] add(double[] a, double[] b, double[] c, double[] d, double[] e)
      adds a number of vectors.
      Parameters:
      a - double[]; vector a
      b - double[]; vector b
      c - double[]; vector c
      d - double[]; vector d
      e - double[]; vector e
      Returns:
      the sum
    • add

      protected double[] add(double[] a, double[] b, double[] c, double[] d, double[] e, double[] f)
      adds a number of vectors.
      Parameters:
      a - double[]; vector a
      b - double[]; vector b
      c - double[]; vector c
      d - double[]; vector d
      e - double[]; vector e
      f - double[]; vector f
      Returns:
      the sum
    • getStepSize

      public double getStepSize()
      Returns:
      Returns the current step size.
    • setStepSize

      public void setStepSize(double stepSize)
      Parameters:
      stepSize - double; The step size to set.
    • getError

      public double[] getError()
      Returns:
      Returns the error.