ShuttleValveNoFlow

model ShuttleValveNoFlow
    outer HydraulicsByFluidon.Media.Environment environment;
    parameter Modelica.SIunits.Volume deadVolume(final min = 1e-9) = 1e-6 "Dead volume at ports"
        annotation (Dialog(group = "Geometry"));
    parameter Boolean forwardFluidProperties = true "Forward fluid properties between ports"
        annotation (
            Dialog(tab = "Fluid Properties"),
            choices(checkBox = true));
    Modelica.SIunits.AbsolutePressure pA(start = environment.pAmbient, nominal = 100000) "Pressure at port A";
    Modelica.SIunits.AbsolutePressure pB(start = environment.pAmbient, nominal = 100000) "Pressure at port B";
    HydraulicsByFluidon.Interfaces.FluidPort fluidPortA(p(start = environment.pAmbient, nominal = 100000)) "Hydraulic port A"
        annotation (Placement(transformation(extent = {
            {-110, -10}, 
            {-90, 10}})));
    HydraulicsByFluidon.Interfaces.FluidPort fluidPortB(p(start = environment.pAmbient, nominal = 100000)) "Hydraulic port B"
        annotation (Placement(transformation(extent = {
            {90, -10}, 
            {110, 10}})));
    HydraulicsByFluidon.Interfaces.FluidPort fluidPortC(p(start = environment.pAmbient, nominal = 100000)) "Hydraulic port C"
        annotation (Placement(
            visible = true,
            transformation(
                extent = {
                    {-10, -110}, 
                    {10, -90}},
                rotation = 0),
            iconTransformation(
                extent = {
                    {-10, -110}, 
                    {10, -90}},
                rotation = 0)));
    HydraulicsByFluidon.Components.Sources.VariablePressureSource variablePressureSource1 annotation (Placement(
        visible = true,
        transformation(
            origin = {0, -10},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 180)));
    HydraulicsByFluidon.Components.Volumes.Volume volumeA(capacity = deadVolume) annotation (Placement(
        visible = true,
        transformation(
            origin = {-70, 0},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
    HydraulicsByFluidon.Components.Volumes.Volume volumeB(capacity = deadVolume) annotation (Placement(
        visible = true,
        transformation(
            origin = {70, 0},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
equation
    if forwardFluidProperties then 
        fluidPortA.fluidTemperature = fluidPortC.fluidTemperature;
        fluidPortB.fluidTemperature = fluidPortC.fluidTemperature;
        fluidPortA.fluidId = fluidPortC.fluidId;
        fluidPortB.fluidId = fluidPortC.fluidId;
        fluidPortA.proportionUndissolvedAir = fluidPortC.proportionUndissolvedAir;
        fluidPortB.proportionUndissolvedAir = fluidPortC.proportionUndissolvedAir;
        fluidPortA.polytropicExponent = fluidPortC.polytropicExponent;
        fluidPortB.polytropicExponent = fluidPortC.polytropicExponent;
    end if;
    connect(volumeA.fluidPort,fluidPortA) annotation (Line(
        points = {
            {-70, 0}, 
            {-100, 0}},
        color = {0, 93, 152}));
    connect(volumeB.fluidPort,fluidPortB) annotation (Line(
        points = {
            {70, 0}, 
            {100, 0}},
        color = {0, 93, 152}));
    connect(variablePressureSource1.fluidPort,fluidPortC) annotation (Line(
        points = {
            {0, -20}, 
            {0, -100}},
        color = {0, 93, 152}));
    volumeA.p = pA;
    volumeB.p = pB;
    variablePressureSource1.setPressure = max(fluidPortA.p, fluidPortB.p);

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 60}},
                initialScale = 0.1),
            graphics = {
                Rectangle(
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-80, 40}, 
                        {80, -40}}), 
                Line(
                    origin = {-60, 0},
                    points = {
                        {20, 20}, 
                        {0, 0}, 
                        {20, -20}}), 
                Line(
                    origin = {60, 0},
                    points = {
                        {-20, 20}, 
                        {0, 0}, 
                        {-20, -20}}), 
                Ellipse(
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {2, 2}, 
                        {-2, -2}},
                    endAngle = 360), 
                Line(points = {
                    {0, -100}, 
                    {0, 0}}), 
                Line(points = {
                    {100, 0}, 
                    {-100, 0}}), 
                Ellipse(
                    origin = {-46, 0},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-10, 10}, 
                        {10, -10}},
                    endAngle = 360)}),
        Documentation(info = "<html>\n            <p>\n                The component ShuttleValveNoFlow is the model of a changeover valve that has no flow through the valve, but only transmits the pressure. \n                It connects port C (the middle port) with the port that has the highest pressure.\n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Valves/CheckValves/ShuttleValve.png\"></center>\n            </p>\n            <p>\n                \n            </p>\n            <p>\n                A typical application of this valve is in a load sensing system to determine the highest load pressure.\n            </p>\n            <p>\n                If you need a shuttle valve that also has a flow characteristic, you can use the component ShuttleValve.\n            </p>\n            </html>"));
end ShuttleValveNoFlow;