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

public abstract Class EmbeddedRungeKuttaFieldIntegrator<T extends RealFieldElement<T>>

extends AdaptiveStepsizeFieldIntegrator<T extends RealFieldElement<T>>
implements FieldButcherArrayProvider<T extends RealFieldElement<T>>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.ode.nonstiff.FieldButcherArrayProvider
Known Direct Subclasses
org.apache.commons.math3.ode.nonstiff.DormandPrince853FieldIntegrator, org.apache.commons.math3.ode.nonstiff.DormandPrince54FieldIntegrator, org.apache.commons.math3.ode.nonstiff.HighamHall54FieldIntegrator
Type Parameters
<T>
the type of the field elements
Imports
org.apache.commons.math3.Field, .RealFieldElement, org.apache.commons.math3.exception.DimensionMismatchException, .MaxCountExceededException, .NoBracketingException, .NumberIsTooSmallException, org.apache.commons.math3.ode.FieldEquationsMapper, .FieldExpandableODE, .FieldODEState, .FieldODEStateAndDerivative, org.apache.commons.math3.util.MathArrays, .MathUtils

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
3.6

Field Summary

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

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

private final T[]
b

External weights for the high order method from Butcher array.

private final T[]
c

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

private final T
exp

Stepsize control exponent.

private final int
fsal

Index of the pre-computed derivative for fsal methods.

private T
maxGrowth

Maximal growth factor for stepsize control.

private T
minReduction

Minimal reduction factor for stepsize control.

private T
safety

Safety factor for stepsize control.

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

Constructor Summary

