Class CachingNumericalIntegrator
java.lang.Object
nl.tudelft.simulation.jstats.ode.integrators.NumericalIntegrator
nl.tudelft.simulation.jstats.ode.integrators.CachingNumericalIntegrator
- All Implemented Interfaces:
Serializable
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 Summary
Modifier and TypeFieldDescriptionprotected NumericalIntegrator
The primer integrator.protected int
the substeps to use when starting the integrator.Fields inherited from class nl.tudelft.simulation.jstats.ode.integrators.NumericalIntegrator
equation, error, stepSize
-
Constructor Summary
ConstructorDescriptionCachingNumericalIntegrator
(double stepSize, DifferentialEquationInterface equation, int cachePlaces, NumericalIntegratorType primerIntegrationMethod, int startingSubSteps) constructs a new CachingNumericalIntegrator with a fixed number of cache places. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
getDY
(int numberDown) get a cached dY-value.double[]
getY
(int numberDown) get a cached Y-value.abstract double[]
next
(double x) The integrators that extend the CachingNumericalIntegrator calculate the value of y(x+stepSize) just based on the x-value.double[]
next
(double x, double[] y) computes the next value.void
setStepSize
(double stepSize) Methods inherited from class nl.tudelft.simulation.jstats.ode.integrators.NumericalIntegrator
add, add, add, add, add, getError, getStepSize, multiply
-
Field Details
-
startingIntegrator
The primer integrator. -
startingSubSteps
protected int startingSubStepsthe 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 stepSizeequation
- DifferentialEquationInterface; the differentialEquationcachePlaces
- int; the number of cache places to storeprimerIntegrationMethod
- NumericalIntegratorType; the primer integrator to usestartingSubSteps
- int; the number of sub-steps per stepSize during starting of the integrator
-
-
Method Details
-
setStepSize
public void setStepSize(double stepSize) - Overrides:
setStepSize
in classNumericalIntegrator
- Parameters:
stepSize
- double; The step size to set.
-
next
public double[] next(double x, double[] y) computes the next value.- Specified by:
next
in classNumericalIntegrator
- Parameters:
x
- double; the x value corresponding to the last y-value computedy
- 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)
-