diff --git a/aviary/mission/height_energy/ode/test/test_landing_eom.py b/aviary/mission/height_energy/ode/test/test_landing_eom.py index 4c06c0cba..f8b61be63 100644 --- a/aviary/mission/height_energy/ode/test/test_landing_eom.py +++ b/aviary/mission/height_energy/ode/test/test_landing_eom.py @@ -44,6 +44,7 @@ def setUp(self): def test_case(self): do_validation_test( + self, self.prob, input_validation_data=detailed_landing_flare, output_validation_data=detailed_landing_flare, diff --git a/aviary/mission/height_energy/ode/test/test_landing_ode.py b/aviary/mission/height_energy/ode/test/test_landing_ode.py index 464b2cbcb..44726345e 100644 --- a/aviary/mission/height_energy/ode/test/test_landing_ode.py +++ b/aviary/mission/height_energy/ode/test/test_landing_ode.py @@ -54,6 +54,7 @@ def test_case(self): set_aviary_initial_values(prob, aviary_options) do_validation_test( + self, prob, input_validation_data=detailed_landing_flare, output_validation_data=detailed_landing_flare, diff --git a/aviary/mission/height_energy/ode/test/test_range_rate.py b/aviary/mission/height_energy/ode/test/test_range_rate.py index 5347740fc..5d84e3d96 100644 --- a/aviary/mission/height_energy/ode/test/test_range_rate.py +++ b/aviary/mission/height_energy/ode/test/test_range_rate.py @@ -27,6 +27,7 @@ def setUp(self): def test_case1(self): do_validation_test( + self, self.prob, input_validation_data=data, output_validation_data=data, diff --git a/aviary/mission/height_energy/ode/test/test_takeoff_eom.py b/aviary/mission/height_energy/ode/test/test_takeoff_eom.py index 10a68bd7b..05f57bcc8 100644 --- a/aviary/mission/height_energy/ode/test/test_takeoff_eom.py +++ b/aviary/mission/height_energy/ode/test/test_takeoff_eom.py @@ -34,6 +34,7 @@ def test_case_ground(self): prob = self._make_prob(climbing=False) do_validation_test( + self, prob, input_validation_data=detailed_takeoff_ground, output_validation_data=detailed_takeoff_ground, @@ -58,6 +59,7 @@ def test_case_climbing(self): prob = self._make_prob(climbing=True) do_validation_test( + self, prob, input_validation_data=detailed_takeoff_climbing, output_validation_data=detailed_takeoff_climbing, diff --git a/aviary/mission/height_energy/ode/test/test_takeoff_ode.py b/aviary/mission/height_energy/ode/test/test_takeoff_ode.py index 407ca6892..67a76ac3a 100644 --- a/aviary/mission/height_energy/ode/test/test_takeoff_ode.py +++ b/aviary/mission/height_energy/ode/test/test_takeoff_ode.py @@ -29,6 +29,7 @@ def test_case_ground(self): prob = self._make_prob(climbing=False) do_validation_test( + self, prob, input_validation_data=detailed_takeoff_ground, output_validation_data=detailed_takeoff_ground, @@ -58,6 +59,7 @@ def test_case_climbing(self): prob = self._make_prob(climbing=True) do_validation_test( + self, prob, input_validation_data=detailed_takeoff_climbing, output_validation_data=detailed_takeoff_climbing, diff --git a/aviary/mission/ode/test/test_altitude_rate.py b/aviary/mission/ode/test/test_altitude_rate.py index 2fae3ee3f..06b70b86a 100644 --- a/aviary/mission/ode/test/test_altitude_rate.py +++ b/aviary/mission/ode/test/test_altitude_rate.py @@ -26,6 +26,7 @@ def setUp(self): def test_case1(self): do_validation_test( + self, self.prob, input_validation_data=data, output_validation_data=data, diff --git a/aviary/mission/ode/test/test_specific_energy_rate.py b/aviary/mission/ode/test/test_specific_energy_rate.py index 9d08b3acf..0d4e88102 100644 --- a/aviary/mission/ode/test/test_specific_energy_rate.py +++ b/aviary/mission/ode/test/test_specific_energy_rate.py @@ -26,6 +26,7 @@ def setUp(self): def test_case1(self): do_validation_test( + self, self.prob, input_validation_data=data, output_validation_data=data, diff --git a/aviary/mission/two_dof/ode/test/test_accel_eom.py b/aviary/mission/two_dof/ode/test/test_accel_eom.py index 5fdaef91d..35ee80b9a 100644 --- a/aviary/mission/two_dof/ode/test/test_accel_eom.py +++ b/aviary/mission/two_dof/ode/test/test_accel_eom.py @@ -40,18 +40,16 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.VELOCITY_RATE], - np.array([5.51533958, 5.51533958]), - tol, - # note: this was finite differenced from GASP. The fd value is: np.array([5.2353365, 5.2353365]) - ) - assert_near_equal( - self.prob[Dynamic.Mission.DISTANCE_RATE], - np.array([425.32808399, 425.32808399]), - tol, - # note: this was finite differenced from GASP. The fd value is: np.array([441.6439, 441.6439]) - ) + # note: values were finite differenced from GASP + # fd values are: VELOCITY_RATE=[5.2353365, 5.2353365], DISTANCE_RATE=[441.6439, 441.6439] + expected_values = { + Dynamic.Mission.VELOCITY_RATE: np.array([5.51533958, 5.51533958]), + Dynamic.Mission.DISTANCE_RATE: np.array([425.32808399, 425.32808399]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) diff --git a/aviary/mission/two_dof/ode/test/test_ascent_eom.py b/aviary/mission/two_dof/ode/test/test_ascent_eom.py index 8a290f83c..8356fd0c3 100644 --- a/aviary/mission/two_dof/ode/test/test_ascent_eom.py +++ b/aviary/mission/two_dof/ode/test/test_ascent_eom.py @@ -39,16 +39,14 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.VELOCITY_RATE], - np.array([2.202965, 2.202965]), - tol, - ) - assert_near_equal( - self.prob[Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE], - np.array([-3.216328, -3.216328]), - tol, - ) + expected_values = { + Dynamic.Mission.VELOCITY_RATE: np.array([2.202965, 2.202965]), + Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE: np.array([-3.216328, -3.216328]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) diff --git a/aviary/mission/two_dof/ode/test/test_flight_eom.py b/aviary/mission/two_dof/ode/test/test_flight_eom.py index 27e224231..ffefe8466 100644 --- a/aviary/mission/two_dof/ode/test/test_flight_eom.py +++ b/aviary/mission/two_dof/ode/test/test_flight_eom.py @@ -40,28 +40,19 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.ALTITUDE_RATE], - np.array([-39.42713005, -39.42713005]), - tol, - ) # note: values from GASP are: np.array([-39.75, -39.75]) - assert_near_equal( - self.prob[Dynamic.Mission.DISTANCE_RATE], - np.array([773.70078935, 773.70078935]), - tol, - # note: these values are finite differenced and lose accuracy. Fd values are:np.array([964.4634921, 964.4634921]) - ) - assert_near_equal( - self.prob['required_lift'], - np.array([147444.41570307, 147444.41570307]), - tol, - # note: values from GASP are: np.array([146288.8, 146288.8]) (estimated based on GASP values) - ) - assert_near_equal( - self.prob[Dynamic.Mission.FLIGHT_PATH_ANGLE], - np.array([-0.0509151, -0.0509151]), - tol, - ) # note: values from GASP are: np.array([-.0513127, -.0513127]) + # note: some values from GASP differ slightly due to calculation method differences + # GASP values: ALTITUDE_RATE=[-39.75, -39.75], DISTANCE_RATE=[964.4634921, 964.4634921] (fd), + # required_lift=[146288.8, 146288.8], FLIGHT_PATH_ANGLE=[-.0513127, -.0513127] + expected_values = { + Dynamic.Mission.ALTITUDE_RATE: np.array([-39.42713005, -39.42713005]), + Dynamic.Mission.DISTANCE_RATE: np.array([773.70078935, 773.70078935]), + 'required_lift': np.array([147444.41570307, 147444.41570307]), + Dynamic.Mission.FLIGHT_PATH_ANGLE: np.array([-0.0509151, -0.0509151]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -131,27 +122,19 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.ALTITUDE_RATE], - np.array([6.24116612, 6.24116612]), - tol, - ) # note: values from GASP are: np.array([5.9667, 5.9667]) - assert_near_equal( - self.prob[Dynamic.Mission.DISTANCE_RATE], - np.array([774.679584, 774.679584]), - tol, - # note: these values are finite differenced and lose accuracy. Fd values are: np.array([799.489, 799.489]) - ) - assert_near_equal( - self.prob['required_lift'], - np.array([162662.70954313, 162662.70954313]), - tol, - ) # note: values from GASP are: np.array([170316.2, 170316.2]) - assert_near_equal( - self.prob[Dynamic.Mission.FLIGHT_PATH_ANGLE], - np.array([0.00805627, 0.00805627]), - tol, - ) # note: values from GASP are:np.array([.0076794487, .0076794487]) + # note: some values from GASP differ slightly due to calculation method differences + # GASP values: ALTITUDE_RATE=[5.9667, 5.9667], DISTANCE_RATE=[799.489, 799.489] (fd), + # required_lift=[170316.2, 170316.2], FLIGHT_PATH_ANGLE=[.0076794487, .0076794487] + expected_values = { + Dynamic.Mission.ALTITUDE_RATE: np.array([6.24116612, 6.24116612]), + Dynamic.Mission.DISTANCE_RATE: np.array([774.679584, 774.679584]), + 'required_lift': np.array([162662.70954313, 162662.70954313]), + Dynamic.Mission.FLIGHT_PATH_ANGLE: np.array([0.00805627, 0.00805627]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) diff --git a/aviary/mission/two_dof/ode/test/test_flight_path_eom.py b/aviary/mission/two_dof/ode/test/test_flight_path_eom.py index beb68da3b..b48bf8a91 100644 --- a/aviary/mission/two_dof/ode/test/test_flight_path_eom.py +++ b/aviary/mission/two_dof/ode/test/test_flight_path_eom.py @@ -23,27 +23,19 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.VELOCITY_RATE], - np.array([-27.10027, -27.10027]), - tol, - ) - assert_near_equal( - self.prob[Dynamic.Mission.DISTANCE_RATE], np.array([0.5403023, 0.5403023]), tol - ) - assert_near_equal(self.prob['normal_force'], np.array([-0.0174524, -0.0174524]), tol) - assert_near_equal(self.prob['fuselage_pitch'], np.array([58.2958, 58.2958]), tol) - assert_near_equal(self.prob['load_factor'], np.array([1.883117, 1.883117]), tol) - assert_near_equal( - self.prob[Dynamic.Mission.ALTITUDE_RATE], - np.array([0.841471, 0.841471]), - tol, - ) - assert_near_equal( - self.prob[Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE], - np.array([15.36423, 15.36423]), - tol, - ) + expected_values = { + Dynamic.Mission.VELOCITY_RATE: np.array([-27.10027, -27.10027]), + Dynamic.Mission.DISTANCE_RATE: np.array([0.5403023, 0.5403023]), + 'normal_force': np.array([-0.0174524, -0.0174524]), + 'fuselage_pitch': np.array([58.2958, 58.2958]), + 'load_factor': np.array([1.883117, 1.883117]), + Dynamic.Mission.ALTITUDE_RATE: np.array([0.841471, 0.841471]), + Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE: np.array([15.36423, 15.36423]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -56,17 +48,17 @@ def test_case2(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.VELOCITY_RATE], - np.array([-27.09537, -27.09537]), - tol, - ) - assert_near_equal( - self.prob[Dynamic.Mission.DISTANCE_RATE], np.array([0.5403023, 0.5403023]), tol - ) - assert_near_equal(self.prob['normal_force'], np.array([-0.0, -0.0]), tol) - assert_near_equal(self.prob['fuselage_pitch'], np.array([57.29578, 57.29578]), tol) - assert_near_equal(self.prob['load_factor'], np.array([1.850816, 1.850816]), tol) + expected_values = { + Dynamic.Mission.VELOCITY_RATE: np.array([-27.09537, -27.09537]), + Dynamic.Mission.DISTANCE_RATE: np.array([0.5403023, 0.5403023]), + 'normal_force': np.array([-0.0, -0.0]), + 'fuselage_pitch': np.array([57.29578, 57.29578]), + 'load_factor': np.array([1.850816, 1.850816]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) diff --git a/aviary/mission/two_dof/ode/test/test_groundroll_eom.py b/aviary/mission/two_dof/ode/test/test_groundroll_eom.py index f18293448..ebb90d218 100644 --- a/aviary/mission/two_dof/ode/test/test_groundroll_eom.py +++ b/aviary/mission/two_dof/ode/test/test_groundroll_eom.py @@ -39,18 +39,19 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.VELOCITY_RATE], - np.array([1.5597, 1.5597]), - tol, - ) - assert_near_equal( - self.prob[Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE], np.array([0.0, 0.0]), tol - ) - assert_near_equal(self.prob[Dynamic.Mission.ALTITUDE_RATE], np.array([0.0, 0.0]), tol) - assert_near_equal(self.prob[Dynamic.Mission.DISTANCE_RATE], np.array([10.0, 10.0]), tol) - assert_near_equal(self.prob['normal_force'], np.array([175200.0, 175200.0]), tol) - assert_near_equal(self.prob['fuselage_pitch'], np.array([0.0, 0.0]), tol) + expected_values = { + Dynamic.Mission.VELOCITY_RATE: np.array([1.5597, 1.5597]), + Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE: np.array([0.0, 0.0]), + Dynamic.Mission.ALTITUDE_RATE: np.array([0.0, 0.0]), + Dynamic.Mission.DISTANCE_RATE: np.array([10.0, 10.0]), + 'normal_force': np.array([175200.0, 175200.0]), + 'fuselage_pitch': np.array([0.0, 0.0]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) + partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) diff --git a/aviary/mission/two_dof/ode/test/test_landing_eom.py b/aviary/mission/two_dof/ode/test/test_landing_eom.py index 68f28316b..128db965c 100644 --- a/aviary/mission/two_dof/ode/test/test_landing_eom.py +++ b/aviary/mission/two_dof/ode/test/test_landing_eom.py @@ -68,36 +68,26 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob.get_val(Mission.Landing.INITIAL_VELOCITY, units='kn'), 142.783, tol - ) # note: actual GASP value is: 142.74 - assert_near_equal( - self.prob.get_val(Mission.Landing.STALL_VELOCITY, units='kn'), 109.8331, tol - ) # note: EAS in GASP, although at this altitude they are nearly identical. actual GASP value is 109.73 - assert_near_equal( - self.prob.get_val('TAS_touchdown', units='kn'), 126.3081, tol - ) # note: actual GASP value is: 126.27 - assert_near_equal( - self.prob.get_val('density_ratio', units='unitless'), 1.0, tol - ) # note: calculated from GASP glide speed values as: .998739 - assert_near_equal( - self.prob.get_val('wing_loading_land', units='lbf/ft**2'), 120.61519375, tol - ) # note: actual GASP value is: 120.61 - assert_near_equal( - self.prob.get_val('theta', units='deg'), 3.56857, tol - ) # note: actual GASP value is: 3.57 - assert_near_equal( - self.prob.get_val('glide_distance', units='ft'), 801.7444, tol - ) # note: actual GASP value is: 802 - assert_near_equal( - self.prob.get_val('tr_distance', units='ft'), 166.5303, tol - ) # note: actual GASP value is: 167 - assert_near_equal( - self.prob.get_val('delay_distance', units='ft'), 213.184, tol - ) # note: actual GASP value is: 213 - assert_near_equal( - self.prob.get_val('flare_alt', units='ft'), 20.73407, tol - ) # note: actual GASP value is: 20.8 + # note: actual GASP values differ slightly + # GASP values: INITIAL_VELOCITY=142.74, STALL_VELOCITY=109.73, TAS_touchdown=126.27, + # density_ratio=.998739, wing_loading_land=120.61, theta=3.57, + # glide_distance=802, tr_distance=167, delay_distance=213, flare_alt=20.8 + expected_values = { + (Mission.Landing.INITIAL_VELOCITY, 'kn'): 142.783, + (Mission.Landing.STALL_VELOCITY, 'kn'): 109.8331, + ('TAS_touchdown', 'kn'): 126.3081, + ('density_ratio', 'unitless'): 1.0, + ('wing_loading_land', 'lbf/ft**2'): 120.61519375, + ('theta', 'deg'): 3.56857, + ('glide_distance', 'ft'): 801.7444, + ('tr_distance', 'ft'): 166.5303, + ('delay_distance', 'ft'): 213.184, + ('flare_alt', 'ft'): 20.73407, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-10, rtol=1e-12) @@ -172,15 +162,17 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob['ground_roll_distance'], 2406.43116212, tol - ) # actual GASP value is: 1798 - assert_near_equal( - self.prob[Mission.Landing.GROUND_DISTANCE], 3588.43116212, tol - ) # actual GASP value is: 2980 - assert_near_equal( - self.prob['average_acceleration'], 0.29308129, tol - ) # actual GASP value is: 0.3932 + # note: actual GASP values differ: ground_roll_distance=1798, GROUND_DISTANCE=2980, + # average_acceleration=0.3932 + expected_values = { + 'ground_roll_distance': 2406.43116212, + Mission.Landing.GROUND_DISTANCE: 3588.43116212, + 'average_acceleration': 0.29308129, + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=5e-12, rtol=1e-12) diff --git a/aviary/mission/two_dof/ode/test/test_rotation_eom.py b/aviary/mission/two_dof/ode/test/test_rotation_eom.py index a4d6ff36d..0d68b85ca 100644 --- a/aviary/mission/two_dof/ode/test/test_rotation_eom.py +++ b/aviary/mission/two_dof/ode/test/test_rotation_eom.py @@ -39,18 +39,18 @@ def test_case1(self): tol = 1e-6 self.prob.run_model() - assert_near_equal( - self.prob[Dynamic.Mission.VELOCITY_RATE], - np.array([1.5597, 1.5597]), - tol, - ) - assert_near_equal( - self.prob[Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE], np.array([0.0, 0.0]), tol - ) - assert_near_equal(self.prob[Dynamic.Mission.ALTITUDE_RATE], np.array([0.0, 0.0]), tol) - assert_near_equal(self.prob[Dynamic.Mission.DISTANCE_RATE], np.array([10.0, 10.0]), tol) - assert_near_equal(self.prob['normal_force'], np.array([175200.0, 175200.0]), tol) - assert_near_equal(self.prob['fuselage_pitch'], np.array([0.0, 0.0]), tol) + expected_values = { + Dynamic.Mission.VELOCITY_RATE: np.array([1.5597, 1.5597]), + Dynamic.Mission.FLIGHT_PATH_ANGLE_RATE: np.array([0.0, 0.0]), + Dynamic.Mission.ALTITUDE_RATE: np.array([0.0, 0.0]), + Dynamic.Mission.DISTANCE_RATE: np.array([10.0, 10.0]), + 'normal_force': np.array([175200.0, 175200.0]), + 'fuselage_pitch': np.array([0.0, 0.0]), + } + + for var_name, expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) diff --git a/aviary/subsystems/aerodynamics/flops_based/test/test_mux_component.py b/aviary/subsystems/aerodynamics/flops_based/test/test_mux_component.py index 0a9fd2ca3..a1c637182 100644 --- a/aviary/subsystems/aerodynamics/flops_based/test/test_mux_component.py +++ b/aviary/subsystems/aerodynamics/flops_based/test/test_mux_component.py @@ -74,11 +74,23 @@ def test_mux(self): laminar_fractions_lower_output = prob['mux.laminar_fractions_lower'] # Assert that the outputs are near the expected values - assert_near_equal(wetted_areas_output, wetted_areas_truth, 1e-7) - assert_near_equal(fineness_ratios_output, fineness_ratios_truth, 1e-7) - assert_near_equal(characteristic_lengths_output, characteristic_lengths_truth, 1e-7) - assert_near_equal(laminar_fractions_upper_output, laminar_fractions_upper_truth, 1e-7) - assert_near_equal(laminar_fractions_lower_output, laminar_fractions_lower_truth, 1e-7) + expected_values = { + 'wetted_areas': (wetted_areas_output, wetted_areas_truth), + 'fineness_ratios': (fineness_ratios_output, fineness_ratios_truth), + 'characteristic_lengths': (characteristic_lengths_output, characteristic_lengths_truth), + 'laminar_fractions_upper': ( + laminar_fractions_upper_output, + laminar_fractions_upper_truth, + ), + 'laminar_fractions_lower': ( + laminar_fractions_lower_output, + laminar_fractions_lower_truth, + ), + } + + for var_name, (output, truth) in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(output, truth, 1e-7) def test_mux_multiengine(self): prob = om.Problem() @@ -151,11 +163,23 @@ def test_mux_multiengine(self): laminar_fractions_lower_output = prob['mux.laminar_fractions_lower'] # Assert that the outputs are near the expected values - assert_near_equal(wetted_areas_output, wetted_areas_truth, 1e-7) - assert_near_equal(fineness_ratios_output, fineness_ratios_truth, 1e-7) - assert_near_equal(characteristic_lengths_output, characteristic_lengths_truth, 1e-7) - assert_near_equal(laminar_fractions_upper_output, laminar_fractions_upper_truth, 1e-7) - assert_near_equal(laminar_fractions_lower_output, laminar_fractions_lower_truth, 1e-7) + expected_values = { + 'wetted_areas': (wetted_areas_output, wetted_areas_truth), + 'fineness_ratios': (fineness_ratios_output, fineness_ratios_truth), + 'characteristic_lengths': (characteristic_lengths_output, characteristic_lengths_truth), + 'laminar_fractions_upper': ( + laminar_fractions_upper_output, + laminar_fractions_upper_truth, + ), + 'laminar_fractions_lower': ( + laminar_fractions_lower_output, + laminar_fractions_lower_truth, + ), + } + + for var_name, (output, truth) in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(output, truth, 1e-7) if __name__ == '__main__': diff --git a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_Clmax.py b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_Clmax.py index e1470a735..53623cae4 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_Clmax.py +++ b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_Clmax.py @@ -49,19 +49,17 @@ def setUp(self): def test_case(self): self.prob.run_model() tol = 6e-4 - print() - reg_data = 2.8155 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.8155, + Dynamic.Atmosphere.MACH: 0.17522, + 'reynolds': 157.19864, + } - reg_data = 0.17522 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) - - reg_data = 157.19864 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(out_stream=None, method='fd') assert_check_partials( diff --git a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_basic_calculations.py b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_basic_calculations.py index deef0d344..ab09f66cd 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_basic_calculations.py +++ b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_basic_calculations.py @@ -44,41 +44,22 @@ def test_case(self): self.prob.run_model() tol = 2.1e-4 - reg_data = 0.74444 - ans = self.prob['VLAM8'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.93578 - ans = self.prob['VDEL4'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.90761 - ans = self.prob['VDEL5'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.9975 - ans = self.prob['VLAM9'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.5 - ans = self.prob['slat_defl_ratio'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.89761 - ans = self.prob[Aircraft.Wing.SLAT_SPAN_RATIO] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.09239 - ans = self.prob['body_to_span_ratio'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.12679 - ans = self.prob['chord_to_body_ratio'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.79208 - ans = self.prob['VLAM12'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'VLAM8': 0.74444, + 'VDEL4': 0.93578, + 'VDEL5': 0.90761, + 'VLAM9': 0.9975, + 'slat_defl_ratio': 0.5, + Aircraft.Wing.SLAT_SPAN_RATIO: 0.89761, + 'body_to_span_ratio': 0.09239, + 'chord_to_body_ratio': 0.12679, + 'VLAM12': 0.79208, + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(out_stream=None, method='fd') assert_check_partials(data, atol=1e-6, rtol=4e-6) diff --git a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_flaps_group.py b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_flaps_group.py index 07e4428bf..8bd5c8115 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_flaps_group.py +++ b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_flaps_group.py @@ -99,25 +99,18 @@ def test_case(self): self.prob.run_model() tol = 6e-4 # checked. high tol for lack of precision in GASP data. - reg_data = 2.8155 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.17522 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) - - reg_data = 157.1111 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.0406 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.0293 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.8155, + Dynamic.Atmosphere.MACH: 0.17522, + 'reynolds': 157.1111, + 'delta_CD': 0.0406, + 'delta_CL': 1.0293, + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(method='fd', out_stream=None) assert_check_partials( @@ -207,25 +200,18 @@ def test_case(self): self.prob.run_model() tol = 9e-4 # checked. high tol for lack of precision in GASP data. - reg_data = 2.56197 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.18368 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.56197, + Dynamic.Atmosphere.MACH: 0.18368, + 'reynolds': 164.78406, + 'delta_CD': 0.0362, + 'delta_CL': 0.7816, + } - reg_data = 164.78406 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.0362 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.7816 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(method='fd', out_stream=None) assert_check_partials( @@ -316,25 +302,18 @@ def test_case(self): self.prob.run_model() tol = 6e-4 # checked. high tol for lack of precision in GASP data. - reg_data = 2.8155 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.17522 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) - - reg_data = 157.1111 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.0406 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.8155, + Dynamic.Atmosphere.MACH: 0.17522, + 'reynolds': 157.1111, + 'delta_CD': 0.0406, + 'delta_CL': 1.0293, + } - reg_data = 1.0293 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(method='fd', out_stream=None) assert_check_partials( @@ -424,25 +403,18 @@ def test_case(self): self.prob.run_model() tol = 9e-4 # checked. high tol for lack of precision in GASP data. - reg_data = 2.56197 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.56197, + Dynamic.Atmosphere.MACH: 0.18368, + 'reynolds': 164.78406, + 'delta_CD': 0.0362, + 'delta_CL': 0.7816, + } - reg_data = 0.18368 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) - - reg_data = 164.78406 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.0362 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.7816 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(method='fd', out_stream=None) assert_check_partials( @@ -532,25 +504,18 @@ def test_case(self): self.prob.run_model() tol = 6e-4 # checked. high tol for lack of precision in GASP data. - reg_data = 2.93271 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.17168 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) - - reg_data = 154.02686 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.93271, + Dynamic.Atmosphere.MACH: 0.17168, + 'reynolds': 154.02686, + 'delta_CD': 0.1070, + 'delta_CL': 1.1441, + } - reg_data = 0.1070 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.1441 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(method='fd', out_stream=None) assert_check_partials( @@ -642,25 +607,18 @@ def test_case(self): self.prob.run_model() tol = 6e-4 # checked. high tol for lack of precision in GASP data. - reg_data = 2.93271 - ans = self.prob['CL_max'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.17168 - ans = self.prob[Dynamic.Atmosphere.MACH] - assert_near_equal(ans, reg_data, tol) - - reg_data = 154.02686 - ans = self.prob['reynolds'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.1070 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.1441 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'CL_max': 2.93271, + Dynamic.Atmosphere.MACH: 0.17168, + 'reynolds': 154.02686, + 'delta_CD': 0.1070, + 'delta_CL': 1.1441, + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(method='fd', out_stream=None) assert_check_partials( diff --git a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_increments.py b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_increments.py index 920add3b5..48803ca65 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_increments.py +++ b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_increments.py @@ -41,15 +41,16 @@ def setUp(self): def test_case(self): self.prob.run_model() tol = 5e-4 - print() - reg_data = 0.0650 - ans = self.prob['delta_CD'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'delta_CD': 0.0650, + 'delta_CL': 1.0293, + } - reg_data = 1.0293 - ans = self.prob['delta_CL'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(out_stream=None, method='fd') assert_check_partials(data, atol=1e-4, rtol=1e-4) diff --git a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_metamodel.py b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_metamodel.py index 488a766b0..f367d5276 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_metamodel.py +++ b/aviary/subsystems/aerodynamics/gasp_based/flaps_model/test/test_metamodel.py @@ -40,65 +40,28 @@ def test_case(self): self.prob.run_model() tol = 1e-4 - reg_data = 1 - ans = self.prob['VDEL1'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.55667 - ans = self.prob['VDEL2'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.76500 - ans = self.prob['VDEL3'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.05498 - ans = self.prob['fus_lift'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.97217 - ans = self.prob['VLAM1'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.09948 - ans = self.prob['VLAM2'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.97217 - ans = self.prob['VLAM3'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.19742 - ans = self.prob['VLAM4'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1 - ans = self.prob['VLAM5'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.80000 - ans = self.prob['VLAM6'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.73500 - ans = self.prob['VLAM7'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.74000 - ans = self.prob['VLAM10'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 0.84232 - ans = self.prob['VLAM11'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.03209 - ans = self.prob['VLAM13'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'VDEL1': 1, + 'VDEL2': 0.55667, + 'VDEL3': 0.76500, + 'fus_lift': 0.05498, + 'VLAM1': 0.97217, + 'VLAM2': 1.09948, + 'VLAM3': 0.97217, + 'VLAM4': 1.19742, + 'VLAM5': 1, + 'VLAM6': 0.80000, + 'VLAM7': 0.73500, + 'VLAM10': 0.74000, + 'VLAM11': 0.84232, + 'VLAM13': 1.03209, + 'VLAM14': 0.99082, + } - reg_data = 0.99082 - ans = self.prob['VLAM14'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(out_stream=None, method='fd') assert_check_partials(data, atol=1e-4, rtol=1e-4) @@ -121,21 +84,17 @@ def test_case(self): self.prob.run_model() tol = 1e-4 - reg_data = 1 - ans = self.prob['VDEL1'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1.25725 - ans = self.prob['VLAM4'] - assert_near_equal(ans, reg_data, tol) - - reg_data = 1 - ans = self.prob['VLAM5'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'VDEL1': 1, + 'VLAM4': 1.25725, + 'VLAM5': 1, + 'VLAM6': 1.0, + } - reg_data = 1.0 - ans = self.prob['VLAM6'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(out_stream=None, method='fd') assert_check_partials(data, atol=1e-4, rtol=1e-4) @@ -157,13 +116,15 @@ def test_case(self): self.prob.run_model() tol = 1e-4 - reg_data = 1.0 - ans = self.prob['VLAM5'] - assert_near_equal(ans, reg_data, tol) + expected_values = { + 'VLAM5': 1.0, + 'VLAM6': 1.11, + } - reg_data = 1.11 - ans = self.prob['VLAM6'] - assert_near_equal(ans, reg_data, tol) + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + ans = self.prob[var_name] + assert_near_equal(ans, reg_data, tol) data = self.prob.check_partials(out_stream=None, method='fd') assert_check_partials(data, atol=1e-4, rtol=1e-4) diff --git a/aviary/subsystems/aerodynamics/gasp_based/test/test_common.py b/aviary/subsystems/aerodynamics/gasp_based/test/test_common.py index 608882a3d..18b5d55d2 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/test/test_common.py +++ b/aviary/subsystems/aerodynamics/gasp_based/test/test_common.py @@ -30,10 +30,14 @@ def testAeroForces(self): prob.run_model() - lift = prob.get_val(Dynamic.Vehicle.LIFT) - drag = prob.get_val(Dynamic.Vehicle.DRAG) - assert_near_equal(lift, [1370.3, 1233.27, 1096.24]) - assert_near_equal(drag, [1370.3, 1301.785, 1164.755]) + expected_values = { + Dynamic.Vehicle.LIFT: [1370.3, 1233.27, 1096.24], + Dynamic.Vehicle.DRAG: [1370.3, 1301.785, 1164.755], + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name), reg_data) partial_data = prob.check_partials(method='cs', out_stream=None) assert_check_partials(partial_data, atol=1e-12, rtol=1e-15) diff --git a/aviary/subsystems/aerodynamics/gasp_based/test/test_interference.py b/aviary/subsystems/aerodynamics/gasp_based/test/test_interference.py index 9ed3eae97..694d2a0df 100644 --- a/aviary/subsystems/aerodynamics/gasp_based/test/test_interference.py +++ b/aviary/subsystems/aerodynamics/gasp_based/test/test_interference.py @@ -47,8 +47,14 @@ def test_common_vars(self): prob.run_model() - assert_near_equal(prob.get_val('ZW_RF'), [-0.8], tol) - assert_near_equal(prob.get_val('wtofd'), [0.144], tol) + expected_values = { + 'ZW_RF': [-0.8], + 'wtofd': [0.144], + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name), reg_data, tol) partial_data = prob.check_partials(method='cs', out_stream=None) assert_check_partials(partial_data, atol=1e-12, rtol=1e-14) @@ -84,8 +90,14 @@ def test_body_ratios(self): prob.run_model() - assert_near_equal(prob.get_val('TCBODYWF'), [0.11957627], tol) - assert_near_equal(prob.get_val('CBODYWF'), [11.974576], tol) + expected_values = { + 'TCBODYWF': [0.11957627], + 'CBODYWF': [11.974576], + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name), reg_data, tol) partial_data = prob.check_partials(method='cs', out_stream=None) assert_check_partials(partial_data, atol=1e-12, rtol=1e-14) @@ -105,10 +117,14 @@ def test_interference_drag(self): prob.run_model() - assert_near_equal( - prob.get_val('interference_independent_of_shielded_area'), [0.05654201], tol - ) - assert_near_equal(prob.get_val('drag_loss_due_to_shielded_wing_area'), [30], tol) + expected_values = { + 'interference_independent_of_shielded_area': [0.05654201], + 'drag_loss_due_to_shielded_wing_area': [30], + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name), reg_data, tol) partial_data = prob.check_partials(method='cs', out_stream=None) assert_check_partials(partial_data, atol=1e-12, rtol=1e-14) @@ -139,10 +155,14 @@ def test_complete_group(self): prob.run_model() - assert_near_equal( - prob.get_val('interference_independent_of_shielded_area'), [0.35794891], tol - ) - assert_near_equal(prob.get_val('drag_loss_due_to_shielded_wing_area'), [83.53366], tol) + expected_values = { + 'interference_independent_of_shielded_area': [0.35794891], + 'drag_loss_due_to_shielded_wing_area': [83.53366], + } + + for var_name, reg_data in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name), reg_data, tol) partial_data = prob.check_partials(method='cs', out_stream=None) assert_check_partials(partial_data, atol=1e-12, rtol=1e-14) diff --git a/aviary/subsystems/atmosphere/test/test_atmosphere.py b/aviary/subsystems/atmosphere/test/test_atmosphere.py index 1c13edfb8..9cd524a96 100644 --- a/aviary/subsystems/atmosphere/test/test_atmosphere.py +++ b/aviary/subsystems/atmosphere/test/test_atmosphere.py @@ -79,25 +79,17 @@ def test_geocentric(self): tol = 1e-4 self.prob.run_model() - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='K'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='Pa'), - expected_pressure, - tol, - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='kg/m**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'K'): expected_temp, + (Dynamic.Atmosphere.STATIC_PRESSURE, 'Pa'): expected_pressure, + (Dynamic.Atmosphere.DENSITY, 'kg/m**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') @@ -169,25 +161,17 @@ def test_geocentric_delta_T(self): 1.58179488e-05, ] # (Pa*s) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='K'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='Pa'), - expected_pressure, - tol, - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='kg/m**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'K'): expected_temp, + (Dynamic.Atmosphere.STATIC_PRESSURE, 'Pa'): expected_pressure, + (Dynamic.Atmosphere.DENSITY, 'kg/m**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') @@ -219,25 +203,17 @@ def test_geodetic(self): tol = 1e-4 self.prob.run_model() - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='K'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='Pa'), - expected_pressure, - tol, - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='kg/m**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'K'): expected_temp, + (Dynamic.Atmosphere.STATIC_PRESSURE, 'Pa'): expected_pressure, + (Dynamic.Atmosphere.DENSITY, 'kg/m**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') @@ -331,28 +307,25 @@ def test_case1(self): 1.31516893e-05, ] # (Pa*s) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='degF'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='lbm/ft**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'degF'): expected_temp, + (Dynamic.Atmosphere.DENSITY, 'lbm/ft**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) # inHg60 is a newer unit in OpenMDAO so we'll do this check only of that newer version is installed if Version(openmdao.__version__) >= Version('3.42.0'): - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), - expected_pressure, - tol, - ) + with self.subTest(var=Dynamic.Atmosphere.STATIC_PRESSURE): + assert_near_equal( + self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), + expected_pressure, + tol, + ) partial_data = self.prob.check_partials(out_stream=None, method='cs') @@ -416,26 +389,24 @@ def test_case1(self): 1.53000203e-05, ] # (Pa*s) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='degF'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='lbm/ft**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'degF'): expected_temp, + (Dynamic.Atmosphere.DENSITY, 'lbm/ft**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) + if Version(openmdao.__version__) >= Version('3.42.0'): - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), - expected_pressure, - tol, - ) + with self.subTest(var=Dynamic.Atmosphere.STATIC_PRESSURE): + assert_near_equal( + self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), + expected_pressure, + tol, + ) partial_data = self.prob.check_partials(out_stream=None, method='cs') @@ -499,26 +470,24 @@ def test_case1(self): 1.59359066e-05, ] # (Pa*s) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='degF'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='lbm/ft**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'degF'): expected_temp, + (Dynamic.Atmosphere.DENSITY, 'lbm/ft**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) + if Version(openmdao.__version__) >= Version('3.42.0'): - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), - expected_pressure, - tol, - ) + with self.subTest(var=Dynamic.Atmosphere.STATIC_PRESSURE): + assert_near_equal( + self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), + expected_pressure, + tol, + ) partial_data = self.prob.check_partials(out_stream=None, method='cs') @@ -582,26 +551,24 @@ def test_case1(self): 1.38565730e-05, ] # (Pa*s) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.TEMPERATURE, units='degF'), expected_temp, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DENSITY, units='lbm/ft**3'), expected_density, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.SPEED_OF_SOUND, units='m/s'), expected_sos, tol - ) - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.DYNAMIC_VISCOSITY, units='Pa*s'), - expected_viscosity, - tol, - ) + expected_values = { + (Dynamic.Atmosphere.TEMPERATURE, 'degF'): expected_temp, + (Dynamic.Atmosphere.DENSITY, 'lbm/ft**3'): expected_density, + (Dynamic.Atmosphere.SPEED_OF_SOUND, 'm/s'): expected_sos, + (Dynamic.Atmosphere.DYNAMIC_VISCOSITY, 'Pa*s'): expected_viscosity, + } + + for (var_name, units), expected in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob.get_val(var_name, units=units), expected, tol) + if Version(openmdao.__version__) >= Version('3.42.0'): - assert_near_equal( - self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), - expected_pressure, - tol, - ) + with self.subTest(var=Dynamic.Atmosphere.STATIC_PRESSURE): + assert_near_equal( + self.prob.get_val(Dynamic.Atmosphere.STATIC_PRESSURE, units='inHg60'), + expected_pressure, + tol, + ) partial_data = self.prob.check_partials(out_stream=None, method='cs') diff --git a/aviary/subsystems/geometry/flops_based/test/test_prep_geom.py b/aviary/subsystems/geometry/flops_based/test/test_prep_geom.py index e334ab0f3..8e433549e 100644 --- a/aviary/subsystems/geometry/flops_based/test/test_prep_geom.py +++ b/aviary/subsystems/geometry/flops_based/test/test_prep_geom.py @@ -152,6 +152,7 @@ def configure(self): ) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -249,6 +250,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=get_flops_data(case_name), output_validation_data=local_variables[case_name], @@ -311,6 +313,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=_hybrid_input_data(case_name), output_validation_data=get_flops_outputs(case_name), @@ -356,6 +359,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=_hybrid_input_data(case_name), output_validation_data=get_flops_outputs(case_name), @@ -409,6 +413,7 @@ def test_case(self, case_name): outputs.extend(Aircraft.Fuselage.WETTED_AREA) do_validation_test( + self, prob, input_validation_data=_hybrid_input_data(case_name), output_validation_data=get_flops_outputs(case_name), @@ -459,6 +464,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -489,6 +495,7 @@ def test_case(self): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=Canard_test_data, output_validation_data=Canard_test_data, @@ -571,6 +578,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=_hybrid_input_data(case_name), output_validation_data=get_flops_outputs(case_name), diff --git a/aviary/subsystems/geometry/gasp_based/test/test_size_group.py b/aviary/subsystems/geometry/gasp_based/test/test_size_group.py index ae3a14d58..206178699 100644 --- a/aviary/subsystems/geometry/gasp_based/test/test_size_group.py +++ b/aviary/subsystems/geometry/gasp_based/test/test_size_group.py @@ -89,43 +89,39 @@ def test_case1(self): self.prob.run_model() tol = 5e-4 - assert_near_equal(self.prob[Aircraft.Fuselage.AVG_DIAMETER], 157.2, tol) - assert_near_equal(self.prob['cabin_height'], 13.1, tol) - assert_near_equal(self.prob['cabin_len'], 72.1, tol) - assert_near_equal(self.prob['nose_height'], 8.6, tol) - - # note: this is the actual GASP value, but for version 3.5. Version 3 has 129.4 - assert_near_equal(self.prob[Aircraft.Fuselage.LENGTH], 129.5, tol) - assert_near_equal(self.prob[Aircraft.Fuselage.WETTED_AREA], 4639.57, tol) - # note: this is the actual GASP value, but for version 3.5. Version 3 has 129.4 - assert_near_equal(self.prob[Aircraft.TailBoom.LENGTH], 129.5, tol) - - assert_near_equal(self.prob[Aircraft.Wing.AREA], 1370.3, tol) - assert_near_equal(self.prob[Aircraft.Wing.SPAN], 117.8, tol) - - assert_near_equal(self.prob[Aircraft.Wing.CENTER_CHORD], 17.49, tol) - assert_near_equal(self.prob[Aircraft.Wing.AVERAGE_CHORD], 12.615, tol) - assert_near_equal(self.prob[Aircraft.Wing.ROOT_CHORD], 16.41, tol) - assert_near_equal( - self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.1397, tol - ) # not exact GASP value, likely due to rounding error - assert_near_equal(self.prob[Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX], 1114, tol) - - assert_near_equal(self.prob[Aircraft.HorizontalTail.AREA], 375.9, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.SPAN], 42.25, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.ROOT_CHORD], 13.16130387591471, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 9.57573, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.MOMENT_ARM], 54.7, tol) - - assert_near_equal(self.prob[Aircraft.VerticalTail.AREA], 469.3, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.SPAN], 28, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.ROOT_CHORD], 18.61267549773935, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 16.83022, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MOMENT_ARM], 49.9, tol) - - assert_near_equal(self.prob[Aircraft.Nacelle.AVG_DIAMETER], 7.35, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.AVG_LENGTH], 14.7, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.SURFACE_AREA], 339.58, tol) + expected_values = { + Aircraft.Fuselage.AVG_DIAMETER: 157.2, + 'cabin_height': 13.1, + 'cabin_len': 72.1, + 'nose_height': 8.6, + Aircraft.Fuselage.LENGTH: 129.5, # note: this is the actual GASP value, but for version 3.5. Version 3 has 129.4 + Aircraft.Fuselage.WETTED_AREA: 4639.57, + Aircraft.TailBoom.LENGTH: 129.5, # note: this is the actual GASP value, but for version 3.5. Version 3 has 129.4 + Aircraft.Wing.AREA: 1370.3, + Aircraft.Wing.SPAN: 117.8, + Aircraft.Wing.CENTER_CHORD: 17.49, + Aircraft.Wing.AVERAGE_CHORD: 12.615, + Aircraft.Wing.ROOT_CHORD: 16.41, + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.1397, # not exact GASP value, likely due to rounding error + Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX: 1114, + Aircraft.HorizontalTail.AREA: 375.9, + Aircraft.HorizontalTail.SPAN: 42.25, + Aircraft.HorizontalTail.ROOT_CHORD: 13.16130387591471, + Aircraft.HorizontalTail.AVERAGE_CHORD: 9.57573, + Aircraft.HorizontalTail.MOMENT_ARM: 54.7, + Aircraft.VerticalTail.AREA: 469.3, + Aircraft.VerticalTail.SPAN: 28, + Aircraft.VerticalTail.ROOT_CHORD: 18.61267549773935, + Aircraft.VerticalTail.AVERAGE_CHORD: 16.83022, + Aircraft.VerticalTail.MOMENT_ARM: 49.9, + Aircraft.Nacelle.AVG_DIAMETER: 7.35, + Aircraft.Nacelle.AVG_LENGTH: 14.7, + Aircraft.Nacelle.SURFACE_AREA: 339.58, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=2e-12, rtol=1e-12) @@ -222,99 +218,47 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Fuselage.AVG_DIAMETER], 157.2, tol - ) # not actual GASP value - assert_near_equal(self.prob['cabin_height'], 13.1, tol) # not actual GASP value - assert_near_equal(self.prob['cabin_len'], 72.09722222, tol) # not actual GASP value - assert_near_equal(self.prob['nose_height'], 8.6, tol) # not actual GASP value - - assert_near_equal(self.prob[Aircraft.Fuselage.LENGTH], 129.5, tol) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Fuselage.WETTED_AREA], 4639.57, tol - ) # not actual GASP value - assert_near_equal(self.prob[Aircraft.TailBoom.LENGTH], 129.5, tol) # not actual GASP value - - assert_near_equal(self.prob[Aircraft.Wing.AREA], 1370.3125, tol) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Wing.SPAN], 117.81878299, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Wing.CENTER_CHORD], 17.48974356, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.AVERAGE_CHORD], 12.61453233, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.ROOT_CHORD], 16.40711451, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.13965584, tol - ) # not actual GASP value - - assert_near_equal( - self.prob['nonfolded_taper_ratio'], 0.93175961, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.FOLDING_AREA], 1167.5966191, tol - ) # not actual GASP value - assert_near_equal( - self.prob['nonfolded_wing_area'], 202.7158809, tol - ) # not actual GASP value - assert_near_equal( - self.prob['tc_ratio_mean_folded'], 0.14847223, tol - ) # not actual GASP value - assert_near_equal(self.prob['nonfolded_AR'], 0.71035382, tol) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX], 208.08091725, tol - ) # not actual GASP value - - assert_near_equal(self.prob['strut_y'], 6, tol) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Strut.LENGTH], 13.11154072, tol - ) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Strut.CHORD], 1.14403031, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.HorizontalTail.AREA], 375.87987047, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.SPAN], 42.25434161, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.ROOT_CHORD], 13.15924684, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 9.57681709, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.MOMENT_ARM], 54.67937726, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.VerticalTail.AREA], 469.31832812, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.SPAN], 27.99574268, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.ROOT_CHORD], 18.61623295, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 16.83214111, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.MOMENT_ARM], 49.88094115, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Nacelle.AVG_DIAMETER], 7.35163168, tol - ) # may not be actual GASP value - assert_near_equal( - self.prob[Aircraft.Nacelle.AVG_LENGTH], 14.70326336, tol - ) # may not be actual GASP value - assert_near_equal( - self.prob[Aircraft.Nacelle.SURFACE_AREA], 339.58410134, tol - ) # may not be actual GASP value + expected_values = { + Aircraft.Fuselage.AVG_DIAMETER: 157.2, # not actual GASP value + 'cabin_height': 13.1, # not actual GASP value + 'cabin_len': 72.09722222, # not actual GASP value + 'nose_height': 8.6, # not actual GASP value + Aircraft.Fuselage.LENGTH: 129.5, # not actual GASP value + Aircraft.Fuselage.WETTED_AREA: 4639.57, # not actual GASP value + Aircraft.TailBoom.LENGTH: 129.5, # not actual GASP value + Aircraft.Wing.AREA: 1370.3125, # not actual GASP value + Aircraft.Wing.SPAN: 117.81878299, # not actual GASP value + Aircraft.Wing.CENTER_CHORD: 17.48974356, # not actual GASP value + Aircraft.Wing.AVERAGE_CHORD: 12.61453233, # not actual GASP value + Aircraft.Wing.ROOT_CHORD: 16.40711451, # not actual GASP value + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.13965584, # not actual GASP value + 'nonfolded_taper_ratio': 0.93175961, # not actual GASP value + Aircraft.Wing.FOLDING_AREA: 1167.5966191, # not actual GASP value + 'nonfolded_wing_area': 202.7158809, # not actual GASP value + 'tc_ratio_mean_folded': 0.14847223, # not actual GASP value + 'nonfolded_AR': 0.71035382, # not actual GASP value + Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX: 208.08091725, # not actual GASP value + 'strut_y': 6, # not actual GASP value + Aircraft.Strut.LENGTH: 13.11154072, # not actual GASP value + Aircraft.Strut.CHORD: 1.14403031, # not actual GASP value + Aircraft.HorizontalTail.AREA: 375.87987047, # not actual GASP value + Aircraft.HorizontalTail.SPAN: 42.25434161, # not actual GASP value + Aircraft.HorizontalTail.ROOT_CHORD: 13.15924684, # not actual GASP value + Aircraft.HorizontalTail.AVERAGE_CHORD: 9.57681709, # not actual GASP value + Aircraft.HorizontalTail.MOMENT_ARM: 54.67937726, # not actual GASP value + Aircraft.VerticalTail.AREA: 469.31832812, # not actual GASP value + Aircraft.VerticalTail.SPAN: 27.99574268, # not actual GASP value + Aircraft.VerticalTail.ROOT_CHORD: 18.61623295, # not actual GASP value + Aircraft.VerticalTail.AVERAGE_CHORD: 16.83214111, # not actual GASP value + Aircraft.VerticalTail.MOMENT_ARM: 49.88094115, # not actual GASP value + Aircraft.Nacelle.AVG_DIAMETER: 7.35163168, # may not be actual GASP value + Aircraft.Nacelle.AVG_LENGTH: 14.70326336, # may not be actual GASP value + Aircraft.Nacelle.SURFACE_AREA: 339.58410134, # may not be actual GASP value + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=3e-10, rtol=1e-12) @@ -410,99 +354,45 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Fuselage.AVG_DIAMETER], 56.2, tol - ) # not actual GASP value - assert_near_equal(self.prob['cabin_height'], 9.18333, tol) # not actual GASP value - assert_near_equal(self.prob['cabin_len'], 435, tol) # not actual GASP value - assert_near_equal(self.prob['nose_height'], 4.68333, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Fuselage.LENGTH], 476.7333, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Fuselage.WETTED_AREA], 13400.44, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.TailBoom.LENGTH], 476.7333, tol - ) # not actual GASP value - - assert_near_equal(self.prob[Aircraft.Wing.AREA], 1370.3125, tol) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Wing.SPAN], 117.81878299, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Wing.CENTER_CHORD], 17.48974356, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.AVERAGE_CHORD], 12.61453233, tol - ) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Wing.ROOT_CHORD], 16.988, tol) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.14151, tol - ) # not actual GASP value - - assert_near_equal( - self.prob['nonfolded_taper_ratio'], 0.85783252, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.FOLDING_AREA], 964.14982163, tol - ) # not actual GASP value - assert_near_equal( - self.prob['nonfolded_wing_area'], 406.16267837, tol - ) # not actual GASP value - assert_near_equal( - self.prob['tc_ratio_mean_folded'], 0.14681715, tol - ) # not actual GASP value - assert_near_equal(self.prob['nonfolded_AR'], 1.5387923, tol) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX], 406.53567274, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.HorizontalTail.AREA], 298.484, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.SPAN], 37.654, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.ROOT_CHORD], 11.7265, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 8.5341, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.MOMENT_ARM], 54.67937726, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.VerticalTail.AREA], 297.003, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.SPAN], 22.2709, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.ROOT_CHORD], 14.8094, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 13.3902, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.MOMENT_ARM], 49.88094115, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Nacelle.AVG_DIAMETER], 7.35163168, tol - ) # may not be actual GASP value - assert_near_equal( - self.prob[Aircraft.Nacelle.AVG_LENGTH], 14.70326336, tol - ) # may not be actual GASP value - assert_near_equal( - self.prob[Aircraft.Nacelle.SURFACE_AREA], 339.58410134, tol - ) # may not be actual GASP value - - assert_near_equal( - self.prob[Aircraft.Electrical.HYBRID_CABLE_LENGTH], 50.6032, tol - ) # not actual GASP value + expected_values = { + Aircraft.Fuselage.AVG_DIAMETER: 56.2, # not actual GASP value + 'cabin_height': 9.18333, # not actual GASP value + 'cabin_len': 435, # not actual GASP value + 'nose_height': 4.68333, # not actual GASP value + Aircraft.Fuselage.LENGTH: 476.7333, # not actual GASP value + Aircraft.Fuselage.WETTED_AREA: 13400.44, # not actual GASP value + Aircraft.TailBoom.LENGTH: 476.7333, # not actual GASP value + Aircraft.Wing.AREA: 1370.3125, # not actual GASP value + Aircraft.Wing.SPAN: 117.81878299, # not actual GASP value + Aircraft.Wing.CENTER_CHORD: 17.48974356, # not actual GASP value + Aircraft.Wing.AVERAGE_CHORD: 12.61453233, # not actual GASP value + Aircraft.Wing.ROOT_CHORD: 16.988, # not actual GASP value + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.14151, # not actual GASP value + 'nonfolded_taper_ratio': 0.85783252, # not actual GASP value + Aircraft.Wing.FOLDING_AREA: 964.14982163, # not actual GASP value + 'nonfolded_wing_area': 406.16267837, # not actual GASP value + 'tc_ratio_mean_folded': 0.14681715, # not actual GASP value + 'nonfolded_AR': 1.5387923, # not actual GASP value + Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX: 406.53567274, # not actual GASP value + Aircraft.HorizontalTail.AREA: 298.484, # not actual GASP value + Aircraft.HorizontalTail.SPAN: 37.654, # not actual GASP value + Aircraft.HorizontalTail.ROOT_CHORD: 11.7265, # not actual GASP value + Aircraft.HorizontalTail.AVERAGE_CHORD: 8.5341, # not actual GASP value + Aircraft.HorizontalTail.MOMENT_ARM: 54.67937726, # not actual GASP value + Aircraft.VerticalTail.AREA: 297.003, # not actual GASP value + Aircraft.VerticalTail.SPAN: 22.2709, # not actual GASP value + Aircraft.VerticalTail.ROOT_CHORD: 14.8094, # not actual GASP value + Aircraft.VerticalTail.AVERAGE_CHORD: 13.3902, # not actual GASP value + Aircraft.VerticalTail.MOMENT_ARM: 49.88094115, # not actual GASP value + Aircraft.Nacelle.AVG_DIAMETER: 7.35163168, # may not be actual GASP value + Aircraft.Nacelle.AVG_LENGTH: 14.70326336, # may not be actual GASP value + Aircraft.Nacelle.SURFACE_AREA: 339.58410134, # may not be actual GASP value + Aircraft.Electrical.HYBRID_CABLE_LENGTH: 50.6032, # not actual GASP value + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-9, rtol=1e-12) @@ -598,82 +488,41 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Fuselage.AVG_DIAMETER], 56.2, tol - ) # not actual GASP value - assert_near_equal(self.prob['cabin_height'], 9.18333, tol) # not actual GASP value - assert_near_equal(self.prob['cabin_len'], 435, tol) # not actual GASP value - assert_near_equal(self.prob['nose_height'], 4.68333, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Fuselage.LENGTH], 476.7333, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Fuselage.WETTED_AREA], 13400.44, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.TailBoom.LENGTH], 476.7333, tol - ) # not actual GASP value - - assert_near_equal(self.prob[Aircraft.Wing.AREA], 1370.3125, tol) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Wing.SPAN], 117.81878299, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Wing.CENTER_CHORD], 17.48974356, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.AVERAGE_CHORD], 12.61453233, tol - ) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Wing.ROOT_CHORD], 16.988, tol) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.14151, tol - ) # not actual GASP value - - assert_near_equal(self.prob['strut_y'], 0, tol) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Strut.LENGTH], 5.2361, tol) # not actual GASP value - assert_near_equal(self.prob[Aircraft.Strut.CHORD], 2.8647, tol) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.HorizontalTail.AREA], 298.484, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.SPAN], 37.654, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.ROOT_CHORD], 11.7265, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 8.5341, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.HorizontalTail.MOMENT_ARM], 54.67937726, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.VerticalTail.AREA], 297.003, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.SPAN], 22.2709, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.ROOT_CHORD], 14.8094, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 13.3902, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.VerticalTail.MOMENT_ARM], 49.88094115, tol - ) # not actual GASP value - - assert_near_equal( - self.prob[Aircraft.Nacelle.AVG_DIAMETER], 7.35163168, tol - ) # may not be actual GASP value - assert_near_equal( - self.prob[Aircraft.Nacelle.AVG_LENGTH], 14.70326336, tol - ) # may not be actual GASP value - assert_near_equal( - self.prob[Aircraft.Nacelle.SURFACE_AREA], 339.58410134, tol - ) # may not be actual GASP value + expected_values = { + Aircraft.Fuselage.AVG_DIAMETER: 56.2, # not actual GASP value + 'cabin_height': 9.18333, # not actual GASP value + 'cabin_len': 435, # not actual GASP value + 'nose_height': 4.68333, # not actual GASP value + Aircraft.Fuselage.LENGTH: 476.7333, # not actual GASP value + Aircraft.Fuselage.WETTED_AREA: 13400.44, # not actual GASP value + Aircraft.TailBoom.LENGTH: 476.7333, # not actual GASP value + Aircraft.Wing.AREA: 1370.3125, # not actual GASP value + Aircraft.Wing.SPAN: 117.81878299, # not actual GASP value + Aircraft.Wing.CENTER_CHORD: 17.48974356, # not actual GASP value + Aircraft.Wing.AVERAGE_CHORD: 12.61453233, # not actual GASP value + Aircraft.Wing.ROOT_CHORD: 16.988, # not actual GASP value + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.14151, # not actual GASP value + 'strut_y': 0, # not actual GASP value + Aircraft.Strut.LENGTH: 5.2361, # not actual GASP value + Aircraft.Strut.CHORD: 2.8647, # not actual GASP value + Aircraft.HorizontalTail.AREA: 298.484, # not actual GASP value + Aircraft.HorizontalTail.SPAN: 37.654, # not actual GASP value + Aircraft.HorizontalTail.ROOT_CHORD: 11.7265, # not actual GASP value + Aircraft.HorizontalTail.AVERAGE_CHORD: 8.5341, # not actual GASP value + Aircraft.HorizontalTail.MOMENT_ARM: 54.67937726, # not actual GASP value + Aircraft.VerticalTail.AREA: 297.003, # not actual GASP value + Aircraft.VerticalTail.SPAN: 22.2709, # not actual GASP value + Aircraft.VerticalTail.ROOT_CHORD: 14.8094, # not actual GASP value + Aircraft.VerticalTail.AVERAGE_CHORD: 13.3902, # not actual GASP value + Aircraft.VerticalTail.MOMENT_ARM: 49.88094115, # not actual GASP value + Aircraft.Nacelle.AVG_DIAMETER: 7.35163168, # may not be actual GASP value + Aircraft.Nacelle.AVG_LENGTH: 14.70326336, # may not be actual GASP value + Aircraft.Nacelle.SURFACE_AREA: 339.58410134, # may not be actual GASP value + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=2e-12, rtol=1e-12) @@ -821,41 +670,40 @@ def test_case1(self): tol = 1e-4 # BWBFuselageGroup - assert_near_equal(self.prob[Aircraft.Fuselage.AVG_DIAMETER], 38, tol) - assert_near_equal(self.prob['cabin_height'], 9.86859989, tol) - # assert_near_equal(self.prob['fuselage.cabin_len'], 43.83334, tol) - assert_near_equal(self.prob['nose_height'], 4.86859989, tol) - assert_near_equal(self.prob[Aircraft.Fuselage.LENGTH], 71.5245514, tol) - assert_near_equal(self.prob[Aircraft.Fuselage.WETTED_AREA], 4573.42578, tol) - assert_near_equal(self.prob[Aircraft.TailBoom.LENGTH], 71.5245514, tol) - - # BWBWingGroup - assert_near_equal(self.prob[Aircraft.Wing.AREA], 2142.85714286, tol) - assert_near_equal(self.prob[Aircraft.Wing.SPAN], 146.38501094, tol) - assert_near_equal(self.prob[Aircraft.Wing.CENTER_CHORD], 22.97244452, tol) - assert_near_equal(self.prob[Aircraft.Wing.AVERAGE_CHORD], 16.2200522, tol) - assert_near_equal(self.prob[Aircraft.Wing.ROOT_CHORD], 20.33371617, tol) - assert_near_equal(self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.13596576, tol) - assert_near_equal(self.prob['wing_volume_no_fold'], 783.62100035, tol) - assert_near_equal(self.prob[Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX], 605.90781747, tol) - assert_near_equal(self.prob[Aircraft.Wing.EXPOSED_AREA], 1352.1135998, tol) - - # EmpennageSize - assert_near_equal(self.prob[Aircraft.HorizontalTail.AREA], 0.00117064, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.SPAN], 0.04467601, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.ROOT_CHORD], 0.03836448, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 0.02808445, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.MOMENT_ARM], 29.69074172, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.AREA], 169.11964286, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.SPAN], 16.98084188, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.ROOT_CHORD], 14.58190052, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 10.67457744, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MOMENT_ARM], 27.82191598, tol) - - # BWBEngineSizeGroup - assert_near_equal(self.prob[Aircraft.Nacelle.AVG_DIAMETER], 5.33382144, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.AVG_LENGTH], 7.24759657, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.SURFACE_AREA], 121.44575974, tol) + expected_values = { + Aircraft.Fuselage.AVG_DIAMETER: 38, + 'cabin_height': 9.86859989, + 'nose_height': 4.86859989, + Aircraft.Fuselage.LENGTH: 71.5245514, + Aircraft.Fuselage.WETTED_AREA: 4573.42578, + Aircraft.TailBoom.LENGTH: 71.5245514, + Aircraft.Wing.AREA: 2142.85714286, + Aircraft.Wing.SPAN: 146.38501094, + Aircraft.Wing.CENTER_CHORD: 22.97244452, + Aircraft.Wing.AVERAGE_CHORD: 16.2200522, + Aircraft.Wing.ROOT_CHORD: 20.33371617, + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.13596576, + 'wing_volume_no_fold': 783.62100035, + Aircraft.Fuel.WING_VOLUME_GEOMETRIC_MAX: 605.90781747, + Aircraft.Wing.EXPOSED_AREA: 1352.1135998, + Aircraft.HorizontalTail.AREA: 0.00117064, + Aircraft.HorizontalTail.SPAN: 0.04467601, + Aircraft.HorizontalTail.ROOT_CHORD: 0.03836448, + Aircraft.HorizontalTail.AVERAGE_CHORD: 0.02808445, + Aircraft.HorizontalTail.MOMENT_ARM: 29.69074172, + Aircraft.VerticalTail.AREA: 169.11964286, + Aircraft.VerticalTail.SPAN: 16.98084188, + Aircraft.VerticalTail.ROOT_CHORD: 14.58190052, + Aircraft.VerticalTail.AVERAGE_CHORD: 10.67457744, + Aircraft.VerticalTail.MOMENT_ARM: 27.82191598, + Aircraft.Nacelle.AVG_DIAMETER: 5.33382144, + Aircraft.Nacelle.AVG_LENGTH: 7.24759657, + Aircraft.Nacelle.SURFACE_AREA: 121.44575974, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=3e-9, rtol=3e-9) diff --git a/aviary/subsystems/mass/flops_based/test/test_air_conditioning.py b/aviary/subsystems/mass/flops_based/test/test_air_conditioning.py index 7200c7641..23daef151 100644 --- a/aviary/subsystems/mass/flops_based/test/test_air_conditioning.py +++ b/aviary/subsystems/mass/flops_based/test/test_air_conditioning.py @@ -40,6 +40,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -120,6 +121,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.AirConditioning.MASS_SCALER, @@ -190,6 +192,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_anti_icing.py b/aviary/subsystems/mass/flops_based/test/test_anti_icing.py index 7b7629c3e..adf79dc98 100644 --- a/aviary/subsystems/mass/flops_based/test/test_anti_icing.py +++ b/aviary/subsystems/mass/flops_based/test/test_anti_icing.py @@ -41,6 +41,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -203,6 +204,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_apu.py b/aviary/subsystems/mass/flops_based/test/test_apu.py index 47d1e31d9..45a4b4328 100644 --- a/aviary/subsystems/mass/flops_based/test/test_apu.py +++ b/aviary/subsystems/mass/flops_based/test/test_apu.py @@ -40,6 +40,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.APU.MASS_SCALER, Aircraft.Fuselage.PLANFORM_AREA], @@ -104,6 +105,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.APU.MASS_SCALER, Aircraft.Fuselage.PLANFORM_AREA], diff --git a/aviary/subsystems/mass/flops_based/test/test_avionics.py b/aviary/subsystems/mass/flops_based/test/test_avionics.py index d5e9d2907..9e693f609 100644 --- a/aviary/subsystems/mass/flops_based/test/test_avionics.py +++ b/aviary/subsystems/mass/flops_based/test/test_avionics.py @@ -42,6 +42,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -113,6 +114,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_canard.py b/aviary/subsystems/mass/flops_based/test/test_canard.py index 32a1527d3..557f4bc6c 100644 --- a/aviary/subsystems/mass/flops_based/test/test_canard.py +++ b/aviary/subsystems/mass/flops_based/test/test_canard.py @@ -46,6 +46,7 @@ def test_case1(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, diff --git a/aviary/subsystems/mass/flops_based/test/test_cargo_containers.py b/aviary/subsystems/mass/flops_based/test/test_cargo_containers.py index 7161b566a..c552f18e0 100644 --- a/aviary/subsystems/mass/flops_based/test/test_cargo_containers.py +++ b/aviary/subsystems/mass/flops_based/test/test_cargo_containers.py @@ -40,6 +40,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -111,6 +112,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_crew.py b/aviary/subsystems/mass/flops_based/test/test_crew.py index f656cea1e..3a1bc4853 100644 --- a/aviary/subsystems/mass/flops_based/test/test_crew.py +++ b/aviary/subsystems/mass/flops_based/test/test_crew.py @@ -39,6 +39,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.CrewPayload.CABIN_CREW_MASS_SCALER, @@ -71,6 +72,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.CrewPayload.FLIGHT_CREW_MASS_SCALER, @@ -105,6 +107,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.CrewPayload.CABIN_CREW_MASS_SCALER, @@ -137,6 +140,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.CrewPayload.FLIGHT_CREW_MASS_SCALER, diff --git a/aviary/subsystems/mass/flops_based/test/test_electrical.py b/aviary/subsystems/mass/flops_based/test/test_electrical.py index 5748dfebd..34ab2acde 100644 --- a/aviary/subsystems/mass/flops_based/test/test_electrical.py +++ b/aviary/subsystems/mass/flops_based/test/test_electrical.py @@ -46,6 +46,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ @@ -86,6 +87,7 @@ def test_case(self): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, 'AdvancedSingleAisle', input_keys=[ @@ -160,6 +162,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=Aircraft.Electrical.MASS_SCALER, @@ -200,6 +203,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_empty_margin.py b/aviary/subsystems/mass/flops_based/test/test_empty_margin.py index 9b1599867..799df33c8 100644 --- a/aviary/subsystems/mass/flops_based/test/test_empty_margin.py +++ b/aviary/subsystems/mass/flops_based/test/test_empty_margin.py @@ -39,6 +39,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -79,6 +80,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_engine.py b/aviary/subsystems/mass/flops_based/test/test_engine.py index fc6278d20..322d318e2 100644 --- a/aviary/subsystems/mass/flops_based/test/test_engine.py +++ b/aviary/subsystems/mass/flops_based/test/test_engine.py @@ -46,6 +46,7 @@ def test_case(self, case_name): prob.set_val(Aircraft.Engine.MASS_SCALER, val=np.zeros(1)) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -163,6 +164,7 @@ def test_case(self, case_name): prob.set_val(Aircraft.Engine.MASS_SCALER, val=np.ones(1)) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_engine_controls.py b/aviary/subsystems/mass/flops_based/test/test_engine_controls.py index ea705a065..5ba06bee0 100644 --- a/aviary/subsystems/mass/flops_based/test/test_engine_controls.py +++ b/aviary/subsystems/mass/flops_based/test/test_engine_controls.py @@ -43,6 +43,7 @@ def test_case(self, case_name): prob.setup(force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Propulsion.TOTAL_SCALED_SLS_THRUST], @@ -112,6 +113,7 @@ def test_case(self, case_name): prob.setup(force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Propulsion.TOTAL_SCALED_SLS_THRUST], diff --git a/aviary/subsystems/mass/flops_based/test/test_engine_oil.py b/aviary/subsystems/mass/flops_based/test/test_engine_oil.py index 961ac2262..9452556e7 100644 --- a/aviary/subsystems/mass/flops_based/test/test_engine_oil.py +++ b/aviary/subsystems/mass/flops_based/test/test_engine_oil.py @@ -46,6 +46,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -122,6 +123,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -194,6 +196,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_engine_pod.py b/aviary/subsystems/mass/flops_based/test/test_engine_pod.py index 07e3ac053..f1579d68d 100644 --- a/aviary/subsystems/mass/flops_based/test/test_engine_pod.py +++ b/aviary/subsystems/mass/flops_based/test/test_engine_pod.py @@ -55,6 +55,7 @@ def test_case(self, case_name): # Tol not that tight, but it is unclear where the pod mass values in files come from, # since they aren't printed in the FLOPS output. flops_validation_test( + self, prob, case_name, input_keys=[ @@ -136,6 +137,7 @@ def test_case(self, case_name): # Tol not that tight, but it is unclear where the pod mass values in files come from, # since they aren't printed in the FLOPS output. flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_fin.py b/aviary/subsystems/mass/flops_based/test/test_fin.py index 24d7af473..102d0d3ba 100644 --- a/aviary/subsystems/mass/flops_based/test/test_fin.py +++ b/aviary/subsystems/mass/flops_based/test/test_fin.py @@ -59,6 +59,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, @@ -133,6 +134,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_fuel_capacity.py b/aviary/subsystems/mass/flops_based/test/test_fuel_capacity.py index 08787edbd..80e6975f8 100644 --- a/aviary/subsystems/mass/flops_based/test/test_fuel_capacity.py +++ b/aviary/subsystems/mass/flops_based/test/test_fuel_capacity.py @@ -59,6 +59,7 @@ def configure(self): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -121,6 +122,7 @@ def test_derivs(self, case_name): prob.setup(force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, @@ -166,6 +168,7 @@ def test_basic(self, case_name): prob.setup(force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, @@ -204,6 +207,7 @@ def test_basic(self, case_name): prob.setup(force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, @@ -248,6 +252,7 @@ def test_basic(self, case_name): prob.setup(force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, diff --git a/aviary/subsystems/mass/flops_based/test/test_fuel_system.py b/aviary/subsystems/mass/flops_based/test/test_fuel_system.py index 12c3fb265..c62db1496 100644 --- a/aviary/subsystems/mass/flops_based/test/test_fuel_system.py +++ b/aviary/subsystems/mass/flops_based/test/test_fuel_system.py @@ -45,6 +45,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Fuel.FUEL_SYSTEM_MASS_SCALER, Aircraft.Fuel.TOTAL_CAPACITY], @@ -122,6 +123,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Fuel.FUEL_SYSTEM_MASS_SCALER, Aircraft.Fuel.TOTAL_CAPACITY], @@ -202,6 +204,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Fuel.FUEL_SYSTEM_MASS_SCALER, Aircraft.Fuel.TOTAL_CAPACITY], diff --git a/aviary/subsystems/mass/flops_based/test/test_furnishings.py b/aviary/subsystems/mass/flops_based/test/test_furnishings.py index af0e1f045..351583e2d 100644 --- a/aviary/subsystems/mass/flops_based/test/test_furnishings.py +++ b/aviary/subsystems/mass/flops_based/test/test_furnishings.py @@ -48,6 +48,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -86,6 +87,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -174,6 +176,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.Furnishings.MASS_SCALER, @@ -205,6 +208,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_fuselage.py b/aviary/subsystems/mass/flops_based/test/test_fuselage.py index 0d409f46f..d31e38f04 100644 --- a/aviary/subsystems/mass/flops_based/test/test_fuselage.py +++ b/aviary/subsystems/mass/flops_based/test/test_fuselage.py @@ -47,6 +47,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -114,6 +115,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -183,6 +185,7 @@ def test_case1(self, case_name): self.prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -221,6 +224,7 @@ def test_case1(self, case_name): self.prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_horizontail_tail.py b/aviary/subsystems/mass/flops_based/test/test_horizontail_tail.py index de43ab99e..11dd9f5d5 100644 --- a/aviary/subsystems/mass/flops_based/test/test_horizontail_tail.py +++ b/aviary/subsystems/mass/flops_based/test/test_horizontail_tail.py @@ -40,6 +40,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -105,6 +106,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.HorizontalTail.AREA, Aircraft.HorizontalTail.MASS_SCALER], @@ -165,6 +167,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_hydraulics.py b/aviary/subsystems/mass/flops_based/test/test_hydraulics.py index 9a31f34a3..ce356219a 100644 --- a/aviary/subsystems/mass/flops_based/test/test_hydraulics.py +++ b/aviary/subsystems/mass/flops_based/test/test_hydraulics.py @@ -55,6 +55,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -134,6 +135,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -212,6 +214,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_instruments.py b/aviary/subsystems/mass/flops_based/test/test_instruments.py index 6e4efd43e..42b1f5475 100644 --- a/aviary/subsystems/mass/flops_based/test/test_instruments.py +++ b/aviary/subsystems/mass/flops_based/test/test_instruments.py @@ -54,6 +54,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Fuselage.PLANFORM_AREA, Aircraft.Instruments.MASS_SCALER], @@ -149,6 +150,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Fuselage.PLANFORM_AREA, Aircraft.Instruments.MASS_SCALER], diff --git a/aviary/subsystems/mass/flops_based/test/test_landing_gear.py b/aviary/subsystems/mass/flops_based/test/test_landing_gear.py index dd585de09..5633de597 100644 --- a/aviary/subsystems/mass/flops_based/test/test_landing_gear.py +++ b/aviary/subsystems/mass/flops_based/test/test_landing_gear.py @@ -43,6 +43,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ @@ -108,6 +109,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ @@ -178,6 +180,7 @@ def test_derivs(self, case_name): prob.setup(force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -221,6 +224,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_landing_mass.py b/aviary/subsystems/mass/flops_based/test/test_landing_mass.py index 50446cc73..efbf572b1 100644 --- a/aviary/subsystems/mass/flops_based/test/test_landing_mass.py +++ b/aviary/subsystems/mass/flops_based/test/test_landing_mass.py @@ -30,6 +30,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Mission.Design.GROSS_MASS, Aircraft.Design.LANDING_TO_TAKEOFF_MASS_RATIO], @@ -58,6 +59,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Mission.Design.GROSS_MASS, Aircraft.Design.LANDING_TO_TAKEOFF_MASS_RATIO], diff --git a/aviary/subsystems/mass/flops_based/test/test_mass_summation.py b/aviary/subsystems/mass/flops_based/test/test_mass_summation.py index 7d52056e9..e3d4bfafc 100644 --- a/aviary/subsystems/mass/flops_based/test/test_mass_summation.py +++ b/aviary/subsystems/mass/flops_based/test/test_mass_summation.py @@ -53,6 +53,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -140,6 +141,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -272,6 +274,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_misc_engine.py b/aviary/subsystems/mass/flops_based/test/test_misc_engine.py index c9d727271..9fc1b9e7b 100644 --- a/aviary/subsystems/mass/flops_based/test/test_misc_engine.py +++ b/aviary/subsystems/mass/flops_based/test/test_misc_engine.py @@ -46,6 +46,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -129,6 +130,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_nacelle.py b/aviary/subsystems/mass/flops_based/test/test_nacelle.py index b9e940fb0..d4e3a0ad8 100644 --- a/aviary/subsystems/mass/flops_based/test/test_nacelle.py +++ b/aviary/subsystems/mass/flops_based/test/test_nacelle.py @@ -49,6 +49,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ @@ -202,6 +203,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_paint.py b/aviary/subsystems/mass/flops_based/test/test_paint.py index 93291f3d4..3e3f94ab4 100644 --- a/aviary/subsystems/mass/flops_based/test/test_paint.py +++ b/aviary/subsystems/mass/flops_based/test/test_paint.py @@ -36,6 +36,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Design.TOTAL_WETTED_AREA, Aircraft.Paint.MASS_PER_UNIT_AREA], @@ -67,6 +68,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Design.TOTAL_WETTED_AREA, Aircraft.Paint.MASS_PER_UNIT_AREA], diff --git a/aviary/subsystems/mass/flops_based/test/test_passenger_service.py b/aviary/subsystems/mass/flops_based/test/test_passenger_service.py index c33810609..2a5b2687b 100644 --- a/aviary/subsystems/mass/flops_based/test/test_passenger_service.py +++ b/aviary/subsystems/mass/flops_based/test/test_passenger_service.py @@ -43,6 +43,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.CrewPayload.PASSENGER_SERVICE_MASS_SCALER, Mission.Design.RANGE], @@ -107,6 +108,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=Aircraft.CrewPayload.PASSENGER_SERVICE_MASS_SCALER, @@ -172,6 +174,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.CrewPayload.PASSENGER_SERVICE_MASS_SCALER, Mission.Design.RANGE], diff --git a/aviary/subsystems/mass/flops_based/test/test_payload.py b/aviary/subsystems/mass/flops_based/test/test_payload.py index b07f51278..44d8e0848 100644 --- a/aviary/subsystems/mass/flops_based/test/test_payload.py +++ b/aviary/subsystems/mass/flops_based/test/test_payload.py @@ -60,6 +60,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) do_validation_test( + self, prob, input_validation_data=validation_data, output_validation_data=validation_data, @@ -99,6 +100,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.CrewPayload.MISC_CARGO, Aircraft.CrewPayload.WING_CARGO], diff --git a/aviary/subsystems/mass/flops_based/test/test_starter.py b/aviary/subsystems/mass/flops_based/test/test_starter.py index a7bd7f40f..9280e80be 100644 --- a/aviary/subsystems/mass/flops_based/test/test_starter.py +++ b/aviary/subsystems/mass/flops_based/test/test_starter.py @@ -45,6 +45,7 @@ def test_case_1(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Nacelle.AVG_DIAMETER, Aircraft.Engine.SCALE_FACTOR], @@ -159,6 +160,7 @@ def test_case_1(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Nacelle.AVG_DIAMETER, Aircraft.Engine.SCALE_FACTOR], diff --git a/aviary/subsystems/mass/flops_based/test/test_surface_controls.py b/aviary/subsystems/mass/flops_based/test/test_surface_controls.py index b941c054b..a940d7daa 100644 --- a/aviary/subsystems/mass/flops_based/test/test_surface_controls.py +++ b/aviary/subsystems/mass/flops_based/test/test_surface_controls.py @@ -38,6 +38,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -101,6 +102,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -167,6 +169,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_thrust_reverser.py b/aviary/subsystems/mass/flops_based/test/test_thrust_reverser.py index 5d81f3015..1b54f63c5 100644 --- a/aviary/subsystems/mass/flops_based/test/test_thrust_reverser.py +++ b/aviary/subsystems/mass/flops_based/test/test_thrust_reverser.py @@ -44,6 +44,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -170,6 +171,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_unusable_fuel.py b/aviary/subsystems/mass/flops_based/test/test_unusable_fuel.py index 449f44e62..c11dad885 100644 --- a/aviary/subsystems/mass/flops_based/test/test_unusable_fuel.py +++ b/aviary/subsystems/mass/flops_based/test/test_unusable_fuel.py @@ -45,6 +45,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -118,6 +119,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.Fuel.UNUSABLE_FUEL_MASS_SCALER, Aircraft.Fuel.TOTAL_CAPACITY], @@ -179,6 +181,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_vertical_tail.py b/aviary/subsystems/mass/flops_based/test/test_vertical_tail.py index a1a13b3cd..4ff9dd4ee 100644 --- a/aviary/subsystems/mass/flops_based/test/test_vertical_tail.py +++ b/aviary/subsystems/mass/flops_based/test/test_vertical_tail.py @@ -40,6 +40,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ @@ -107,6 +108,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[Aircraft.VerticalTail.AREA, Aircraft.VerticalTail.MASS_SCALER], @@ -172,6 +174,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_wing_common.py b/aviary/subsystems/mass/flops_based/test/test_wing_common.py index 64b4e5dfd..b627bab2c 100644 --- a/aviary/subsystems/mass/flops_based/test/test_wing_common.py +++ b/aviary/subsystems/mass/flops_based/test/test_wing_common.py @@ -42,6 +42,7 @@ def test_case(self, case_name): prob = self.prob flops_validation_test( + self, prob, case_name, input_keys=[ @@ -107,6 +108,7 @@ def test_case(self, case_name): prob = self.prob flops_validation_test( + self, prob, case_name, input_keys=[ @@ -175,6 +177,7 @@ def test_case(self, case_name): prob = self.prob flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_wing_detailed.py b/aviary/subsystems/mass/flops_based/test/test_wing_detailed.py index 340200710..e171644c3 100644 --- a/aviary/subsystems/mass/flops_based/test/test_wing_detailed.py +++ b/aviary/subsystems/mass/flops_based/test/test_wing_detailed.py @@ -65,6 +65,7 @@ def test_case(self, case_name): self.prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_wing_group.py b/aviary/subsystems/mass/flops_based/test/test_wing_group.py index 0a63f5038..1f7206cc9 100644 --- a/aviary/subsystems/mass/flops_based/test/test_wing_group.py +++ b/aviary/subsystems/mass/flops_based/test/test_wing_group.py @@ -56,6 +56,7 @@ def test_case(self): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, self.prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/flops_based/test/test_wing_simple.py b/aviary/subsystems/mass/flops_based/test/test_wing_simple.py index 36d022a62..3aa0e5635 100644 --- a/aviary/subsystems/mass/flops_based/test/test_wing_simple.py +++ b/aviary/subsystems/mass/flops_based/test/test_wing_simple.py @@ -47,6 +47,7 @@ def test_case(self, case_name): prob.setup(check=False, force_alloc_complex=True) flops_validation_test( + self, prob, case_name, input_keys=[ diff --git a/aviary/subsystems/mass/gasp_based/test/test_fixed.py b/aviary/subsystems/mass/gasp_based/test/test_fixed.py index 8e1a10d66..03d967490 100644 --- a/aviary/subsystems/mass/gasp_based/test/test_fixed.py +++ b/aviary/subsystems/mass/gasp_based/test/test_fixed.py @@ -64,14 +64,17 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2203729275531838, tol - ) # bug fixed value - assert_near_equal(self.prob['c_strut_braced'], 1, tol) # bug fixed value - assert_near_equal(self.prob['c_gear_loc'], 1, tol) # bug fixed value - # bug fixed value - assert_near_equal(self.prob[Aircraft.Engine.POSITION_FACTOR], 0.95, tol) - assert_near_equal(self.prob['half_sweep'], 0.3947081519145335, tol) # bug fixed value + expected_values = { + Aircraft.Wing.MATERIAL_FACTOR: 1.2203729275531838, # bug fixed value + 'c_strut_braced': 1, # bug fixed value + 'c_gear_loc': 1, # bug fixed value + Aircraft.Engine.POSITION_FACTOR: 0.95, # bug fixed value + 'half_sweep': 0.3947081519145335, # bug fixed value + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -109,14 +112,17 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2213063198183813, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['c_strut_braced'], 1, tol) - assert_near_equal(self.prob['c_gear_loc'], 0.95, tol) # not actual bug fixed value - # not actual bug fixed value - assert_near_equal(self.prob[Aircraft.Engine.POSITION_FACTOR], 1, tol) - assert_near_equal(self.prob['half_sweep'], 0.3947081519145335, tol) + expected_values = { + Aircraft.Wing.MATERIAL_FACTOR: 1.2213063198183813, # not actual bug fixed value + 'c_strut_braced': 1, + 'c_gear_loc': 0.95, # not actual bug fixed value + Aircraft.Engine.POSITION_FACTOR: 1, # not actual bug fixed value + 'half_sweep': 0.3947081519145335, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -155,15 +161,17 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2213063198183813, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['c_strut_braced'], 1, tol) - assert_near_equal(self.prob['c_gear_loc'], 0.95, tol) # not actual bug fixed value - assert_near_equal( - self.prob[Aircraft.Engine.POSITION_FACTOR], 0.98, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['half_sweep'], 0.3947081519145335, tol) + expected_values = { + Aircraft.Wing.MATERIAL_FACTOR: 1.2213063198183813, # not actual bug fixed value + 'c_strut_braced': 1, + 'c_gear_loc': 0.95, # not actual bug fixed value + Aircraft.Engine.POSITION_FACTOR: 0.98, # not actual bug fixed value + 'half_sweep': 0.3947081519145335, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -202,15 +210,17 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2213063198183813, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['c_strut_braced'], 1, tol) - assert_near_equal(self.prob['c_gear_loc'], 0.95, tol) # not actual bug fixed value - assert_near_equal( - self.prob[Aircraft.Engine.POSITION_FACTOR], 0.95, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['half_sweep'], 0.3947081519145335, tol) + expected_values = { + Aircraft.Wing.MATERIAL_FACTOR: 1.2213063198183813, # not actual bug fixed value + 'c_strut_braced': 1, + 'c_gear_loc': 0.95, # not actual bug fixed value + Aircraft.Engine.POSITION_FACTOR: 0.95, # not actual bug fixed value + 'half_sweep': 0.3947081519145335, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -249,15 +259,17 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2213063198183813, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['c_strut_braced'], 1, tol) - assert_near_equal(self.prob['c_gear_loc'], 0.95, tol) # not actual bug fixed value - assert_near_equal( - self.prob[Aircraft.Engine.POSITION_FACTOR], 0.9, tol - ) # not actual bug fixed value - assert_near_equal(self.prob['half_sweep'], 0.3947081519145335, tol) + expected_values = { + Aircraft.Wing.MATERIAL_FACTOR: 1.2213063198183813, # not actual bug fixed value + 'c_strut_braced': 1, + 'c_gear_loc': 0.95, # not actual bug fixed value + Aircraft.Engine.POSITION_FACTOR: 0.9, # not actual bug fixed value + 'half_sweep': 0.3947081519145335, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -289,15 +301,15 @@ def test_case1(self): self.prob.run_model() tol = 1e-4 - assert_near_equal( - self.prob[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS], 36000, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['payload_mass_des'], 36000, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['payload_mass_max'], 46040, tol - ) # bug fixed value and original value + expected_values = { + Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS: 36000, # bug fixed value and original value + 'payload_mass_des': 36000, # bug fixed value and original value + 'payload_mass_max': 46040, # bug fixed value and original value + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) @@ -367,12 +379,17 @@ def setUp(self): def test_case1(self): self.prob.run_model() - assert_near_equal( - self.prob['aug_mass'], 9394.3, 0.0017 - ) # electrified diff configuration value v3.6. Higher tol because num_wires is discrete in GASP and is not in Aviary + expected_values = { + 'aug_mass': 9394.3, # electrified diff configuration value v3.6. Higher tol because num_wires is discrete in GASP and is not in Aviary + } + tol = 0.0017 - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=4e-12, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=4e-12, rtol=1e-12) @use_tempdirs @@ -427,25 +444,21 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 12606.0, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 3785.0, + Aircraft.Engine.ADDITIONAL_MASS: 1765.0 / 2, + 'eng_comb_mass': 14370.8, + 'wing_mounted_mass': 24446.343040697346, + } tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 12606.0, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 3785.0, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Engine.ADDITIONAL_MASS], 1765.0 / 2, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['eng_comb_mass'], 14370.8, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['wing_mounted_mass'], 24446.343040697346, tol - ) # bug fixed value and original value - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=2e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=2e-11, rtol=1e-12) @use_tempdirs @@ -506,28 +519,22 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 12606.0, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 3785.0, + Aircraft.Engine.ADDITIONAL_MASS: 1765.0 / 2, + 'eng_comb_mass': 14370.8, + 'prop_mass_all': 0, + 'wing_mounted_mass': 24446.343040697346, + } tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 12606.0, tol - ) # note: these are only the right values because this was given a prop mass of zero. This is not a large single aisle test case - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 3785.0, tol - ) # note: these are only the right values because this was given a prop mass of zero. This is not a large single aisle test case - assert_near_equal( - self.prob[Aircraft.Engine.ADDITIONAL_MASS], 1765.0 / 2, tol - ) # note: these are only the right values because this was given a prop mass of zero. This is not a large single aisle test case - assert_near_equal( - self.prob['eng_comb_mass'], 14370.8, tol - ) # note: these are only the right values because this was given a prop mass of zero. This is not a large single aisle test case - assert_near_equal( - self.prob['prop_mass_all'], 0, tol - ) # note: these are only the right values because this was given a prop mass of zero. This is not a large single aisle test case - assert_near_equal( - self.prob['wing_mounted_mass'], 24446.343040697346, tol - ) # note: these are only the right values because this was given a prop mass of zero. This is not a large single aisle test case - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=2e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=2e-11, rtol=1e-12) # arbitrary test case with multiple engine types @@ -586,24 +593,20 @@ def test_case_1(self): self.prob.run_model() tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 23405.94, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 8074.09809932, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Engine.ADDITIONAL_MASS], [882.4158, 513.0], tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['eng_comb_mass'], 26142.7716, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['wing_mounted_mass'], 41417.49593562, tol - ) # bug fixed value and original value + expected_values = { + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 23405.94, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 8074.09809932, + Aircraft.Engine.ADDITIONAL_MASS: [882.4158, 513.0], + 'eng_comb_mass': 26142.7716, + 'wing_mounted_mass': 41417.49593562, + } - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-8, rtol=1e-8) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-8, rtol=1e-8) @use_tempdirs @@ -684,14 +687,19 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + 'loc_MAC_vtail': 0.44959578484694906, + Aircraft.HorizontalTail.MASS: 2285, + Aircraft.VerticalTail.MASS: 2312, + } tol = 5e-4 - assert_near_equal(self.prob['loc_MAC_vtail'], 0.44959578484694906, tol) # bug fixed value - # bug fixed value - assert_near_equal(self.prob[Aircraft.HorizontalTail.MASS], 2285, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MASS], 2312, tol) # bug fixed value - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-11, rtol=1e-12) # this is a different configuration with turbofan_23k_1 test case @@ -740,14 +748,17 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Wing.HIGH_LIFT_MASS: 4829.6, + } tol = 5e-4 - # bug fixed value - assert_near_equal(self.prob[Aircraft.Wing.HIGH_LIFT_MASS], 4829.6, tol) - partial_data = self.prob.check_partials( - out_stream=None, method='cs', show_only_incorrect=True - ) - assert_check_partials(partial_data, atol=5e-10, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs', show_only_incorrect=True) + assert_check_partials(data, atol=5e-10, rtol=1e-12) # this is the large single aisle 1 V3 test case @@ -796,12 +807,17 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Controls.MASS: 3945, + } tol = 5e-4 - # bug fixed value - assert_near_equal(self.prob[Aircraft.Controls.MASS], 3945, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-11, rtol=1e-12) @use_tempdirs @@ -838,16 +854,18 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.LandingGear.TOTAL_MASS: 7511, + Aircraft.LandingGear.MAIN_GEAR_MASS: 6384.35, + } tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.LandingGear.TOTAL_MASS], 7511, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 6384.35, tol - ) # bug fixed value and original value - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=3e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=3e-11, rtol=1e-12) @use_tempdirs @@ -877,16 +895,18 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.LandingGear.TOTAL_MASS: 7016, + Aircraft.LandingGear.MAIN_GEAR_MASS: 5963.6, + } tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.LandingGear.TOTAL_MASS], 7016, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 5963.6, tol - ) # not actual GASP value - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-12, rtol=1e-12) @use_tempdirs @@ -922,12 +942,16 @@ def test_case1(self): self.prob.run_model() tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 5614.3311546, tol - ) # bug fixed value and original value + expected_values = { + Aircraft.LandingGear.MAIN_GEAR_MASS: 5614.3311546, + } - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-10, rtol=1e-10) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-10, rtol=1e-10) # this is the large single aisle 1 V3 test case @@ -1123,65 +1147,36 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.LandingGear.MAIN_GEAR_MASS: 6384.35, + Aircraft.Wing.MATERIAL_FACTOR: 1.2203729275531838, + 'c_strut_braced': 1, + 'c_gear_loc': 1, + Aircraft.Engine.POSITION_FACTOR: 0.95, + 'half_sweep': 0.3947081519145335, + Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS: 36000, + 'payload_mass_des': 36000, + 'payload_mass_max': 46040, + 'loc_MAC_vtail': 0.44959578484694906, + Aircraft.HorizontalTail.MASS: 2285, + Aircraft.VerticalTail.MASS: 2312, + Aircraft.Wing.HIGH_LIFT_MASS: 4082.1, + Aircraft.Controls.MASS: 3945, + Aircraft.LandingGear.TOTAL_MASS: 7511, + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 12606, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 3785, + Aircraft.Engine.ADDITIONAL_MASS: 1765 / 2, + 'eng_comb_mass': 14370.8, + 'wing_mounted_mass': 24446.343040697346, + } tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 6384.35, tol - ) # bug fixed value and original value - - assert_near_equal( - self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2203729275531838, tol - ) # bug fixed value - assert_near_equal(self.prob['c_strut_braced'], 1, tol) # bug fixed value and original value - assert_near_equal(self.prob['c_gear_loc'], 1, tol) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Engine.POSITION_FACTOR], 0.95, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['half_sweep'], 0.3947081519145335, tol - ) # bug fixed value and original value - - assert_near_equal( - self.prob[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS], 36000, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['payload_mass_des'], 36000, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['payload_mass_max'], 46040, tol - ) # bug fixed value and original value - - assert_near_equal(self.prob['loc_MAC_vtail'], 0.44959578484694906, tol) # bug fixed value - # bug fixed value - assert_near_equal(self.prob[Aircraft.HorizontalTail.MASS], 2285, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MASS], 2312, tol) # bug fixed value - # bug fixed value - assert_near_equal(self.prob[Aircraft.Wing.HIGH_LIFT_MASS], 4082.1, tol) - # bug fixed value - assert_near_equal(self.prob[Aircraft.Controls.MASS], 3945, tol) - - assert_near_equal( - self.prob[Aircraft.LandingGear.TOTAL_MASS], 7511, tol - ) # bug fixed value and original value + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 12606, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 3785, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob[Aircraft.Engine.ADDITIONAL_MASS], 1765 / 2, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['eng_comb_mass'], 14370.8, tol - ) # bug fixed value and original value - assert_near_equal( - self.prob['wing_mounted_mass'], 24446.343040697346, tol - ) # bug fixed value and original value - - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=3e-11, rtol=1e-12) + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=3e-11, rtol=1e-12) @use_tempdirs @@ -1432,60 +1427,42 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.LandingGear.MAIN_GEAR_MASS: 5963.6, + 'aug_mass': 228.51036478, + Aircraft.Wing.MATERIAL_FACTOR: 1.2213063198183813, + 'c_strut_braced': 0.9928, + 'c_gear_loc': 1, + Aircraft.Engine.POSITION_FACTOR: 1, + 'half_sweep': 0.3947081519145335, + Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS: 36000, + 'payload_mass_des': 36000, + 'payload_mass_max': 46040, + 'loc_MAC_vtail': 1.799, + Aircraft.HorizontalTail.MASS: 2275, + Aircraft.VerticalTail.MASS: 2297, + Aircraft.Wing.HIGH_LIFT_MASS: 4162.1, + Aircraft.Controls.MASS: 3895, + Aircraft.LandingGear.TOTAL_MASS: 7016, + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 12606, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 3785, + Aircraft.Engine.ADDITIONAL_MASS: 1765 / 2, + 'eng_comb_mass': 14599.28196478, + 'wing_mounted_mass': 24027.6, + 'prop_mass_all': 0, + } tol = 5e-4 - assert_near_equal( - self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 5963.6, tol - ) # not actual GASP value - assert_near_equal(self.prob['aug_mass'], 228.51036478, tol) # not actual GASP value - - assert_near_equal(self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.2213063198183813, tol) - assert_near_equal(self.prob['c_strut_braced'], 0.9928, tol) # not actual GASP value - assert_near_equal(self.prob['c_gear_loc'], 1, tol) # not actual GASP value - # not actual GASP value - assert_near_equal(self.prob[Aircraft.Engine.POSITION_FACTOR], 1, tol) - assert_near_equal( - self.prob['half_sweep'], 0.3947081519145335, tol - ) # bug fixed and original value - - assert_near_equal( - self.prob[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS], 36000, tol - ) # bug fixed and original value - assert_near_equal(self.prob['payload_mass_des'], 36000, tol) # bug fixed and original value - assert_near_equal(self.prob['payload_mass_max'], 46040, tol) # bug fixed and original value - - assert_near_equal(self.prob['loc_MAC_vtail'], 1.799, tol) # not actual GASP value - # original GASP value - assert_near_equal(self.prob[Aircraft.HorizontalTail.MASS], 2275, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MASS], 2297, tol) # original GASP value - # original GASP value - assert_near_equal(self.prob[Aircraft.Wing.HIGH_LIFT_MASS], 4162.1, tol) - - # original GASP value - assert_near_equal(self.prob[Aircraft.Controls.MASS], 3895, tol) - - assert_near_equal( - self.prob[Aircraft.LandingGear.TOTAL_MASS], 7016, tol - ) # not actual GASP value - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 12606, tol - ) # bug fixed and original value - assert_near_equal( - self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 3785, tol - ) # bug fixed and original value - assert_near_equal( - self.prob[Aircraft.Engine.ADDITIONAL_MASS], 1765 / 2, tol - ) # bug fixed and original value - assert_near_equal(self.prob['eng_comb_mass'], 14599.28196478, tol) # not actual GASP value - assert_near_equal(self.prob['wing_mounted_mass'], 24027.6, tol) # not actual GASP value - assert_near_equal(self.prob['prop_mass_all'], 0, tol) # bug fixed and original value - - partial_data = self.prob.check_partials( + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials( out_stream=None, method='cs', form='central', ) - assert_check_partials(partial_data, atol=3e-10, rtol=1e-12) + assert_check_partials(data, atol=3e-10, rtol=1e-12) @use_tempdirs @@ -1679,15 +1656,21 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Wing.MATERIAL_FACTOR: 1.19461189, + 'c_strut_braced': 1, + 'c_gear_loc': 0.95, + Aircraft.Engine.POSITION_FACTOR: 1.05, + 'half_sweep': 0.47984874, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.19461189, tol) - assert_near_equal(self.prob['c_strut_braced'], 1, tol) - assert_near_equal(self.prob['c_gear_loc'], 0.95, tol) - assert_near_equal(self.prob[Aircraft.Engine.POSITION_FACTOR], 1.05, tol) - assert_near_equal(self.prob['half_sweep'], 0.47984874, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-12, rtol=1e-12) class BWBPayloadGroupTestCase(unittest.TestCase): @@ -1713,14 +1696,20 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS: 33750.0, + Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS: 33750.0, + 'payload_mass_des': 33750.0, + 'payload_mass_max': 48750.0, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS], 33750.0, tol) - assert_near_equal(self.prob[Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS], 33750.0, tol) - assert_near_equal(self.prob['payload_mass_des'], 33750.0, tol) - assert_near_equal(self.prob['payload_mass_max'], 48750.0, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-12, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-12, rtol=1e-12) class BWBEngineTestCase(unittest.TestCase): @@ -1758,17 +1747,23 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 7005.15475443, + Aircraft.Nacelle.MASS: 487.39296691, + 'pylon_mass': 558.757916785, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 2092.30176475, + Aircraft.Engine.ADDITIONAL_MASS: 153.16770871, + 'eng_comb_mass': 7311.49017184, + 'wing_mounted_mass': 0, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 7005.15475443, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.MASS], 487.39296691, tol) - assert_near_equal(self.prob['pylon_mass'], 558.757916785, tol) - assert_near_equal(self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 2092.30176475, tol) - assert_near_equal(self.prob[Aircraft.Engine.ADDITIONAL_MASS], 153.16770871, tol) - assert_near_equal(self.prob['eng_comb_mass'], 7311.49017184, tol) - assert_near_equal(self.prob['wing_mounted_mass'], 0, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=2e-9, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=2e-9, rtol=1e-12) class BWBTailTestCase(unittest.TestCase): @@ -1818,13 +1813,19 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + 'loc_MAC_vtail': 0.97683077, + Aircraft.HorizontalTail.MASS: 1.02401953, + Aircraft.VerticalTail.MASS: 864.17404177, + } tol = 1e-7 - assert_near_equal(self.prob['loc_MAC_vtail'], 0.97683077, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.MASS], 1.02401953, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MASS], 864.17404177, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-11, rtol=1e-12) class BWBHighLiftTestCase(unittest.TestCase): @@ -1864,16 +1865,19 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Wing.HIGH_LIFT_MASS: 1068.88854499, + 'flap_mass': 1068.46572125, + 'slat_mass': 0.42282374, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.Wing.HIGH_LIFT_MASS], 1068.88854499, tol) - assert_near_equal(self.prob['flap_mass'], 1068.46572125, tol) # WFLAP = 997.949249689 - assert_near_equal(self.prob['slat_mass'], 0.42282374, tol) # WLED + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) - partial_data = self.prob.check_partials( - out_stream=None, method='cs', show_only_incorrect=True - ) - assert_check_partials(partial_data, atol=5e-10, rtol=1e-12) + data = self.prob.check_partials(out_stream=None, method='cs', show_only_incorrect=True) + assert_check_partials(data, atol=5e-10, rtol=1e-12) @use_tempdirs @@ -1915,12 +1919,18 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.Wing.SURFACE_CONTROL_MASS: 2045.5556421, + Aircraft.Controls.MASS: 2174.28611375, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.Wing.SURFACE_CONTROL_MASS], 2045.5556421, tol) - assert_near_equal(self.prob[Aircraft.Controls.MASS], 2174.28611375, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=1e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=1e-11, rtol=1e-12) class BWBGearTestCase(unittest.TestCase): @@ -1952,12 +1962,18 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.LandingGear.TOTAL_MASS: 7800.0, + Aircraft.LandingGear.MAIN_GEAR_MASS: 6630.0, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.LandingGear.TOTAL_MASS], 7800.0, tol) - assert_near_equal(self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 6630.0, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=3e-11, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=3e-11, rtol=1e-12) class BWBFixedMassGroupTestCase1(unittest.TestCase): @@ -2086,33 +2102,39 @@ def setUp(self): def test_case1(self): self.prob.run_model() + expected_values = { + Aircraft.LandingGear.TOTAL_MASS: 7800.0, + Aircraft.LandingGear.MAIN_GEAR_MASS: 6630.0, + Aircraft.Wing.MATERIAL_FACTOR: 1.19461189, + 'c_strut_braced': 1, + 'c_gear_loc': 0.95, + Aircraft.Engine.POSITION_FACTOR: 0.95, + 'half_sweep': 0.47984874, + Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS: 33750.0, + 'payload_mass_des': 33750, + 'payload_mass_max': 48750, + 'loc_MAC_vtail': 0.97683077, + Aircraft.HorizontalTail.MASS: 1.02401953, + Aircraft.VerticalTail.MASS: 864.17404177, + Aircraft.Wing.HIGH_LIFT_MASS: 1068.88854499, + Aircraft.Controls.MASS: 2114.98158947, + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 7005.15475443, + Aircraft.Nacelle.MASS: 549.8807447, + Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS: 2230.13208284, + Aircraft.Engine.ADDITIONAL_MASS: 153.16770871, + 'pylon_mass': 565.18529673, + 'eng_comb_mass': 7311.49017184, + 'wing_mounted_mass': 0.0, + Aircraft.Wing.SURFACE_CONTROL_MASS: 1986.25111783, + } tol = 1e-7 - assert_near_equal(self.prob[Aircraft.LandingGear.TOTAL_MASS], 7800.0, tol) - assert_near_equal(self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 6630.0, tol) - assert_near_equal(self.prob[Aircraft.Wing.MATERIAL_FACTOR], 1.19461189, tol) - assert_near_equal(self.prob['c_strut_braced'], 1, tol) - assert_near_equal(self.prob['c_gear_loc'], 0.95, tol) - assert_near_equal(self.prob[Aircraft.Engine.POSITION_FACTOR], 0.95, tol) - assert_near_equal(self.prob['half_sweep'], 0.47984874, tol) - assert_near_equal(self.prob[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS], 33750.0, tol) - assert_near_equal(self.prob['payload_mass_des'], 33750, tol) - assert_near_equal(self.prob['payload_mass_max'], 48750, tol) - assert_near_equal(self.prob['loc_MAC_vtail'], 0.97683077, tol) - assert_near_equal(self.prob[Aircraft.HorizontalTail.MASS], 1.02401953, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.MASS], 864.17404177, tol) - assert_near_equal(self.prob[Aircraft.Wing.HIGH_LIFT_MASS], 1068.88854499, tol) - assert_near_equal(self.prob[Aircraft.Controls.MASS], 2114.98158947, tol) - assert_near_equal(self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 7005.15475443, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.MASS], 549.8807447, tol) - assert_near_equal(self.prob[Aircraft.Propulsion.TOTAL_ENGINE_POD_MASS], 2230.13208284, tol) - assert_near_equal(self.prob[Aircraft.Engine.ADDITIONAL_MASS], 153.16770871, tol) - assert_near_equal(self.prob['pylon_mass'], 565.18529673, tol) - assert_near_equal(self.prob['eng_comb_mass'], 7311.49017184, tol) - assert_near_equal(self.prob['wing_mounted_mass'], 0.0, tol) - assert_near_equal(self.prob[Aircraft.Wing.SURFACE_CONTROL_MASS], 1986.25111783, tol) - partial_data = self.prob.check_partials(out_stream=None, method='cs') - assert_check_partials(partial_data, atol=2e-9, rtol=1e-12) + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) + + data = self.prob.check_partials(out_stream=None, method='cs') + assert_check_partials(data, atol=2e-9, rtol=1e-12) if __name__ == '__main__': diff --git a/aviary/subsystems/mass/gasp_based/test/test_mass_summation.py b/aviary/subsystems/mass/gasp_based/test/test_mass_summation.py index 1e8d43955..e19473d7d 100644 --- a/aviary/subsystems/mass/gasp_based/test/test_mass_summation.py +++ b/aviary/subsystems/mass/gasp_based/test/test_mass_summation.py @@ -69,78 +69,43 @@ def test_case1(self): # print(f'wetted_area: {self.prob[Aircraft.Fuselage.WETTED_AREA]}') tol = 5e-4 - # size values: - assert_near_equal(self.prob['gasp_based_geom.cabin_height'], 13.1, tol) - assert_near_equal(self.prob['gasp_based_geom.cabin_len'], 72.09722222222223, tol) - assert_near_equal(self.prob['gasp_based_geom.nose_height'], 8.6, tol) - - assert_near_equal(self.prob[Aircraft.Wing.CENTER_CHORD], 17.63, tol) - assert_near_equal(self.prob[Aircraft.Wing.ROOT_CHORD], 16.54, tol) - assert_near_equal( - self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.1397, tol - ) # not exact GASP value from the output file, likely due to rounding error - - assert_near_equal(self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 9.6509873673743, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 16.96457870166355, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.AVG_LENGTH], 14.7, tol) - - # fixed mass values: - assert_near_equal(self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 6384.35, tol) - assert_near_equal(self.prob['loc_MAC_vtail'], 0.44959578484694906, tol) - - # wing values: - assert_near_equal(self.prob['isolated_wing_mass'], 15758, tol) - assert_near_equal(self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 12606, tol) - assert_near_equal(self.prob[Aircraft.Engine.ADDITIONAL_MASS], 1765 / 2, tol) - - # fuel values: - # modified from GASP value to account for updated crew mass. GASP value is - # 78843.6 - assert_near_equal(self.prob['OEM_wingfuel_mass'], 79500.16001078, tol) - # modified from GASP value to account for updated crew mass. GASP value is - # 102408.05695930264 - assert_near_equal(self.prob['fus_mass_full'], 101735.01012115, tol) - # modified from GASP value to account for updated crew mass. GASP value is - # 1757 - assert_near_equal( - self.prob[Aircraft.Fuel.FUEL_SYSTEM_MASS], 1783.50656044, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 1757 - assert_near_equal(self.prob[Aircraft.Design.STRUCTURE_MASS], 50266.438, tol) - assert_near_equal( - self.prob[Aircraft.Fuselage.MASS], 18624.42144949, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 18814 - - # modified from GASP value to account for updated crew mass. GASP value is - # 42843.6 - assert_near_equal( - self.prob[Mission.Summary.FUEL_MASS_REQUIRED], 43500.16001078, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 42843.6 - assert_near_equal( - self.prob[Aircraft.Propulsion.MASS], 16161.21, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 16127 - assert_near_equal( - self.prob[Mission.Summary.FUEL_MASS], 43500.16001078, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 42844.0 - assert_near_equal( - self.prob['fuel_mass_min'], 33460.16001078, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 32803.6 - assert_near_equal( - self.prob[Aircraft.Fuel.WING_VOLUME_DESIGN], 869.61632311, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 856.4910800459031 - assert_near_equal( - self.prob['OEM_fuel_vol'], 1589.29615013, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 1576.1710061411081 - assert_near_equal( - self.prob[Mission.Summary.OPERATING_MASS], 95899.83998922, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 96556.0 - # extra_fuel_mass calculated differently in this version, so test for payload_mass_max_fuel not included - assert_near_equal(self.prob['volume_wingfuel_mass'], 57066.3, tol) - assert_near_equal(self.prob['max_wingfuel_mass'], 57066.3, tol) - assert_near_equal( - self.prob[Aircraft.Fuel.AUXILIARY_FUEL_CAPACITY], 0, tol - ) # always zero when no body tank - assert_near_equal(self.prob['extra_fuel_volume'], 0, tol) # always zero when no body tank - assert_near_equal(self.prob['max_extra_fuel_mass'], 0, tol) # always zero when no body tank + expected_values = { + 'gasp_based_geom.cabin_height': 13.1, + 'gasp_based_geom.cabin_len': 72.09722222222223, + 'gasp_based_geom.nose_height': 8.6, + Aircraft.Wing.CENTER_CHORD: 17.63, + Aircraft.Wing.ROOT_CHORD: 16.54, + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.1397, # not exact GASP value from the output file, likely due to rounding error + Aircraft.HorizontalTail.AVERAGE_CHORD: 9.6509873673743, + Aircraft.VerticalTail.AVERAGE_CHORD: 16.96457870166355, + Aircraft.Nacelle.AVG_LENGTH: 14.7, + Aircraft.LandingGear.MAIN_GEAR_MASS: 6384.35, + 'loc_MAC_vtail': 0.44959578484694906, + 'isolated_wing_mass': 15758, + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 12606, + Aircraft.Engine.ADDITIONAL_MASS: 1765 / 2, + 'OEM_wingfuel_mass': 79500.16001078, # modified from GASP value to account for updated crew mass. GASP value is 78843.6 + 'fus_mass_full': 101735.01012115, # modified from GASP value to account for updated crew mass. GASP value is 102408.05695930264 + Aircraft.Fuel.FUEL_SYSTEM_MASS: 1783.50656044, # modified from GASP value to account for updated crew mass. GASP value is 1757 + Aircraft.Design.STRUCTURE_MASS: 50266.438, + Aircraft.Fuselage.MASS: 18624.42144949, # modified from GASP value to account for updated crew mass. GASP value is 18814 + Mission.Summary.FUEL_MASS_REQUIRED: 43500.16001078, # modified from GASP value to account for updated crew mass. GASP value is 42843.6 + Aircraft.Propulsion.MASS: 16161.21, # modified from GASP value to account for updated crew mass. GASP value is 16127 + Mission.Summary.FUEL_MASS: 43500.16001078, # modified from GASP value to account for updated crew mass. GASP value is 42844.0 + 'fuel_mass_min': 33460.16001078, # modified from GASP value to account for updated crew mass. GASP value is 32803.6 + Aircraft.Fuel.WING_VOLUME_DESIGN: 869.61632311, # modified from GASP value to account for updated crew mass. GASP value is 856.4910800459031 + 'OEM_fuel_vol': 1589.29615013, # modified from GASP value to account for updated crew mass. GASP value is 1576.1710061411081 + Mission.Summary.OPERATING_MASS: 95899.83998922, # modified from GASP value to account for updated crew mass. GASP value is 96556.0 + 'volume_wingfuel_mass': 57066.3, # extra_fuel_mass calculated differently in this version, so test for payload_mass_max_fuel not included + 'max_wingfuel_mass': 57066.3, + Aircraft.Fuel.AUXILIARY_FUEL_CAPACITY: 0, # always zero when no body tank + 'extra_fuel_volume': 0, # always zero when no body tank + 'max_extra_fuel_mass': 0, # always zero when no body tank + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=3e-10, rtol=1e-12) diff --git a/aviary/subsystems/propulsion/propeller/test/test_propeller_performance.py b/aviary/subsystems/propulsion/propeller/test/test_propeller_performance.py index 82920c0d0..b0d9f6936 100644 --- a/aviary/subsystems/propulsion/propeller/test/test_propeller_performance.py +++ b/aviary/subsystems/propulsion/propeller/test/test_propeller_performance.py @@ -258,13 +258,18 @@ def compare_results(self, case_idx_begin, case_idx_end): for case_idx in range(case_idx_begin, case_idx_end): idx = case_idx - case_idx_begin - assert_near_equal(cthr[idx], CT[case_idx], tolerance=tol) - assert_near_equal(ctlf[idx], XFT[case_idx], tolerance=tol) - assert_near_equal(tccl[idx], CTX[case_idx], tolerance=tol) - assert_near_equal(thrt[idx], thrust[case_idx], tolerance=tol) - assert_near_equal(peff[idx], prop_eff[case_idx], tolerance=tol) - assert_near_equal(lfac[idx], install_loss[case_idx], tolerance=tol) - assert_near_equal(ieff[idx], install_eff[case_idx], tolerance=tol) + expected_values = { + 'thrust_coefficient': (cthr[idx], CT[case_idx]), + 'comp_tip_loss_factor': (ctlf[idx], XFT[case_idx]), + 'thrust_coefficient_comp_loss': (tccl[idx], CTX[case_idx]), + 'thrust': (thrt[idx], thrust[case_idx]), + 'propeller_efficiency': (peff[idx], prop_eff[case_idx]), + 'install_loss_factor': (lfac[idx], install_loss[case_idx]), + 'install_efficiency': (ieff[idx], install_eff[case_idx]), + } + for var_name, (actual, expected) in expected_values.items(): + with self.subTest(case_idx=case_idx, var=var_name): + assert_near_equal(actual, expected, tolerance=tol) def test_case_0_1_2(self): # Case 0, 1, 2, to test installation loss factor computation. diff --git a/aviary/subsystems/test/test_flops_based_premission.py b/aviary/subsystems/test/test_flops_based_premission.py index 2ef158f33..b741cf6fc 100644 --- a/aviary/subsystems/test/test_flops_based_premission.py +++ b/aviary/subsystems/test/test_flops_based_premission.py @@ -88,6 +88,7 @@ def test_case(self, case_name): ) flops_validation_test( + self, prob, case_name, input_keys=[], @@ -133,6 +134,7 @@ def test_diff_configuration_mass(self): set_aviary_initial_values(prob, flops_inputs) flops_validation_test( + self, prob, 'LargeSingleAisle2FLOPS', input_keys=[], @@ -178,6 +180,7 @@ def test_mass_aero_only(self): prob.run_model() flops_validation_test( + self, prob, 'LargeSingleAisle2FLOPS', input_keys=[], @@ -258,6 +261,7 @@ def test_case_all_subsystems(self, case_name): set_aviary_initial_values(prob, flops_inputs) flops_validation_test( + self, prob, case_name, input_keys=[], @@ -446,6 +450,7 @@ def test_case_geom(self): set_aviary_initial_values(prob, flops_inputs) flops_validation_test( + self, prob, case_name, input_keys=[], diff --git a/aviary/subsystems/test/test_premission.py b/aviary/subsystems/test/test_premission.py index 129fbc78d..0c9262431 100644 --- a/aviary/subsystems/test/test_premission.py +++ b/aviary/subsystems/test/test_premission.py @@ -135,76 +135,42 @@ def test_GASP_mass_FLOPS_everything_else(self): # Check the outputs from GASP mass and geometry (FLOPS outputs are not tested) tol = 5e-4 - # size values: - assert_near_equal(self.prob['gasp_based_geom.cabin_height'], 13.1, tol) - assert_near_equal(self.prob['gasp_based_geom.cabin_len'], 72.09722222222223, tol) - assert_near_equal(self.prob['gasp_based_geom.nose_height'], 8.6, tol) - - assert_near_equal(self.prob[Aircraft.Wing.CENTER_CHORD], 17.63, tol) - assert_near_equal(self.prob[Aircraft.Wing.ROOT_CHORD], 16.54, tol) - assert_near_equal( - self.prob[Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED], 0.1397, tol - ) # not exact GASP value from the output file, likely due to rounding error - - assert_near_equal(self.prob[Aircraft.HorizontalTail.AVERAGE_CHORD], 9.6509873673743, tol) - assert_near_equal(self.prob[Aircraft.VerticalTail.AVERAGE_CHORD], 16.96457870166355, tol) - assert_near_equal(self.prob[Aircraft.Nacelle.AVG_LENGTH], 14.7, tol) - - # fixed mass values: - assert_near_equal(self.prob[Aircraft.LandingGear.MAIN_GEAR_MASS], 6384.35, tol) - assert_near_equal(self.prob['loc_MAC_vtail'], 0.44959578484694906, tol) - - # wing values: - assert_near_equal(self.prob['isolated_wing_mass'], 16205, tol) - assert_near_equal(self.prob[Aircraft.Propulsion.TOTAL_ENGINE_MASS], 12606, tol) - assert_near_equal(self.prob[Aircraft.Engine.ADDITIONAL_MASS], 1765 / 2, tol) - - # fuel values: - # modified from GASP value to account for updated crew mass. GASP value is - # 78843.6 - assert_near_equal(self.prob['OEM_wingfuel_mass'], 77977.7, tol) - # modified from GASP value to account for updated crew mass. GASP value is - # 102408.05695930264 - assert_near_equal(self.prob['fus_mass_full'], 102812.6654177, tol) - # modified from GASP value to account for updated crew mass. GASP value is - # 1757 - assert_near_equal( - self.prob[Aircraft.Fuel.FUEL_SYSTEM_MASS], 1721.08, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 1757 - assert_near_equal(self.prob[Aircraft.Design.STRUCTURE_MASS], 50931.4, tol) - assert_near_equal( - self.prob[Aircraft.Fuselage.MASS], 18833.76678366, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 18814 - - # modified from GASP value to account for updated crew mass. GASP value is - # 42843.6 - assert_near_equal( - self.prob[Mission.Summary.FUEL_MASS_REQUIRED], 41977.7, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 42843.6 - assert_near_equal( - self.prob[Aircraft.Propulsion.MASS], 16098.7, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 16127 - assert_near_equal( - self.prob[Mission.Summary.FUEL_MASS], 41977.68, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 42844.0 - assert_near_equal( - self.prob['fuel_mass_min'], 31937.68, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 32803.6 - assert_near_equal( - self.prob[Aircraft.Fuel.WING_VOLUME_DESIGN], 839.18, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 856.4910800459031 - assert_near_equal( - self.prob['OEM_fuel_vol'], 1558.86, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 1576.1710061411081 - assert_near_equal( - self.prob[Mission.Summary.OPERATING_MASS], 97422.32, tol - ) # modified from GASP value to account for updated crew mass. GASP value is 96556.0 - # extra_fuel_mass calculated differently in this version, so test for fuel_mass.fuel_and_oem.payload_mass_max_fuel not included - assert_near_equal(self.prob['volume_wingfuel_mass'], 57066.3, tol) - assert_near_equal(self.prob['max_wingfuel_mass'], 57066.3, tol) - - assert_near_equal(self.prob['extra_fuel_volume'], 0, tol) # always zero when no body tank - assert_near_equal(self.prob['max_extra_fuel_mass'], 0, tol) # always zero when no body tank + expected_values = { + 'gasp_based_geom.cabin_height': 13.1, + 'gasp_based_geom.cabin_len': 72.09722222222223, + 'gasp_based_geom.nose_height': 8.6, + Aircraft.Wing.CENTER_CHORD: 17.63, + Aircraft.Wing.ROOT_CHORD: 16.54, + Aircraft.Wing.THICKNESS_TO_CHORD_UNWEIGHTED: 0.1397, # not exact GASP value from the output file, likely due to rounding error + Aircraft.HorizontalTail.AVERAGE_CHORD: 9.6509873673743, + Aircraft.VerticalTail.AVERAGE_CHORD: 16.96457870166355, + Aircraft.Nacelle.AVG_LENGTH: 14.7, + Aircraft.LandingGear.MAIN_GEAR_MASS: 6384.35, + 'loc_MAC_vtail': 0.44959578484694906, + 'isolated_wing_mass': 16205, + Aircraft.Propulsion.TOTAL_ENGINE_MASS: 12606, + Aircraft.Engine.ADDITIONAL_MASS: 1765 / 2, + 'OEM_wingfuel_mass': 77977.7, # modified from GASP value to account for updated crew mass. GASP value is 78843.6 + 'fus_mass_full': 102812.6654177, # modified from GASP value to account for updated crew mass. GASP value is 102408.05695930264 + Aircraft.Fuel.FUEL_SYSTEM_MASS: 1721.08, # modified from GASP value to account for updated crew mass. GASP value is 1757 + Aircraft.Design.STRUCTURE_MASS: 50931.4, + Aircraft.Fuselage.MASS: 18833.76678366, # modified from GASP value to account for updated crew mass. GASP value is 18814 + Mission.Summary.FUEL_MASS_REQUIRED: 41977.7, # modified from GASP value to account for updated crew mass. GASP value is 42843.6 + Aircraft.Propulsion.MASS: 16098.7, # modified from GASP value to account for updated crew mass. GASP value is 16127 + Mission.Summary.FUEL_MASS: 41977.68, # modified from GASP value to account for updated crew mass. GASP value is 42844.0 + 'fuel_mass_min': 31937.68, # modified from GASP value to account for updated crew mass. GASP value is 32803.6 + Aircraft.Fuel.WING_VOLUME_DESIGN: 839.18, # modified from GASP value to account for updated crew mass. GASP value is 856.4910800459031 + 'OEM_fuel_vol': 1558.86, # modified from GASP value to account for updated crew mass. GASP value is 1576.1710061411081 + Mission.Summary.OPERATING_MASS: 97422.32, # modified from GASP value to account for updated crew mass. GASP value is 96556.0 + 'volume_wingfuel_mass': 57066.3, # extra_fuel_mass calculated differently in this version, so test for fuel_mass.fuel_and_oem.payload_mass_max_fuel not included + 'max_wingfuel_mass': 57066.3, + 'extra_fuel_volume': 0, # always zero when no body tank + 'max_extra_fuel_mass': 0, # always zero when no body tank + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(self.prob[var_name], expected_val, tol) partial_data = self.prob.check_partials(out_stream=None, method='cs') assert_check_partials(partial_data, atol=3e-10, rtol=1e-12) diff --git a/aviary/validation_cases/benchmark_tests/test_bench_FwGm.py b/aviary/validation_cases/benchmark_tests/test_bench_FwGm.py index 4083292d5..d5ceb81fb 100644 --- a/aviary/validation_cases/benchmark_tests/test_bench_FwGm.py +++ b/aviary/validation_cases/benchmark_tests/test_bench_FwGm.py @@ -38,17 +38,20 @@ def bench_test_swap_3_FwGm_IPOPT(self): rtol = 1e-2 # There are no truth values for these. - assert_near_equal(prob.get_val(Mission.Design.GROSS_MASS), 177536.28, tolerance=rtol) - - assert_near_equal(prob.get_val(Mission.Summary.OPERATING_MASS), 101262.9, tolerance=rtol) - - assert_near_equal(prob.get_val(Mission.Summary.TOTAL_FUEL_MASS), 38417.3, tolerance=rtol) - - assert_near_equal(prob.get_val(Mission.Landing.GROUND_DISTANCE), 2613.4, tolerance=rtol) - - assert_near_equal( - prob.get_val('traj.desc2.timeseries.distance')[-1], 3675.0, tolerance=rtol - ) + expected_values = { + Mission.Design.GROSS_MASS: 177536.28, + Mission.Summary.OPERATING_MASS: 101262.9, + Mission.Summary.TOTAL_FUEL_MASS: 38417.3, + Mission.Landing.GROUND_DISTANCE: 2613.4, + 'traj.desc2.timeseries.distance': 3675.0, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + if var_name == 'traj.desc2.timeseries.distance': + assert_near_equal(prob.get_val(var_name)[-1], expected_val, tolerance=rtol) + else: + assert_near_equal(prob.get_val(var_name), expected_val, tolerance=rtol) @require_pyoptsparse(optimizer='SNOPT') def bench_test_swap_3_FwGm_SNOPT(self): @@ -66,17 +69,20 @@ def bench_test_swap_3_FwGm_SNOPT(self): rtol = 1e-2 # There are no truth values for these. - assert_near_equal(prob.get_val(Mission.Design.GROSS_MASS), 177536.28, tolerance=rtol) - - assert_near_equal(prob.get_val(Mission.Summary.OPERATING_MASS), 101262.9, tolerance=rtol) - - assert_near_equal(prob.get_val(Mission.Summary.TOTAL_FUEL_MASS), 38417.3, tolerance=rtol) - - assert_near_equal(prob.get_val(Mission.Landing.GROUND_DISTANCE), 2613.4, tolerance=rtol) - - assert_near_equal( - prob.get_val('traj.desc2.timeseries.distance')[-1], 3675.0, tolerance=rtol - ) + expected_values = { + Mission.Design.GROSS_MASS: 177536.28, + Mission.Summary.OPERATING_MASS: 101262.9, + Mission.Summary.TOTAL_FUEL_MASS: 38417.3, + Mission.Landing.GROUND_DISTANCE: 2613.4, + 'traj.desc2.timeseries.distance': 3675.0, + } + + for var_name, expected_val in expected_values.items(): + with self.subTest(var=var_name): + if var_name == 'traj.desc2.timeseries.distance': + assert_near_equal(prob.get_val(var_name)[-1], expected_val, tolerance=rtol) + else: + assert_near_equal(prob.get_val(var_name), expected_val, tolerance=rtol) if __name__ == '__main__': diff --git a/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py b/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py index 206aa067b..9c4b9e5e9 100644 --- a/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py +++ b/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py @@ -36,37 +36,18 @@ def test_bench_GwGm_IPOPT(self): rtol = 1e-3 # There are no truth values for these. - assert_near_equal( - prob.get_val(Mission.Design.GROSS_MASS, units='lbm'), - 171646.48312684, - tolerance=rtol, - ) - - assert_near_equal( - prob.get_val(Mission.Summary.OPERATING_MASS, units='lbm'), - 95100.07583783, - tolerance=rtol, - ) - - assert_near_equal( - prob.get_val(Mission.Summary.TOTAL_FUEL_MASS, units='lbm'), - 40546.40728901, - tolerance=rtol, - ) - - assert_near_equal( - prob.get_val(Mission.Landing.GROUND_DISTANCE, units='ft'), - 2655.5028412, - tolerance=rtol, - ) - - assert_near_equal(prob.get_val(Mission.Summary.RANGE, units='NM'), 3675.0, tolerance=rtol) - - assert_near_equal( - prob.get_val(Mission.Landing.TOUCHDOWN_MASS, units='lbm'), - 136098.07583783, - tolerance=rtol, - ) + expected_values = { + (Mission.Design.GROSS_MASS, 'lbm'): 171646.48312684, + (Mission.Summary.OPERATING_MASS, 'lbm'): 95100.07583783, + (Mission.Summary.TOTAL_FUEL_MASS, 'lbm'): 40546.40728901, + (Mission.Landing.GROUND_DISTANCE, 'ft'): 2655.5028412, + (Mission.Summary.RANGE, 'NM'): 3675.0, + (Mission.Landing.TOUCHDOWN_MASS, 'lbm'): 136098.07583783, + } + + for (var_name, units), expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name, units=units), expected_val, tolerance=rtol) @require_pyoptsparse(optimizer='SNOPT') def test_bench_GwGm_SNOPT(self): @@ -83,37 +64,18 @@ def test_bench_GwGm_SNOPT(self): rtol = 1e-3 # There are no truth values for these. - assert_near_equal( - prob.get_val(Mission.Design.GROSS_MASS, units='lbm'), - 171646.48312684, - tolerance=rtol, - ) - - assert_near_equal( - prob.get_val(Mission.Summary.OPERATING_MASS, units='lbm'), - 95100.07583783, - tolerance=rtol, - ) - - assert_near_equal( - prob.get_val(Mission.Summary.TOTAL_FUEL_MASS, units='lbm'), - 40546.40728901, - tolerance=rtol, - ) - - assert_near_equal( - prob.get_val(Mission.Landing.GROUND_DISTANCE, units='ft'), - 2655.5028412, - tolerance=rtol, - ) - - assert_near_equal(prob.get_val(Mission.Summary.RANGE, units='NM'), 3675.0, tolerance=rtol) - - assert_near_equal( - prob.get_val(Mission.Landing.TOUCHDOWN_MASS, units='lbm'), - 136098.07583783, - tolerance=rtol, - ) + expected_values = { + (Mission.Design.GROSS_MASS, 'lbm'): 171646.48312684, + (Mission.Summary.OPERATING_MASS, 'lbm'): 95100.07583783, + (Mission.Summary.TOTAL_FUEL_MASS, 'lbm'): 40546.40728901, + (Mission.Landing.GROUND_DISTANCE, 'ft'): 2655.5028412, + (Mission.Summary.RANGE, 'NM'): 3675.0, + (Mission.Landing.TOUCHDOWN_MASS, 'lbm'): 136098.07583783, + } + + for (var_name, units), expected_val in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(prob.get_val(var_name, units=units), expected_val, tolerance=rtol) if __name__ == '__main__': diff --git a/aviary/validation_cases/benchmark_tests/test_bench_multimission.py b/aviary/validation_cases/benchmark_tests/test_bench_multimission.py index 110e1317a..2f74b3bed 100644 --- a/aviary/validation_cases/benchmark_tests/test_bench_multimission.py +++ b/aviary/validation_cases/benchmark_tests/test_bench_multimission.py @@ -42,11 +42,17 @@ def test_multimission(self): self.assertTrue(prob.result.success) - assert_near_equal(objective_expected_value, objective, tolerance=1e-3) - assert_near_equal(mission1_fuel_expected_value, mission1_fuel, tolerance=1e-3) - assert_near_equal(mission2_fuel_expected_value, mission2_fuel, tolerance=1e-3) - assert_near_equal(mission1_cargo_expected_value, mission1_cargo, tolerance=1e-3) - assert_near_equal(mission2_cargo_expected_value, mission2_cargo, tolerance=1e-3) + expected_values = { + 'objective': (objective_expected_value, objective), + 'mission1_fuel': (mission1_fuel_expected_value, mission1_fuel), + 'mission2_fuel': (mission2_fuel_expected_value, mission2_fuel), + 'mission1_cargo': (mission1_cargo_expected_value, mission1_cargo), + 'mission2_cargo': (mission2_cargo_expected_value, mission2_cargo), + } + + for var_name, (expected, actual) in expected_values.items(): + with self.subTest(var=var_name): + assert_near_equal(expected, actual, tolerance=1e-3) if __name__ == '__main__': diff --git a/aviary/validation_cases/benchmark_tests/test_bench_off_design.py b/aviary/validation_cases/benchmark_tests/test_bench_off_design.py index 678019c8e..5601c722c 100644 --- a/aviary/validation_cases/benchmark_tests/test_bench_off_design.py +++ b/aviary/validation_cases/benchmark_tests/test_bench_off_design.py @@ -72,14 +72,18 @@ def compare_results(self, comparison_prob): ] for var in prob_var_list: - assert_near_equal(comparison_prob.get_val(var), self.prob.get_val(var), tolerance=1e-6) + with self.subTest(var=var): + assert_near_equal( + comparison_prob.get_val(var), self.prob.get_val(var), tolerance=1e-6 + ) for var in inputs_var_list: - assert_near_equal( - comparison_prob.aviary_inputs.get_val(var), - self.prob.aviary_inputs.get_val(var), - tolerance=1e-12, - ) + with self.subTest(var=var): + assert_near_equal( + comparison_prob.aviary_inputs.get_val(var), + self.prob.aviary_inputs.get_val(var), + tolerance=1e-12, + ) @require_pyoptsparse(optimizer='SNOPT') def test_fallout_mission_match(self): @@ -318,14 +322,18 @@ def compare_results(self, comparison_prob): ] for var in prob_var_list: - assert_near_equal(comparison_prob.get_val(var), self.prob.get_val(var), tolerance=1e-6) + with self.subTest(var=var): + assert_near_equal( + comparison_prob.get_val(var), self.prob.get_val(var), tolerance=1e-6 + ) for var in inputs_var_list: - assert_near_equal( - comparison_prob.aviary_inputs.get_val(var[0], var[1]), - self.prob.aviary_inputs.get_val(var[0], var[1]), - tolerance=1e-12, - ) + with self.subTest(var=var[0]): + assert_near_equal( + comparison_prob.aviary_inputs.get_val(var[0], var[1]), + self.prob.aviary_inputs.get_val(var[0], var[1]), + tolerance=1e-12, + ) @require_pyoptsparse(optimizer='SNOPT') def test_fallout_mission_match(self): @@ -473,7 +481,7 @@ def test_alternate_mission_changed(self): ) assert_near_equal( prob_alternate.get_val(Mission.Summary.GROSS_MASS, 'lbm'), - 148682.74829764, + 148689.61930389, tolerance=1e-6, ) assert_near_equal( diff --git a/aviary/validation_cases/validation_tests.py b/aviary/validation_cases/validation_tests.py index 57224f7e4..012555ad9 100644 --- a/aviary/validation_cases/validation_tests.py +++ b/aviary/validation_cases/validation_tests.py @@ -1,4 +1,4 @@ -import warnings +import unittest from enum import Enum import openmdao.api as om @@ -20,6 +20,7 @@ def do_validation_test( + test: unittest.TestCase, prob: om.Problem, input_validation_data: AviaryValues, output_validation_data: AviaryValues, @@ -43,61 +44,53 @@ def do_validation_test( Parameters ---------- + test : unittest + The unittest housing this function call prob : om.Problem An instantiated and set-up Problem. case_name : str Name of the case being run. input_validation_data : AviaryValues - Input variables and their values to use when running the problem. - The object must contain at a minimum all the input variables listed - in input_keys. + Input variables and their values to use when running the problem. The object must contain at + a minimum all the input variables listed in input_keys. output_validation_data : AviaryValues - Output variables and their values to which output from the problem - will be compared. The object must contain at a minimum all the - output variables listed in output_keys. Note that input_validation_data - and output_validation_data may be the same object. + Output variables and their values to which output from the problem will be compared. The + object must contain at a minimum all the output variables listed in output_keys. Note that + input_validation_data and output_validation_data may be the same object. input_keys : str, or iter of str - List of input variables whose values will be transferred from - the input validation data in order to run the problem. + List of input variables whose values will be transferred from the input validation data in + order to run the problem. output_keys : str, or iter of str - List of output variables whose values will be looked up in - the output validation data and compared against the outputs from the - problem. + List of output variables whose values will be looked up in the output validation data and + compared against the outputs from the problem. aviary_option_keys: str, or iter of str - List of aviary_options keys whose values will be looked up and - listed in the options printout. If None, all items in aviary_options - will be listed. + List of aviary_options keys whose values will be looked up and listed in the options + printout. If None, all items in aviary_options will be listed. tol : float - Relative tolerance for comparing problem outputs against - validation data. The default is 1.0e-4. + Relative tolerance for comparing problem outputs against validation data. The default is + 1.0e-4. atol : float - Absolute tolerance for checking partial derivative calculations. The - default is 1.0e-12. + Absolute tolerance for checking partial derivative calculations. The default is 1.0e-12. rtol : float - Relative tolerance for checking partial derivative calculations. The - default is 1.0e-12. + Relative tolerance for checking partial derivative calculations. The default is 1.0e-12. method : str Type of differencing to use. The default is "cs". step : float - Step size for approximation. Default is None, which means 1e-6 for 'fd' and 1e-40 for - 'cs'. + Step size for approximation. Default is None, which means 1e-6 for 'fd' and 1e-40 for 'cs'. check_values : bool - If true, check output values against validation data. The default is - true. + If true, check output values against validation data. The default is true. check_partials : bool If true, check partial derivative calculations. The default is true. excludes : None or list_like - List of glob patterns for pathnames to exclude from the partial derivative check. - Default is None, which excludes nothing. + List of glob patterns for pathnames to exclude from the partial derivative check. Default is + None, which excludes nothing. list_options: bool - If True, values of options for all components in the model will be listed - on standard output. Default is False. + If True, values of options for all components in the model will be listed on standard + output. Default is False. list_inputs: bool - If True, prob.model.list_inputs() will be called after the model is run. - Default is False. + If True, prob.model.list_inputs() will be called after the model is run. Default is False. list_outputs: bool - If True, prob.model.list_outputs() will be called after the model is run. - Default is False. + If True, prob.model.list_outputs() will be called after the model is run. Default is False. """ input_key_list = _assure_is_list(input_keys) output_key_list = _assure_is_list(output_keys) @@ -126,10 +119,8 @@ def do_validation_test( for key in output_key_list: desired, units = output_validation_data.get_item(key) actual = prob.get_val(key, units) - try: + with test.subTest(key): assert_near_equal(actual, desired, tol) - except ValueError as err: - raise ValueError(f'ValueError for key = {key}') from err if check_partials: partial_data = prob.check_partials( @@ -139,6 +130,7 @@ def do_validation_test( def flops_validation_test( + test: unittest.TestCase, prob: om.Problem, case_name: str, input_keys: list, @@ -164,6 +156,8 @@ def flops_validation_test( Parameters ---------- + test : unittest + The unittest housing this function call prob : om.Problem An instantiated and set-up Problem. case_name : str @@ -238,6 +232,7 @@ def flops_validation_test( return do_validation_test( + test=test, prob=prob, input_validation_data=flops_inputs, output_validation_data=flops_outputs,