程序包 org.hipparchus.ode

类 VariationalEquation

java.lang.Object
org.hipparchus.ode.VariationalEquation

public class VariationalEquation extends Object
This class defines a set of secondary equations to compute the global Jacobian matrices with respect to the initial state vector and, if any, to some parameters of the primary ODE set.

The primary set of ODE for which Jaobian matrices are requested may be:

  • a full-fledged ODEJacobiansProvider that computes by itself both the ODE and its local partial derivatives,
  • a simple OrdinaryDifferentialEquation which must therefore be completed with a finite differences configuration to compute local partial derivatives (so-called internal differentiation).

As the variational equation automatically inserts secondary differential equations, in the expandable ODE, data for initial state must also be inserted before integration and matrices result must be extracted after integration. This implies a precise scheduling of the calls to the various methods of this class. The proper scheduling is the following one:

   // set up equations
   ODEJacobiansProvider jode       = new MyODE(...);
   ExpandableODE        expandable = new Expandable(jode);
   VariationalEquation  ve         = new VariationalEquation(expandable, jode);

   // set up initial state
   ODEState initWithoutDerivatives = new ODEState(t0, y0);
   ve.setInitialMainStateJacobian(dYdY0); // only needed if the default identity matrix is not suitable
   ve.setInitialParameterJacobian(name, dYdP); // only needed if the default zero matrix is not suitable
   ODEState initWithDerivatives = ve.setUpInitialState(initWithoutDerivatives);

   // perform integration on the expanded equations with the expanded initial state
   ODEStateAndDerivative finalState = integrator.integrate(expandable, initWithDerivatives, finalT);

   // extract Jacobian matrices
   dYdY0 = ve.extractMainSetJacobian(finalState);
   dYdP  = ve.extractParameterJacobian(finalState, name);
 

The most important part is to not forget to call setUpInitialState(ODEState) to add the secondary state with the initial matrices to the ODEState used in the integrate method. Forgetting to do this and passing only a ODEState without the secondary state set up will trigger an error as the state vector will not have the correct dimension.

另请参阅:
  • 构造器详细资料

  • 方法详细资料

    • setInitialMainStateJacobian

      public void setInitialMainStateJacobian(double[][] dYdY0) throws MathIllegalArgumentException
      设置相对于状态的雅可比矩阵的初始值。

      如果未调用此方法,则相对于状态的雅可比矩阵的初始值将设置为单位矩阵。

      此方法必须在setUpInitialState(ODEState)之前调用

      参数:
      dYdY0 - 相对于状态的初始雅可比矩阵
      抛出:
      MathIllegalArgumentException - 如果矩阵维度不正确
    • setInitialParameterJacobian

      public void setInitialParameterJacobian(String pName, double[] dYdP) throws MathIllegalArgumentException
      设置相对于一个参数的雅可比矩阵的初始值。

      如果对于某些参数未调用此方法,则相对于该参数的雅可比矩阵的列的初始值将设置为零。

      此方法必须在setUpInitialState(ODEState)之前调用

      参数:
      pName - 参数名称
      dYdP - 相对于参数的初始雅可比列向量
      抛出:
      MathIllegalArgumentException - 如果参数不受支持
      MathIllegalArgumentException - 如果列向量与状态维度不匹配
    • setUpInitialState

      public ODEState setUpInitialState(ODEState initialState)
      设置初始状态。

      此方法通过覆盖对应于实例的附加状态分量将初始雅可比矩阵数据插入到ODE state中。必须在积分方程之前调用此方法。

      此方法必须在之后setInitialMainStateJacobian(double[][])setInitialParameterJacobian(String, double[])之后调用。

      参数:
      initialState - 初始状态,不包括初始雅可比矩阵
      返回:
      初始化雅可比矩阵后的新初始状态实例
    • extractMainSetJacobian

      public double[][] extractMainSetJacobian(ODEState state)
      提取相对于状态的雅可比矩阵。
      参数:
      state - 从中提取雅可比矩阵的状态
      返回:
      相对于状态的雅可比矩阵 dY/dY0。
    • extractParameterJacobian

      public double[] extractParameterJacobian(ODEState state, String pName)
      提取相对于一个参数的雅可比矩阵。
      参数:
      state - 要提取雅可比矩阵的状态
      pName - 计算雅可比矩阵的参数名称
      返回:
      相对于指定参数的雅可比矩阵 dY/dP