类 VariationalEquation
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.
- 另请参阅:
-
嵌套类概要
-
构造器概要
构造器说明VariationalEquation
(ExpandableODE expandable, ODEJacobiansProvider jode) 使用解析的局部偏导数构建变分方程。VariationalEquation
(ExpandableODE expandable, OrdinaryDifferentialEquation ode, double[] hY, ParametersController controller, ParameterConfiguration... paramsAndSteps) 使用有限差分计算局部偏导数构建变分方程。 -
方法概要
修饰符和类型方法说明double[][]
extractMainSetJacobian
(ODEState state) 提取相对于状态的雅可比矩阵。double[]
extractParameterJacobian
(ODEState state, String pName) 提取相对于一个参数的雅可比矩阵。void
setInitialMainStateJacobian
(double[][] dYdY0) 设置相对于状态的雅可比矩阵的初始值。void
setInitialParameterJacobian
(String pName, double[] dYdP) 设置相对于一个参数的雅可比矩阵的初始值。setUpInitialState
(ODEState initialState) 设置初始状态。
-
构造器详细资料
-
VariationalEquation
public VariationalEquation(ExpandableODE expandable, OrdinaryDifferentialEquation ode, double[] hY, ParametersController controller, ParameterConfiguration... paramsAndSteps) throws VariationalEquation.MismatchedEquations 使用有限差分计算局部偏导数构建变分方程。- 参数:
-
expandable
- 可扩展集合,应将变分方程注册到其中 -
ode
- 请求雅可比矩阵的基本常微分方程 -
hY
- 用于相对于状态向量进行有限差分计算的步长 -
controller
- 更改参数的控制器 -
paramsAndSteps
- 计算雅可比矩阵 df/dp 的参数和步骤 - 抛出:
-
VariationalEquation.MismatchedEquations
- 如果可扩展集合的主要集合与ode
不匹配
-
VariationalEquation
public VariationalEquation(ExpandableODE expandable, ODEJacobiansProvider jode) throws VariationalEquation.MismatchedEquations 使用解析的局部偏导数构建变分方程。参数必须属于由
Parameterizable.getParametersNames()
给出的支持参数,因此微分方程的主要集合必须是Parameterizable
。请注意,每次选择都会清除先前选择的参数。
- 参数:
-
expandable
- 可扩展集合,应将变分方程注册到其中 -
jode
- 要扩展的主要一阶微分方程集 - 抛出:
-
VariationalEquation.MismatchedEquations
- 如果可扩展集合的主要集合与ode
不匹配
-
-
方法详细资料
-
setInitialMainStateJacobian
设置相对于状态的雅可比矩阵的初始值。如果未调用此方法,则相对于状态的雅可比矩阵的初始值将设置为单位矩阵。
此方法必须在
setUpInitialState(ODEState)
之前调用- 参数:
-
dYdY0
- 相对于状态的初始雅可比矩阵 - 抛出:
-
MathIllegalArgumentException
- 如果矩阵维度不正确
-
setInitialParameterJacobian
public void setInitialParameterJacobian(String pName, double[] dYdP) throws MathIllegalArgumentException 设置相对于一个参数的雅可比矩阵的初始值。如果对于某些参数未调用此方法,则相对于该参数的雅可比矩阵的列的初始值将设置为零。
此方法必须在
setUpInitialState(ODEState)
之前调用- 参数:
-
pName
- 参数名称 -
dYdP
- 相对于参数的初始雅可比列向量 - 抛出:
-
MathIllegalArgumentException
- 如果参数不受支持 -
MathIllegalArgumentException
- 如果列向量与状态维度不匹配
-
setUpInitialState
设置初始状态。此方法通过覆盖对应于实例的附加状态分量将初始雅可比矩阵数据插入到
ODE state
中。必须在积分方程之前调用此方法。此方法必须在之后
setInitialMainStateJacobian(double[][])
和setInitialParameterJacobian(String, double[])
之后调用。- 参数:
-
initialState
- 初始状态,不包括初始雅可比矩阵 - 返回:
- 初始化雅可比矩阵后的新初始状态实例
-
extractMainSetJacobian
提取相对于状态的雅可比矩阵。- 参数:
-
state
- 从中提取雅可比矩阵的状态 - 返回:
- 相对于状态的雅可比矩阵 dY/dY0。
-
extractParameterJacobian
提取相对于一个参数的雅可比矩阵。- 参数:
-
state
- 要提取雅可比矩阵的状态 -
pName
- 计算雅可比矩阵的参数名称 - 返回:
- 相对于指定参数的雅可比矩阵 dY/dP
-