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

public Class ContinuousOutputModel

extends Object
implements StepHandler, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.ode.sampling.StepHandler
Imports
java.io.Serializable, java.util.ArrayList, .List, org.apache.commons.math3.exception.DimensionMismatchException, .MathIllegalArgumentException, .MaxCountExceededException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.ode.sampling.StepHandler, .StepInterpolator, org.apache.commons.math3.util.FastMath

This class stores all information provided by an ODE integrator during the integration process and build a continuous model of the solution from this.

This class act as a step handler from the integrator point of view. It is called iteratively during the integration process and stores a copy of all steps information in a sorted collection for later use. Once the integration process is over, the user can use the setInterpolatedTime and getInterpolatedState to retrieve this information at any time. It is important to wait for the integration to be over before attempting to call setInterpolatedTime because some internal variables are set only once the last step has been handled.

This is useful for example if the main loop of the user application should remain independent from the integration process or if one needs to mimic the behaviour of an analytical model despite a numerical model is used (i.e. one needs the ability to get the model value at any time or to navigate through the data).

If problem modeling is done with several separate integration phases for contiguous intervals, the same ContinuousOutputModel can be used as step handler for all integration phases as long as they are performed in order and in the same direction. As an example, one can extrapolate the trajectory of a satellite with one model (i.e. one set of differential equations) up to the beginning of a maneuver, use another more complex model including thrusters modeling and accurate attitude control during the maneuver, and revert to the first model after the end of the maneuver. If the same continuous output model handles the steps of all integration phases, the user do not need to bother when the maneuver begins or ends, he has all the data available in a transparent manner.

An important feature of this class is that it implements the Serializable interface. This means that the result of an integration can be serialized and reused later (if stored into a persistent medium like a filesystem or a database) or elsewhere (if sent to another application). Only the result of the integration is stored, there is no reference to the integrated problem by itself.

One should be aware that the amount of data stored in a ContinuousOutputModel instance can be important if the state vector is large, if the integration interval is long or if the steps are small (which can result from small tolerance settings in adaptive step size integrators).

Since
1.2
See Also
StepHandler, StepInterpolator

Field Summary

Modifier and TypeField and Description
private double
finalTime

Final integration time.

private boolean
forward

Integration direction indicator.

private int
index

Current interpolator index.

private double
initialTime

Initial integration time.

private static final long
serialVersionUID

Serializable version identifier

private List<StepInterpolator>
steps

Steps table.

Constructor Summary

AccessConstructor and Description
public
ContinuousOutputModel()

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public void
append(final ContinuousOutputModel
model to add at the end of the instance
model
)

Append another model at the end of the instance.

public double

Returns:

final integration time
getFinalTime
()

Get the final integration time.

public double

Returns:

initial integration time
getInitialTime
()

Get the initial integration time.

public double[]

Returns:

derivatives of the state vector at time getInterpolatedTime
getInterpolatedDerivatives
()

Get the derivatives of the state vector of the interpolated point.

public double[]

Returns:

interpolated secondary derivatives at the current interpolation date
getInterpolatedSecondaryDerivatives
(final int
index of the secondary set, as returned by ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)
secondaryStateIndex
)

Get the interpolated secondary derivatives corresponding to the secondary equations.

public double[]

Returns:

interpolated secondary state at the current interpolation date
getInterpolatedSecondaryState
(final int
index of the secondary set, as returned by ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)
secondaryStateIndex
)

Get the interpolated secondary state corresponding to the secondary equations.

public double[]

Returns:

state vector at time getInterpolatedTime
getInterpolatedState
()

Get the state vector of the interpolated point.

public double

Returns:

interpolation point time
getInterpolatedTime
()

Get the time of the interpolated point.

public void
handleStep(final StepInterpolator
interpolator for the last accepted step.
interpolator
,
final boolean
true if the step is the last one
isLast
)

Implements org.apache.commons.math3.ode.sampling.StepHandler.handleStep.

Handle the last accepted step.

public void
init(double
start value of the independent time variable
t0
,
double[]
array containing the start value of the state vector
y0
,
double
target time for the integration
t
)

Implements org.apache.commons.math3.ode.sampling.StepHandler.init.

Initialize step handler at the start of an ODE integration.

private int

Returns:

-1 if the double is before the interval, 0 if it is in the interval, and +1 if it is after the interval, according to the interval direction
locatePoint
(final double
point to locate
time
,
final StepInterpolator
step interval
interval
)

Compare a step interval and a double.

public void
setInterpolatedTime(final double
time of the interpolated point
time
)

Set the time of the interpolated point.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

finalTimeback to summary
private double finalTime

Final integration time.

forwardback to summary
private boolean forward

Integration direction indicator.

indexback to summary
private int index

Current interpolator index.

initialTimeback to summary
private double initialTime

Initial integration time.

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable version identifier

stepsback to summary
private List<StepInterpolator> steps

Steps table.

Constructor Detail

ContinuousOutputModelback to summary
public ContinuousOutputModel()

Simple constructor. Build an empty continuous output model.

Method Detail

