Exemplo n.º 1
0
def head_orifice(Diam, RatioVCOrifice, FlowRate):
    """Return the head of the orifice."""
    #Checking input validity
    ut.check_range([Diam, ">0", "Diameter"], [FlowRate, ">0", "Flow rate"],
                   [RatioVCOrifice, "0-1", "VC orifice ratio"])
    return ((FlowRate / (RatioVCOrifice * area_circle(Diam).magnitude))**2 /
            (2 * gravity.magnitude))
Exemplo n.º 2
0
def pipe_ID(FlowRate, Pressure):
    """Return the internal diameter of a pipe for a given pressure
    recovery constraint. """
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Pressure, ">0", "Pressure"])
    return np.sqrt(FlowRate /
                   ((np.pi / 4) * np.sqrt(2 * gravity.magnitude * Pressure)))
Exemplo n.º 3
0
def diam_hagen(FlowRate, HeadLossFric, Length, Nu):
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Length, ">0", "Length"],
                   [HeadLossFric, ">0", "Headloss due to friction"],
                   [Nu, ">0", "Nu"])
    return ((128 * Nu * FlowRate * Length) /
            (gravity.magnitude * HeadLossFric * np.pi))**(1 / 4)
Exemplo n.º 4
0
def width_rect_weir(FlowRate, Height):
    """Return the width of a rectangular weir."""
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Height, ">0", "Height"])
    return ((3 / 2) * FlowRate /
            (con.VC_ORIFICE_RATIO * np.sqrt(2 * gravity.magnitude) *
             Height**(3 / 2)))
Exemplo n.º 5
0
def area_orifice(Height, RatioVCOrifice, FlowRate):
    """Return the area of the orifice."""
    #Checking input validity
    ut.check_range([Height, ">0", "Height"], [FlowRate, ">0", "Flow rate"],
                   [RatioVCOrifice, "0-1, >0", "VC orifice ratio"])
    return FlowRate / (RatioVCOrifice *
                       np.sqrt(2 * gravity.magnitude * Height))
Exemplo n.º 6
0
def re_rect(FlowRate, Width, DistCenter, Nu, openchannel):
    """Return the Reynolds Number for a rectangular channel."""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([FlowRate, ">0", "Flow rate"], [Nu, ">0", "Nu"])
    return (4 * FlowRate *
            radius_hydraulic(Width, DistCenter, openchannel).magnitude /
            (Width * DistCenter * Nu))
Exemplo n.º 7
0
def viscosity_kinematic(temp):
    """Return the kinematic viscosity of water at a given temperature.

    If given units, the function will automatically convert to Kelvin.
    If not given units, the function will assume Kelvin.
    """
    ut.check_range([temp, ">0", "Temperature in Kelvin"])
    return (viscosity_dynamic(temp).magnitude / density_water(temp).magnitude)
Exemplo n.º 8
0
def headloss_exp_general(Vel, KMinor):
    """Return the minor head loss due to expansion in the general case.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity
    ut.check_range([Vel, ">0", "Velocity"], [KMinor, '>=0', 'K minor'])
    return KMinor * Vel**2 / (2 * gravity.magnitude)
Exemplo n.º 9
0
def headloss_manifold(FlowRate, Diam, Length, KMinor, Nu, PipeRough,
                      NumOutlets):
    """Return the total head loss through the manifold."""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([NumOutlets, ">0, int", 'Number of outlets'])
    return (headloss(FlowRate, Diam, Length, Nu, PipeRough, KMinor).magnitude *
            ((1 / 3) + (1 / (2 * NumOutlets)) + (1 / (6 * NumOutlets**2))))
Exemplo n.º 10
0
def viscosity_dynamic(temp):
    """Return the dynamic viscosity of water at a given temperature.

    If given units, the function will automatically convert to Kelvin.
    If not given units, the function will assume Kelvin.
    """
    ut.check_range([temp, ">0", "Temperature in Kelvin"])
    return 2.414 * (10**-5) * 10**(247.8 / (temp - 140))
Exemplo n.º 11
0
def headloss_weir(FlowRate, Width):
    """Return the headloss of a weir."""
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"])
    return (
        ((3 / 2) * FlowRate /
         (con.VC_ORIFICE_RATIO * np.sqrt(2 * gravity.magnitude) * Width))**(2 /
                                                                            3))
Exemplo n.º 12
0
def headloss_kozeny(Length, Diam, Vel, Porosity, Nu):
    """Return the Carmen Kozeny Sand Bed head loss."""
    #Checking input validity
    ut.check_range([Length, ">0", "Length"], [Diam, ">0", "Diam"],
                   [Vel, ">0", "Velocity"], [Nu, ">0", "Nu"],
                   [Porosity, "0-1", "Porosity"])
    return (K_KOZENY * Length * Nu / gravity.magnitude * (1 - Porosity)**2 /
            Porosity**3 * 36 * Vel / Diam**2)
Exemplo n.º 13
0
def flow_transition(Diam, Nu):
    """Return the flow rate for the laminar/turbulent transition.

    This equation is used in some of the other equations for flow.
    """
    #Checking input validity
    ut.check_range([Diam, ">0", "Diameter"], [Nu, ">0", "Nu"])
    return np.pi * Diam * RE_TRANSITION_PIPE * Nu / 4
Exemplo n.º 14
0
def flow_hagen(Diam, HeadLossFric, Length, Nu):
    """Return the flow rate for laminar flow with only major losses."""
    #Checking input validity
    ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"],
                   [HeadLossFric, ">=0", "Headloss due to friction"],
                   [Nu, ">0", "Nu"])
    return (np.pi * Diam**4) / (128 *
                                Nu) * gravity.magnitude * HeadLossFric / Length
Exemplo n.º 15
0
def headloss_exp(FlowRate, Diam, KMinor):
    """Return the minor head loss (due to expansions) in a pipe.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Diam, ">0", "Diameter"],
                   [KMinor, ">=0", "K minor"])
    return KMinor * 8 / (gravity.magnitude * np.pi**2) * FlowRate**2 / Diam**4
