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

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

extends AbstractFieldIntegrator<T extends RealFieldElement<T>>
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.ode.nonstiff.EmbeddedRungeKuttaFieldIntegrator, org.apache.commons.math3.ode.MultistepFieldIntegrator
Type Parameters
<T>
the type of the field elements
Imports
org.apache.commons.math3.Field, .RealFieldElement, org.apache.commons.math3.exception.DimensionMismatchException, .MaxCountExceededException, .NumberIsTooSmallException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.ode.AbstractFieldIntegrator, .FieldEquationsMapper, .FieldODEState, .FieldODEStateAndDerivative, org.apache.commons.math3.util.FastMath, .MathArrays, .MathUtils

This abstract class holds the common part of all adaptive stepsize integrators for Ordinary Differential Equations.

These algorithms perform integration with stepsize control, which means the user does not specify the integration step but rather a tolerance on error. The error threshold is computed as

threshold_i = absTol_i + relTol_i * max (abs (ym), abs (ym+1))
where absTol_i is the absolute tolerance for component i of the state vector and relTol_i is the relative tolerance for the same component. The user can also use only two scalar values absTol and relTol which will be used for all components.

Note that only the main part of the state vector is used for stepsize control. The secondary parts of the state vector are explicitly ignored for stepsize control.

If the estimated error for ym+1 is such that

sqrt((sum (errEst_i / threshold_i)^2 ) / n) < 1
(where n is the main set dimension) then the step is accepted, otherwise the step is rejected and a new attempt is made with a new stepsize.

Since
3.6

Field Summary

Modifier and TypeField and Description
private T
initialStep

User supplied initial step.

protected int
mainSetDimension

Main set dimension.

private T
maxStep

Maximal step.

private T
minStep

Minimal step.

protected double
scalAbsoluteTolerance

Allowed absolute scalar error.

protected double
scalRelativeTolerance

Allowed relative scalar error.

protected double[]
vecAbsoluteTolerance

Allowed absolute vectorial error.

protected double[]
vecRelativeTolerance

Allowed relative vectorial error.

Constructor Summary

