PropValve33LS

model PropValve33LS
    parameter Real inputMax = 10 "Input value for 100 % open"
        annotation (Dialog(group = "Control Parameters"));
    parameter Modelica.SIunits.AngularFrequency angFreq = 2 * Modelica.Constants.pi * 50 "Angular frequency"
        annotation (Dialog(group = "Control Parameters"));
    parameter Modelica.SIunits.DampingCoefficient damping = 0.7 "Damping"
        annotation (Dialog(group = "Control Parameters"));
    parameter Modelica.SIunits.TimeAging vMax = 100 "max. Velocity"
        annotation (Dialog(group = "Control Parameters"));
    parameter Modelica.SIunits.TimeAging vMin = -100 "min. Velocity"
        annotation (Dialog(group = "Control Parameters"));

    extends HydraulicsByFluidon.Components.Valves.Base.PartialValve33LS;
    extends HydraulicsByFluidon.Components.Valves.Base.PartialValveControlSignal_63;
    extends HydraulicsByFluidon.Components.Valves.Base.PartialValveProp_63;

    Modelica.SIunits.DimensionlessRatio Stroke(start = 0) "rel. Position of valve spool";
    Modelica.SIunits.TimeAging Velocity(start = 0) "rel. Velocity of valve spool";
    Modelica.Blocks.Nonlinear.Limiter limiter(limitsAtInit = true, strict = true, uMax = 1, uMin = -1);
equation
    if enableStrokeOut then 
        valveStrokeOut = Stroke;
    end if;
    if noEvent(vMax < Velocity) then 
        der(Stroke) = vMax;
    elseif noEvent(Velocity < vMin) then 
        der(Stroke) = vMin;
    else 
        der(Stroke) = Velocity;
    end if;
    ssLS = if noEvent(switchBand < Stroke) then portA.p else portT.p;
    gain1.u = Stroke;
    limiter.u = Input / inputMax;
    valveEdgePA.Input = Stroke;
    der(Velocity) = angFreq * (angFreq * (limiter.y - Stroke) - 2 * damping * Velocity);

    annotation (Documentation(info = "<html>\n            <p>\n                The component PropValve33LS is a model of a 3-way proportional valve where the \n                stroke follows the input signal with a 2nd order delay. In addition to PropValve33PT2, it has a fourth port (<i>LS</i>)\n                connected to port A or port T, depending on the stroke.\n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Valves/DirectionalValves/LSDirectionalValves/PropValve33LS.png\"></center>\n            </p>\n            <p>\n                For a positive stroke (right position), the flow is scaled in proportion to the input signal starting from 0 to \n                <var>Input value for 100 % open</var> with nominal flow (as given by <var>Nominal volume flow</var>/<var>Nominal pressure difference</var>) \n                corresponding to an input value of <var>Input value for 100 % open</var>. In case of a negative stroke (left position) \n                the same applies for input from 0 to -<var>Input value for 100 % open</var>.\n            </p>\n            <p>\n                The valve stroke can be shifted by <var>Valve edge general relative overlap</var>. In accordance with common \n                valve parameters a negative overlap will open the valve edge. <var>Valve edge general relative overlap</var> \n                is applied to all valve edges simultaneously. If at least one of the edge-specific values, e. g. \n                <var>Valve edge PA relative overlap</var> is set to a value different from 0, then  \n                <var>Valve edge general relative overlap</var> is ignored and the individual overlaps are used.\n            </p>\n            <p>\n                The default relationship between input signal and flow rate of the metering edge is linear, but can be changed through the use of a 1D look-up table. \n                The look-up table is provided either manually or by importing a text file. If the parameter <var>Table is provided by file</var> is set to <i>false</i>, the \n                manually entered datapoints from <var>Manually provided look-up table</var> will be used. If it is set to <i>true</i>, the table <var>Table name on file</var> \n                from the file <var>File where look-up table is stored</var> will be utilized. \n            </p> \n            <p>\n                The text file must follow a specific syntax such that it can be read by Modelica. The input values as well as the output values must lie within \n                the range from 0 to 1. An output value of 1 (100 %) corresponds to a fully-opened metering edge. An example for a properly formatted text file with \n                two tables is given in the figure below: \n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/ModelicaTableIdealResistorVariable.png\" width=\"300\"></center>\n            </p>\n            <p>\n                A table is declared by its datatype (e. g. double), followed by the table name (e. g. tab1) and its dimensions in brackets (e. g. (5,2)). As can \n                be seen, multiple tables can be defined in the same text file. The table declaration is followed by the actual data. The first column of the table \n                represents the input of the 1D table, whereas the second column lists the corresponding output values. The input values of the table must be in \n                increasing order. The component interpolates linearly between the listed input values. More information regarding the format of tables can be found \n                at <a href=\"modelica://Modelica.Blocks.Tables.CombiTable1D\">CombiTable1D</a>.\n            </p>\n            <p>\n                Port LS is connected to port A if <var>Stroke</var> > <var>Relative stroke at which the LS port is switched</var>,\n                else port LS is connected to port T.\n                Pressure at port LS follows pressure at A or T with first order delay with </var>Time constant of LS signal</var>.\n            </p>\n        </html>"));
end PropValve33LS;