コード例 #1
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_84km():
    h = np.array([52000,
                  60000,
                  84500
                  ])  # m
    expected_T = np.array([267.850,
                           245.450,
                           187.650
                           ])  # K

    expected_rho = np.array([7.6687e-4,
                             2.8832e-4,
                             7.3914e-6
                             ])  # kg / m3

    expected_a = np.array([328.2055,
                           314.1822,
                           274.7099,
                           ])  # m/s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #2
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_51km():
    h = np.array([47200,
                  49000,
                  51000
                  ])  # m
    expected_T = np.array([270.650,
                           270.650,
                           270.650
                           ])  # K

    expected_rho = np.array([0.0013919,
                             0.0011090,
                             0.00086160
                             ])  # kg / m3

    expected_a = np.array([329.9165,
                           329.9165,
                           329.9165
                           ])  # m / s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #3
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_32km():
    h = np.array([22100,
                  24000,
                  28800,
                  32000
                  ])  # m
    expected_T = np.array([218.750,
                           220.650,
                           225.450,
                           228.650
                           ])  # K

    expected_rho = np.array([0.062711,
                             0.046267,
                             0.021708,
                             0.013225
                             ])  # kg / m3

    expected_a = np.array([296.6020,
                           297.8873,
                           301.1100,
                           303.2394
                           ])  # m/s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #4
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_71km():
    h = np.array([51500,
                  60000,
                  71000
                  ])  # m
    expected_T = np.array([269.250,
                           245.450,
                           214.650
                           ])  # K

    expected_rho = np.array([0.00081298,
                             2.8832e-4,
                             6.4211e-5
                             ])  # kg / m3

    expected_a = np.array([329.0621,
                           314.1823,
                           293.8092
                           ])  # m / s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #5
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_47km():
    h = np.array([32200,
                  36000,
                  42000,
                  47000
                  ])  # m
    expected_T = np.array([229.210,
                           239.850,
                           256.650,
                           270.650
                           ])  # K

    expected_rho = np.array([0.012805,
                             0.0070344,
                             0.0028780,
                             0.0014275
                             ])  # kg / m3

    expected_a = np.array([303.6105,
                           310.5774,
                           321.2704,
                           329.9165
                           ])  # m / s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #6
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_20km():
    h = np.array([12000,
                  14200,
                  17500,
                  20000
                  ])  # m
    expected_T = np.array([216.650,
                           216.650,
                           216.650,
                           216.650,
                           ])  # K

    expected_rho = np.array([0.31083,
                             0.21971,
                             0.13058,
                             0.088035
                             ])  # kg / m3

    expected_a = np.array([295.1749,
                           295.1749,
                           295.1749,
                           295.1749,
                           ])

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #7
0
ファイル: test_isa.py プロジェクト: martosc/PyFME
def test_results_under_11km():
    h = np.array([0.0,
                  50.0,
                  550.0,
                  6500.0,
                  10000.0,
                  11000.0
                  ])  # m
    expected_T = np.array([288.150,
                           287.825,
                           284.575,
                           245.900,
                           223.150,
                           216.650
                           ])  # K

    expected_rho = np.array([1.2250,
                             1.2191,
                             1.1616,
                             0.62384,
                             0.41271,
                             0.36392
                             ])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #8
0
def test_stagnation_pressure():

    # subsonic case
    _, p, _, a = atm(11000)
    tas = 240

    p_stagnation_expected = 34952.7493849545
    p_stagnation = stagnation_pressure(p, a, tas)
    assert_almost_equal(p_stagnation, p_stagnation_expected)

    # supersonic case
    _, p, _, a = atm(11000)
    tas = 400
    p_stagnation_expected = 65521.299596290904

    p_stagnation = stagnation_pressure(p, a, tas)
    assert_almost_equal(p_stagnation, p_stagnation_expected)
コード例 #9
0
def test_stagnation_pressure():

    # subsonic case
    _, p, _, a = atm(11000)
    tas = 240

    p_stagnation_expected = 34952.7493849545
    p_stagnation = stagnation_pressure(p, a, tas)
    assert_almost_equal(p_stagnation, p_stagnation_expected)

    # supersonic case
    _, p, _, a = atm(11000)
    tas = 400
    p_stagnation_expected = 65521.299596290904

    p_stagnation = stagnation_pressure(p, a, tas)
    assert_almost_equal(p_stagnation, p_stagnation_expected)
