Lor*_*zen 4 parameters annotations dymola
我有一个使用不同组件的仿真模型。为了快速了解所用参数,我使用注释功能通过以下方式显示某些模型参数(例如 m_flow_nominal):
textString="Nominal Flow Rate = %m_flow_nominal"
Run Code Online (Sandbox Code Playgroud)
在注释对话框中。哪个会发出类似的东西
标称流量 = 5
这对于整数参数非常有效。
我还有一个从其他值计算的参数。比如,让我们说一个身体的体积。当我尝试通过以下方式显示此参数时:
textString="Volume = %volume"
Run Code Online (Sandbox Code Playgroud)
我将给出计算体积的公式,而不是最终值。例如
体积 = a * b * c
在这种情况下如何显示体积的最终值,而不是公式?
这是实际问题:
parameter Modelica.SIunits.Length xBorFie = 10 "Borefield length";
parameter Modelica.SIunits.Length yBorFie = 30 "Borefield width";
parameter Modelica.SIunits.Length dBorHol = 5 "Distance between two boreholes";
parameter Integer nXBorHol = integer((xBorFie+dBorHol)/dBorHol) "Number of boreholes in x-direction";
parameter Integer nYBorHol = integer((yBorFie+dBorHol)/dBorHol) "Number of boreholes in y-direction";
final parameter Integer nBorHol = nXBorHol*nYBorHol "Number of boreholes";
Run Code Online (Sandbox Code Playgroud)
使用时
textString="Number of boreholes = %nBorHol"
Run Code Online (Sandbox Code Playgroud)
我得到
钻孔数 = nXBorHol*nYBorHol
我认为唯一的可能性是使用 DynamicSelect()功能。这可用于在例如图标中显示变化的值。要使用它,您必须手动调整图标注释。它记录在 Modelica Language Specification 3.4, Section 18.6.6 中。
如何使用它的一些很好的例子DynamicSelect()是:
Modelica.Blocks.Interaction.Show.RealValue 显示如何显示值Modelica.Blocks.Interfaces.partialBooleanSO 显示如何更改图标的线条和填充颜色Modelica.StateGraph.Examples.Utilities.Tank 显示如何更改矩形的大小以显示罐内的液位的缺点DynamicSelect()是它有时需要在显示值之前初始化/模拟模型(我认为如果它不是从文字或参数计算出来的)。优点是当查看模型时,它们会在模拟过程中更新。
对于您的情况,图标的实现可能如下所示:
annotation (Icon(graphics={Text(
extent={{-100,-20},{100,20}},
lineColor={0,0,0},
textString="NoB=" + DynamicSelect("?", String(nBorHol)))}));
Run Code Online (Sandbox Code Playgroud)
这导致图标显示
NoB=21
对我来说,它在更改相应参数之一时也会立即适应。
| 归档时间: |
|
| 查看次数: |
167 次 |
| 最近记录: |