AccessConstructor and Description
protected
EmbeddedRungeKuttaFieldIntegrator(final Field<T>
field to which the time and state vector elements belong
field
,
final String
name of the method
name
,
final int
index of the pre-computed derivative for fsal methods or -1 if method is not fsal
fsal
,
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
EmbeddedRungeKuttaFieldIntegrator(final Field<T>
field to which the time and state vector elements belong
field
,
final String
name of the method
name
,
final int
index of the pre-computed derivative for fsal methods or -1 if method is not fsal
fsal
,
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 RungeKuttaFieldStepInterpolator<T>

Returns:

external weights for the high order method from Butcher array
createInterpolator
(boolean
integration direction indicator
forward
,
T[][]
slopes at the intermediate points
yDotK
,
final FieldODEStateAndDerivative<T>
start of the global step
globalPreviousState
,
final FieldODEStateAndDerivative<T>
end of the global step
globalCurrentState
,
FieldEquationsMapper<T>
equations mapper for the all equations
mapper
)

Create an interpolator.

protected abstract T

Returns:

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

Compute the error ratio.

protected T

Returns:

p/q computed in the instance field
fraction
(final int
numerator
p
,
final int
denominator
q
)

Create a fraction.

protected T

Returns:

p/q computed in the instance field
fraction
(final double
numerator
p
,
final double
denominator
q
)

Create a fraction.

public T

Returns:

maximal growth factor
getMaxGrowth
()

Get the maximal growth factor for stepsize control.

public T

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 T

Returns:

safety factor
getSafety
()

Get the safety factor for stepsize control.

public FieldODEStateAndDerivative<T>
integrate(final FieldExpandableODE<T>
differential equations to integrate
equations
,
final FieldODEState<T>
initial state (time, primary and secondary state vectors)
initialState
,
final T
target time for the integration (can be set to a value smaller than t0 for backward integration)
finalTime
)

Implements org.apache.commons.math3.ode.FirstOrderFieldIntegrator.integrate.

Integrate the differential equations up to the given time.

public void
setMaxGrowth(final T
maximal growth factor
maxGrowth
)

Set the maximal growth factor for stepsize control.

public void
setMinReduction(final T
minimal reduction factor
minReduction
)

Set the minimal reduction factor for stepsize control.

public void
setSafety(final T
safety factor
safety
)

Set the safety factor for stepsize control.

Inherited from org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeFieldIntegrator:
filterStepgetMaxStepgetMinStepinitializeStepresetInternalStatesanityCheckssetInitialStepSizesetStepSizeControlsetStepSizeControl

Field Detail

aback to summary
private final T[][] a

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

bback to summary
private final T[] b

External weights for the high order method from Butcher array.

cback to summary
private final T[] c

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

expback to summary
private final T exp

Stepsize control exponent.

fsalback to summary
private final int fsal

Index of the pre-computed derivative for fsal methods.

maxGrowthback to summary
private T maxGrowth

Maximal growth factor for stepsize control.

minReductionback to summary
private T minReduction

Minimal reduction factor for stepsize control.

safetyback to summary
private T safety

Safety factor for stepsize control.

Constructor Detail

EmbeddedRungeKuttaFieldIntegratorback to summary
protected EmbeddedRungeKuttaFieldIntegrator(final Field<T> field, final String name, final int fsal, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance)

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

Parameters
field:Field<T>

field to which the time and state vector elements belong

name:String

name of the method

fsal:int

index of the pre-computed derivative for fsal methods or -1 if method is not fsal

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

EmbeddedRungeKuttaFieldIntegratorback to summary
protected EmbeddedRungeKuttaFieldIntegrator(final Field<T> field, final String name, final int fsal, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance)

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

Parameters
field:Field<T>

field to which the time and state vector elements belong

name:String

name of the method

fsal:int

index of the pre-computed derivative for fsal methods or -1 if method is not fsal

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

createInterpolatorback to summary
protected abstract RungeKuttaFieldStepInterpolator<T> createInterpolator(boolean forward, T[][] yDotK, final FieldODEStateAndDerivative<T> globalPreviousState, final FieldODEStateAndDerivative<T> globalCurrentState, FieldEquationsMapper<T> mapper)

Create an interpolator.

Parameters
forward:boolean

integration direction indicator

yDotK:T[][]

slopes at the intermediate points

globalPreviousState:FieldODEStateAndDerivative<T>

start of the global step

globalCurrentState:FieldODEStateAndDerivative<T>

end of the global step

mapper:FieldEquationsMapper<T>

equations mapper for the all equations

Returns:RungeKuttaFieldStepInterpolator<T>

external weights for the high order method from Butcher array

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

Compute the error ratio.

Parameters
yDotK:T[][]

derivatives computed during the first stages

y0:T[]

estimate of the step at the start of the step

y1:T[]

estimate of the step at the end of the step

h:T

current step

Returns:T

error ratio, greater than 1 if step should be rejected

fractionback to summary
protected T fraction(final int p, final int q)

Create a fraction.

Parameters
p:int

numerator

q:int

denominator

Returns:T

p/q computed in the instance field

fractionback to summary
protected T fraction(final double p, final double q)

Create a fraction.

Parameters
p:double

numerator

q:double

denominator

Returns:T

p/q computed in the instance field

getMaxGrowthback to summary
public T getMaxGrowth()

Get the maximal growth factor for stepsize control.

Returns:T

maximal growth factor

getMinReductionback to summary
public T getMinReduction()

Get the minimal reduction factor for stepsize control.

Returns:T

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 T getSafety()

Get the safety factor for stepsize control.

Returns:T

safety factor

integrateback to summary
public FieldODEStateAndDerivative<T> integrate(final FieldExpandableODE<T> equations, final FieldODEState<T> initialState, final T finalTime) throws NumberIsTooSmallException, DimensionMismatchException, MaxCountExceededException, NoBracketingException

Implements org.apache.commons.math3.ode.FirstOrderFieldIntegrator.integrate.

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

Integrate the differential equations up to the given time.

This method solves an Initial Value Problem (IVP).

Since this method stores some internal state variables made available in its public interface during integration (getCurrentSignedStepsize()), it is not thread-safe.

Parameters
equations:FieldExpandableODE<T>

differential equations to integrate

initialState:FieldODEState<T>

initial state (time, primary and secondary state vectors)

finalTime:T

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

Returns:FieldODEStateAndDerivative<T>

final state, its time will be the same as finalTime if integration reached its target, but may be different if some org.apache.commons.math3.ode.events.FieldEventHandler stops it at some point.

Exceptions
NumberIsTooSmallException:
if integration step is too small
MaxCountExceededException:
if the number of functions evaluations is exceeded
NoBracketingException:
if the location of an event cannot be bracketed
setMaxGrowthback to summary
public void setMaxGrowth(final T maxGrowth)

Set the maximal growth factor for stepsize control.

Parameters
maxGrowth:T

maximal growth factor

setMinReductionback to summary
public void setMinReduction(final T minReduction)

Set the minimal reduction factor for stepsize control.

Parameters
minReduction:T

minimal reduction factor

setSafetyback to summary
public void setSafety(final T safety)

Set the safety factor for stepsize control.

Parameters
safety:T

safety factor