Exemplo n.º 16
0
def flow_orifice(Diam, Height, RatioVCOrifice):
    """Return the flow rate of the orifice."""
    #Checking input validity
    ut.check_range([Diam, ">0", "Diameter"],
                   [RatioVCOrifice, "0-1", "VC orifice ratio"])
    if Height > 0:
        return (RatioVCOrifice * area_circle(Diam).magnitude *
                np.sqrt(2 * gravity.magnitude * Height))
    else:
        return 0
Exemplo n.º 17
0
def headloss_fric(FlowRate, Diam, Length, Nu, PipeRough):
    """Return the major head loss (due to wall shear) in a pipe.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([Length, ">0", "Length"])
    return (fric(FlowRate, Diam, Nu, PipeRough) * 8 /
            (gravity.magnitude * np.pi**2) * (Length * FlowRate**2) / Diam**5)
Exemplo n.º 18
0
def diam_pipeminor(FlowRate, HeadLossExpans, KMinor):
    """Return the pipe ID that would result in the given minor losses.

    This function applies to both laminar and turbulent flow.
    """
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [KMinor, ">=0", "K minor"],
                   [HeadLossExpans, ">0", "Headloss due to expansion"])
    return (np.sqrt(4 * FlowRate / np.pi) *
            (KMinor / (2 * gravity.magnitude * HeadLossExpans))**(1 / 4))
Exemplo n.º 19
0
def density_water(temp):
    """Return the density of water at a given temperature.

    If given units, the function will automatically convert to Kelvin.
    If not given units, the function will assume Kelvin.
    """
    ut.check_range([temp, ">0", "Temperature in Kelvin"])
    rhointerpolated = interpolate.CubicSpline(WATER_DENSITY_TABLE[0],
                                              WATER_DENSITY_TABLE[1])
    return np.asscalar(rhointerpolated(temp))
Exemplo n.º 20
0
def headloss_exp_rect(FlowRate, Width, DistCenter, KMinor):
    """Return the minor head loss due to expansion in a rectangular channel.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"],
                   [DistCenter, ">0", "DistCenter"],
                   [KMinor, ">=0", "K minor"])
    return (KMinor * FlowRate**2 / (2 * gravity.magnitude *
                                    (Width * DistCenter)**2))
Exemplo n.º 21
0
def headloss_fric_general(Area, PerimWetted, Vel, Length, Nu, PipeRough):
    """Return the major head loss due to wall shear in the general case.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([Length, ">0", "Length"])
    return (fric_general(Area, PerimWetted, Vel, Nu, PipeRough) * Length /
            (4 * radius_hydraulic_general(Area, PerimWetted).magnitude) *
            Vel**2 / (2 * gravity.magnitude))
Exemplo n.º 22
0
def flow_pipeminor(Diam, HeadLossExpans, KMinor):
    """Return the flow rate with only minor losses.

    This function applies to both laminar and turbulent flows.
    """
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([HeadLossExpans, ">=0", "Headloss due to expansion"],
                   [KMinor, ">0", "K minor"])
    return (area_circle(Diam).magnitude *
            np.sqrt(2 * gravity.magnitude * HeadLossExpans / KMinor))
Exemplo n.º 23
0
def flow_swamee(Diam, HeadLossFric, Length, Nu, PipeRough):
    """Return the flow rate for turbulent flow with only major losses."""
    #Checking input validity
    ut.check_range([Diam, ">0", "Diameter"], [Length, ">0", "Length"],
                   [HeadLossFric, ">0", "Headloss due to friction"],
                   [Nu, ">0", "Nu"], [PipeRough, "0-1", "Pipe roughness"])
    logterm = np.log10(
        PipeRough / (3.7 * Diam) +
        2.51 * Nu * np.sqrt(Length /
                            (2 * gravity.magnitude * HeadLossFric * Diam**3)))
    return ((-np.pi / np.sqrt(2)) * Diam**(5 / 2) * logterm *
            np.sqrt(gravity.magnitude * HeadLossFric / Length))
Exemplo n.º 24
0
def flow_orifice_vert(Diam, Height, RatioVCOrifice):
    """Return the vertical flow rate of the orifice."""
    #Checking input validity
    ut.check_range([RatioVCOrifice, "0-1", "VC orifice ratio"])
    if Height > -Diam / 2:
        flow_vert = integrate.quad(
            lambda z:
            (Diam * np.sin(np.arccos(z / (Diam / 2))) * np.sqrt(Height - z)),
            -Diam / 2, min(Diam / 2, Height))
        return flow_vert[0] * RatioVCOrifice * np.sqrt(2 * gravity.magnitude)
    else:
        return 0
Exemplo n.º 25
0
def radius_hydraulic(Width, DistCenter, openchannel):
    """Return the hydraulic radius.

    Width and DistCenter are length values and openchannel is a boolean.
    """
    ut.check_range([Width, ">0", "Width"], [DistCenter, ">0", "DistCenter"],
                   [openchannel, "boolean", "openchannel"])
    if openchannel:
        return (Width * DistCenter) / (Width + 2 * DistCenter)
        # if openchannel is True, the channel is open. Otherwise, the channel
        # is assumed to have a top.
    else:
        return (Width * DistCenter) / (2 * (Width + DistCenter))
Exemplo n.º 26
0
def headloss_fric_rect(FlowRate, Width, DistCenter, Length, Nu, PipeRough,
                       openchannel):
    """Return the major head loss due to wall shear in a rectangular channel.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([Length, ">0", "Length"])
    return (
        fric_rect(FlowRate, Width, DistCenter, Nu, PipeRough, openchannel) *
        Length /
        (4 * radius_hydraulic(Width, DistCenter, openchannel).magnitude) *
        FlowRate**2 / (2 * gravity.magnitude * (Width * DistCenter)**2))
