PropPRVstatic

model PropPRVstatic
    parameter Real InputScaling = 1e+7 "Input scaling";
    parameter Modelica.SIunits.VolumeFlowRate NominalVolumeFlow = 5e-4 "Nominal volume flow";
    parameter Modelica.SIunits.Pressure NominalPressureDifference = 500000 "Nominal pressure difference";
    parameter Modelica.SIunits.Density ReferenceDensity = 860 "Reference density for volume flow and pressure difference";
    parameter Modelica.SIunits.Volume deadVolume(final min = 1e-9) = 1e-6 "Dead volume at ports";
    parameter Boolean Balanced = true "Balanced valve"
        annotation (choices(checkBox = true));
    parameter Boolean exact = false "Find exact opening point"
        annotation (choices(checkBox = true));

    extends HydraulicsByFluidon.Components.Valves.Base.PartialPRV;

    Modelica.Blocks.Interfaces.RealInput Input "Set value of opening pressure"
        annotation (Placement(
            visible = true,
            transformation(
                origin = {120, 0},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = 180),
            iconTransformation(
                origin = {120, 0},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = 180)));
    HydraulicsByFluidon.Components.Valves.Base.SimplePRVstatic simplePRVstatic(fixedOpeningPressure = false, openingPressure = openingPressure, forwardFluidProperties = false, Balanced = Balanced, NominalPressureDifference = NominalPressureDifference, NominalVolumeFlow = NominalVolumeFlow, ReferenceDensity = ReferenceDensity) annotation (Placement(
        visible = true,
        transformation(
            origin = {0, 0},
            extent = {
                {-12, -10}, 
                {12, 10}},
            rotation = 0)));
    HydraulicsByFluidon.Components.Volumes.Volume volumeA(capacity = deadVolume) annotation (Placement(
        visible = true,
        transformation(
            origin = {0, -70},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
    HydraulicsByFluidon.Components.Volumes.Volume volumeB(capacity = deadVolume) annotation (Placement(
        visible = true,
        transformation(
            origin = {0, 70},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
protected
    Modelica.SIunits.Pressure openingPressure;
equation
    connect(fluidPortA,volumeA.fluidPort) annotation (Line(
        points = {
            {0, -100}, 
            {0, -70}},
        color = {0, 93, 152}));
    connect(volumeA.fluidPort,simplePRVstatic.fluidPortA) annotation (Line(
        points = {
            {0, -70}, 
            {0, -10}},
        color = {0, 93, 152}));
    connect(volumeB.fluidPort,fluidPortB) annotation (Line(
        points = {
            {0, 70}, 
            {0, 100}},
        color = {0, 93, 152}));
    connect(simplePRVstatic.fluidPortB,volumeB.fluidPort) annotation (Line(
        points = {
            {0, 10}, 
            {0, 70}},
        color = {0, 93, 152}));
    openingPressure = InputScaling * max(0, Input);
    volumeA.p = pA;
    volumeB.p = pB;

    annotation (
        Icon(
            coordinateSystem(
                extent = {
                    {-120, -100}, 
                    {120, 100}},
                preserveAspectRatio = false),
            graphics = {
                Rectangle(
                    origin = {80, 20},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-40, 0}, 
                        {20, -40}}), 
                Line(
                    origin = {70, 0},
                    points = {
                        {10, -20}, 
                        {-10, 20}}), 
                Polygon(
                    origin = {80, 65},
                    rotation = -13,
                    fillPattern = FillPattern.Solid,
                    points = {
                        {0, 0}, 
                        {-5, -20}, 
                        {5, -20}, 
                        {0, 0}}), 
                Line(
                    origin = {60, -25},
                    points = {
                        {0, 0}, 
                        {20, 90}})}),
        Documentation(info = "<html>\n            <p>\n                The component PropPRVstatic is a model of a proportional pressure relief valve without\n                dynamic characteristics. For all pressures exceeding opening pressure the valve opens and \n                the flow increases linearly following the slope given by parameters <var>Nominal volume flow</var> and \n                <var>Nominal pressure difference</var>.\n            </p>\n            <p>\n                The opening 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 opening pressure 200e5 Pa, <var>Input scaling</var> must be set to 20e5 [Pa/V] (200e5 / 10).\n                If the opening 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 opening pressure is not limited but only proportional to <var>input</var>.\n            </p>\n            <p>\n                If the valve is balanced (<var>Balanced valve</var> = true) the valve opens when the supply pressure exceeds \n                the opening pressure:\n            </p>\n            <p>\n                Opening condition: fluidPortA.p &#62; opening pressure + pAmbient\n            </p>\n            <p>\n                If the valve is not balanced (<var>Balanced valve</var> = false) the tank pressure is considered: \n            </p>\n            <p>\n                Opening condition: fluidPortA.p &#62; opening pressure + fluidPortB.p\n            </p>\n            <p>\n                If <var>Find exact opening point</var> is set to true, the valve opens exactly at the time when the opening pressure is exceeded. \n                If it is set to false, the valve may open earlier or later depending on simulation's step size.\n                This setting avoids an event (and probably a slow down of simulation) by using noEvent().\n            </p>\n            <p>\n                The component part PRVstatic is not a model of a pressure relief valve according to its \n                physical structure. It merely represents the characteristic behavior of a pressure relief \n                valve. Therefore dynamic effects such as forces due to inertia will not be represented.\n            </p>\n            </html>"));
end PropPRVstatic;