LocalResistance

model LocalResistance "Local Resistance"
    import HydraulicsByFluidon.Media.Base.FluidInterface;

    parameter Real Zeta(min = 0) = 1 "Pressure loss coefficient";
    parameter Modelica.SIunits.Length D = 0.032 "Diameter";

    extends HydraulicsByFluidon.Components.Base.PartialResistorBase;

protected
    Real A = 0.25 * (D * D * Modelica.Constants.pi);
    Real signDp;
    Real pMax;
equation
    pMax = max(fluidPortA.p, fluidPortB.p);
    signDp = noEvent(sign(dp));
    fluidPortB.mFlow = sqrt(2 / Zeta) * A * sqrt(abs(dp) * FluidInterface.calcRho(fluidId, pMax, fluidPortB.fluidTemperature)) * signDp * FluidInterface.calcLaminarFactor(abs(dp));

    annotation (
        Icon(coordinateSystem(
            preserveAspectRatio = true,
            extent = {
                {-100, -100}, 
                {100, 100}})),
        Documentation(info = "<html>\n            <p>\n                The component LocalResistance is a model of a flow resistance that represents the local pressure loss, which is typically \n                calculated with the <var>Pressure loss coefficient</var> zeta.\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/Zeta.png\"></center>\n            </p>\n            <p>\n                <var>Diameter</var> is used for calculation of flow velocity v.\n            </p>\n            <p>\n                Values of <var>Pressure loss coefficient</var> can be found in literature, e. g. in I.E. Idelchik, Handbook of Hydraulic Resistance.\n            </p>\n            <p>\n                In the following tables standard values for the resistance coefficient <var>Zeta</var> are given. It is distinguished between \n                bends (without marked radius of curvature R) and elbows (with considerable radius of curvature R), circular \n                cross-sections are always assumed:\n            </p>\n            <p>\n                Bend\n            </p>\n            <p>\n                For bends with distinct radius of curvature R the resistance coefficient <var>Zeta</var> changes depending on the angle of \n                curvature phi according to the formula:\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistanceZetaBend.png\"></center>\n            </p>\n            <p>\n                From the first table the values for <var>Zeta</var> <sub>90deg</sub> depending on the ratio radius of curvature R to tube \n                diameter d can be taken. The second table specifies values for the factor k depending on the angle of \n                curvature phi (where appropriate interpolation is necessary).\n            </p>\n            <p>\n                <img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistanceRdTable.png\">\n                <img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistancePhiTable.png\">\n            </p>\n            <p>\n                At multiple bends, the following equations can give clues for the calculation of <var>Zeta</var>:\n            </p>\n            <p>\n                Double bend (two bends arranged semicircular):\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistanceZeta2.png\"></center>\n            </p>\n            <p>\n                Room crooked (two bends arranged angular to each other):\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistanceZeta3.png\"></center>\n            </p>\n            <p>\n                Floor crooked (two bends arranged s-shaped):\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistanceZeta4.png\"></center>\n            </p>\n            <p>\n                Elbow\n            </p>\n            <p>\n                For bends without marked radius of curvature R, <var>Zeta</var> can be taken out of the following table and/or can be computed by interpolation:\n            </p>\n            <p>\n                <img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/LocalResistanceBendTable.png\">\n            </p></html>"));
end LocalResistance;