def test_area_ratio():
    fl = isentropic.IsentropicFlow(1.4)
    M_list = [0.0, 0.38, 0.79, 1.0, 1.24, 2.14]
    expected_area_ratios = [np.infty, 1.6587, 1.0425, 1.0, 1.043, 1.902]
    np.testing.assert_array_almost_equal(fl.A_Astar(M_list),
                                         expected_area_ratios,
                                         decimal=3)
def test_pressure_ratio():
    fl = isentropic.IsentropicFlow(1.4)
    M_list = [0.0, 0.27, 0.89, 1.0, 1.30, 2.05]
    expected_pressure_ratios = [1.0, 0.9506, 0.5977, 0.5283, 0.3609, 0.1182]
    np.testing.assert_array_almost_equal(fl.p_p0(M_list),
                                         expected_pressure_ratios,
                                         decimal=4)
Beispiel #3
0
def test_speed_of_sound_ratio():
    fl = isentropic.IsentropicFlow(1.4)
    M_list = [0.0, 0.3, 1.0, 1.3, 2.5]
    expected_sound_speed_ratios = [1.0, 0.99112, 0.91287, 0.86451, 0.6667]

    np.testing.assert_array_almost_equal(fl.a_a0(M_list),
                                         expected_sound_speed_ratios,
                                         decimal=3)
def test_PrandtlMeyerExpansion_example():
    # Example 4.13 from Anderson. Default gamma=1.4 used
    fl = isentropic.IsentropicFlow()
    pm = isentropic.PrandtlMeyerExpansion(M_1=1.5, theta=np.radians(20), fl=fl)
    np.testing.assert_almost_equal(pm.M_2, 2.207, decimal=3)
    np.testing.assert_almost_equal(pm.p2_p1, 0.340, decimal=3)
    np.testing.assert_almost_equal(pm.T2_T1, 0.735, decimal=3)
    np.testing.assert_almost_equal(pm.mu_1, np.radians(41.81), decimal=3)
    np.testing.assert_almost_equal(pm.mu_2, np.radians(26.95), decimal=3)
def test_density_ratio():
    fl = isentropic.IsentropicFlow(1.4)
    M_list = [0.0, 0.27, 0.89, 1.0, 1.30, 2.05]
    expected_density_ratios = [
        1.0, 0.96446008, 0.69236464, 0.63393815, 0.48290279, 0.21760078
    ]
    density_ratios = fl.rho_rho0(M_list)
    np.testing.assert_array_almost_equal(density_ratios,
                                         expected_density_ratios,
                                         decimal=4)
def test_mach_from_area_ratio_supersonic():
    fl = isentropic.IsentropicFlow(1.4)
    A_Astar_list = [1.0, 1.043, 1.328, 1.902, 4.441]
    expected_ratios = [1.0, 1.24, 1.69, 2.14, 3.05]
    mach_from_area_ratios = [
        isentropic.mach_from_area_ratio(A_Astar, fl)[1]  # Supersonic
        for A_Astar in A_Astar_list
    ]

    np.testing.assert_array_almost_equal(mach_from_area_ratios,
                                         expected_ratios,
                                         decimal=2)
def test_mach_from_area_ratio_subsonic():
    fl = isentropic.IsentropicFlow(1.4)
    A_Astar_list = [
        np.inf,
        2.4027,
        1.7780,
        1.0382,
        1.0,
    ]
    expected_ratios = [0.0, 0.25, 0.35, 0.8, 1.0]
    mach_from_area_ratios = [
        isentropic.mach_from_area_ratio(A_Astar, fl)[0]  # Subsonic
        for A_Astar in A_Astar_list
    ]
    np.testing.assert_array_almost_equal(mach_from_area_ratios,
                                         expected_ratios,
                                         decimal=3)
def test_isentropic_flow_has_the_gamma_indicated_in_constructor():
    gamma = 1.4
    flow = isentropic.IsentropicFlow(gamma)
    np.testing.assert_almost_equal(flow.gamma, gamma, decimal=3)
def test_area_ratio_no_zero_division_error():
    fl = isentropic.IsentropicFlow()
    assert np.isposinf(fl.A_Astar(0))
Beispiel #10
0
        x = np.asarray([x])

    result = np.piecewise(x, [(0.0 <= x) & (x < 1.0), (1.0 <= x) & (x <= 3.0)], [A_1, A_2])
    if len(result) == 1:
        result = result[0]

    return result

radius = np.sqrt(A(x) / np.pi) * 10  # dm

# Plot nozzle shape
nozzle = plt.fill_between(x, radius, -radius, facecolor="#cccccc")
plt.xlim(0, 3)
plt.title("Nozzle")
plt.xlabel("x (m)")
plt.ylabel("Radius (dm)")
plt.plot()


# 1. Back pressure pB is ambient pressure
p_B = p_amb
# 2. Find minimum area in domain
A_e = A(x[-1])  # m^2
A_c = np.min(A(x))  # m^2
# 3. Compute subsonic and supersonic Mach number at the exit
fl = isentropic.IsentropicFlow(gamma=g)
# M_e_sub, M_e_sup = isentropic.mach_from_area_ratio(fl, A_e / A_c)

# print(M_e_sub, M_e_sup)