appendback to summary
public void append(final ContinuousOutputModel model) throws MathIllegalArgumentException, MaxCountExceededException

Append another model at the end of the instance.

Parameters
model:ContinuousOutputModel

model to add at the end of the instance

Exceptions
MathIllegalArgumentException:
if the model to append is not compatible with the instance (dimension of the state vector, propagation direction, hole between the dates)
MaxCountExceededException:
if the number of functions evaluations is exceeded during step finalization
getFinalTimeback to summary
public double getFinalTime()

Get the final integration time.

Returns:double

final integration time

getInitialTimeback to summary
public double getInitialTime()

Get the initial integration time.

Returns:double

initial integration time

getInterpolatedDerivativesback to summary
public double[] getInterpolatedDerivatives() throws MaxCountExceededException

Get the derivatives of the state vector of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls to the associated setInterpolatedTime(double) method.

Returns:double[]

derivatives of the state vector at time getInterpolatedTime

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded
Since
3.4
See Also
setInterpolatedTime(double), getInterpolatedState(), getInterpolatedSecondaryState(int), getInterpolatedSecondaryDerivatives(int)
getInterpolatedSecondaryDerivativesback to summary
public double[] getInterpolatedSecondaryDerivatives(final int secondaryStateIndex) throws MaxCountExceededException

Get the interpolated secondary derivatives corresponding to the secondary equations.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls to the associated setInterpolatedTime(double) method.

Parameters
secondaryStateIndex:int

index of the secondary set, as returned by ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)

Returns:double[]

interpolated secondary derivatives at the current interpolation date

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded
Since
3.4
See Also
setInterpolatedTime(double), getInterpolatedState(), getInterpolatedDerivatives(), getInterpolatedSecondaryState(int)
getInterpolatedSecondaryStateback to summary
public double[] getInterpolatedSecondaryState(final int secondaryStateIndex) throws MaxCountExceededException

Get the interpolated secondary state corresponding to the secondary equations.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls to the associated setInterpolatedTime(double) method.

Parameters
secondaryStateIndex:int

index of the secondary set, as returned by ExpandableStatefulODE.addSecondaryEquations(SecondaryEquations)

Returns:double[]

interpolated secondary state at the current interpolation date

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded
Since
3.2
See Also
setInterpolatedTime(double), getInterpolatedState(), getInterpolatedDerivatives(), getInterpolatedSecondaryDerivatives(int)
getInterpolatedStateback to summary
public double[] getInterpolatedState() throws MaxCountExceededException

Get the state vector of the interpolated point.

The returned vector is a reference to a reused array, so it should not be modified and it should be copied if it needs to be preserved across several calls to the associated setInterpolatedTime(double) method.

Returns:double[]

state vector at time getInterpolatedTime

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded
See Also
setInterpolatedTime(double), getInterpolatedDerivatives(), getInterpolatedSecondaryState(int), getInterpolatedSecondaryDerivatives(int)
getInterpolatedTimeback to summary
public double getInterpolatedTime()

Get the time of the interpolated point. If setInterpolatedTime has not been called, it returns the final integration time.

Returns:double

interpolation point time

handleStepback to summary
public void handleStep(final StepInterpolator interpolator, final boolean isLast) throws MaxCountExceededException

Implements org.apache.commons.math3.ode.sampling.StepHandler.handleStep.

Handle the last accepted step. A copy of the information provided by the last step is stored in the instance for later use.

Parameters
interpolator:StepInterpolator

interpolator for the last accepted step.

isLast:boolean

true if the step is the last one

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded during step finalization
initback to summary
public void init(double t0, double[] y0, double t)

Implements org.apache.commons.math3.ode.sampling.StepHandler.init.

Doc from org.apache.commons.math3.ode.sampling.StepHandler.init.

Initialize step handler at the start of an ODE integration.

This method is called once at the start of the integration. It may be used by the step handler to initialize some internal data if needed.

Parameters
t0:double

start value of the independent time variable

y0:double[]

array containing the start value of the state vector

t:double

target time for the integration

locatePointback to summary
private int locatePoint(final double time, final StepInterpolator interval)

Compare a step interval and a double.

Parameters
time:double

point to locate

interval:StepInterpolator

step interval

Returns:int

-1 if the double is before the interval, 0 if it is in the interval, and +1 if it is after the interval, according to the interval direction

setInterpolatedTimeback to summary
public void setInterpolatedTime(final double time)

Set the time of the interpolated point.

This method should not be called before the integration is over because some internal variables are set only once the last step has been handled.

Setting the time outside of the integration interval is now allowed, but should be used with care since the accuracy of the interpolator will probably be very poor far from this interval. This allowance has been added to simplify implementation of search algorithms near the interval endpoints.

Note that each time this method is called, the internal arrays returned in getInterpolatedState(), getInterpolatedDerivatives() and getInterpolatedSecondaryState(int) will be overwritten. So if their content must be preserved across several calls, user must copy them.

Parameters
time:double

time of the interpolated point

See Also
getInterpolatedState(), getInterpolatedDerivatives(), getInterpolatedSecondaryState(int)