gpt4 book ai didi

modelica - 如何在 Dymola 中定义记录的自定义参数?

转载 作者:行者123 更新时间:2023-12-01 21:52:51 25 4
gpt4 key购买 nike

在ThermoSysPro库中有一个StodolaTurbine组件的自定义参数,在涡轮组件的图 TableView 中,我可以看到自定义参数属于一条记录。但是这条记录没有参数,这种情况下如何添加一个自定义参数呢?

enter image description here

enter image description here

enter image description here

最佳答案

您设置的每个修饰符都会显示在参数窗口中。您不仅可以为参数设置修饰符,还可以为或多或少不是最终的所有内容设置修饰符:所有变量和组件实例也是如此,无论它们在参数窗口中是否可见。 Dymola 将在“自定义参数”部分显示此类修饰符。

有几种方法可以设置这样的修饰符:

  1. 直接在文本层中输入修饰方程
  2. 使用组件参数窗口中的“添加修饰符”选项卡
  3. 使用显示组件打开实例并在子组件中设置参数

在旧的 Dymola 版本中,这些修饰符仅显示在一般参数组中,这会导致混淆。因此他们将其移至“自定义参数”部分。

例子

让我们使用下面的简单代码来演示三种不同的方法。

package Demo
model StepSine
Modelica.Blocks.Sources.Step step annotation (Placement(transformation(extent={{-20,20},{20,60}})));
Modelica.Blocks.Interfaces.RealOutput y annotation (Placement(transformation(extent={{100,-10},{120,10}})));
Modelica.Blocks.Math.Add add annotation (Placement(transformation(extent={{60,-10},{80,10}})));
Modelica.Blocks.Sources.Sine sine annotation (Placement(transformation(extent={{-20,-60},{20,-20}})));
equation
connect(add.y, y) annotation (Line(points={{81,0},{110,0}}, color={0,0,127}));
connect(step.y, add.u1) annotation (Line(points={{22,40},{40,40},{40,6},{58,6}}, color={0,0,127}));
connect(sine.y, add.u2) annotation (Line(points={{22,-40},{40,-40},{40,-6},{58,-6}}, color={0,0,127}));
end StepSine;

model Example
StepSine stepSine annotation (Placement(transformation(extent={{-8,-10},{12,10}})));
end Example;
end Demo;

这里我们创建了类 StepSine,它只是向正弦信号添加一个阶跃。组件的任何参数都不会传播,但使用上述方法我们仍然可以在 Example 中设置它们。

  1. 使用文字图层

    1. 转到文本层并键入 StepSine stepSine(add.k1=-1)
    2. 查看stepSine的参数窗口。您获得了第一个自定义参数。
  2. 使用“添加修饰符”

    1. 打开ExamplestepSine的参数窗口
    2. 切换到“添加修饰符”标签
    3. 键入 step.height=1 并单击“确定”
    4. 再次检查参数窗口。您获得了第二个自定义参数。
  3. 使用“显示组件”

    1. 使用右键单击打开 stepSine -> 显示组件
    2. 然后打开sine的参数窗口,输入例如3为振幅
    3. 再次查看stepSine的参数窗口。您获得了第三个自定义参数。

关于modelica - 如何在 Dymola 中定义记录的自定义参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58941502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com