【问题标题】:Modelica/Dymola Run Linearized Model with Initial ValuesModelica/Dymola 使用初始值运行线性化模型
【发布时间】:2021-11-19 16:09:12
【问题描述】:

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

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

最好的问候, 阿克塞尔

【问题讨论】:

    标签: initialization modelica dymola state-space linearization


    【解决方案1】:

    您可以使用块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 函数)来为您工作。更准确地说,它

    • 线性化任何合适的模型。我使用了 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");
    

    【讨论】:

    • 您好,感谢您的回答,这对我帮助很大。我还有一个问题:在您的示例中,我们仅使用 1 进行初始化。但是我如何从我的原始模型中获得初始条件,并进行线性化?
    • 取决于您如何设置这些起始值。这样的事情会有帮助吗? w_str = ModelManagement.Structure.AST.Components.ComponentModifiers("Modelica.Mechanics.Rotational.Examples.CoupledClutches","J1.w.start"); 这将读取组件 J1 中旋转起始值的修饰符。您仍然需要删除 = 并转换为字符串,但这应该可以使用 w_start = Modelica.Utilities.Strings.scanReal(w_str[1],2);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-12
    • 1970-01-01
    • 2013-12-16
    • 2013-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多