org.apache.commons.math3.ode

## Class ExpandableStatefulODE

- java.lang.Object
- - org.apache.commons.math3.ode.ExpandableStatefulODE

-     public class ExpandableStatefulODE
      extends Object

  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
  Version:
    $Id: ExpandableStatefulODE.java 1416643 2012-12-03 19:37:14Z tn $
  See Also:
    `FirstOrderDifferentialEquations`, `JacobianMatrices`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `private static class` | `ExpandableStatefulODE.SecondaryComponent` Components of the compound stateful ODE.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private List<ExpandableStatefulODE.SecondaryComponent>` | `components` Components of the expandable ODE.
    `private FirstOrderDifferentialEquations` | `primary` Primary differential equation.
    `private EquationsMapper` | `primaryMapper` Mapper for primary equation.
    `private double[]` | `primaryState` State.
    `private double[]` | `primaryStateDot` State derivative.
    `private double` | `time` Time.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExpandableStatefulODE(FirstOrderDifferentialEquations primary)` Build an expandable set from its primary ODE set.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addSecondaryEquations(SecondaryEquations secondary)` Add a set of secondary equations to be integrated along with the primary set.
    `void` | `computeDerivatives(double t, double[] y, double[] yDot)` Get the current time derivative of the complete state vector.
    `double[]` | `getCompleteState()` Get the complete current state.
    `FirstOrderDifferentialEquations` | `getPrimary()` Get the primary set of differential equations.
    `EquationsMapper` | `getPrimaryMapper()` Get an equations mapper for the primary equations set.
    `double[]` | `getPrimaryState()` Get primary part of the current state.
    `double[]` | `getPrimaryStateDot()` Get primary part of the current state derivative.
    `EquationsMapper[]` | `getSecondaryMappers()` Get the equations mappers for the secondary equations sets.
    `double[]` | `getSecondaryState(int index)` Get secondary part of the current state.
    `double[]` | `getSecondaryStateDot(int index)` Get secondary part of the current state derivative.
    `double` | `getTime()` Get current time.
    `int` | `getTotalDimension()` Return the dimension of the complete set of equations.
    `void` | `setCompleteState(double[] completeState)` Set the complete current state.
    `void` | `setPrimaryState(double[] primaryState)` Set primary part of the current state.
    `void` | `setSecondaryState(int index, double[] secondaryState)` Set secondary part of the current state.
    `void` | `setTime(double time)` Set current time.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### primary

          private final FirstOrderDifferentialEquations primary

      Primary differential equation.

    - #### primaryMapper

          private final EquationsMapper primaryMapper

      Mapper for primary equation.

    - #### time

          private double time

      Time.

    - #### primaryState

          private final double[] primaryState

      State.

    - #### primaryStateDot

          private final double[] primaryStateDot

      State derivative.

    - #### components

          private List<ExpandableStatefulODE.SecondaryComponent> components

      Components of the expandable ODE.

  - ### Constructor Detail

    - #### ExpandableStatefulODE

          public ExpandableStatefulODE(FirstOrderDifferentialEquations primary)

      Build an expandable set from its primary ODE set.
      Parameters:
        `primary` - the primary set of differential equations to be integrated.

  - ### Method Detail

    - #### getPrimary

          public FirstOrderDifferentialEquations getPrimary()

      Get the primary set of differential equations.
      Returns:
        primary set of differential equations

    - #### getTotalDimension

          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:
        dimension of the complete set of equations

    - #### computeDerivatives

          public void computeDerivatives(double t,
                                double[] y,
                                double[] yDot)
                                  throws MaxCountExceededException,
                                         DimensionMismatchException

      Get the current time derivative of the complete state vector.
      Parameters:
        `t` - current value of the independent time variable
        `y` - array containing the current value of the complete state vector
        `yDot` - placeholder array where to put the time derivative of the complete state vector
      Throws:
        `MaxCountExceededException` - if the number of functions evaluations is exceeded
        `DimensionMismatchException` - if arrays dimensions do not match equations settings

    - #### addSecondaryEquations

          public int addSecondaryEquations(SecondaryEquations secondary)

      Add a set of secondary equations to be integrated along with the primary set.
      Parameters:
        `secondary` - secondary equations set
      Returns:
        index of the secondary equation in the expanded state

    - #### getPrimaryMapper

          public EquationsMapper getPrimaryMapper()

      Get an equations mapper for the primary equations set.
      Returns:
        mapper for the primary set
      See Also:
        `getSecondaryMappers()`

    - #### getSecondaryMappers

          public EquationsMapper[] getSecondaryMappers()

      Get the equations mappers for the secondary equations sets.
      Returns:
        equations mappers for the secondary equations sets
      See Also:
        `getPrimaryMapper()`

    - #### setTime

          public void setTime(double time)

      Set current time.
      Parameters:
        `time` - current time

    - #### getTime

          public double getTime()

      Get current time.
      Returns:
        current time

    - #### setPrimaryState

          public void setPrimaryState(double[] primaryState)
                               throws DimensionMismatchException

      Set primary part of the current state.
      Parameters:
        `primaryState` - primary part of the current state
      Throws:
        `DimensionMismatchException` - if the dimension of the array does not match the primary set

    - #### getPrimaryState

          public double[] getPrimaryState()

      Get primary part of the current state.
      Returns:
        primary part of the current state

    - #### getPrimaryStateDot

          public double[] getPrimaryStateDot()

      Get primary part of the current state derivative.
      Returns:
        primary part of the current state derivative

    - #### setSecondaryState

          public void setSecondaryState(int index,
                               double[] secondaryState)
                                 throws DimensionMismatchException

      Set secondary part of the current state.
      Parameters:
        `index` - index of the part to set as returned by `addSecondaryEquations(SecondaryEquations)`
        `secondaryState` - secondary part of the current state
      Throws:
        `DimensionMismatchException` - if the dimension of the partial state does not match the selected equations set dimension

    - #### getSecondaryState

          public double[] getSecondaryState(int index)

      Get secondary part of the current state.
      Parameters:
        `index` - index of the part to set as returned by `addSecondaryEquations(SecondaryEquations)`
      Returns:
        secondary part of the current state

    - #### getSecondaryStateDot

          public double[] getSecondaryStateDot(int index)

      Get secondary part of the current state derivative.
      Parameters:
        `index` - index of the part to set as returned by `addSecondaryEquations(SecondaryEquations)`
      Returns:
        secondary part of the current state derivative

    - #### setCompleteState

          public void setCompleteState(double[] completeState)
                                throws DimensionMismatchException

      Set the complete current state.
      Parameters:
        `completeState` - complete current state to copy data from
      Throws:
        `DimensionMismatchException` - if the dimension of the complete state does not match the complete equations sets dimension

    - #### getCompleteState

          public double[] getCompleteState()
                                    throws DimensionMismatchException

      Get the complete current state.
      Returns:
        complete current state
      Throws:
        `DimensionMismatchException` - if the dimension of the complete state does not match the complete equations sets dimension

Copyright (c) 2003-2013 Apache Software Foundation