问题描述
在文档中指出,该 cardinality()
函数已弃用,不应再使用.但是,它仍然在诸如 ThermoSysPro 之类的库中使用.
In the documentation it is indicated, that cardinality()
function is deprecated and should no longer be used. However, it is still used in the libraries such as ThermoSysPro.
例如
if (cardinality(C) == 0) then
some code
end if;
其中 C
是 FluidInlet
或 FluidOutlet
谁能举一个简单的例子来说明如何替换它?
Could anyone give a simple example of how it could be replaced?
推荐答案
通常的解决方案是使连接器有条件,如果启用,您需要它已连接.
The usual solution is to make the connector conditional, and if enabled you require that it is connected.
对于物理连接器,您可以看到热端口和支持的处理方式:Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort
Modelica.Mechanics.Rotational.Interfaces.PartialElementaryOneFlangeAndSupport2
For physical connectors you can see how heatports and support is handled in:Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort
Modelica.Mechanics.Rotational.Interfaces.PartialElementaryOneFlangeAndSupport2
对于控制信号,您可以看到 p_in
、h_in
等在Modelica.Fluid.Sources.Boundary_pT
Modelica.Fluid.Sources.Boundary_ph
For control signals you can see how p_in
, h_in
etc are handled inModelica.Fluid.Sources.Boundary_pT
Modelica.Fluid.Sources.Boundary_ph
然而,ThermoSysPro 的连接器不属于这两个类别,理想情况下也应该清理.
However, the connectors of ThermoSysPro belong in neither of those categories and that should ideally also be cleaned up.
这篇关于替换 Modelica 中已弃用的函数基数(c)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!