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

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

extends Object
implements FirstOrderFieldIntegrator<T extends RealFieldElement<T>>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.ode.FirstOrderFieldIntegrator
Known Direct Subclasses
org.apache.commons.math3.ode.nonstiff.AdaptiveStepsizeFieldIntegrator, org.apache.commons.math3.ode.nonstiff.RungeKuttaFieldIntegrator
Type Parameters
<T>
the type of the field elements
Imports
java.util.ArrayList, .Collection, .Collections, .Comparator, .Iterator, .List, .SortedSet, .TreeSet, org.apache.commons.math3.Field, .RealFieldElement, org.apache.commons.math3.analysis.solvers.BracketedRealFieldUnivariateSolver, .FieldBracketingNthOrderBrentSolver, org.apache.commons.math3.exception.DimensionMismatchException, .MaxCountExceededException, .NoBracketingException, .NumberIsTooSmallException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.ode.events.FieldEventHandler, .FieldEventState, org.apache.commons.math3.ode.sampling.AbstractFieldStepInterpolator, .FieldStepHandler, org.apache.commons.math3.util.FastMath, .IntegerSequence

Base class managing common boilerplate for all integrators.
Since
3.6

Field Summary

Modifier and TypeField and Description
private static final double
DEFAULT_FUNCTION_VALUE_ACCURACY

Default function value accuracy.

private static final double
DEFAULT_RELATIVE_ACCURACY

Default relative accuracy.

private transient FieldExpandableODE<T>
equations

Differential equations to integrate.

private IntegerSequence.Incrementor
evaluations

Counter for number of evaluations.

private Collection<FieldEventState<T>>
eventsStates

Events states.

private final Field<T>
field

Field to which the time and state vector elements belong.

private boolean
isLastStep

Indicator for last step.

private final String
name

Name of the method.

private boolean
resetOccurred

Indicator that a state or derivative reset was triggered by some event.

private boolean
statesInitialized

Initialization indicator of events states.

private Collection<FieldStepHandler<T>>
stepHandlers

Step handler.

private T
stepSize

Current stepsize.

private FieldODEStateAndDerivative<T>
stepStart

Current step start.

Constructor Summary

AccessConstructor and Description
protected
AbstractFieldIntegrator(final Field<T>
field to which the time and state vector elements belong
field
,
final String
name of the method
name
)

Build an instance.

Method Summary

Modifier and TypeMethod and Description
protected FieldODEStateAndDerivative<T>

Returns:

state at end of step
acceptStep
(final AbstractFieldStepInterpolator<T>
step interpolator
interpolator
,
final T
final integration time
tEnd
)

Accept a step, triggering events and step handlers.

public void
addEventHandler(final FieldEventHandler<T>
event handler
handler
,
final double
maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)
maxCheckInterval
,
final double
convergence threshold in the event time search
convergence
,
final int
upper limit of the iteration count in the event time search events.
maxIterationCount
)

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

Add an event handler to the integrator.

public void
addEventHandler(final FieldEventHandler<T>
event handler
handler
,
final double
maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)
maxCheckInterval
,
final double
convergence threshold in the event time search
convergence
,
final int
upper limit of the iteration count in the event time search events.
maxIterationCount
,
final BracketedRealFieldUnivariateSolver<T>
solver to use to locate the event
solver
)

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

Add an event handler to the integrator.

public void
addStepHandler(final FieldStepHandler<T>
handler for the accepted steps
handler
)

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

Add a step handler to this integrator.

public void
clearEventHandlers()

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

Remove all the event handlers that have been added to the integrator.

public void
clearStepHandlers()

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

Remove all the step handlers that have been added to the integrator.

public T[]

Returns:

state completed with derivatives
computeDerivatives
(final T
current value of the independent time variable
t
,
final T[]
array containing the current value of the state vector
y
)

Compute the derivatives and check the number of evaluations.

public T
getCurrentSignedStepsize()

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