コード例 #10
0
def test_results_under_51km():
    h = np.array([47200, 49000, 51000])  # m
    expected_T = np.array([270.650, 270.650, 270.650])  # K

    expected_rho = np.array([0.0013919, 0.0011090, 0.00086160])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #11
0
def test_results_under_84km():
    h = np.array([52000, 60000, 84500])  # m
    expected_T = np.array([267.850, 245.450, 187.650])  # K

    expected_rho = np.array([7.6687e-4, 2.8832e-4, 7.3914e-6])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #12
0
def test_results_under_71km():
    h = np.array([51500, 60000, 71000])  # m
    expected_T = np.array([269.250, 245.450, 214.650])  # K

    expected_rho = np.array([0.00081298, 2.8832e-4, 6.4211e-5])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #13
0
def test_results_under_47km():
    h = np.array([32200, 36000, 42000, 47000])  # m
    expected_T = np.array([229.210, 239.850, 256.650, 270.650])  # K

    expected_rho = np.array([0.012805, 0.0070344, 0.0028780,
                             0.0014275])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #14
0
def test_results_under_32km():
    h = np.array([22100, 24000, 28800, 32000])  # m
    expected_T = np.array([218.750, 220.650, 225.450, 228.650])  # K

    expected_rho = np.array([0.062711, 0.046267, 0.021708,
                             0.013225])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #15
0
def test_results_under_11km():
    h = np.array([0.0, 50.0, 550.0, 6500.0, 10000.0, 11000.0])  # m
    expected_T = np.array(
        [288.150, 287.825, 284.575, 245.900, 223.150, 216.650])  # K

    expected_rho = np.array(
        [1.2250, 1.2191, 1.1616, 0.62384, 0.41271, 0.36392])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #16
0
def test_sea_level():
    h = 0.0  # m
    expected_T = 288.15  # K
    expected_p = 101325.0  # Pa
    expected_rho = 1.2250  # kg / m3

    T, p, rho = atm(h)

    # Reads: "Assert if T equals expected_T"
    assert_equal(T, expected_T)
    assert_equal(p, expected_p)
    assert_almost_equal(rho, expected_rho, decimal=4)
コード例 #17
0
ファイル: test_isa.py プロジェクト: martosc/PyFME
def test_sea_level():
    h = 0.0  # m
    expected_T = 288.15  # K
    expected_p = 101325.0  # Pa
    expected_rho = 1.2250  # kg / m3

    T, p, rho = atm(h)

    # Reads: "Assert if T equals expected_T"
    assert_equal(T, expected_T)
    assert_equal(p, expected_p)
    assert_almost_equal(rho, expected_rho, decimal=4)
コード例 #18
0
def test_results_under_20km():
    h = np.array([12000, 14200, 17500, 20000])  # m
    expected_T = np.array([
        216.650,
        216.650,
        216.650,
        216.650,
    ])  # K

    expected_rho = np.array([0.31083, 0.21971, 0.13058, 0.088035])  # kg / m3

    for ii, h_ in enumerate(h):
        T, p, rho = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
コード例 #19
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_11km():
    h = np.array([0.0, 50.0, 550.0, 6500.0, 10000.0, 11000.0])  # m
    expected_T = np.array(
        [288.150, 287.825, 284.575, 245.900, 223.150, 216.650])  # K

    expected_rho = np.array(
        [1.2250, 1.2191, 1.1616, 0.62384, 0.41271, 0.36392])  # kg / m3

    expected_a = np.array(
        [340.4155, 340.2235, 338.2972, 314.4700, 299.5701, 295.1749])  # m / s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #20
