I try to a model in which when the pressure inside the ClosedVolume
exceed a certain pressure level, then HDVentile
opens and the fluid flows into the boundary1
component. I defined the nports=1 in sweptvolume
and nPorts =2 in ClosedVolume
. In this case it throws an error saying
Sizes do not match in connection, size of 'ClosedVolume.ports' is [2] and size of 'Swept1.ports' is
If I set the nports=2 in sweptvolume
and nPorts =2 in ClosedVolume
, then it throws an error saying:
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
Do you know how to handle this error? Thanks in advance!
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;
I think the last connect should be
connect(ClosedVolume.ports[2], Swept1.ports[1]);
and for Swept1
it should be nPorts = 1
.
If you then add an input to HDVentile e.g. using
HDVentile.opening = 0;
the system should work.
Background: nports
corresponds to the number of connections to the component. Then you usually only connect a single line to each port. Therefore you need two for the ClosedVolume
and single one for Swept1
.