Get the current signed value of the integration stepsize.

public FieldODEStateAndDerivative<T>
getCurrentStepStart()

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

Get the current value of the step start time ti.

protected FieldExpandableODE<T>

Returns:

differential equations to integrate
getEquations
()

Get the differential equations to integrate.

public int
getEvaluations()

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

Get the number of evaluations of the differential equations function.

protected IntegerSequence.Incrementor

Returns:

evaluations counter
getEvaluationsCounter
()

Get the evaluations counter.

public Collection<FieldEventHandler<T>>
getEventHandlers()

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

Get all the event handlers that have been added to the integrator.

public Field<T>

Returns:

field to which state vector elements belong
getField
()

Get the field to which state vector elements belong.

public int
getMaxEvaluations()

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

Get the maximal number of functions evaluations.

public String
public Collection<FieldStepHandler<T>>
getStepHandlers()

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

Get all the step handlers that have been added to the integrator.

protected T

Returns:

current step size
getStepSize
()

Get the current step size.

protected FieldODEStateAndDerivative<T>

Returns:

current step start
getStepStart
()

Getcurrent step start.

protected FieldODEStateAndDerivative<T>

Returns:

initial state with derivatives added
initIntegration
(final FieldExpandableODE<T>
equations to integrate
eqn
,
final T
start value of the independent time variable
t0
,
final T[]
array containing the start value of the state vector
y0
,
final T
target time for the integration
t
)

Prepare the start of an integration.

protected boolean

Returns:

true if this step is the last one
isLastStep
()

Check if this step is the last one.

protected boolean

Returns:

true if a reset occurred while last step was accepted
resetOccurred
()

Check if a reset occurred while last step was accepted.

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

Check the integration span.

protected void
setIsLastStep(final boolean
if true, this step is the last one
isLastStep
)

Set the last state flag.

public void
setMaxEvaluations(int
maximal number of function evaluations (negative values are silently converted to maximal integer value, thus representing almost unlimited evaluations)
maxEvaluations
)

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

Set the maximal number of differential equations function evaluations.

protected void
setStateInitialized(final boolean
new value for the flag
stateInitialized
)

Set the stateInitialized flag.

protected void
setStepSize(final T
step size to set
stepSize
)

Set the current step size.

protected void
setStepStart(final FieldODEStateAndDerivative<T>
step start
stepStart
)

Set current step start.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FUNCTION_VALUE_ACCURACYback to summary
private static final double DEFAULT_FUNCTION_VALUE_ACCURACY

Default function value accuracy.

DEFAULT_RELATIVE_ACCURACYback to summary
private static final double DEFAULT_RELATIVE_ACCURACY

Default relative accuracy.

equationsback to summary
private transient FieldExpandableODE<T> equations

Differential equations to integrate.

evaluationsback to summary
private IntegerSequence.Incrementor evaluations

Counter for number of evaluations.

eventsStatesback to summary
private Collection<FieldEventState<T>> eventsStates

Events states.

fieldback to summary
private final Field<T> field

Field to which the time and state vector elements belong.

isLastStepback to summary
private boolean isLastStep

Indicator for last step.

nameback to summary
private final String name

Name of the method.

resetOccurredback to summary
private boolean resetOccurred

Indicator that a state or derivative reset was triggered by some event.

statesInitializedback to summary
private boolean statesInitialized

Initialization indicator of events states.

stepHandlersback to summary
private Collection<FieldStepHandler<T>> stepHandlers

Step handler.

stepSizeback to summary
private T stepSize

Current stepsize.

stepStartback to summary
private FieldODEStateAndDerivative<T> stepStart

Current step start.

Constructor Detail

AbstractFieldIntegratorback to summary
protected AbstractFieldIntegrator(final Field<T> field, final String name)

Build an instance.

Parameters
field:Field<T>

field to which the time and state vector elements belong

name:String

name of the method

Method Detail

