无法扩展包含连接的块

huangapple go评论49阅读模式
英文:

Failed to expand block containing connect

问题

我试图建立一个根据温度条件连接的连接,以表示在分层热储罐内工作的温度敏感充电管道,以下是用于读取储罐的几个体积的for循环:

`for i in 2:nSeg loop
    if (sensor_T_inflow.T > vol[i].T) and (sensor_T_inflow.T < vol[i-1].T) then
      connect(feedPort, vol[i].ports[3])
        annotation (Line(points={{-50,-60},{6,-60},{6,
          -16},{16,-16}}, color={0,127,255}));
    end if;
  end for;`

然而,我遇到了错误,例如体积2的错误如下:

未能展开包含连接的块:
if (sensor_T_inflow.T > vol[2].T and sensor_T_inflow.T < vol[1].T) then connect(feedPort, vol[2].ports[3]); end if;

模型包含无效的连接语句。
检查中止。

这可能有一个愚蠢的解决方案,但我已检查了所有我的元素的名称和它们的温度属性,它们与这段代码片段匹配,我确认错误特别来自if条件。这是我的模型 如果您能看一下。

我尝试注释掉条件,检查是成功的,只是我有大约40个变量不平衡的问题。如果您有关于如何解决这些不平衡的建议,我将非常感激。

非常感谢您提前的帮助。

英文:

I´m trying to set a connection with a conditional on the temperature, to represent a temperature-sensible charging pipe that works inside a stratified heat storage tank, with the following for loop reading the several volumes of the tank,

`for i in 2:nSeg loop
    if (sensor_T_inflow.T > vol[i].T) and (sensor_T_inflow.T < vol[i-1].T) then
      connect(feedPort, vol[i].ports[3])
        annotation (Line(points={{-50,-60},{6,-60},{6,
          -16},{16,-16}}, color={0,127,255}));
    end if;
  end for;`

However I get the errors such as this one for the volume 2:

Failed to expand block containing connect:
if (sensor_T_inflow.T > vol[2].T and sensor_T_inflow.T < vol[1].T) then
connect(feedPort, vol[2].ports[3]);
end if;

The model contained invalid connect statements.
Check aborted.

This might have a silly solution but I checked the names of all my elements and their temperature properties and they match with this code snippet, and I confirmed the error comes specially from the if conditional. Here is my model If you could take a look at it.

I tried commenting out the conditional and the check was succesful, only that I have a misbalance of about 40 variables to equations. If you got any advice on how to solve those misbalances I´d be much grateful as well.

Thanks a lot in advance.

答案1

得分: 1

连接语句不得依赖于时间变化的变量。

(技术性说明在 https://specification.modelica.org/master/connectors-and-connections.html#restrictions-of-connections-and-connectors 中排在首位)

一种解决方法是将其转换为阀门组件的数组,并以类似的方式对其进行控制。

英文:

The connect-statements may not depend on time-varying variables.

(The technical statement is first in the list in https://specification.modelica.org/master/connectors-and-connections.html#restrictions-of-connections-and-connectors )

A solution would be to turn that into an array of valve-components, and have them controlled in a similar way.

huangapple
  • 本文由 发表于 2023年2月19日 20:02:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500010.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定