为什么 Modelica.Blocks.Continously.Derivative 输入不能将 Modelica.Blocks.Sources.CombiTimeTable 作为输入?

scl*_*cls 0 derivative modelica openmodelica

我是 Modelica 的新手。

我使用 OpenModelica 连接编辑器完成了此操作。

图形

用下面的代码

model chariot_portique
  Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(extrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint, table = [0, 0; 4, 3; 8, 3; 12, 0; 16, 0; 20, -3; 24, -3; 28, 0], tableOnFile = false) annotation(
    Placement(transformation(extent = {{-80, 20}, {-60, 40}})));
  Modelica.Blocks.Continuous.Derivative derivative(T = 1, k = 1)  annotation(
    Placement(visible = true, transformation(origin = {-26, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(combiTimeTable.y, derivative.u) annotation(
    Line(points = {{-58, 30}, {-38, 30}}, color = {0, 0, 127}));
  annotation(
    experiment(StopTime = 20),
    uses(Modelica(version = "4.0.0")));
end chariot_portique;
Run Code Online (Sandbox Code Playgroud)

不幸的是验证这个模型会引发

The type of variables combiTimeTable.y and derivative.u are inconsistent in connect equations.
Run Code Online (Sandbox Code Playgroud)

如何解决?

我尝试在 CombiTimeTable 和 Derivative 之间插入 SISO 或 DiscreteSISO 块。但这没有用。

mar*_*rco 5

y的输出CombiTimeTable是一个向量,但导数块需要一个标量输入。您必须向 connect 语句添加索引并指定应使用输出向量的哪个元素。

您有一个包含 2 列的表,因此 的大小y为 1(第一列始终是时间,所有其他列用于输出值)。因此,您必须添加[1]连接。

  connect(combiTimeTable.y[1], derivative.u) annotation (...);
Run Code Online (Sandbox Code Playgroud)

y当您以图形方式创建连接时,OMEdit 将打开一个对话框,询问应使用哪个索引:

OMEdit - 创建连接对话框中的索引选择

您可以在此处选择创建时使用的索引,因此无需手动编辑连接的代码。