ClosedVolume

model ClosedVolume "Volume of fixed size, closed to the ambient, with inlet/outlet ports"
    import Modelica.Constants.pi;

    extends Modelica.Fluid.Vessels.BaseClasses.PartialLumpedVessel(final fluidVolume = V, vesselArea = pi * (0.75 * V) ^ (0.666666666666667), heatTransfer(surfaceAreas = {4 * pi * (0.75 * V / pi) ^ (0.666666666666667)}));

    parameter SI.Volume V "Volume";
equation
    for i in 1:nPorts loop
        vessel_ps_static[i] = medium.p;
    end for;
    Wb_flow = 0;

    annotation (
        defaultComponentName = "volume",
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Ellipse(
                    extent = {
                        {-100, 100}, 
                        {100, -100}},
                    fillPattern = FillPattern.Sphere,
                    fillColor = {170, 213, 255}), 
                Text(
                    extent = {
                        {-150, 12}, 
                        {150, -18}},
                    textString = "V=%V")}),
        Documentation(info = "<html>\n<p>\nIdeally mixed volume of constant size with two fluid ports and one medium model.\nThe flow properties are computed from the upstream quantities, pressures are equal in both nodes and the medium model if <code>use_portsData=false</code>.\nHeat transfer through a thermal port is possible, it equals zero if the port remains unconnected.\nA spherical shape is assumed for the heat transfer area, with V=4/3*pi*r^3, A=4*pi*r^2.\nIdeal heat transfer is assumed per default; the thermal port temperature is equal to the medium temperature.\n</p>\n<p>\nIf <code>use_portsData=true</code>, the port pressures represent the pressures just after the outlet (or just before the inlet) in the attached pipe.\nThe hydraulic resistances <code>portsData.zeta_in</code> and <code>portsData.zeta_out</code> determine the dissipative pressure drop between volume and port depending on\nthe direction of mass flow. See <a href=\"modelica://Modelica.Fluid.Vessels.BaseClasses.VesselPortsData\">VesselPortsData</a> and <em>[Idelchik, Handbook of Hydraulic Resistance, 2004]</em>.\n</p>\n</html>"));
end ClosedVolume;