Exemplo n.º 27
0
def fric_general(Area, PerimWetted, Vel, Nu, PipeRough):
    """Return the friction factor for a general channel."""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([PipeRough, "0-1", "Pipe roughness"])
    if re_general(Vel, Area, PerimWetted, Nu) >= RE_TRANSITION_PIPE:
        #Swamee-Jain friction factor adapted for any cross-section.
        #Diam = 4*R*h
        f = (0.25 / (np.log10(
            (PipeRough /
             (3.7 * 4 * radius_hydraulic_general(Area, PerimWetted).magnitude)
             ) + (5.74 / re_general(Vel, Area, PerimWetted, Nu)**0.9)))**2)
    else:
        f = 64 / re_general(Vel, Area, PerimWetted, Nu)
    return f
Exemplo n.º 28
0
def fric(FlowRate, Diam, Nu, PipeRough):
    """Return the friction factor for pipe flow.

    This equation applies to both laminar and turbulent flows.
    """
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([PipeRough, "0-1", "Pipe roughness"])
    if re_pipe(FlowRate, Diam, Nu) >= RE_TRANSITION_PIPE:
        #Swamee-Jain friction factor for turbulent flow; best for
        #Re>3000 and ε/Diam < 0.02
        f = (0.25 / (np.log10(PipeRough / (3.7 * Diam) +
                              5.74 / re_pipe(FlowRate, Diam, Nu)**0.9))**2)
    else:
        f = 64 / re_pipe(FlowRate, Diam, Nu)
    return f
Exemplo n.º 29
0
def fric_rect(FlowRate, Width, DistCenter, Nu, PipeRough, openchannel):
    """Return the friction factor for a rectangular channel."""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([PipeRough, "0-1", "Pipe roughness"])
    if re_rect(FlowRate, Width, DistCenter, Nu,
               openchannel) >= RE_TRANSITION_PIPE:
        #Swamee-Jain friction factor adapted for rectangular channel.
        #Diam = 4*R_h in this case.
        return (0.25 / (np.log10(
            (PipeRough /
             (3.7 * 4 *
              radius_hydraulic(Width, DistCenter, openchannel).magnitude)) +
            (5.74 /
             (re_rect(FlowRate, Width, DistCenter, Nu, openchannel)**0.9))))**
                2)
    else:
        return 64 / re_rect(FlowRate, Width, DistCenter, Nu, openchannel)
Exemplo n.º 30
0
def diam_swamee(FlowRate, HeadLossFric, Length, Nu, PipeRough):
    """Return the inner diameter of a pipe.

    The Swamee Jain equation is dimensionally correct and returns the
    inner diameter of a pipe given the flow rate and the head loss due
    to shear on the pipe walls. The Swamee Jain equation does NOT take
    minor losses into account. This equation ONLY applies to turbulent
    flow.
    """
    #Checking input validity
    ut.check_range([FlowRate, ">0", "Flow rate"], [Length, ">0", "Length"],
                   [HeadLossFric, ">0", "Headloss due to friction"],
                   [Nu, ">0", "Nu"], [PipeRough, "0-1", "Pipe roughness"])
    a = ((PipeRough**1.25) * ((Length * FlowRate**2) /
                              (gravity.magnitude * HeadLossFric))**4.75)
    b = (Nu * FlowRate**9.4 * (Length /
                               (gravity.magnitude * HeadLossFric))**5.2)
    return 0.66 * (a + b)**0.04