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

public abstract Class EmbeddedRungeKuttaIntegrator

extends AdaptiveStepsizeIntegrator
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.ode.nonstiff.DormandPrince54Integrator, org.apache.commons.math3.ode.nonstiff.HighamHall54Integrator, org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator
Imports
org.apache.commons.math3.exception.DimensionMismatchException, .MaxCountExceededException, .NoBracketingException, .NumberIsTooSmallException, org.apache.commons.math3.ode.ExpandableStatefulODE, org.apache.commons.math3.util.FastMath

This class implements the common part of all embedded Runge-Kutta integrators for Ordinary Differential Equations.

These methods are embedded explicit Runge-Kutta methods with two sets of coefficients allowing to estimate the error, their Butcher arrays are as follows :

   0  |
  c2  | a21
  c3  | a31  a32
  ... |        ...
  cs  | as1  as2  ...  ass-1
      |--------------------------
      |  b1   b2  ...   bs-1  bs
      |  b'1  b'2 ...   b's-1 b's

In fact, we rather use the array defined by ej = bj - b'j to compute directly the error rather than computing two estimates and then comparing them.

Some methods are qualified as fsal (first same as last) methods. This means the last evaluation of the derivatives in one step is the same as the first in the next step. Then, this evaluation can be reused from one step to the next one and the cost of such a method is really s-1 evaluations despite the method still has s stages. This behaviour is true only for successful steps, if the step is rejected after the error estimation phase, no evaluation is saved. For an fsal method, we have cs = 1 and asi = bi for all i.

Since
1.2

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 double
exp

Stepsize control exponent.

private final boolean
fsal

Indicator for fsal methods.

private double
maxGrowth

Maximal growth factor for stepsize control.

private double
minReduction

Minimal reduction factor for stepsize control.

private final RungeKuttaStepInterpolator
prototype

Prototype of the step interpolator.

private double
safety

Safety factor for stepsize control.

Inherited from org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeIntegrator:
mainSetDimensionscalAbsoluteTolerancescalRelativeTolerancevecAbsoluteTolerancevecRelativeTolerance

Constructor Summary

AccessConstructor and Description
protected
EmbeddedRungeKuttaIntegrator(final String
name of the method
name
,
final boolean
indicate that the method is an fsal
fsal
,
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
minimal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this
minStep
,
final double
maximal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this
maxStep
,
final double
allowed absolute error
scalAbsoluteTolerance
,
final double
allowed relative error
scalRelativeTolerance
)

Build a Runge-Kutta integrator with the given Butcher array.

protected
EmbeddedRungeKuttaIntegrator(final String
name of the method
name
,
final boolean
indicate that the method is an fsal
fsal
,
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
minimal step (must be positive even for backward integration), the last step can be smaller than this
minStep
,
final double
maximal step (must be positive even for backward integration)
maxStep
,
final double[]
allowed absolute error
vecAbsoluteTolerance
,
final double[]
allowed relative error
vecRelativeTolerance
)

Build a Runge-Kutta integrator with the given Butcher array.

Method Summary

Modifier and TypeMethod and Description
protected abstract double

Returns:

error ratio, greater than 1 if step should be rejected
estimateError
(double[][]
derivatives computed during the first stages
yDotK
,
double[]
estimate of the step at the start of the step
y0
,
double[]
estimate of the step at the end of the step
y1
,
double
current step
h
)

Compute the error ratio.

public double

Returns:

maximal growth factor
getMaxGrowth
()

Get the maximal growth factor for stepsize control.

public double

Returns:

minimal reduction factor
getMinReduction
()

Get the minimal reduction factor for stepsize control.

public abstract int

Returns:

order of the method
getOrder
()

Get the order of the method.

public double

Returns:

safety factor
getSafety
()

Get the safety factor for stepsize control.

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.nonstiff.AdaptiveStepsizeIntegrator.integrate.

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

public void
setMaxGrowth(final double
maximal growth factor
maxGrowth
)

Set the maximal growth factor for stepsize control.