AccessConstructor and Description
public
AdaptiveStepsizeFieldIntegrator(final Field<T>
field to which the time and state vector elements belong
field
,
final String
name of the method
name
,
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 an integrator with the given stepsize bounds.

public
AdaptiveStepsizeFieldIntegrator(final Field<T>
field to which the time and state vector elements belong
field
,
final String
name of the method
name
,
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
vecAbsoluteTolerance
,
final double[]
allowed relative error
vecRelativeTolerance
)

Build an integrator with the given stepsize bounds.

Method Summary

Modifier and TypeMethod and Description
protected T

Returns:

a bounded integration step (h if no bound is reach, or a bounded value)
filterStep
(final T
signed step
h
,
final boolean
forward integration indicator
forward
,
final boolean
if true, steps smaller than the minimal value are silently increased up to this value, if false such small steps generate an exception
acceptSmall
)

Filter the integration step.

public T

Returns:

maximal step
getMaxStep
()

Get the maximal step.

public T

Returns:

minimal step
getMinStep
()

Get the minimal step.

public T

Returns:

first integration step
initializeStep
(final boolean
forward integration indicator
forward
,
final int
order of the method
order
,
final T[]
scaling vector for the state vector (can be shorter than state vector)
scale
,
final FieldODEStateAndDerivative<T>
state at integration start time
state0
,
final FieldEquationsMapper<T>
mapper for all the equations
mapper
)

Initialize the integration step.

protected void
resetInternalState()

Reset internal state to dummy values.

protected void
sanityChecks(final FieldODEState<T>
set of differential equations
eqn
,
final T
target time for the integration
t
)

Overrides org.apache.commons.math3.ode.AbstractFieldIntegrator.sanityChecks.

Check the integration span.

public void
setInitialStepSize(final T
initial step size to use (must be positive even for backward integration ; providing a negative value or a value outside of the min/max step interval will lead the integrator to ignore the value and compute the initial step size by itself)
initialStepSize
)

Set the initial step size.

public void
setStepSizeControl(final double
minimal step (must be positive even for backward integration), the last step can be smaller than this
minimalStep
,
final double
maximal step (must be positive even for backward integration)
maximalStep
,
final double
allowed absolute error
absoluteTolerance
,
final double
allowed relative error
relativeTolerance
)

Set the adaptive step size control parameters.

public void
setStepSizeControl(final double
minimal step (must be positive even for backward integration), the last step can be smaller than this
minimalStep
,
final double
maximal step (must be positive even for backward integration)
maximalStep
,
final double[]
allowed absolute error
absoluteTolerance
,
final double[]
allowed relative error
relativeTolerance
)

Set the adaptive step size control parameters.

Inherited from org.apache.commons.math3.ode.AbstractFieldIntegrator:
acceptStepaddEventHandleraddEventHandleraddStepHandlerclearEventHandlersclearStepHandlerscomputeDerivativesgetCurrentSignedStepsizegetCurrentStepStartgetEquationsgetEvaluationsgetEvaluationsCountergetEventHandlersgetFieldgetMaxEvaluationsgetNamegetStepHandlersgetStepSizegetStepStartinitIntegrationisLastStepresetOccurredsetIsLastStepsetMaxEvaluationssetStateInitializedsetStepSizesetStepStart

Field Detail

initialStepback to summary
private T initialStep

User supplied initial step.

mainSetDimensionback to summary
protected int mainSetDimension

Main set dimension.

maxStepback to summary
private T maxStep

Maximal step.

minStepback to summary
private T minStep

Minimal step.

scalAbsoluteToleranceback to summary
protected double scalAbsoluteTolerance

Allowed absolute scalar error.

scalRelativeToleranceback to summary
protected double scalRelativeTolerance

Allowed relative scalar error.

vecAbsoluteToleranceback to summary
protected double[] vecAbsoluteTolerance

Allowed absolute vectorial error.

vecRelativeToleranceback to summary
protected double[] vecRelativeTolerance

Allowed relative vectorial error.

Constructor Detail

AdaptiveStepsizeFieldIntegratorback to summary
public AdaptiveStepsizeFieldIntegrator(final Field<T> field, final String name, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance)

Build an integrator with the given stepsize bounds. The default step handler does nothing.

Parameters
field:Field<T>

field to which the time and state vector elements belong

name:String

name of the method

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

AdaptiveStepsizeFieldIntegratorback to summary
public AdaptiveStepsizeFieldIntegrator(final Field<T> field, final String name, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance)

Build an integrator with the given stepsize bounds. The default step handler does nothing.

Parameters
field:Field<T>

field to which the time and state vector elements belong

name:String

name of the method

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

vecAbsoluteTolerance:double[]

allowed absolute error

vecRelativeTolerance:double[]

allowed relative error

Method Detail

filterStepback to summary
protected T filterStep(final T h, final boolean forward, final boolean acceptSmall) throws NumberIsTooSmallException

Filter the integration step.

Parameters
h:T

signed step

forward:boolean

forward integration indicator

acceptSmall:boolean

if true, steps smaller than the minimal value are silently increased up to this value, if false such small steps generate an exception

Returns:T

a bounded integration step (h if no bound is reach, or a bounded value)

Exceptions
NumberIsTooSmallException:
if the step is too small and acceptSmall is false
getMaxStepback to summary
public T getMaxStep()

Get the maximal step.

Returns:T

maximal step

getMinStepback to summary
public T getMinStep()

Get the minimal step.

Returns:T

minimal step

initializeStepback to summary
public T initializeStep(final boolean forward, final int order, final T[] scale, final FieldODEStateAndDerivative<T> state0, final FieldEquationsMapper<T> mapper) throws MaxCountExceededException, DimensionMismatchException

Initialize the integration step.

Parameters
forward:boolean

forward integration indicator

order:int

order of the method

scale:T[]

scaling vector for the state vector (can be shorter than state vector)

state0:FieldODEStateAndDerivative<T>

state at integration start time

mapper:FieldEquationsMapper<T>

mapper for all the equations

Returns:T

first integration step

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded
DimensionMismatchException:
if arrays dimensions do not match equations settings
resetInternalStateback to summary
protected void resetInternalState()

Reset internal state to dummy values.

sanityChecksback to summary
protected void sanityChecks(final FieldODEState<T> eqn, final T t) throws DimensionMismatchException, NumberIsTooSmallException

Overrides org.apache.commons.math3.ode.AbstractFieldIntegrator.sanityChecks.

Doc from org.apache.commons.math3.ode.AbstractFieldIntegrator.sanityChecks.

Check the integration span.

Parameters
eqn:FieldODEState<T>

set of differential equations

t:T

target time for the integration

Annotations
@Override
Exceptions
DimensionMismatchException:
if adaptive step size integrators tolerance arrays dimensions are not compatible with equations settings
NumberIsTooSmallException:
if integration span is too small
setInitialStepSizeback to summary
public void setInitialStepSize(final T initialStepSize)

Set the initial step size.

This method allows the user to specify an initial positive step size instead of letting the integrator guess it by itself. If this method is not called before integration is started, the initial step size will be estimated by the integrator.

Parameters
initialStepSize:T

initial step size to use (must be positive even for backward integration ; providing a negative value or a value outside of the min/max step interval will lead the integrator to ignore the value and compute the initial step size by itself)

setStepSizeControlback to summary
public void setStepSizeControl(final double minimalStep, final double maximalStep, final double absoluteTolerance, final double relativeTolerance)

Set the adaptive step size control parameters.

A side effect of this method is to also reset the initial step so it will be automatically computed by the integrator if setInitialStepSize is not called by the user.

Parameters
minimalStep:double

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

maximalStep:double

maximal step (must be positive even for backward integration)

absoluteTolerance:double

allowed absolute error

relativeTolerance:double

allowed relative error

setStepSizeControlback to summary
public void setStepSizeControl(final double minimalStep, final double maximalStep, final double[] absoluteTolerance, final double[] relativeTolerance)

Set the adaptive step size control parameters.

A side effect of this method is to also reset the initial step so it will be automatically computed by the integrator if setInitialStepSize is not called by the user.

Parameters
minimalStep:double

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

maximalStep:double

maximal step (must be positive even for backward integration)

absoluteTolerance:double[]

allowed absolute error

relativeTolerance:double[]

allowed relative error