在DYMOLA中的注释中显示参数 [英] Displaying parameter in annotation in DYMOLA

查看:124
本文介绍了在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

Nominal Flow Rate = 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()函数.这可以用来显示一个变化的值,例如一个图标.要使用它,您将必须手动修改Icon注释.它在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 value
  • Modelica.Blocks.Interfaces.partialBooleanSO shows how to change line- and fill colors of icons
  • Modelica.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

NoB=21

对我来说,当更改相应参数之一时,它也会立即适应.

For me it also immediately adapts when changing one of the respective parameters.

这篇关于在DYMOLA中的注释中显示参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