我是Dymola的新手,我想运行一个具有初始条件的线性化模型。
我知道如何线性化它。我可以在命令窗口中获取StateSpace对象,也可以获取dslin.mat。现在我想用初始条件来运行它。我在dsin.txt文件中找到了它们,但无法将它们组合在一起。有没有实现的方式,或者我需要自己写?
致以最好的问候,Axel
发布于 2021-11-22 08:46:38
您可以使用块Modelica.Blocks.Continuous.StateSpace
构建一个包含状态空间描述的模型,如下所示:
相应的代码是:
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函数)为您做一些工作。更准确地说,它
sys
的状态空间块的参数。这包括模型中具有新参数的初始条件的初始条件
// 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");
https://stackoverflow.com/questions/70037748
复制相似问题