更改 Modelica 标准库模型中参数的注释(Evaluate=true/false ) [英] Change annotation(Evaluate=true/false ) for parameters in models from Modelica Standard Library

查看:36
本文介绍了更改 Modelica 标准库模型中参数的注释(Evaluate=true/false )的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在模拟中使用了 Modelica 标准库 (MSL) 中的一些组件.这些组件每个都有一些参数.例如,Modelica.Fluid.Sources.MassFlowSource_T 有一个 参数 m_flow.通常,无需重新编译即可在模拟运行之间更改参数.m_flow 不是这种情况,因为它有一个annotation(Evaluate=true),所以它用于符号处理.
是否可以在实例化时更改参数的注释?我尝试了以下方法,但没有奏效.

I am using some components from the Modelica Standard Library (MSL) in my simulations. These components each have some parameters. For example, Modelica.Fluid.Sources.MassFlowSource_T has a parameter m_flow. Usually, parameters can be changed between simulation runs without re-compilation. This is not the case for m_flow, because it has an annotation(Evaluate=true), so it is used for symbolic processing.
Is it possible to change the annotations of parameters at instantiation? I tried the following, but it didn't work.

Modelica.Fluid.Sources.MassFlowSource_T source2(
    redeclare package Medium = Medium2,
    nPorts=1,
    m_flow=22.17 annotation(Evaluate=false));

当然有一些解决方法,比如先制作一个副本并在那里更改注释或使用 use_m_flow_in=true 和一个常量源块.

Of course there are workarounds, like making a copy first and changing the annotation there or using use_m_flow_in=true and a constant source block.

推荐答案

据我所知,这在当前的 Modelica 规范中是不可能的.如果您扩展 MassFlowSource_T,某些工具可能会支持它:

As far as I know this is not possible with current Modelica Specification. Some tools might support it if you extend MassFlowSource_T:

model MassFlowSource_T_2
  extends Modelica.Fluid.Sources.MassFlowSource_T;
  // declare m_flow here again with annotation(Evaluate=false);
end MassFlowSource_T_2;

use MassFlowSource_T_2 when you declare source2.

有一些工作正在进行中以扩展注释的指定/处理方式但它需要一段时间才能进入 Modelica 规范:https://trac.modelica.org/Modelica/ticket/1293(不开放给尚未公开).

There is some work in progress to extend the way annotations are specified/handled but it will be a while until it makes it into the Modelica Specification: https://trac.modelica.org/Modelica/ticket/1293 (not open to the public yet).

这篇关于更改 Modelica 标准库模型中参数的注释(Evaluate=true/false )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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