acceptStepback to summary
protected FieldODEStateAndDerivative<T> acceptStep(final AbstractFieldStepInterpolator<T> interpolator, final T tEnd) throws MaxCountExceededException, DimensionMismatchException, NoBracketingException

Accept a step, triggering events and step handlers.

Parameters
interpolator:AbstractFieldStepInterpolator<T>

step interpolator

tEnd:T

final integration time

Returns:FieldODEStateAndDerivative<T>

state at end of step

Exceptions
MaxCountExceededException:
if the interpolator throws one because the number of functions evaluations is exceeded
DimensionMismatchException:
if arrays dimensions do not match equations settings
NoBracketingException:
if the location of an event cannot be bracketed
addEventHandlerback to summary
public void addEventHandler(final FieldEventHandler<T> handler, final double maxCheckInterval, final double convergence, final int maxIterationCount)

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

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

Add an event handler to the integrator.

The default solver is a 5th order org.apache.commons.math3.analysis.solvers.FieldBracketingNthOrderBrentSolver.

Parameters
handler:FieldEventHandler<T>

event handler

maxCheckInterval:double

maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)

convergence:double

convergence threshold in the event time search

maxIterationCount:int

upper limit of the iteration count in the event time search events.

addEventHandlerback to summary
public void addEventHandler(final FieldEventHandler<T> handler, final double maxCheckInterval, final double convergence, final int maxIterationCount, final BracketedRealFieldUnivariateSolver<T> solver)

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

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

Add an event handler to the integrator.

Parameters
handler:FieldEventHandler<T>

event handler

maxCheckInterval:double

maximal time interval between switching function checks (this interval prevents missing sign changes in case the integration steps becomes very large)

convergence:double

convergence threshold in the event time search

maxIterationCount:int

upper limit of the iteration count in the event time search events.

solver:BracketedRealFieldUnivariateSolver<T>

solver to use to locate the event

addStepHandlerback to summary
public void addStepHandler(final FieldStepHandler<T> handler)

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

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

Add a step handler to this integrator.

The handler will be called by the integrator for each accepted step.

Parameters
handler:FieldStepHandler<T>

handler for the accepted steps

clearEventHandlersback to summary
public void clearEventHandlers()

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

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

Remove all the event handlers that have been added to the integrator.

clearStepHandlersback to summary
public void clearStepHandlers()

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

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

Remove all the step handlers that have been added to the integrator.

computeDerivativesback to summary
public T[] computeDerivatives(final T t, final T[] y) throws DimensionMismatchException, MaxCountExceededException, NullPointerException

Compute the derivatives and check the number of evaluations.

Parameters
t:T

current value of the independent time variable

y:T[]

array containing the current value of the state vector

Returns:T[]

state completed with derivatives

