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

public Class ExpandableStatefulODE

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, org.apache.commons.math3.exception.DimensionMismatchException, .MaxCountExceededException

This class represents a combined set of first order differential equations, with at least a primary set of equations expandable by some sets of secondary equations.

One typical use case is the computation of the Jacobian matrix for some ODE. In this case, the primary set of equations corresponds to the raw ODE, and we add to this set another bunch of secondary equations which represent the Jacobian matrix of the primary set.

We want the integrator to use only the primary set to estimate the errors and hence the step sizes. It should not use the secondary equations in this computation. The integrator will be able to know where the primary set ends and so where the secondary sets begin.

Since
3.0
See Also
FirstOrderDifferentialEquations, JacobianMatrices

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ExpandableStatefulODE.SecondaryComponent

Components of the compound stateful ODE.

Field Summary

Modifier and TypeField and Description
private List<ExpandableStatefulODE.SecondaryComponent>
components

Components of the expandable ODE.

private final FirstOrderDifferentialEquations
primary

Primary differential equation.

private final EquationsMapper
primaryMapper

Mapper for primary equation.

private final double[]
private final double[]
primaryStateDot

State derivative.

private double
time

Time.

Constructor Summary

AccessConstructor and Description
public
ExpandableStatefulODE(final FirstOrderDifferentialEquations
the primary set of differential equations to be integrated.
primary
)

Build an expandable set from its primary ODE set.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

index of the secondary equation in the expanded state
addSecondaryEquations
(final SecondaryEquations
secondary equations set
secondary
)

Add a set of secondary equations to be integrated along with the primary set.

public void
computeDerivatives(final double
current value of the independent time variable
t
,
final double[]
array containing the current value of the complete state vector
y
,
final double[]
placeholder array where to put the time derivative of the complete state vector
yDot
)

Get the current time derivative of the complete state vector.

public double[]

Returns:

complete current state
getCompleteState
()

Get the complete current state.

public FirstOrderDifferentialEquations

Returns:

primary set of differential equations
getPrimary
()

Get the primary set of differential equations.

public EquationsMapper

Returns:

mapper for the primary set
getPrimaryMapper
()

Get an equations mapper for the primary equations set.

public double[]

Returns:

primary part of the current state
getPrimaryState
()

Get primary part of the current state.

public double[]

Returns:

primary part of the current state derivative
getPrimaryStateDot
()

Get primary part of the current state derivative.

public EquationsMapper[]

Returns:

equations mappers for the secondary equations sets
getSecondaryMappers
()

Get the equations mappers for the secondary equations sets.

public double[]

Returns:

secondary part of the current state
getSecondaryState
(final int
index of the part to set as returned by addSecondaryEquations(SecondaryEquations)
index
)

Get secondary part of the current state.

public double[]

Returns:

secondary part of the current state derivative
getSecondaryStateDot
(final int
index of the part to set as returned by addSecondaryEquations(SecondaryEquations)
index
)

Get secondary part of the current state derivative.

public double

Returns:

current time
getTime
()

Get current time.

public int

Returns:

dimension of the complete set of equations
getTotalDimension
()

Return the dimension of the complete set of equations.

public void
setCompleteState(final double[]
complete current state to copy data from
completeState
)

Set the complete current state.

public void
setPrimaryState(final double[]
primary part of the current state
primaryState
)

Set primary part of the current state.

public void
setSecondaryState(final int
index of the part to set as returned by addSecondaryEquations(SecondaryEquations)
index
,
final double[]
secondary part of the current state
secondaryState
)

Set secondary part of the current state.

public void
setTime(final double
current time
time
)

Set current time.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

componentsback to summary
private List<ExpandableStatefulODE.SecondaryComponent> components

Components of the expandable ODE.

primaryback to summary
private final FirstOrderDifferentialEquations primary

Primary differential equation.

primaryMapperback to summary
private final EquationsMapper primaryMapper

Mapper for primary equation.

primaryStateback to summary
private final double[] primaryState

State.

primaryStateDotback to summary
private final double[] primaryStateDot

State derivative.

timeback to summary
private double time

Time.

Constructor Detail

ExpandableStatefulODEback to summary
public ExpandableStatefulODE(final FirstOrderDifferentialEquations primary)

Build an expandable set from its primary ODE set.

Parameters
primary:FirstOrderDifferentialEquations

the primary set of differential equations to be integrated.

Method Detail

addSecondaryEquationsback to summary
public int addSecondaryEquations(final SecondaryEquations secondary)

Add a set of secondary equations to be integrated along with the primary set.

Parameters
secondary:SecondaryEquations

secondary equations set

Returns:int

index of the secondary equation in the expanded state

