Error: Sizes do not match in connection - Sweptvolume and ClosedVolume -Modelica

Error: Sizes do not match in connection - Sweptvolume and ClosedVolume -Modelica

我尝试建立一个模型,其中当 ClosedVolume 内部的压力超过某个压力水平时,HDVentile 打开并且流体流入 boundary1 组件。我在 sweptvolume 中定义了 nports=1,在 ClosedVolume 中定义了 nPorts =2。在这种情况下,它会抛出一条错误消息

Sizes do not match in connection, size of 'ClosedVolume.ports' is [2] and size of 'Swept1.ports' is

如果我在 sweptvolume 中设置 nports=2 并且在 ClosedVolume 中设置 nPorts =2,那么它会抛出一条错误消息:

Assertion failed: each ports[i] of volume can at most be connected to one component. If two or more connections are present, ideal mixing takes place with these connections, which is usually not the intention of the modeller. Increase nPorts to add an additional port

你知道如何处理这个错误吗?提前致谢!

model modelmitclosedvolume
    //Declaration(s)
    Real V_max = 0.000003;
    Real V_tod = 0.000002;
    Real N = 2800;
    replaceable package medium = Modelica.Media.Water.StandardWater( );
    //Component(s)
    Modelica.Fluid.Machines.SweptVolume Swept1 (
        pistonCrossArea = 0.0001131,
        clearance = 0.000000250621,
        redeclare package Medium = Modelica.Media.Water.StandardWater,
        nPorts = 2,
        use_portsData = false,
        p_start = 1e5,
        use_T_start = true,
        T_start = 293.15,
        V(start = 0.005),
        m(start = 0.005));
    inner Modelica.Fluid.System system (p_ambient = 101325);
    Modelica.Mechanics.Translational.Sources.Position Posit1 (exact = true, useSupport = false);
    Modelica.Blocks.Sources.Sine Sine1 (
        amplitude = 0.005567,
        freqHz = 46.66,
        offset = 0.005567,
        phase = -Modelica.Constants.pi/4);
    Modelica.Fluid.Pipes.DynamicPipe pipe3 (
        length = 0.5,
        diameter = 0.03,
        redeclare package Medium = Modelica.Media.Water.StandardWater,
        momentumDynamics = system.momentumDynamics,
        massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial,
        energyDynamics = system.energyDynamics,
        allowFlowReversal = system.allowFlowReversal,
        modelStructure = Modelica.Fluid.Types.ModelStructure.a_vb);
    Modelica.Fluid.Valves.ValveLinear HDVentile (dp_nominal = 95, m_flow_nominal = 0.05867441, redeclare package Medium = medium);
    Modelica.Fluid.Pipes.DynamicPipe pipe4 (
        length = 0.5,
        diameter = 0.03,
        redeclare package Medium = Modelica.Media.Water.StandardWater,
        momentumDynamics = system.momentumDynamics,
        massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial,
        energyDynamics = system.energyDynamics,
        allowFlowReversal = system.allowFlowReversal,
        modelStructure = Modelica.Fluid.Types.ModelStructure.a_vb);
    Modelica.Fluid.Sources.FixedBoundary boundary1 (p = 500e5, redeclare package Medium = Modelica.Media.Water.StandardWater, nPorts = 1);
    Modelica.Fluid.Vessels.ClosedVolume ClosedVolume (
        V = 0.005/6,
        nPorts = 2,
        portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.001),Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.001)},
        redeclare package Medium = medium);


equation
    //Connection(s)
    connect(Posit1.flange, Swept1.flange);
    connect(Sine1.y, Posit1.s_ref);
    connect(pipe3.port_b, HDVentile.port_a);
    connect(HDVentile.port_b, pipe4.port_a);
    connect(pipe4.port_b, boundary1.ports[1]);
    connect(ClosedVolume.ports[1], pipe3.port_a);
    connect(ClosedVolume.ports, Swept1.ports);
end  modelmitclosedvolume;

我认为最后一个连接应该是

    connect(ClosedVolume.ports[2], Swept1.ports[1]);

而对于 Swept1 它应该是 nPorts = 1.

如果您随后向 HDVentile 添加输入,例如使用

    HDVentile.opening = 0;

系统应该可以工作。

背景:nports对应组件的连接数。那么您通常只将一条线连接到每个端口。因此,ClosedVolume 需要两个,Swept1.

需要一个