0
ファイル: trimmer.py プロジェクト: BraMurgas/PyFME
def func(trimmed_params, h, TAS, gamma, turn_rate, aircraft, dynamic_eqs):
    """Function to optimize
    """
    alpha = trimmed_params[0]
    beta = trimmed_params[1]

    delta_e = trimmed_params[2]
    delta_ail = trimmed_params[3]
    delta_r = trimmed_params[4]
    delta_t = trimmed_params[5]

    if abs(turn_rate) < 1e-8:
        phi = 0
    else:
        phi = turn_coord_cons(turn_rate, alpha, beta, TAS, gamma)

    theta = rate_of_climb_cons(gamma, alpha, beta, phi)

    # w = turn_rate * k_h
    # k_h = sin(theta) i_b + sin(phi) * cos(theta) j_b + cos(theta) * sin(phi)
    # w = p * i_b + q * j_b + r * k_b
    p = - turn_rate * sin(theta)
    q = turn_rate * sin(phi) * cos(theta)
    r = turn_rate * cos(theta) * sin(phi)

    ang_vel = np.array([p, q, r])

    lin_vel = wind2body((TAS, 0, 0), alpha, beta)

    # FIXME: This implied some changes in the aircraft model.
    # psi angle does not influence the attitude of the aircraft for gravity
    # force projection. So it is set to 0.
    attitude = np.array([theta, phi, 0])
    _, _, rho, _ = atm(h)
    forces, moments = aircraft.get_forces_and_moments(TAS, rho, alpha, beta,
                                                      delta_e, 0, delta_ail,
                                                      delta_r, delta_t,
                                                      attitude)
    mass, inertia = aircraft.mass_and_inertial_data()

    vel = np.concatenate((lin_vel[:], ang_vel[:]))

    output = dynamic_eqs(0, vel, mass, inertia, forces, moments)

    return output
コード例 #21
0
ファイル: trimmer.py プロジェクト: BraMurgas/PyFME
def func(trimmed_params, h, TAS, gamma, turn_rate, aircraft, dynamic_eqs):
    """Function to optimize
    """
    alpha = trimmed_params[0]
    beta = trimmed_params[1]

    delta_e = trimmed_params[2]
    delta_ail = trimmed_params[3]
    delta_r = trimmed_params[4]
    delta_t = trimmed_params[5]

    if abs(turn_rate) < 1e-8:
        phi = 0
    else:
        phi = turn_coord_cons(turn_rate, alpha, beta, TAS, gamma)

    theta = rate_of_climb_cons(gamma, alpha, beta, phi)

    # w = turn_rate * k_h
    # k_h = sin(theta) i_b + sin(phi) * cos(theta) j_b + cos(theta) * sin(phi)
    # w = p * i_b + q * j_b + r * k_b
    p = -turn_rate * sin(theta)
    q = turn_rate * sin(phi) * cos(theta)
    r = turn_rate * cos(theta) * sin(phi)

    ang_vel = np.array([p, q, r])

    lin_vel = wind2body((TAS, 0, 0), alpha, beta)

    # FIXME: This implied some changes in the aircraft model.
    # psi angle does not influence the attitude of the aircraft for gravity
    # force projection. So it is set to 0.
    attitude = np.array([theta, phi, 0])
    _, _, rho, _ = atm(h)
    forces, moments = aircraft.get_forces_and_moments(TAS, rho, alpha, beta,
                                                      delta_e, 0, delta_ail,
                                                      delta_r, delta_t,
                                                      attitude)
    mass, inertia = aircraft.mass_and_inertial_data()

    vel = np.concatenate((lin_vel[:], ang_vel[:]))

    output = dynamic_eqs(0, vel, mass, inertia, forces, moments)

    return output
コード例 #22
0
def test_cas2tas():

    # sea level
    cas = 275
    tas_expected = 275

    tas = cas2tas(cas, p_0, rho_0)

    assert_almost_equal(tas, tas_expected)

    # Test at 11000m
    _, p, rho, _ = atm(11000)
    cas = 162.03569680495048
    tas_expected = 275

    tas = cas2tas(cas, p, rho)

    assert_almost_equal(tas, tas_expected)
コード例 #23
0
def test_tas2cas():

    # sea level
    tas = 275
    cas_expected = 275

    cas = tas2cas(tas, p_0, rho_0)

    assert_almost_equal(cas, cas_expected)

    # Test at 11000m
    _, p, rho, _ = atm(11000)
    tas = 275
    cas_expected = 162.03569680495048

    cas = tas2cas(tas, p, rho)

    assert_almost_equal(cas, cas_expected)
