PressureControlValve

model PressureControlValve
    parameter Modelica.SIunits.Pressure SetPressure = 1e+7 "Set pressure (relative value)";
    parameter Modelica.SIunits.Pressure DeviationPA = -500000 "Deviation P-A";
    parameter Modelica.SIunits.Pressure DeviationAT = 500000 "Deviation A-T";
    parameter Real gain = 1 "Controller gain";

    extends HydraulicsByFluidon.Components.Valves.Base.PartialPressureValve_32;

protected
    parameter Modelica.SIunits.AbsolutePressure SetPressureAbs = SetPressure + environment.pAmbient;
equation
    if noEvent(portA.p <= SetPressureAbs) then 
        ssU = min(1, (SetPressureAbs + volumeFlowP / NominalVolumeFlow * DeviationPA - portA.p) * (1e-5) * gain);
    else 
        ssU = max(-1, (SetPressureAbs - volumeFlowT / NominalVolumeFlow * DeviationAT - portA.p) * (1e-5) * gain);
    end if;

    annotation (
        Icon(
            coordinateSystem(
                extent = {
                    {-100, -100}, 
                    {100, 100}},
                preserveAspectRatio = false),
            graphics = {
                Line(
                    origin = {40, -20},
                    points = {
                        {0, 0}, 
                        {4, 20}, 
                        {12, -20}, 
                        {20, 20}, 
                        {28, -20}, 
                        {36, 20}, 
                        {44, -20}, 
                        {48, 0}})}),
        Documentation(info = "<html>\n            <p>\n                The component PressureControlValve is a model of a 3-port pressure control valve. \n                It maintains a largely constant outlet pressure even at a variable (higher) supply pressure. In addition to a 2-port pressure reducing valve \n                it also reduces the outlet pressure to tank.\n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Valves/PressureValves/PressureControlValve.png\"></center>\n            </p>\n            <p>\n                If supply pressure <var>pA</var> is less than <var>Set pressure (relative value)</var> the valve acts like an orifice \n                with the characteristics <var>Nominal volume flow</var> and <var>Nominal pressure difference</var>.\n            </p>\n            <p>\n                For all pressures deviating from <var>Set pressure (relative value)</var> the valve opens and \n                the flow increases linearly following the slope given by parameters <var>Nominal volume flow</var> and \n                <var>Pressure drop</var>. For flow P->A the outlet pressure deviates by <var>Deviation P-A</var> @ <var>Nominal volume flow</var>\n                and by <var>Deviation P-A</var> @ -<var>Nominal volume flow</var> for flow A->T.\n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Valves/PressureValves/PressureControlValveSketch.png\"></center>\n            </p>\n            <p>\n                The component PressureControlValve is not a model of a pressure control valve according to its \n                physical structure. It merely represents the characteristic behavior of a pressure control \n                valve. Therefore dynamic effects such as forces due to inertia will not be represented.\n            </p>\n            </html>"));
end PressureControlValve;