public void
setMinReduction(final double
minimal reduction factor
minReduction
)

Set the minimal reduction factor for stepsize control.

public void
setSafety(final double
safety factor
safety
)

Set the safety factor for stepsize control.

Inherited from org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeIntegrator:
filterStepgetCurrentStepStartgetMaxStepgetMinStepinitializeStepresetInternalStatesanityCheckssetInitialStepSizesetStepSizeControlsetStepSizeControl

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).

expback to summary
private final double exp

Stepsize control exponent.

fsalback to summary
private final boolean fsal

Indicator for fsal methods.

maxGrowthback to summary
private double maxGrowth

Maximal growth factor for stepsize control.

minReductionback to summary
private double minReduction

Minimal reduction factor for stepsize control.

prototypeback to summary
private final RungeKuttaStepInterpolator prototype

Prototype of the step interpolator.

safetyback to summary
private double safety

Safety factor for stepsize control.

Constructor Detail

EmbeddedRungeKuttaIntegratorback to summary
protected EmbeddedRungeKuttaIntegrator(final String name, final boolean fsal, final double[] c, final double[][] a, final double[] b, final RungeKuttaStepInterpolator prototype, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance)

Build a Runge-Kutta integrator with the given Butcher array.

Parameters
name:String

name of the method

fsal:boolean

indicate that the method is an fsal

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

minStep:double

minimal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this

maxStep:double

maximal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this

scalAbsoluteTolerance:double

allowed absolute error

scalRelativeTolerance:double

allowed relative error

EmbeddedRungeKuttaIntegratorback to summary
protected EmbeddedRungeKuttaIntegrator(final String name, final boolean fsal, final double[] c, final double[][] a, final double[] b, final RungeKuttaStepInterpolator prototype, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance)

Build a Runge-Kutta integrator with the given Butcher array.

Parameters
name:String

name of the method

fsal:boolean

indicate that the method is an fsal

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

minStep:double

minimal step (must be positive even for backward integration), the last step can be smaller than this

maxStep:double

maximal step (must be positive even for backward integration)

vecAbsoluteTolerance:double[]

allowed absolute error

vecRelativeTolerance:double[]

allowed relative error

Method Detail

estimateErrorback to summary
protected abstract double estimateError(double[][] yDotK, double[] y0, double[] y1, double h)

Compute the error ratio.

Parameters
yDotK:double[][]

derivatives computed during the first stages

y0:double[]

estimate of the step at the start of the step

y1:double[]

estimate of the step at the end of the step

h:double

current step

Returns:double

error ratio, greater than 1 if step should be rejected

getMaxGrowthback to summary
public double getMaxGrowth()

Get the maximal growth factor for stepsize control.

Returns:double

maximal growth factor

getMinReductionback to summary
public double getMinReduction()

Get the minimal reduction factor for stepsize control.

Returns:double

minimal reduction factor

getOrderback to summary
public abstract int getOrder()

Get the order of the method.

Returns:int

order of the method

getSafetyback to summary
public double getSafety()

Get the safety factor for stepsize control.

Returns:double

safety factor

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

Implements abstract org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeIntegrator.integrate.

Doc from org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeIntegrator.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

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

complete set of differential equations to integrate

t:double

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

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

Annotations
@Override
Exceptions
NumberIsTooSmallException:

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

if integration step is too small

DimensionMismatchException:

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

if the dimension of the complete state does not match the complete equations sets dimension

MaxCountExceededException:

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

if the number of functions evaluations is exceeded

NoBracketingException:

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

if the location of an event cannot be bracketed

setMaxGrowthback to summary
public void setMaxGrowth(final double maxGrowth)

Set the maximal growth factor for stepsize control.

Parameters
maxGrowth:double

maximal growth factor

setMinReductionback to summary
public void setMinReduction(final double minReduction)

Set the minimal reduction factor for stepsize control.

Parameters
minReduction:double

minimal reduction factor

setSafetyback to summary
public void setSafety(final double safety)

Set the safety factor for stepsize control.

Parameters
safety:double

safety factor