在 DYMOLA 中显示注释中的参数 [英] Displaying parameter in annotation in DYMOLA
问题描述
我有一个使用不同组件的仿真模型.为了快速了解使用的参数,我使用注释功能通过以下方式显示某些模型参数(例如 m_flow_nominal):
I have a simulation model using different components. In order to get a quick overview of the used parameters I use the functionality of annotations to display certain model parameters (e.g. m_flow_nominal) via:
textString="Nominal Flow Rate = %m_flow_nominal"
在注释对话框中.哪个会发出类似
in the annotation dialog. Which will give out something like
标称流量 = 5
这对于整数参数非常有效.
This is working perfectly fine for parameters that are integers.
我还有一个从其他值计算出来的参数.比如,让我们说一个身体的体积.当我尝试通过以下方式显示此参数时:
I also have a parameter that is calculated from other values. Like, let's say the Volume of a body. When I try to display this parameters via:
textString="Volume = %volume"
我将给出计算体积的公式,而不是最终值.例如
Instead of the final value I will be given the formula the volume is calculated with. For example
体积 = a * b * c
Volume = a * b * c
在这种情况下如何显示成交量的最终值,而不是公式?
How can I display the final value of the volume in this case, instead of the formula?
实际问题如下:
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";
使用时
textString="Number of boreholes = %nBorHol"
我明白了
钻孔数 = nXBorHol*nYBorHol
Number of boreholes = nXBorHol*nYBorHol
推荐答案
我认为唯一的可能是使用 DynamicSelect()
函数.这可用于显示例如内的变化值.一个图标.要使用它,您必须手动调整图标注释.它记录在 Modelica 语言规范 3.4 的第 18.6.6 节中.
I think the only possibility is to use the DynamicSelect()
function. This can be used to show a changing value within e.g. an icon. To use it you will have to manually adapt the Icon annotation. It is documented in the Modelica Language Specification 3.4, Section 18.6.6.
如何使用此 DynamicSelect()
的一些很好的例子是:
Some good examples of how this DynamicSelect()
can be used are:
Modelica.Blocks.Interaction.Show.RealValue
显示如何显示值Modelica.Blocks.Interfaces.partialBooleanSO
显示如何更改图标的线条和填充颜色Modelica.StateGraph.Examples.Utilities.Tank
显示如何更改矩形的大小以显示水箱内的液位
Modelica.Blocks.Interaction.Show.RealValue
shows how to display a valueModelica.Blocks.Interfaces.partialBooleanSO
shows how to change line- and fill colors of iconsModelica.StateGraph.Examples.Utilities.Tank
shows how to change the size of a rectangle to display the level within a tank
DynamicSelect()
的缺点是它有时需要在显示值之前初始化/模拟模型(我认为如果它不是从文字或参数计算出来的).优点是当查看模型时,它们会在模拟过程中更新.
The disadvantage of DynamicSelect()
is that it will sometimes need to initialize/simulate the model before showing a value (I think if it is not computed from literals or parameters). The advantage is that they are updated during the simulation when looking at the model.
对于您的情况,图标的实现可能如下所示:
For your case the implementation of the icon could look like:
annotation (Icon(graphics={Text(
extent={{-100,-20},{100,20}},
lineColor={0,0,0},
textString="NoB=" + DynamicSelect("?", String(nBorHol)))}));
导致图标显示
NoB=21
对我来说,当更改相应参数之一时,它也会立即适应.
For me it also immediately adapts when changing one of the respective parameters.
这篇关于在 DYMOLA 中显示注释中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!