Throttle

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

    parameter Modelica.SIunits.Length diameter = 0.001 "Diameter";
    parameter Modelica.SIunits.Length length = 0.01 "Length";

    extends Base.HydTwoPortVertical;

protected
    Modelica.SIunits.PressureDifference dp(start = 0);
    Real coefficient;
    Real rho;
    Real nu;
equation
    fluidPortA.mFlow + fluidPortB.mFlow = 0;
    dp = fluidPortB.p - fluidPortA.p;
    nu = 0.5 * (FluidInterface.calcNu(fluidPortA.fluidId, fluidPortA.p, fluidPortA.fluidTemperature) + FluidInterface.calcNu(fluidPortB.fluidId, fluidPortB.p, fluidPortB.fluidTemperature));
    coefficient = Modelica.Constants.pi * diameter ^ 4 / (128 * length);
    fluidPortB.mFlow = coefficient / nu * dp;

    annotation (
        Icon(
            coordinateSystem(initialScale = 0.1),
            graphics = {
                Line(
                    origin = {10, 0},
                    points = {
                        {12, -30}, 
                        {4, -20}, 
                        {0, 0}, 
                        {4, 20}, 
                        {12, 30}},
                    smooth = Smooth.Bezier), 
                Line(
                    origin = {-10, 0},
                    points = {
                        {-12, -30}, 
                        {-4, -20}, 
                        {0, 0}, 
                        {-4, 20}, 
                        {-12, 30}},
                    smooth = Smooth.Bezier), 
                Line(points = {
                    {0, 90}, 
                    {0, -90}})}),
        Documentation(info = "<html>\n            <p>\n                The component Throttle is a model of a fluid resistance with to a large extent linear shaped dependence of the VolumeFlow on the pressure\n                difference pA-pB connected to the component.\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LaminarFlow.png\"></center>\n            </p>\n            <p>\n                It is parameterized by the geometric parameters <var>Diameter</var> and <var>Length</var>. The kinetic viscosity of the fluid and its density\n                are considered in their temperature dependency.\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/Throttle.png\"></center>\n            </p>\n            <p>\n                The Throttle is suitable for modeling a bore, if the ratio of its length l to its diameter d is comparatively large (approx. l/d > 10).\n                It does not take any inductance into consideration. If desired, a PipeWithoutCapacity or a Pipe is the correct component instead.\n            </p></html>"));
end Throttle;