Orifice

model Orifice "Orifice"
    import HydraulicsByFluidon.Media;
    import HydraulicsByFluidon.Media.Base.FluidInterface;

    parameter Modelica.SIunits.Length diameter = 0.001 "Diameter";
    parameter Real alphaD = 0.6 "Flow coefficient alphaD";

    extends Base.HydTwoPortVertical;

protected
    Modelica.SIunits.PressureDifference dp(start = 0);
    Real coefficient;
equation
    fluidPortA.mFlow + fluidPortB.mFlow = 0;
    dp = fluidPortB.p - fluidPortA.p;
    coefficient = 0.25 * (alphaD * Modelica.Constants.pi) * diameter ^ 2 * sqrt(2);
    fluidPortB.mFlow = coefficient * sqrt(abs(dp) * FluidInterface.calcRho(fluidId, max(fluidPortA.p, fluidPortB.p), fluidPortB.fluidTemperature)) * noEvent(sign(dp)) * FluidInterface.calcLaminarFactor(abs(dp));

    annotation (
        Icon(
            coordinateSystem(initialScale = 0.1),
            graphics = {
                Line(
                    origin = {10, 0},
                    points = {
                        {20, -20}, 
                        {0, 0}, 
                        {20, 20}}), 
                Line(
                    origin = {-10, 0},
                    points = {
                        {-20, -20}, 
                        {0, 0}, 
                        {-20, 20}}), 
                Line(points = {
                    {0, 90}, 
                    {0, -90}})}),
        Documentation(info = "<html>\n            <p>\n                The component Orifice is a model of a sharp-edged fluid resistance with a - to a large extent - root-like relationship between the \n                flow rate and the pressure difference pA - pB acting on the component. The flow rate is independent of the viscosity of the hydraulic fluid.\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/TurbulentFlow.png\"></center>\n            </p>\n            <p>\n                It is parameterized by the geometric parameters <var>Diameter</var> and <var>Flow Coefficient alphaD</var>.\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/Orifice.png\"></center>\n            </p>\n            <p>\n                The Orifice is suitable for modeling an orifice opening, if the ratio of its length l to its diameter d is comparatively small (approx. l/d < 1.5).\n            </p>\n            <p>\n                The density of the hydraulics fluid is considered.\n            </p></html>"));
end Orifice;