コード例 #24
0
def test_eas2tas():

    # sea level
    eas = 149.88797172756003
    tas_expected = 149.88797172756003

    tas = eas2tas(eas, rho_0)

    assert_almost_equal(tas, tas_expected)

    # Test at 11000m
    _, _, rho, _ = atm(11000)
    eas = 149.88797172756003
    tas_expected = 275

    tas = eas2tas(eas, rho)

    assert_almost_equal(tas, tas_expected)
コード例 #25
0
def test_tas2eas():

    # sea level
    tas = 275
    eas_expected = 275

    eas = tas2eas(tas, rho_0)

    assert_almost_equal(eas, eas_expected)

    # Test at 11000m
    _, _, rho, _ = atm(11000)
    tas = 275
    eas_expected = 149.88797172756003

    eas = tas2eas(tas, rho)

    assert_almost_equal(eas, eas_expected)
コード例 #26
0
def test_eas2cas():

    # sea level
    eas = 275
    cas_expected = 275

    cas = eas2cas(eas, p_0, rho_0)

    assert_almost_equal(cas, cas_expected)

    # Test at 11000m
    _, p, rho, _ = atm(11000)
    eas = 149.88797172756003
    cas_expected = 162.03569680495048

    cas = eas2cas(eas, p, rho)

    assert_almost_equal(cas, cas_expected)
コード例 #27
0
def test_cas2eas():

    # sea level
    cas = 275
    eas_expected = 275

    eas = cas2eas(cas, p_0, rho_0)

    assert_almost_equal(eas, eas_expected)

    # Test at 11000m
    _, p, rho, _ = atm(11000)
    cas = 162.03569680495048
    eas_expected = 149.88797172756003

    eas = cas2eas(cas, p, rho)

    assert_almost_equal(eas, eas_expected)
コード例 #28
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_results_under_11km():
    h = np.array([0.0,
                  50.0,
                  550.0,
                  6500.0,
                  10000.0,
                  11000.0
                  ])  # m
    expected_T = np.array([288.150,
                           287.825,
                           284.575,
                           245.900,
                           223.150,
                           216.650
                           ])  # K

    expected_rho = np.array([1.2250,
                             1.2191,
                             1.1616,
                             0.62384,
                             0.41271,
                             0.36392
                             ])  # kg / m3

    expected_a = np.array([340.4155,
                           340.2235,
                           338.2972,
                           314.4700,
                           299.5701,
                           295.1749
                           ])  # m / s

    for ii, h_ in enumerate(h):
        T, p, rho, a = atm(h_)
        assert_almost_equal(T, expected_T[ii], decimal=3)
        assert_almost_equal(rho, expected_rho[ii], decimal=4)
        assert_almost_equal(a, expected_a[ii], decimal=2)
コード例 #29
0
ファイル: example_004.py プロジェクト: BraMurgas/PyFME
    TAS = np.empty_like(time)
    TAS[0] = TAS_

    # Linear Momentum and Angular Momentum eqs.
    equations = System(integrator='dopri5',
                       model='euler_flat_earth',
                       jac=False)
    u, v, w = lin_vel
    p, q, r = ang_vel

    equations.set_initial_values(u, v, w,
                                 p, q, r,
                                 theta, phi, psi_0,
                                 x_0, y_0, h)

    _, _, rho, _ = atm(h)

    # Define control vectors.
    delta_e, delta_ail, delta_r, delta_t = control_vector
    d_e = np.ones_like(time) * delta_e
    d_e[np.where(time<2)] = delta_e * 1.30
    d_e[np.where(time<1)] = delta_e * 0.70
    d_a = np.ones_like(time) * delta_ail
    d_r = np.ones_like(time) * delta_r
    d_t = np.ones_like(time) * delta_t

    attitude = theta, phi, psi_0

    # Rename function to make it shorter
    forces_and_moments = cessna_310.get_forces_and_moments
    for ii, t in enumerate(time[1:]):
コード例 #30
0
ファイル: test_isa.py プロジェクト: BraMurgas/PyFME
def test_altitude_is_out_of_range():
    wrong_h = (-1.0, 84501)  # m

    for h in wrong_h:
        with pytest.raises(ValueError):
            atm(h)
コード例 #31
0
def test_altitude_is_out_of_range(recwarn):
    wrong_h = (-1.0, 84501)  # m

    for h in wrong_h:
        with pytest.raises(ValueError):
            atm(h)