示例#1
1
def mach_from_nu(nu, in_radians=True, gamma=1.4):
    r"""Computes the Mach number given a Prandtl-Meyer angle, :math:`\nu`.

    Uses the relation between Mach number and Prandtl-Meyer angle for
    isentropic flow, to iteratively compute and return the Mach number.

    Parameters
    ----------
    nu : float
        Prandtl-Meyer angle, by default in radians.
    in_radians : bool, optional
        When set as False, converts nu from degrees to radians.
    gamma : float, optional
        Specific heat ratio.

    Returns
    -------
    M : float
        Mach number corresponding to :math:`\nu`.

    Raises
    ------
    ValueError
        If :math:`\nu` is 0 or negative or above the theoretical maxima based on
        :math:`\gamma`.

    """
    if not in_radians:
        nu = np.radians(nu)

    nu_max = np.pi / 2.0 * (np.sqrt((gamma + 1.0) / (gamma - 1.0)) - 1)
    if nu <= 0.0 or nu >= nu_max:
        raise ValueError(
            "Prandtl-Meyer angle must be between (0, %f) radians." % nu_max
        )

    eq = implicit(PrandtlMeyerExpansion.nu)
    M = sp.optimize.newton(eq, 2.0, args=(nu,))

    return M
示例#2
0
def mach_from_nu(nu, in_radians=True, gamma=1.4):
    r"""Computes the Mach number given a Prandtl-Meyer angle, :math:`\nu`.

    Uses the relation between Mach number and Prandtl-Meyer angle for
    isentropic flow, to iteratively compute and return the Mach number.

    Parameters
    ----------
    nu : float
        Prandtl-Meyer angle, by default in radians.
    in_radians : bool, optional
        When set as False, converts nu from degrees to radians.
    gamma : float, optional
        Specific heat ratio.

    Returns
    -------
    M : float
        Mach number corresponding to :math:`\nu`.

    Raises
    ------
    ValueError
        If :math:`\nu` is 0 or negative or above the theoretical maxima based on
        :math:`\gamma`.

    """
    if not in_radians:
        nu = np.radians(nu)

    nu_max = np.pi / 2.0 * (np.sqrt((gamma + 1.0) / (gamma - 1.0)) - 1)
    if nu <= 0.0 or nu >= nu_max:
        raise ValueError(
            "Prandtl-Meyer angle must be between (0, %f) radians." % nu_max)

    eq = implicit(PrandtlMeyerExpansion.nu)
    M = newton(eq, 2.0, args=(nu, ))

    return M
示例#3
0
def mach_from_area_ratio(A_Astar, fl=None):
    """Computes the Mach number given an area ratio asuming isentropic flow.

    Uses the relation between Mach number and area ratio for isentropic flow,
    and returns both the subsonic and the supersonic solution.

    Parameters
    ----------
    A_Astar : float
        Cross sectional area.
    fl : IsentropicFlow, optional
        Isentropic flow object, default flow with gamma = 7 / 5.

    Returns
    -------
    out : tuple of floats
        Subsonic and supersonic Mach number solution of the equation.

    Raises
    ------
    ValueError
        If the area ratio is less than 1.0 (the critical area is always the
        minimum).

    """
    if not fl:
        fl = IsentropicFlow(gamma=1.4)
    eq = implicit(fl.A_Astar)
    if A_Astar < 1.0:
        raise ValueError("Area ratio must be greater than 1")
    elif A_Astar == 1.0:
        M_sub = M_sup = 1.0
    else:
        M_sub = sp.optimize.bisect(eq, 0.0, 1.0, args=(A_Astar,))
        M_sup = sp.optimize.newton(eq, 2.0, args=(A_Astar,))

    return M_sub, M_sup
示例#4
0
def mach_from_area_ratio(A_Astar, fl=None):
    """Computes the Mach number given an area ratio asuming isentropic flow.

    Uses the relation between Mach number and area ratio for isentropic flow,
    and returns both the subsonic and the supersonic solution.

    Parameters
    ----------
    A_Astar : float
        Cross sectional area.
    fl : IsentropicFlow, optional
        Isentropic flow object, default flow with gamma = 7 / 5.

    Returns
    -------
    out : tuple of floats
        Subsonic and supersonic Mach number solution of the equation.

    Raises
    ------
    ValueError
        If the area ratio is less than 1.0 (the critical area is always the
        minimum).

    """
    if not fl:
        fl = IsentropicFlow(gamma=1.4)
    eq = implicit(fl.A_Astar)
    if A_Astar < 1.0:
        raise ValueError("Area ratio must be greater than 1")
    elif A_Astar == 1.0:
        M_sub = M_sup = 1.0
    else:
        M_sub = bisect(eq, 0.0, 1.0, args=(A_Astar, ))
        M_sup = newton(eq, 2.0, args=(A_Astar, ))

    return M_sub, M_sup