PropPressureControlValve

model PropPressureControlValve
    parameter Real InputScaling = 1e+7 "Input scaling";
    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;

    Modelica.Blocks.Interfaces.RealInput Input annotation (Placement(
        visible = true,
        transformation(
            origin = {120, 0},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 180),
        iconTransformation(
            origin = {120, -20},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 180)));
protected
    Modelica.SIunits.AbsolutePressure SetPressureAbs = InputScaling * Input + 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 = {
                Rectangle(
                    origin = {80, 0},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-40, 0}, 
                        {20, -40}}), 
                Polygon(
                    origin = {80, 45},
                    rotation = -13,
                    fillPattern = FillPattern.Solid,
                    points = {
                        {0, 0}, 
                        {-5, -20}, 
                        {5, -20}, 
                        {0, 0}}), 
                Line(
                    origin = {70, -20},
                    points = {
                        {10, -20}, 
                        {-10, 20}}), 
                Line(
                    origin = {60, -45},
                    points = {
                        {0, 0}, 
                        {20, 90}})}),
        Documentation(info = "<html>\n            <p>\n                The component PropPressureControlValve is a model of a 3-port pressure control valve with an input of set pressure. \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/PropPressureControlValve.png\"></center>\n            </p>\n            <p>\n                The set pressure is calculated by <var>Input</var> * <var>Input scaling</var>. If <var>input</var> should be in the range\n                of 0 to 10 [V] and maximum set pressure 200e5 Pa, <var>Input scaling</var> must be set to 20e5 [Pa/V] (200e5 / 10).\n                If the set pressure should be given directly by <var>input</var>, <var>Input scaling</var> must be set to 1. <b>Please note:</b>\n                the upper value of set pressure is not limited but only proportional to <var>input</var>.\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/PropPressureControlValveSketch.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 PropPressureControlValve;