def test_get_q(self): get_alt_for_q_with_constant_mach(534.2, 0.8) alt_a = get_alt_for_q_with_constant_mach(600., 0.8, tol=0.01) alt_b = get_alt_for_q_with_constant_mach(400., 0.8, tol=0.01) self.assertAlmostEqual(alt_a, 12144.30, delta=1.5) # TODO: should be 0.01 self.assertAlmostEqual(alt_b, 22058.47, delta=2.5) # TODO: should be 0.01
def test_get_alt_for_q_with_constant_mach(self): """tests ``get_alt_for_q_with_constant_mach`` for various altitudes""" alt = get_alt_for_q_with_constant_mach(534.2, 0.8, pressure_units='psf', alt_units='ft', nmax=20, tol=5.) assert np.allclose(alt, 15064.6441438) tol = 0.001 # in feet alt_a = get_alt_for_q_with_constant_mach(600., 0.8, pressure_units='psf', alt_units='ft', nmax=20, tol=tol) alt_b = get_alt_for_q_with_constant_mach(400., 0.8, pressure_units='psf', alt_units='ft', nmax=20, tol=tol) self.assertAlmostEqual(alt_a, 12144.30, delta=1.25) # TODO: should be 0.01 self.assertAlmostEqual(alt_b, 22058.47, delta=2.25) # TODO: should be 0.01
def test_get_alt_for_q_with_constant_mach2(self): """tests ``get_alt_for_q_with_constant_mach``""" mach = 0.8 alt_targets = [0., 10., 20., 30., 40., 50.] for alt_target in alt_targets: pressure1 = atm_dynamic_pressure(alt_target * 1000., mach) alt1 = get_alt_for_q_with_constant_mach(pressure1, mach) #self.assertAlmostEqual(alt1, alt_target) assert np.allclose( alt1, alt_target * 1000, atol=1.), 'alt1=%s alt_target=%s' % (alt1, alt_target * 1000) pressure2 = atm_dynamic_pressure(alt_target, mach, alt_units='kft', pressure_units='psi') tol = 0.005 # 5 feet alt2 = get_alt_for_q_with_constant_mach(pressure2, mach, pressure_units='psi', alt_units='kft', tol=tol) assert np.allclose( alt2, alt_target, atol=1e-3), 'alt2=%s alt_target=%s' % (alt2, alt_target)
def test_get_q(self): get_alt_for_q_with_constant_mach(534.2, 0.8) alt_a = get_alt_for_q_with_constant_mach(600., 0.8, tol=0.01) alt_b = get_alt_for_q_with_constant_mach(400., 0.8, tol=0.01) self.assertAlmostEqual(alt_a, 12144.30, delta=1.5) # TODO: should be 0.01 self.assertAlmostEqual(alt_b, 22058.47, delta=2.5) # TODO: should be 0.01