Class CachingNumericalIntegrator

java.lang.Object
nl.tudelft.simulation.jstats.ode.integrators.NumericalIntegrator
nl.tudelft.simulation.jstats.ode.integrators.CachingNumericalIntegrator
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Adams, Milne

public abstract class CachingNumericalIntegrator extends NumericalIntegrator
The CachingNumericalIntegrator is the basis for an integrator that needs access to previously calculated values of y', e.g. y'_(k-1), y'_(k-2), etc.

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
See Also:
  • Field Details

    • startingIntegrator

      protected NumericalIntegrator startingIntegrator
      The primer integrator.
    • startingSubSteps

      protected int startingSubSteps
      the substeps to use when starting the integrator.
  • Constructor Details

    • CachingNumericalIntegrator

      public CachingNumericalIntegrator(double stepSize, DifferentialEquationInterface equation, int cachePlaces, NumericalIntegratorType primerIntegrationMethod, int startingSubSteps)
      constructs a new CachingNumericalIntegrator with a fixed number of cache places.
      Parameters:
      stepSize - double; the stepSize
      equation - DifferentialEquationInterface; the differentialEquation
      cachePlaces - int; the number of cache places to store
      primerIntegrationMethod - NumericalIntegratorType; the primer integrator to use
      startingSubSteps - int; the number of sub-steps per stepSize during starting of the integrator
  • Method Details

    • setStepSize

      public void setStepSize(double stepSize)
      Overrides:
      setStepSize in class NumericalIntegrator
      Parameters:
      stepSize - double; The step size to set.
    • next

      public double[] next(double x, double[] y)
      computes the next value.
      Specified by:
      next in class NumericalIntegrator
      Parameters:
      x - double; the x value corresponding to the last y-value computed
      y - double[]; the last y value
      Returns:
      the new value
    • getY

      public double[] getY(int numberDown)
      get a cached Y-value.
      Parameters:
      numberDown - int; the number of the previous value we want
      Returns:
      the corresponding Y-value
    • getDY

      public double[] getDY(int numberDown)
      get a cached dY-value.
      Parameters:
      numberDown - int; the number of the previous value we want
      Returns:
      the corresponding dY-value
    • next

      public abstract double[] next(double x)
      The integrators that extend the CachingNumericalIntegrator calculate the value of y(x+stepSize) just based on the x-value. They retrieve y(x), y(x-stepSize), etc. or y(k), y(k-1) all from the cache.
      Parameters:
      x - double; the x-value to use in the calculation
      Returns:
      the value of y(x+stepSize)