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
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
Modifier and TypeFieldDescriptionprotected DifferentialEquationInterface
the equation to integrate.protected double[]
the calculated error of the last step.protected double
the step size to use. -
Constructor Summary
ConstructorDescriptionNumericalIntegrator
(double stepSize, DifferentialEquationInterface equation) constructs a new NumericalIntegrator. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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[]
getError()
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)
-
Field Details
-
stepSize
protected double stepSizethe step size to use. -
error
protected double[] errorthe calculated error of the last step. -
equation
the equation to integrate.
-
-
Constructor Details
-
NumericalIntegrator
constructs a new NumericalIntegrator.- Parameters:
stepSize
- double; the stepSizeequation
- 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 computedy
- 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 constantvector
- double[]; the vector- Returns:
- the new vector
-
add
protected double[] add(double[] a, double[] b) adds two vectors.- Parameters:
a
- double[]; vector ab
- 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 ab
- double[]; vector bc
- 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 ab
- double[]; vector bc
- double[]; vector cd
- 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 ab
- double[]; vector bc
- double[]; vector cd
- double[]; vector de
- 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 ab
- double[]; vector bc
- double[]; vector cd
- double[]; vector de
- double[]; vector ef
- 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.
-