使用 Modelica integerExp 函数的 LTI 状态空间模型离散化不起作用

我需要在 Openmodelica (OMEdit) 中对连续 LTI 状态空间模型执行 ZOH 离散化。 我尝试了两种方法:

  1. 使用矩阵指数(Matrices.exp 函数)计算离散化 A 矩阵 (Ad) 和后续计算离散化 B 矩阵 (Bd) 以下等式:Bd = A-1 (Ad - I) B,其中 I 是单位矩阵;这个代数方程可以通过直接计算矩阵求逆(Matrices.inv 函数)来求解,或者更有效地通过求解 Bd矩阵使用 Matrices.solve2 函数:Bd = Matrices.solve2(A,(Ad-identity(2))),从而避免矩阵求逆的计算。然而,在这两种情况下,A 矩阵必须是可逆的,这通常(并且经常)不成立。
  2. 使用 Matrices.integralExp 函数,它应该返回两个离散矩阵(Ad,Bd)并且应该适用于一般矩阵 A,无论是可逆的还是单数的;但是,此功能对我不起作用 - 它返回错误消息:“在令牌附近没有可行的替代方案:(”。

为了演示目的,我附上了这两种方法的代码。状态空间模型表示一个非常简单的线性化摆的二阶系统,其长度为 1 m,质量为 1 kg,重力加速度为 9.81 m/s2。离散化的采样时间为 0.1 s。第一个代码工作正常(A 在这种特殊情况下是可逆的)但第二个代码没有。有谁知道我做错了什么?如有任何建议,我将不胜感激。

方法#1:

model ssDiscretization
  import Modelica.Math.Matrices;
  // Continuous LTI state-space model of pendulum: L=1,m=1,g=9.81
  Real A[2,2] = [0,1; -9.81,0] "system matrix";
  Real B[2,1] = [0; 1] "input matrix";
  // Discretization with sampling time 0.1 s
  Real Ad[2,2] = Matrices.exp(A,0.1) "T = 0.1 s";
  Real Bd[2,1] = Matrices.inv(A)*(Ad - identity(2))*B;
end ssDiscretization;

方法#2:

model ssDiscretization
  import Modelica.Math.Matrices;
  // Continuous LTI state-space model of pendulum: L=1,2];
  Real Bd[2,1];
  (Ad,Bd) = Matrices.integralExp(A,B,0.1) "T = 0.1 s";
end ssDiscretization;

奥利弗

shangguan1 回答:使用 Modelica integerExp 函数的 LTI 状态空间模型离散化不起作用

您忘记了示例 2 中的 equation 关键字。它仍然无法在 OpenModelica 中工作,因为该函数中的别名 na=size(A,1) 似乎有问题,但您可以轻松修复源代码以使其工作.

model ssDiscretization
  import Modelica.Math.Matrices;
  // Continuous LTI state-space model of pendulum: L=1,m=1,g=9.81
  Real A[2,2] = [0,1; -9.81,0] "system matrix";
  Real B[2,1] = [0; 1] "input matrix";
  // Discretization with sampling time 0.1 s
  Real Ad[2,2];
  Real Bd[2,1];
equation // This was missing
  (Ad,Bd) = Matrices.integralExp(A,B,0.1) "T = 0.1 s";
end ssDiscretization;
本文链接:https://www.f2er.com/606517.html

大家都在问