computeDerivativesback to summary
public void computeDerivatives(final double t, final double[] y, final double[] yDot) throws MaxCountExceededException, DimensionMismatchException

Get the current time derivative of the complete state vector.

Parameters
t:double

current value of the independent time variable

y:double[]

array containing the current value of the complete state vector

yDot:double[]

placeholder array where to put the time derivative of the complete state vector

Exceptions
MaxCountExceededException:
if the number of functions evaluations is exceeded
DimensionMismatchException:
if arrays dimensions do not match equations settings
getCompleteStateback to summary
public double[] getCompleteState() throws DimensionMismatchException

Get the complete current state.

Returns:double[]

complete current state

Exceptions
DimensionMismatchException:
if the dimension of the complete state does not match the complete equations sets dimension
getPrimaryback to summary
public FirstOrderDifferentialEquations getPrimary()

Get the primary set of differential equations.

Returns:FirstOrderDifferentialEquations

primary set of differential equations

getPrimaryMapperback to summary
public EquationsMapper getPrimaryMapper()

Get an equations mapper for the primary equations set.

Returns:EquationsMapper

mapper for the primary set

See Also
getSecondaryMappers()
getPrimaryStateback to summary
public double[] getPrimaryState()

Get primary part of the current state.

Returns:double[]

primary part of the current state

getPrimaryStateDotback to summary
public double[] getPrimaryStateDot()

Get primary part of the current state derivative.

Returns:double[]

primary part of the current state derivative

getSecondaryMappersback to summary
public EquationsMapper[] getSecondaryMappers()

Get the equations mappers for the secondary equations sets.

Returns:EquationsMapper[]

equations mappers for the secondary equations sets

See Also
getPrimaryMapper()
getSecondaryStateback to summary
public double[] getSecondaryState(final int index)

Get secondary part of the current state.

Parameters
index:int

index of the part to set as returned by addSecondaryEquations(SecondaryEquations)

Returns:double[]

secondary part of the current state

getSecondaryStateDotback to summary
public double[] getSecondaryStateDot(final int index)

Get secondary part of the current state derivative.

Parameters
index:int

index of the part to set as returned by addSecondaryEquations(SecondaryEquations)

Returns:double[]

secondary part of the current state derivative

getTimeback to summary
public double getTime()

Get current time.

Returns:double

current time

getTotalDimensionback to summary
public int getTotalDimension()

Return the dimension of the complete set of equations.

The complete set of equations correspond to the primary set plus all secondary sets.

Returns:int

dimension of the complete set of equations

setCompleteStateback to summary
public void setCompleteState(final double[] completeState) throws DimensionMismatchException

Set the complete current state.

Parameters
completeState:double[]

complete current state to copy data from

Exceptions
DimensionMismatchException:
if the dimension of the complete state does not match the complete equations sets dimension
setPrimaryStateback to summary
public void setPrimaryState(final double[] primaryState) throws DimensionMismatchException

Set primary part of the current state.

Parameters
primaryState:double[]

primary part of the current state

Exceptions
DimensionMismatchException:
if the dimension of the array does not match the primary set
setSecondaryStateback to summary
public void setSecondaryState(final int index, final double[] secondaryState) throws DimensionMismatchException

Set secondary part of the current state.

Parameters
index:int

index of the part to set as returned by addSecondaryEquations(SecondaryEquations)

secondaryState:double[]

secondary part of the current state

Exceptions
DimensionMismatchException:
if the dimension of the partial state does not match the selected equations set dimension
setTimeback to summary
public void setTime(final double time)

Set current time.

Parameters
time:double

current time

org.apache.commons.math3.ode back to summary

private Class ExpandableStatefulODE.SecondaryComponent

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.ode.ExpandableStatefulODE.SecondaryComponent

Components of the compound stateful ODE.

Field Summary

Modifier and TypeField and Description
private final SecondaryEquations
equation

Secondary differential equation.

private final EquationsMapper
mapper

Mapper between local and complete arrays.

private final double[]
state

State.

private final double[]
stateDot

State derivative.

Constructor Summary

AccessConstructor and Description
pack-priv
SecondaryComponent(final SecondaryEquations
secondary differential equation
equation
,
final int
index to use for the first element in the complete arrays
firstIndex
)

Simple constructor.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

equationback to summary
private final SecondaryEquations equation

Secondary differential equation.

mapperback to summary
private final EquationsMapper mapper

Mapper between local and complete arrays.

stateback to summary
private final double[] state

State.

stateDotback to summary
private final double[] stateDot

State derivative.

Constructor Detail

SecondaryComponentback to summary
pack-priv SecondaryComponent(final SecondaryEquations equation, final int firstIndex)

Simple constructor.

Parameters
equation:SecondaryEquations

secondary differential equation

firstIndex:int

index to use for the first element in the complete arrays