Class RungeKuttaIntegrator
- java.lang.Object
-
- org.apache.commons.math4.legacy.ode.AbstractIntegrator
-
- org.apache.commons.math4.legacy.ode.nonstiff.RungeKuttaIntegrator
-
- All Implemented Interfaces:
FirstOrderIntegrator
,ODEIntegrator
- Direct Known Subclasses:
ClassicalRungeKuttaIntegrator
,EulerIntegrator
,GillIntegrator
,LutherIntegrator
,MidpointIntegrator
,ThreeEighthesIntegrator
public abstract class RungeKuttaIntegrator extends AbstractIntegrator
This class implements the common part of all fixed step Runge-Kutta integrators for Ordinary Differential Equations.These methods are explicit Runge-Kutta methods, their Butcher arrays are as follows :
0 | c2 | a21 c3 | a31 a32 ... | ... cs | as1 as2 ... ass-1 |-------------------------- | b1 b2 ... bs-1 bs
- Since:
- 1.2
- See Also:
EulerIntegrator
,ClassicalRungeKuttaIntegrator
,GillIntegrator
,MidpointIntegrator
-
-
Field Summary
-
Fields inherited from class org.apache.commons.math4.legacy.ode.AbstractIntegrator
isLastStep, resetOccurred, stepHandlers, stepSize, stepStart
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RungeKuttaIntegrator(String name, double[] c, double[][] a, double[] b, org.apache.commons.math4.legacy.ode.nonstiff.RungeKuttaStepInterpolator prototype, double step)
Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
integrate(ExpandableStatefulODE equations, double t)
Integrate a set of differential equations up to the given time.double[]
singleStep(FirstOrderDifferentialEquations equations, double t0, double[] y0, double t)
Fast computation of a single step of ODE integration.-
Methods inherited from class org.apache.commons.math4.legacy.ode.AbstractIntegrator
acceptStep, addEventHandler, addEventHandler, addStepHandler, clearEventHandlers, clearStepHandlers, computeDerivatives, getCounter, getCurrentSignedStepsize, getCurrentStepStart, getEvaluations, getEventHandlers, getExpandable, getMaxEvaluations, getName, getStepHandlers, initIntegration, integrate, sanityChecks, setEquations, setMaxEvaluations, setStateInitialized
-
-
-
-
Constructor Detail
-
RungeKuttaIntegrator
protected RungeKuttaIntegrator(String name, double[] c, double[][] a, double[] b, org.apache.commons.math4.legacy.ode.nonstiff.RungeKuttaStepInterpolator prototype, double step)
Simple constructor. Build a Runge-Kutta integrator with the given step. The default step handler does nothing.- Parameters:
name
- name of the methodc
- time steps from Butcher array (without the first zero)a
- internal weights from Butcher array (without the first empty row)b
- propagation weights for the high order method from Butcher arrayprototype
- prototype of the step interpolator to usestep
- integration step
-
-
Method Detail
-
integrate
public void integrate(ExpandableStatefulODE equations, double t) throws NumberIsTooSmallException, DimensionMismatchException, MaxCountExceededException, NoBracketingException
Integrate a set of differential equations up to the given time.This method solves an Initial Value Problem (IVP).
The set of differential equations is composed of a main set, which can be extended by some sets of secondary equations. The set of equations must be already set up with initial time and partial states. At integration completion, the final time and partial states will be available in the same object.
Since this method stores some internal state variables made available in its public interface during integration (
AbstractIntegrator.getCurrentSignedStepsize()
), it is not thread-safe.- Specified by:
integrate
in classAbstractIntegrator
- Parameters:
equations
- complete set of differential equations to integratet
- target time for the integration (can be set to a value smaller thant0
for backward integration)- Throws:
NumberIsTooSmallException
- if integration step is too smallDimensionMismatchException
- if the dimension of the complete state does not match the complete equations sets dimensionMaxCountExceededException
- if the number of functions evaluations is exceededNoBracketingException
- if the location of an event cannot be bracketed
-
singleStep
public double[] singleStep(FirstOrderDifferentialEquations equations, double t0, double[] y0, double t)
Fast computation of a single step of ODE integration.This method is intended for the limited use case of very fast computation of only one step without using any of the rich features of general integrators that may take some time to set up (i.e. no step handlers, no events handlers, no additional states, no interpolators, no error control, no evaluations count, no sanity checks ...). It handles the strict minimum of computation, so it can be embedded in outer loops.
This method is not used at all by the
integrate(ExpandableStatefulODE, double)
method. It also completely ignores the step set at construction time, and uses only a single step to go fromt0
tot
.As this method does not use any of the state-dependent features of the integrator, it should be reasonably thread-safe if and only if the provided differential equations are themselves thread-safe.
- Parameters:
equations
- differential equations to integratet0
- initial timey0
- initial value of the state vector at t0t
- target time for the integration (can be set to a value smaller thant0
for backward integration)- Returns:
- state vector at
t
-
-