1

我是 Dymola 的新手,我想运行具有初始条件的线性化模型。

我知道如何线性化它。我可以在命令窗口中获取 StateSpace 对象或获取 dslin.mat。现在我想在初始条件下运行它。我在 dsin.txt 文件中找到了它们,但无法将它们组合在一起。有没有实现的方法还是我需要自己写?

最好的问候,阿克塞尔

4

1 回答 1

3

您可以使用该模块Modelica.Blocks.Continuous.StateSpace构建包含状态空间描述的模型,如下所示:

带有来自 MSL 的状态空间模块的模型

相应的代码是:

model StateSpaceModel
  Modelica.Blocks.Continuous.StateSpace sys annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
  Modelica.Blocks.Sources.Step step(startTime=0.5) annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
equation 
  connect(step.y, sys.u[1]) annotation (Line(points={{-39,0},{-12,0}}, color={0,0,127}));
  annotation (uses(Modelica(version="4.0.0")));
end StateSpaceModel;

此外,您可以使用为您做一些工作的脚本(或 Modelica 函数)。更准确地说,它

  • 线性化任何合适的模型。我使用了 MSL 本身的状态空间模型,因此您可以确定结果是正确的。
  • 将上述模型转换为能够从命令行设置参数
  • 设置名为 的状态空间块的参数sys。这包括那些用于初始条件的x_start
  • 使用新参数模拟模型
// Get state-space description of a model
ss = Modelica_LinearSystems2.ModelAnalysis.Linearize("Modelica.Blocks.Continuous.StateSpace");

// Translate custom example, set parameters to result of the above linearization, add initial conditions for states and simulate
translateModel("StateSpaceModel")
sys.A = ss.A;
sys.B = ss.B;
sys.C = ss.C; // in case of an error here, check if 'OutputCPUtime == false;'
sys.D = ss.D;
sys.x_start = ones(size(sys.A,1));
simulateModel("StateSpaceModel", resultFile="StateSpaceModel");
于 2021-11-22T08:46:37.610 回答