Exceptions
DimensionMismatchException:
if arrays dimensions do not match equations settings
MaxCountExceededException:
if the number of functions evaluations is exceeded
NullPointerException:
if the ODE equations have not been set (i.e. if this method is called outside of a call to integrate
getCurrentSignedStepsizeback to summary
public T getCurrentSignedStepsize()

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

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

Get the current signed value of the integration stepsize.

This method can be called during integration (typically by the object implementing the differential equations problem) if the signed value of the current stepsize that is tried is needed.

The result is undefined if the method is called outside of calls to integrate.

Returns:T

current signed value of the stepsize

getCurrentStepStartback to summary
public FieldODEStateAndDerivative<T> getCurrentStepStart()

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

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

Get the current value of the step start time ti.

This method can be called during integration (typically by the object implementing the differential equations problem) if the value of the current step that is attempted is needed.

The result is undefined if the method is called outside of calls to integrate.

Returns:FieldODEStateAndDerivative<T>

current value of the state at step start time ti

getEquationsback to summary
protected FieldExpandableODE<T> getEquations()

Get the differential equations to integrate.

Returns:FieldExpandableODE<T>

differential equations to integrate

getEvaluationsback to summary
public int getEvaluations()

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

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

Get the number of evaluations of the differential equations function.

The number of evaluations corresponds to the last call to the integrate method. It is 0 if the method has not been called yet.

Returns:int

number of evaluations of the differential equations function

getEvaluationsCounterback to summary
protected IntegerSequence.Incrementor getEvaluationsCounter()

Get the evaluations counter.

Returns:IntegerSequence.Incrementor

evaluations counter

getEventHandlersback to summary
public Collection<FieldEventHandler<T>> getEventHandlers()

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

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

Get all the event handlers that have been added to the integrator.

Returns:Collection<FieldEventHandler<T>>

an unmodifiable collection of the added events handlers

getFieldback to summary
public Field<T> getField()

Get the field to which state vector elements belong.

Returns:Field<T>

field to which state vector elements belong

getMaxEvaluationsback to summary
public int getMaxEvaluations()

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

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

Get the maximal number of functions evaluations.

Returns:int

maximal number of functions evaluations

getNameback to summary
public String getName()

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

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

Get the name of the method.

Returns:String

name of the method

getStepHandlersback to summary
public Collection<FieldStepHandler<T>> getStepHandlers()

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

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

Get all the step handlers that have been added to the integrator.

Returns:Collection<FieldStepHandler<T>>

an unmodifiable collection of the added events handlers

getStepSizeback to summary
protected T getStepSize()

Get the current step size.

Returns:T

current step size

getStepStartback to summary
protected FieldODEStateAndDerivative<T> getStepStart()

Getcurrent step start.

Returns:FieldODEStateAndDerivative<T>

current step start

initIntegrationback to summary
protected FieldODEStateAndDerivative<T> initIntegration(final FieldExpandableODE<T> eqn, final T t0, final T[] y0, final T t)

Prepare the start of an integration.

Parameters
eqn:FieldExpandableODE<T>

equations to integrate

t0:T

start value of the independent time variable

y0:T[]

array containing the start value of the state vector

t:T

target time for the integration

Returns:FieldODEStateAndDerivative<T>

initial state with derivatives added

isLastStepback to summary
protected boolean isLastStep()

Check if this step is the last one.

Returns:boolean

true if this step is the last one

resetOccurredback to summary
protected boolean resetOccurred()

Check if a reset occurred while last step was accepted.

Returns:boolean

true if a reset occurred while last step was accepted

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

Check the integration span.

Parameters
eqn:FieldODEState<T>

set of differential equations

t:T

target time for the integration

Exceptions
NumberIsTooSmallException:
if integration span is too small
DimensionMismatchException:
if adaptive step size integrators tolerance arrays dimensions are not compatible with equations settings
setIsLastStepback to summary
protected void setIsLastStep(final boolean isLastStep)

Set the last state flag.

Parameters
isLastStep:boolean

if true, this step is the last one

setMaxEvaluationsback to summary
public void setMaxEvaluations(int maxEvaluations)

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

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

Set the maximal number of differential equations function evaluations.

The purpose of this method is to avoid infinite loops which can occur for example when stringent error constraints are set or when lots of discrete events are triggered, thus leading to many rejected steps.

Parameters
maxEvaluations:int

maximal number of function evaluations (negative values are silently converted to maximal integer value, thus representing almost unlimited evaluations)

setStateInitializedback to summary
protected void setStateInitialized(final boolean stateInitialized)

Set the stateInitialized flag.

This method must be called by integrators with the value false before they start integration, so a proper lazy initialization is done automatically on the first step.

Parameters
stateInitialized:boolean

new value for the flag

setStepSizeback to summary
protected void setStepSize(final T stepSize)

Set the current step size.

Parameters
stepSize:T

step size to set

setStepStartback to summary
protected void setStepStart(final FieldODEStateAndDerivative<T> stepStart)

Set current step start.

Parameters
stepStart:FieldODEStateAndDerivative<T>

step start