OpenTank

model OpenTank
    outer HydraulicsByFluidon.Media.Environment environment;
    parameter Boolean useEnvironmentPressure = true "Pressure at the fluid port equals environment.pAmbient"
        annotation (choices(checkBox = true));
    parameter Modelica.SIunits.AbsolutePressure pressure = environment.pAmbient "Pressure at the fluid port if useAmbientPressure = false";
    HydraulicsByFluidon.Interfaces.FluidPort fluidPort(p(start = pressure, nominal = 100000)) "Hydraulic port"
        annotation (Placement(transformation(extent = {
            {-10, 90}, 
            {10, 110}})));
equation
    fluidPort.p = if useEnvironmentPressure then environment.pAmbient else pressure;

    annotation (
        defaultComponentName = "tank",
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    pattern = LinePattern.Dash,
                    color = {0, 0, 0},
                    points = {
                        {-60, 30}, 
                        {-60, -30}, 
                        {60, -30}, 
                        {60, 30}}), 
                Line(
                    pattern = LinePattern.Dash,
                    color = {0, 0, 0},
                    points = {
                        {-60, 10}, 
                        {60, 10}}), 
                Line(
                    color = {0, 93, 152},
                    points = {
                        {0, 100}, 
                        {0, 20}}), 
                Text(
                    visible = if useEnvironmentPressure then false else true,
                    extent = {
                        {-80, -20}, 
                        {80, -60}},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    textString = "p=%pressure Pa"), 
                Text(
                    extent = {
                        {-100, -60}, 
                        {100, -100}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Documentation(info = "<html>\n                                        <p>\n                                            The OpenTank component is the model of an open tank with unlimited volume in the sense of a line\n                                            termination. The pressure at <i>fluidPort</i> can either be set to <i>environment.pAmbient</i>\n                                            pressure or a different pressure. \n                                        </p>\n                                      </html>"));
end OpenTank;