VariableDisplacementPump

model VariableDisplacementPump
    extends HydraulicsByFluidon.Components.Pumps.Base.PartialDisplacementPump;

    Modelica.Blocks.Interfaces.RealInput setpoint annotation (Placement(
        visible = true,
        transformation(
            origin = {-100, -100},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0),
        iconTransformation(
            origin = {-100, -80},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0)));
    Modelica.Blocks.Nonlinear.Limiter limiter(limitsAtInit = true, strict = true, uMin = -1, uMax = 1);
protected
    Real flowFactor;
equation
    flowFactor = limiter.y;
    limiter.u = setpoint;
    pumpInt.volume = dispVolume * flowFactor * min(1, min(fluidPortA.p, fluidPortB.p) / minSuctionPressure);

    annotation (
        Documentation(info = "<html>\n            <p>Model of a pump with variable displacement volume and losses.\n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Pumps/VariableDisplacementPump.png\"></center>\n            </p>\n            <p>\n                The main parameters of the pump are its maximum <var>Displacement volume</var> and the \n                <var>Rotational moment of inertia</var>. The displacement volume can be adjusted by using\n                the <i>setpoint</i> signal:\n            </p>\n            <p>\n            <table>\n                <tr>\n                    <td><i>setpoint</i> = 0</td><td>displacement volume = 0</td>\n                </tr>\n                <tr>\n                    <td><i>setpoint</i> > 1</td><td>displacement volume = <var>dispVolume</var><br/>sign(w) = sign(fluidPortA.mFlow)</td>\n                </tr>                                        \n                <tr>\n                    <td><i>setpoint</i> < -1</td><td>displacement volume = <var>dispVolume</var><br/>sign(w) = -sign(fluidPortA.mFlow)</td>\n                </tr>                                        \n                <tr>\n                    <td>1 > <i>setpoint</i> > 0</td><td>displacement volume = <var>dispVolume</var> * <i>setpoint</i><br/>sign(w) = sign(fluidPortA.mFlow)</td>\n                </tr>\n                <tr>\n                    <td>-1 < <i>setpoint</i> < 0</td><td>displacement volume = <var>dispVolume</var> * <i>setpoint</i><br/>sign(w) = -sign(fluidPortA.mFlow)</td>\n                </tr>\n            </table>\n            </p>\n            <p>\n                The losses are parameterised by providing volumetric and mechanical efficiencies <var>Volumetric efficiency</var> and <var>Mechanical efficiency</var> for a given operating point. \n                The operating point is characterised by a reference pressure difference <var>Reference pressure difference</var> and a corresponding shaft speed <var>Reference speed</var>. \n                Based on the entered values, the parameters of a laminar throttle (volumetric losses) and a linear damper (representing the\n                mechanical losses) are determined automatically. Unlike the efficiencies, the parameters of these two elements typically do not vary\n                significantly with the operating conditions.\n            </p>\n            <p>\n                The parameter <var>Ratio external Leakage / total Leakage</var> allows to split the leakage between internal and external leakage. A gear pump e. g. typically has no \n                external leakage, <var>Ratio external Leakage / total Leakage</var> has to be set to 0. In contrast, a piston pump has a significant external leakage\n                (0.5 < <var>Ratio external Leakage / total Leakage</var> <= 1).\n            </p>\n            <p>\n                <i>minSuctionPressure</i> takes into account that a pump requires a minimaum suction pressure for full flow. Below this pressure, \n                the flow rate is reduced. In this model, the reduction is assumed to be simplified as a linear function of suction pressure in \n                relation to <i>minSuctionPressure</i>.\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Pumps/PumpSuctionPressure.png\"></center>\n            </p>\n            </html>"),
        Icon(
            graphics = {
                Line(points = {
                    {-100, 10}, 
                    {-59, 10}}), 
                Line(points = {
                    {-100, -10}, 
                    {-59, -10}}), 
                Line(points = {
                    {59, 10}, 
                    {100, 10}}), 
                Line(points = {
                    {59, -10}, 
                    {100, -10}}), 
                Line(points = {
                    {-80, -80}, 
                    {80, 80}}), 
                Line(
                    origin = {91, 0},
                    points = {
                        {-9, -30}, 
                        {-4, -20}, 
                        {1, 0}, 
                        {-4, 20}, 
                        {-9, 30}},
                    smooth = Smooth.Bezier), 
                Polygon(
                    origin = {44, -65},
                    rotation = 30,
                    fillPattern = FillPattern.Solid,
                    points = {
                        {80, 80}, 
                        {85, 60}, 
                        {75, 60}, 
                        {80, 80}}), 
                Polygon(
                    origin = {183, -15},
                    rotation = 150,
                    fillPattern = FillPattern.Solid,
                    points = {
                        {80, 80}, 
                        {85, 60}, 
                        {75, 60}, 
                        {80, 80}}), 
                Polygon(
                    origin = {-33, 80},
                    rotation = -45,
                    fillPattern = FillPattern.Solid,
                    points = {
                        {80, 80}, 
                        {85, 60}, 
                        {75, 60}, 
                        {80, 80}})},
            coordinateSystem(initialScale = 0.1)));
end VariableDisplacementPump;