def test_set_temperature(self): fdm = CreateFDM(self.sandbox) fdm.load_model('ball') fdm.run_ic() atmos = fdm.get_atmosphere() eRankine = 3 # Check that there are no side effects if we call SetTemperature() # twice in a row. atmos.set_temperature(520, 0.0, eRankine) fdm.run_ic() self.assertAlmostEqual(1.0, fdm['atmosphere/T-R'] / 520.0) atmos.set_temperature(500, 0.0, eRankine) fdm.run_ic() self.assertAlmostEqual(1.0, fdm['atmosphere/T-R'] / 500.0) # Check that it works while a temperature gradient is set graded_delta_T_K = -10.0 fdm['atmosphere/SL-graded-delta-T'] = graded_delta_T_K * self.K_to_R atmos.set_temperature(530, 1000.0, eRankine) fdm['ic/h-sl-ft'] = 1000. fdm.run_ic() self.assertAlmostEqual(1.0, fdm['atmosphere/T-R'] / 530.0) del fdm
def test_set_temperature(self): fdm = CreateFDM(self.sandbox) fdm.load_model('ball') fdm.run_ic() atmos = fdm.get_atmosphere() eRankine = 3 # Check that there are no side effects if we call SetTemperature() # twice in a row. atmos.set_temperature(520, 0.0, eRankine) fdm.run_ic() self.assertAlmostEqual(1.0, fdm['atmosphere/T-R']/520.0) atmos.set_temperature(500, 0.0, eRankine) fdm.run_ic() self.assertAlmostEqual(1.0, fdm['atmosphere/T-R']/500.0) # Regression test for a bug reported in FlightGear. Checks that the # temperature bias is updated correctly when the temperature is forced # to a constant value. for alt in range(5000): h = alt*1000 fdm['atmosphere/delta-T'] = 0.0 # Make sure there is no temperature bias atmos.set_temperature(354, h, eRankine) self.assertAlmostEqual(1.0, atmos.get_temperature(h)/354.0, msg='\nFailed at h={} ft'.format(h)) # Check that it works while a temperature gradient is set graded_delta_T_K = -10.0 fdm['atmosphere/SL-graded-delta-T'] = graded_delta_T_K*self.K_to_R atmos.set_temperature(530, 1000.0, eRankine) fdm['ic/h-sl-ft'] = 1000. fdm.run_ic() self.assertAlmostEqual(1.0, fdm['atmosphere/T-R']/530.0) del fdm