Top Description Fields Constructors Methods
org.apache.commons.math3.ode.nonstiff

public abstract Class RungeKuttaIntegrator

extends AbstractIntegrator
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.ode.nonstiff.ThreeEighthesIntegrator, org.apache.commons.math3.ode.nonstiff.EulerIntegrator, org.apache.commons.math3.ode.nonstiff.GillIntegrator, org.apache.commons.math3.ode.nonstiff.ClassicalRungeKuttaIntegrator, org.apache.commons.math3.ode.nonstiff.LutherIntegrator, org.apache.commons.math3.ode.nonstiff.MidpointIntegrator
Imports
org.apache.commons.math3.exception.DimensionMismatchException, .MaxCountExceededException, .NoBracketingException, .NumberIsTooSmallException, org.apache.commons.math3.ode.AbstractIntegrator, .ExpandableStatefulODE, .FirstOrderDifferentialEquations, org.apache.commons.math3.util.FastMath

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

Modifier and TypeField and Description
private final double[][]
a

Internal weights from Butcher array (without the first empty row).

private final double[]
b

External weights for the high order method from Butcher array.

private final double[]
c

Time steps from Butcher array (without the first zero).

private final RungeKuttaStepInterpolator
prototype

Prototype of the step interpolator.

private final double
step

Integration step.

Inherited from org.apache.commons.math3.ode.AbstractIntegrator:
isLastStepresetOccurredstepHandlersstepSizestepStart

Constructor Summary

AccessConstructor and Description
protected
RungeKuttaIntegrator(final String
name of the method
name
,
final double[]
time steps from Butcher array (without the first zero)
c
,
final double[][]
internal weights from Butcher array (without the first empty row)
a
,
final double[]
propagation weights for the high order method from Butcher array
b
,
final RungeKuttaStepInterpolator
prototype of the step interpolator to use
prototype
,
final double
integration step
step
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public void
integrate(final ExpandableStatefulODE
complete set of differential equations to integrate
equations
,
final double
target time for the integration (can be set to a value smaller than t0 for backward integration)
t
)

Implements abstract org.apache.commons.math3.ode.AbstractIntegrator.integrate.

Integrate a set of differential equations up to the given time.

public double[]

Returns:

state vector at t
singleStep
(final FirstOrderDifferentialEquations
differential equations to integrate
equations
,
final double
initial time
t0
,
final double[]
initial value of the state vector at t0
y0
,
final double
target time for the integration (can be set to a value smaller than t0 for backward integration)
t
)

Fast computation of a single step of ODE integration.

Inherited from org.apache.commons.math3.ode.AbstractIntegrator:
acceptStepaddEventHandleraddEventHandleraddStepHandlerclearEventHandlersclearStepHandlerscomputeDerivativesgetCountergetCurrentSignedStepsizegetCurrentStepStartgetEvaluationsgetEvaluationsCountergetEventHandlersgetExpandablegetMaxEvaluationsgetNamegetStepHandlersinitIntegrationintegratesanityCheckssetEquationssetMaxEvaluationssetStateInitialized

Field Detail

aback to summary
private final double[][] a

Internal weights from Butcher array (without the first empty row).

bback to summary
private final double[] b

External weights for the high order method from Butcher array.

cback to summary
private final double[] c

Time steps from Butcher array (without the first zero).

prototypeback to summary
private final RungeKuttaStepInterpolator prototype

Prototype of the step interpolator.

stepback to summary
private final double step

Integration step.

Constructor Detail

RungeKuttaIntegratorback to summary
protected RungeKuttaIntegrator(final String name, final double[] c, final double[][] a, final double[] b, final RungeKuttaStepInterpolator prototype, final double step)

Simple constructor. Build a Runge-Kutta integrator with the given step. The default step handler does nothing.

Parameters
name:String

name of the method

c:double[]

time steps from Butcher array (without the first zero)

a:double[][]

internal weights from Butcher array (without the first empty row)

b:double[]

propagation weights for the high order method from Butcher array

prototype:RungeKuttaStepInterpolator

prototype of the step interpolator to use

step:double

integration step

Method Detail

integrateback to summary
public void integrate(final ExpandableStatefulODE equations, final double t) throws NumberIsTooSmallException, DimensionMismatchException, MaxCountExceededException, NoBracketingException

Implements abstract org.apache.commons.math3.ode.AbstractIntegrator.integrate.

Doc from org.apache.commons.math3.ode.AbstractIntegrator.integrate.

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 (getCurrentSignedStepsize()), it is not thread-safe.

Parameters
equations:ExpandableStatefulODE

complete set of differential equations to integrate

t:double

target time for the integration (can be set to a value smaller than t0 for backward integration)

Annotations
@Override
Exceptions
NumberIsTooSmallException:
if integration step is too small
DimensionMismatchException:
if the dimension of the complete state does not match the complete equations sets dimension
MaxCountExceededException:
if the number of functions evaluations is exceeded
NoBracketingException:
if the location of an event cannot be bracketed
singleStepback to summary
public double[] singleStep(final FirstOrderDifferentialEquations equations, final double t0, final double[] y0, final 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 from t0 to t.

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:FirstOrderDifferentialEquations

differential equations to integrate

t0:double

initial time

y0:double[]

initial value of the state vector at t0

t:double

target time for the integration (can be set to a value smaller than t0 for backward integration)

Returns:double[]

state vector at t