计算带有连接器的模型中的方程数

Counting the number of equations in models with connectors

我目前正在评估 Dymola 2020 以构建太阳能发电厂模型,但我对使用自定义连接器的模型中的方程式数量感到困惑。

代码如下:

connector Port
  flow Real Q;
  Real P;
  Real T;
end Port;
model Inlet
  parameter Real Q = 1;
  parameter Real P = 2;
  parameter Real T = 3;
  Port a;
equation 
  a.Q = Q;
  a.P = P;
  a.T = T;
end Inlet;

我在模型中设置了3个方程,但是出现错误显示有4个方程。方程式是如何计算的?为什么有4个?

The problem is structurally singular.

It has 3 scalar unknowns and 4 scalar equations. The Real part has 3 unknowns and 4 equations. The Integer part has 0 unknowns and 0 equations. The Boolean part has 0 unknowns and 0 equations. The String part has 0 unknowns and 0 equations.

The number of scalar Real unknown elements are 3. The number of scalar Real equation elements are 4.

Part of the problem for Real elements is overdetermined. There are 1 scalar equations too many in the set: a.T = T; a.P = P; a.Q = Q;

您的示例存在两个不同的问题:

  1. 连接器通常包含 的 across/potential 和 flow/through 个变量 Modelica Language Specification, Section 9.3.1. Following this convention, the models using these connectors usually define a relation between flow and across variables. For some general - and very readable - information on the definition of connectors see Modelica by Exmple。我认为遵循这个约定不是强制性的,但是如果你在对物理系统建模时这样做会让生活变得更轻松。

  2. Inlet设置所有接口变量。物理源模型设置跨变量或流变量。你有一个压力源或一个流量源,它不能同时设置。这归结为管道计算流量的压降或压降的流量。模型通常假设跨变量 流量变量由外部决定。从该模型使用其 equation 部分中定义的关系计算另一个。对于您的示例,所有这些都归结为:如果删除任何方程式,例如a.Q = Q; 来自 Inlet,模型检查。对此的解释是如何从连接器和模型生成方程式。有关这方面的更多信息,请参阅第 110 页底部的 Modelica Language Specification,第 9.2 节,说 "Each connection set is used to generate..."

关于以上两点,我建议看一下Modelica Standard Library的FluidHeatFlow库,尤其是Modelica.Thermal.FluidHeatFlow.Interfaces.FlowPort中定义的接口。从您的接口变量来看,该库服务于类似的物理域。

为了更简单的开始,仔细看看 Modelica.Thermal.HeatTransfer 也很有意义。这个包只有一对 across/flow 变量,因此更容易理解。

如评论中所述,我认为您应该研究 Modelica 的 stream connectors,它本质上支持热流体组件中的零流量和反向流动。

它们可能有点难以理解,所以不久前我在 GitHub 上放了一个小示例包,演示了流连接器的基础知识。如果您有兴趣,可以在这里找到它:https://github.com/justnielsen/ModelicaTutorials. There is also a Wiki 解释 Stream connector 语法的页面。

顺便说一下,Claytex 有一个很好的 blog, updated weekly. They have a post from 2017 on stream connectors: https://www.claytex.com/tech-blog/fluid-connectors-modelica-standard-library/

此致, 雷内·贾斯特·尼尔森