From edb87a6489a19ccfe9bc747f385160be4bcc8171 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Sun, 8 Dec 2024 20:28:16 -0500 Subject: [PATCH 01/16] add design payload weight into calculation for design fuel mass required to fix error with the aircraft design changing for off design missions --- aviary/subsystems/mass/gasp_based/fuel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aviary/subsystems/mass/gasp_based/fuel.py b/aviary/subsystems/mass/gasp_based/fuel.py index b9b973fc9..806905929 100644 --- a/aviary/subsystems/mass/gasp_based/fuel.py +++ b/aviary/subsystems/mass/gasp_based/fuel.py @@ -1344,7 +1344,7 @@ def compute(self, inputs, outputs): - control_wt - fixed_equip_wt - useful_wt - - payload_wt + - payload_wt_des - fuel_sys_wt ) / GRAV_ENGLISH_LBM outputs["fuel_mass_min"] = ( From cf1ca159d7b8e323be404511f3ed60aabdb7363c Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Sun, 8 Dec 2024 20:34:48 -0500 Subject: [PATCH 02/16] update PayloadMass calculations to allow for specification of design num_passengers separately from as flown passengers --- aviary/subsystems/mass/gasp_based/fixed.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aviary/subsystems/mass/gasp_based/fixed.py b/aviary/subsystems/mass/gasp_based/fixed.py index 3f083f3b3..aecbe131d 100644 --- a/aviary/subsystems/mass/gasp_based/fixed.py +++ b/aviary/subsystems/mass/gasp_based/fixed.py @@ -294,12 +294,14 @@ def compute(self, inputs, outputs): Aircraft.CrewPayload.PASSENGER_MASS_WITH_BAGS, units='lbm') PAX = aviary_options.get_val( Aircraft.CrewPayload.NUM_PASSENGERS, units='unitless') + PAX_des = aviary_options.get_val( + Aircraft.CrewPayload.Design.NUM_PASSENGERS, units='unitless') cargo_mass = inputs[Aircraft.CrewPayload.CARGO_MASS] outputs[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS] = \ payload_mass = pax_mass * PAX - outputs["payload_mass_des"] = payload_mass - outputs["payload_mass_max"] = pax_mass * PAX + cargo_mass + outputs["payload_mass_des"] = pax_mass * PAX_des + outputs["payload_mass_max"] = pax_mass * PAX_des + cargo_mass class ElectricAugmentationMass(om.ExplicitComponent): From 01e2b6b39492f7e483c853f982fb5b0a29e42924 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Sun, 8 Dec 2024 22:39:35 -0500 Subject: [PATCH 03/16] updates to allow for design vs as flown cargo --- aviary/interface/methods_for_level2.py | 3 ++- .../test_aircraft/aircraft_for_bench_GwGm.csv | 1 + aviary/subsystems/mass/gasp_based/fixed.py | 9 +++++++-- aviary/utils/preprocessors.py | 3 +++ aviary/variable_info/variable_meta_data.py | 16 +++++++++++++++- aviary/variable_info/variables.py | 1 + 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/aviary/interface/methods_for_level2.py b/aviary/interface/methods_for_level2.py index 01d141f07..ab5ec0146 100644 --- a/aviary/interface/methods_for_level2.py +++ b/aviary/interface/methods_for_level2.py @@ -1347,7 +1347,8 @@ def add_post_mission_systems(self, include_landing=True): mass_resid={'units': 'lbm'}) if self.mass_method is GASP: - payload_mass_src = Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS + #payload_mass_src = Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS + payload_mass_src = Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS else: payload_mass_src = Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index 2f3c32e0d..3039a89f9 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -7,6 +7,7 @@ aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless aircraft:crew_and_payload:cargo_mass,10040,lbm +aircraft:crew_and_payload:design:cargo_mass,10040,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm aircraft:crew_and_payload:design:num_passengers,180,unitless aircraft:crew_and_payload:passenger_mass_with_bags,200,lbm diff --git a/aviary/subsystems/mass/gasp_based/fixed.py b/aviary/subsystems/mass/gasp_based/fixed.py index aecbe131d..19f72e15a 100644 --- a/aviary/subsystems/mass/gasp_based/fixed.py +++ b/aviary/subsystems/mass/gasp_based/fixed.py @@ -272,6 +272,8 @@ def setup(self): add_aviary_output(self, Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS, val=0) + add_aviary_output(self, Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS, val=0) + self.add_output( "payload_mass_des", val=0, units="lbm", desc="WPLDES: design payload" ) @@ -297,11 +299,14 @@ def compute(self, inputs, outputs): PAX_des = aviary_options.get_val( Aircraft.CrewPayload.Design.NUM_PASSENGERS, units='unitless') cargo_mass = inputs[Aircraft.CrewPayload.CARGO_MASS] + cargo_mass_des = aviary_options.get_val( + Aircraft.CrewPayload.Design.CARGO_MASS, units='lbm') outputs[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS] = \ payload_mass = pax_mass * PAX - outputs["payload_mass_des"] = pax_mass * PAX_des - outputs["payload_mass_max"] = pax_mass * PAX_des + cargo_mass + outputs["payload_mass_des"] = pax_mass * PAX_des + cargo_mass + outputs["payload_mass_max"] = pax_mass * PAX_des + cargo_mass_des + outputs[Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS] = pax_mass * PAX + cargo_mass class ElectricAugmentationMass(om.ExplicitComponent): diff --git a/aviary/utils/preprocessors.py b/aviary/utils/preprocessors.py index deec2fb94..b6b1c0495 100644 --- a/aviary/utils/preprocessors.py +++ b/aviary/utils/preprocessors.py @@ -162,6 +162,9 @@ def preprocess_crewpayload(aviary_options: AviaryValues): raise om.AnalysisError( f"ERROR: In preprocesssors.py: NUM_PASSENGERS ({aviary_options.get_val(Aircraft.CrewPayload.NUM_PASSENGERS)}) is larger than the number of seats set by Design.NUM_PASSENGERS ({aviary_options.get_val(Aircraft.CrewPayload.Design.NUM_PASSENGERS)}) .") + print(Aircraft.CrewPayload.CARGO_MASS, aviary_options.get_val(Aircraft.CrewPayload.CARGO_MASS, 'lbm')) + print(Aircraft.CrewPayload.Design.CARGO_MASS, aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS, 'lbm')) + if Aircraft.CrewPayload.NUM_FLIGHT_ATTENDANTS not in aviary_options: flight_attendants_count = 0 # assume no passengers diff --git a/aviary/variable_info/variable_meta_data.py b/aviary/variable_info/variable_meta_data.py index 2ad85f2ea..cfcd26a24 100644 --- a/aviary/variable_info/variable_meta_data.py +++ b/aviary/variable_info/variable_meta_data.py @@ -684,7 +684,7 @@ ] }, units='lbm', - desc='total mass of cargo' + desc='total mass of as-flown cargo' ) add_meta_data( @@ -763,6 +763,20 @@ default_value=0, ) +add_meta_data( + Aircraft.CrewPayload.Design.CARGO_MASS, + meta_data=_MetaData, + historical_name={"GASP": 'INGASP.WCARGO', + # ['WTS.WSP(36,2)', '~WEIGHT.WCARGO', '~WTSTAT.WSP(36,2)', '~INERT.WCARGO',], + "FLOPS": None, + "LEAPS1": ['(WeightABC)self._cargo_weight', + 'aircraft.outputs.L0_weights_summary.cargo_weight', + ] + }, + units='lbm', + desc='total mass of cargo for design mission' +) + add_meta_data( # Note user override # - see also: Aircraft.CrewPayload.FLIGHT_CREW_MASS_SCALER diff --git a/aviary/variable_info/variables.py b/aviary/variable_info/variables.py index e720115c3..b8b292a02 100644 --- a/aviary/variable_info/variables.py +++ b/aviary/variable_info/variables.py @@ -133,6 +133,7 @@ class Design: NUM_FIRST_CLASS = 'aircraft:crew_and_payload:design:num_first_class' NUM_TOURIST_CLASS = 'aircraft:crew_and_payload:design:num_tourist_class' NUM_PASSENGERS = 'aircraft:crew_and_payload:design:num_passengers' + CARGO_MASS = 'aircraft:crew_and_payload:design:cargo_mass' class Design: # These variables are values that do not fall into a particular aircraft From ea9a51e3c634ecef338087aec3d9a30d52914eb8 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Sun, 8 Dec 2024 23:01:04 -0500 Subject: [PATCH 04/16] addition of max_cargo_mass variable to h nable ackwards compatability of gasp based aviary missions --- .../test_aircraft/aircraft_for_bench_GwGm.csv | 5 +++-- aviary/subsystems/mass/gasp_based/fixed.py | 5 +++-- aviary/variable_info/variable_meta_data.py | 16 +++++++++++++++- aviary/variable_info/variables.py | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index 3039a89f9..97b07e91b 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -6,8 +6,9 @@ aircraft:controls:cockpit_control_mass_scaler,1,unitless aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless -aircraft:crew_and_payload:cargo_mass,10040,lbm -aircraft:crew_and_payload:design:cargo_mass,10040,lbm +aircraft:crew_and_payload:cargo_mass,0,lbm +aircraft:crew_and_payload:design:cargo_mass,0,lbm +aircraft:crew_and_payload:max_cargo_mass,10040,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm aircraft:crew_and_payload:design:num_passengers,180,unitless aircraft:crew_and_payload:passenger_mass_with_bags,200,lbm diff --git a/aviary/subsystems/mass/gasp_based/fixed.py b/aviary/subsystems/mass/gasp_based/fixed.py index 19f72e15a..34233bbea 100644 --- a/aviary/subsystems/mass/gasp_based/fixed.py +++ b/aviary/subsystems/mass/gasp_based/fixed.py @@ -301,11 +301,12 @@ def compute(self, inputs, outputs): cargo_mass = inputs[Aircraft.CrewPayload.CARGO_MASS] cargo_mass_des = aviary_options.get_val( Aircraft.CrewPayload.Design.CARGO_MASS, units='lbm') + cargo_mass_max = aviary_options.get_val(Aircraft.CrewPayload.MAX_CARGO_MASS, units='lbm') outputs[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS] = \ payload_mass = pax_mass * PAX - outputs["payload_mass_des"] = pax_mass * PAX_des + cargo_mass - outputs["payload_mass_max"] = pax_mass * PAX_des + cargo_mass_des + outputs["payload_mass_des"] = pax_mass * PAX_des + cargo_mass_des + outputs["payload_mass_max"] = pax_mass * PAX_des + cargo_mass_max outputs[Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS] = pax_mass * PAX + cargo_mass diff --git a/aviary/variable_info/variable_meta_data.py b/aviary/variable_info/variable_meta_data.py index cfcd26a24..c9e1024d3 100644 --- a/aviary/variable_info/variable_meta_data.py +++ b/aviary/variable_info/variable_meta_data.py @@ -687,6 +687,20 @@ desc='total mass of as-flown cargo' ) +add_meta_data( + Aircraft.CrewPayload.MAX_CARGO_MASS, + meta_data=_MetaData, + historical_name={"GASP": 'INGASP.WCARGO', + # ['WTS.WSP(36,2)', '~WEIGHT.WCARGO', '~WTSTAT.WSP(36,2)', '~INERT.WCARGO',], + "FLOPS": None, + "LEAPS1": ['(WeightABC)self._cargo_weight', + 'aircraft.outputs.L0_weights_summary.cargo_weight', + ] + }, + units='lbm', + desc='Maximum mass of cargo' +) + add_meta_data( Aircraft.CrewPayload.CATERING_ITEMS_MASS_PER_PASSENGER, meta_data=_MetaData, @@ -774,7 +788,7 @@ ] }, units='lbm', - desc='total mass of cargo for design mission' + desc='total mass of cargo flown on design mission' ) add_meta_data( diff --git a/aviary/variable_info/variables.py b/aviary/variable_info/variables.py index b8b292a02..79f543141 100644 --- a/aviary/variable_info/variables.py +++ b/aviary/variable_info/variables.py @@ -87,6 +87,7 @@ class CrewPayload: 'aircraft:crew_and_payload:flight_crew_mass_scaler' MASS_PER_PASSENGER = 'aircraft:crew_and_payload:mass_per_passenger' + MAX_CARGO_MASS = 'aircraft:crew_and_payload:max_cargo_mass' MISC_CARGO = 'aircraft:crew_and_payload:misc_cargo' From 8aa98a53a3c9374dc025f41e7998c68d7f8c5aa3 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Mon, 9 Dec 2024 00:08:50 -0500 Subject: [PATCH 05/16] update preprocessors to manage cargo_mass variables and print cargo assumptions to command line --- .../test_aircraft/aircraft_for_bench_GwGm.csv | 4 +- aviary/utils/preprocessors.py | 71 ++++++++++++++++++- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index 97b07e91b..9c0af29ad 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -7,8 +7,8 @@ aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless aircraft:crew_and_payload:cargo_mass,0,lbm -aircraft:crew_and_payload:design:cargo_mass,0,lbm -aircraft:crew_and_payload:max_cargo_mass,10040,lbm +#aircraft:crew_and_payload:design:cargo_mass,0,lbm +#aircraft:crew_and_payload:max_cargo_mass,10040,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm aircraft:crew_and_payload:design:num_passengers,180,unitless aircraft:crew_and_payload:passenger_mass_with_bags,200,lbm diff --git a/aviary/utils/preprocessors.py b/aviary/utils/preprocessors.py index b6b1c0495..ae6aeb155 100644 --- a/aviary/utils/preprocessors.py +++ b/aviary/utils/preprocessors.py @@ -162,8 +162,75 @@ def preprocess_crewpayload(aviary_options: AviaryValues): raise om.AnalysisError( f"ERROR: In preprocesssors.py: NUM_PASSENGERS ({aviary_options.get_val(Aircraft.CrewPayload.NUM_PASSENGERS)}) is larger than the number of seats set by Design.NUM_PASSENGERS ({aviary_options.get_val(Aircraft.CrewPayload.Design.NUM_PASSENGERS)}) .") - print(Aircraft.CrewPayload.CARGO_MASS, aviary_options.get_val(Aircraft.CrewPayload.CARGO_MASS, 'lbm')) - print(Aircraft.CrewPayload.Design.CARGO_MASS, aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS, 'lbm')) + # Check and process cargo variables + input_cargo = Aircraft.CrewPayload.CARGO_MASS in aviary_options + input_max_cargo = Aircraft.CrewPayload.MAX_CARGO_MASS in aviary_options + input_des_cargo = Aircraft.CrewPayload.Design.CARGO_MASS in aviary_options + + if input_cargo: + cargo = aviary_options.get_val(Aircraft.CrewPayload.CARGO_MASS,'lbm') + if input_max_cargo: + max_cargo = aviary_options.get_val(Aircraft.CrewPayload.MAX_CARGO_MASS,'lbm') + if input_des_cargo: + des_cargo = aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS,'lbm') + # user has set all three check if consistent + else: + # user has set cargo & max: assume des = max + des_cargo = max_cargo + print('Aircraft.CrewPayload.Design.CARGO_MASS missing, assume Design.CARGO_MASS = MAX_CARGO_MASS') + elif input_des_cargo: + # user has set cargo & des: assume max = des + des_cargo = aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS,'lbm') + max_cargo = des + print('Aircraft.CrewPayload.MAX_CARGO_MASS missing, assume MAX_CARGO_MASS = Design.CARGO_MASS') + else: + # user has set cargo only: assume intention to set max only and + print('WARNING: User has only set CARGO_MASS for backwards compatiability Aviary is assuming you intended to set MAX_CARGO_MASS. Setting CARGO_MASS and Design.CARGO_MASS = 0') + max_cargo = cargo + cargo = 0 + des_cargo = 0 + + elif input_max_cargo: + max_cargo = aviary_options.get_val(Aircraft.CrewPayload.MAX_CARGO_MASS,'lbm') + if input_des_cargo: + des_cargo = aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS,'lbm') + # user has set max & des: assume flown = 0 + cargo = 0 + print('Aircraft.CrewPayload.CARGO_MASS missing, assume CARGO_MASS = 0') + else: + # user has set max only: assume flown = des = 0 + cargo = 0 + des_cargo = 0 + print('Aircraft.CrewPayload.CARGO_MASS and Aircraft.CrewPayload.Design.CARGO_MASS missing, assume CARGO_MASS and Design.CARGO_MASS = 0. No Cargo is flown on any mission') + + elif input_des_cargo: + des_cargo = aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS,'lbm') + # user has only input des: assume max = des and flown = 0 + max_cargo = des_cargo + cargo = 0 + print('Aircraft.CrewPayload.CARGO_MASS and Aircraft.CrewPayload.MAX_CARGO_MASS missing, assume CARGO_MASS = 0 and MAX_CARGO_MASS = Design.CARGO_MASS') + + else: + #user has input no cargo information + cargo = max_cargo = des_cargo = 0 + print('No CARGO variables detected, assume CARGO_MASS = MAX_CARGO_MASS = Design.CARGO_MASS = 0') + + # check for potential cargo errors: + if cargo > des_cargo: + print('WARNING! as flown cargo > design cargo') + + if cargo > max_cargo or des_cargo > max_cargo: + print('WARNING! as flown and/or design cargo > max_cargo') + + # calculate and check total payload NOTE this is only used for error messaging the calculations for analysis are subsystems/mass/gasp_based: + pax_mass = aviary_options.get_val(Aircraft.CrewPayload.PASSENGER_MASS_WITH_BAGS,'lbm') + design_passenger_payload_mass = design_num_pax * pax_mass + des_payload = design_passenger_payload_mass + des_cargo + num_pax = aviary_options.get_val(Aircraft.CrewPayload.NUM_PASSENGERS) + as_flown_passenger_payload_mass = num_pax * pax_mass + as_flown_payload = as_flown_passenger_payload_mass + cargo + if as_flown_payload > des_payload: + print('WARNING! as flown payload > design payload! Please re-design the aircraft!') if Aircraft.CrewPayload.NUM_FLIGHT_ATTENDANTS not in aviary_options: flight_attendants_count = 0 # assume no passengers From d44b6c358a81f61a251fbf2df82bdd9711154acf Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Mon, 9 Dec 2024 00:48:30 -0500 Subject: [PATCH 06/16] set assumed cargo parameters at end of logic flow and clean up warning message --- aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv | 2 +- aviary/utils/preprocessors.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index 9c0af29ad..afacab5bf 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -6,7 +6,7 @@ aircraft:controls:cockpit_control_mass_scaler,1,unitless aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless -aircraft:crew_and_payload:cargo_mass,0,lbm +aircraft:crew_and_payload:cargo_mass,10040,lbm #aircraft:crew_and_payload:design:cargo_mass,0,lbm #aircraft:crew_and_payload:max_cargo_mass,10040,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm diff --git a/aviary/utils/preprocessors.py b/aviary/utils/preprocessors.py index ae6aeb155..dcdfd09cb 100644 --- a/aviary/utils/preprocessors.py +++ b/aviary/utils/preprocessors.py @@ -185,7 +185,7 @@ def preprocess_crewpayload(aviary_options: AviaryValues): print('Aircraft.CrewPayload.MAX_CARGO_MASS missing, assume MAX_CARGO_MASS = Design.CARGO_MASS') else: # user has set cargo only: assume intention to set max only and - print('WARNING: User has only set CARGO_MASS for backwards compatiability Aviary is assuming you intended to set MAX_CARGO_MASS. Setting CARGO_MASS and Design.CARGO_MASS = 0') + print('WARNING: User has only set Aircraft.CrewPayload.CARGO_MASS. For backwards compatiability, Aviary is assuming user intended to set MAX_CARGO_MASS. Setting CARGO_MASS and Design.CARGO_MASS = 0') max_cargo = cargo cargo = 0 des_cargo = 0 @@ -231,6 +231,11 @@ def preprocess_crewpayload(aviary_options: AviaryValues): as_flown_payload = as_flown_passenger_payload_mass + cargo if as_flown_payload > des_payload: print('WARNING! as flown payload > design payload! Please re-design the aircraft!') + + # set assumed cargo mass variables: + aviary_options.set_val(Aircraft.CrewPayload.CARGO_MASS, cargo, 'lbm') + aviary_options.set_val(Aircraft.CrewPayload.MAX_CARGO_MASS, max_cargo, 'lbm') + aviary_options.set_val(Aircraft.CrewPayload.Design.CARGO_MASS, des_cargo, 'lbm') if Aircraft.CrewPayload.NUM_FLIGHT_ATTENDANTS not in aviary_options: flight_attendants_count = 0 # assume no passengers From 292871f5ebafe3e1bac23c082fc472ac5c58c8e4 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Mon, 9 Dec 2024 12:30:24 -0500 Subject: [PATCH 07/16] update preprocessors with error message when flying with more payload than design --- aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv | 2 +- aviary/utils/preprocessors.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index afacab5bf..4b94bb3dc 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -7,7 +7,7 @@ aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless aircraft:crew_and_payload:cargo_mass,10040,lbm -#aircraft:crew_and_payload:design:cargo_mass,0,lbm +aircraft:crew_and_payload:design:cargo_mass,10040,lbm #aircraft:crew_and_payload:max_cargo_mass,10040,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm aircraft:crew_and_payload:design:num_passengers,180,unitless diff --git a/aviary/utils/preprocessors.py b/aviary/utils/preprocessors.py index dcdfd09cb..01b35574b 100644 --- a/aviary/utils/preprocessors.py +++ b/aviary/utils/preprocessors.py @@ -181,7 +181,7 @@ def preprocess_crewpayload(aviary_options: AviaryValues): elif input_des_cargo: # user has set cargo & des: assume max = des des_cargo = aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS,'lbm') - max_cargo = des + max_cargo = des_cargo print('Aircraft.CrewPayload.MAX_CARGO_MASS missing, assume MAX_CARGO_MASS = Design.CARGO_MASS') else: # user has set cargo only: assume intention to set max only and @@ -231,6 +231,8 @@ def preprocess_crewpayload(aviary_options: AviaryValues): as_flown_payload = as_flown_passenger_payload_mass + cargo if as_flown_payload > des_payload: print('WARNING! as flown payload > design payload! Please re-design the aircraft!') + raise om.AnalysisError( + f"ERROR: In preprocesssors.py: as_flown payload {as_flown_payload} = passenger_payload_mass {as_flown_passenger_payload_mass} + cargo_mass {cargo} is larger than the design payload {des_payload} = design_passenger_payload {design_passenger_payload_mass} + Design.cargo_mass {des_cargo} : Aricraft must be re-designed") # set assumed cargo mass variables: aviary_options.set_val(Aircraft.CrewPayload.CARGO_MASS, cargo, 'lbm') From 9d8a693ae0a168b9d01496f044d9e5adf72ddc68 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Mon, 9 Dec 2024 18:25:43 -0500 Subject: [PATCH 08/16] setting Design.CARGO_MASS as a promoted aviary_input rather than an option --- aviary/subsystems/mass/gasp_based/fixed.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aviary/subsystems/mass/gasp_based/fixed.py b/aviary/subsystems/mass/gasp_based/fixed.py index 34233bbea..ac87c327e 100644 --- a/aviary/subsystems/mass/gasp_based/fixed.py +++ b/aviary/subsystems/mass/gasp_based/fixed.py @@ -269,9 +269,9 @@ def initialize(self): def setup(self): add_aviary_input(self, Aircraft.CrewPayload.CARGO_MASS, val=10040) + add_aviary_input(self,Aircraft.CrewPayload.Design.CARGO_MASS, val=0) add_aviary_output(self, Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS, val=0) - add_aviary_output(self, Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS, val=0) self.add_output( @@ -299,8 +299,7 @@ def compute(self, inputs, outputs): PAX_des = aviary_options.get_val( Aircraft.CrewPayload.Design.NUM_PASSENGERS, units='unitless') cargo_mass = inputs[Aircraft.CrewPayload.CARGO_MASS] - cargo_mass_des = aviary_options.get_val( - Aircraft.CrewPayload.Design.CARGO_MASS, units='lbm') + cargo_mass_des = inputs[Aircraft.CrewPayload.Design.CARGO_MASS] cargo_mass_max = aviary_options.get_val(Aircraft.CrewPayload.MAX_CARGO_MASS, units='lbm') outputs[Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS] = \ From 9ed90931b1f5199b4e25fbc4c3ea50040dee0779 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Mon, 9 Dec 2024 22:18:06 -0500 Subject: [PATCH 09/16] update variable_meta_data --- aviary/variable_info/variable_meta_data.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/aviary/variable_info/variable_meta_data.py b/aviary/variable_info/variable_meta_data.py index c9e1024d3..69c067767 100644 --- a/aviary/variable_info/variable_meta_data.py +++ b/aviary/variable_info/variable_meta_data.py @@ -676,12 +676,9 @@ add_meta_data( Aircraft.CrewPayload.CARGO_MASS, meta_data=_MetaData, - historical_name={"GASP": 'INGASP.WCARGO', - # ['WTS.WSP(36,2)', '~WEIGHT.WCARGO', '~WTSTAT.WSP(36,2)', '~INERT.WCARGO',], + historical_name={"GASP": None, "FLOPS": None, - "LEAPS1": ['(WeightABC)self._cargo_weight', - 'aircraft.outputs.L0_weights_summary.cargo_weight', - ] + "LEAPS1": None }, units='lbm', desc='total mass of as-flown cargo' @@ -780,12 +777,9 @@ add_meta_data( Aircraft.CrewPayload.Design.CARGO_MASS, meta_data=_MetaData, - historical_name={"GASP": 'INGASP.WCARGO', - # ['WTS.WSP(36,2)', '~WEIGHT.WCARGO', '~WTSTAT.WSP(36,2)', '~INERT.WCARGO',], + historical_name={"GASP": None "FLOPS": None, - "LEAPS1": ['(WeightABC)self._cargo_weight', - 'aircraft.outputs.L0_weights_summary.cargo_weight', - ] + "LEAPS1": None }, units='lbm', desc='total mass of cargo flown on design mission' From 44d7c92a82c8542d66393ba101386a8b4dd17d4d Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Tue, 10 Dec 2024 00:41:40 -0500 Subject: [PATCH 10/16] update variable meta_data and improvements to error messaging in preprocessors.py --- aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv | 6 +++--- aviary/utils/preprocessors.py | 8 ++++++++ aviary/variable_info/variable_meta_data.py | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index 4b94bb3dc..c05f0de09 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -6,9 +6,9 @@ aircraft:controls:cockpit_control_mass_scaler,1,unitless aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless -aircraft:crew_and_payload:cargo_mass,10040,lbm -aircraft:crew_and_payload:design:cargo_mass,10040,lbm -#aircraft:crew_and_payload:max_cargo_mass,10040,lbm +aircraft:crew_and_payload:cargo_mass,0,lbm +#aircraft:crew_and_payload:design:cargo_mass,0,lbm +#aircraft:crew_and_payload:max_cargo_mass,0,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm aircraft:crew_and_payload:design:num_passengers,180,unitless aircraft:crew_and_payload:passenger_mass_with_bags,200,lbm diff --git a/aviary/utils/preprocessors.py b/aviary/utils/preprocessors.py index 01b35574b..175ff1f24 100644 --- a/aviary/utils/preprocessors.py +++ b/aviary/utils/preprocessors.py @@ -7,6 +7,7 @@ from aviary.utils.named_values import get_keys from aviary.variable_info.variable_meta_data import _MetaData from aviary.variable_info.variables import Aircraft, Mission, Settings +from aviary.variable_info.enums import ProblemType from aviary.utils.test_utils.variable_test import get_names_from_hierarchy @@ -166,6 +167,8 @@ def preprocess_crewpayload(aviary_options: AviaryValues): input_cargo = Aircraft.CrewPayload.CARGO_MASS in aviary_options input_max_cargo = Aircraft.CrewPayload.MAX_CARGO_MASS in aviary_options input_des_cargo = Aircraft.CrewPayload.Design.CARGO_MASS in aviary_options + + problem_type = aviary_options.get_val(Settings.PROBLEM_TYPE) if input_cargo: cargo = aviary_options.get_val(Aircraft.CrewPayload.CARGO_MASS,'lbm') @@ -173,6 +176,9 @@ def preprocess_crewpayload(aviary_options: AviaryValues): max_cargo = aviary_options.get_val(Aircraft.CrewPayload.MAX_CARGO_MASS,'lbm') if input_des_cargo: des_cargo = aviary_options.get_val(Aircraft.CrewPayload.Design.CARGO_MASS,'lbm') + if problem_type == ProblemType.SIZING and cargo != des_cargo: + cargo = des_cargo + print('Warning! Aircraft.CrewPayload.CARGO_MASS != Aircraft.CrewPayload.Design.CARGO_MASS for sizing mission. Setting as-flown CARGO_MASS = Design.CARGO_MASS') # user has set all three check if consistent else: # user has set cargo & max: assume des = max @@ -221,6 +227,8 @@ def preprocess_crewpayload(aviary_options: AviaryValues): if cargo > max_cargo or des_cargo > max_cargo: print('WARNING! as flown and/or design cargo > max_cargo') + raise om.AnalysisError( + f"ERROR: In preprocesssors.py: Aircraft.CrewPayload.CARGO_MASS {cargo} and/or Aircraft.CrewPayload.Design.CARGO_MASS {des_cargo} > Aircraft.CrewPayload.MAX_CARGO_MASS {max_cargo}") # calculate and check total payload NOTE this is only used for error messaging the calculations for analysis are subsystems/mass/gasp_based: pax_mass = aviary_options.get_val(Aircraft.CrewPayload.PASSENGER_MASS_WITH_BAGS,'lbm') diff --git a/aviary/variable_info/variable_meta_data.py b/aviary/variable_info/variable_meta_data.py index 69c067767..7409f2797 100644 --- a/aviary/variable_info/variable_meta_data.py +++ b/aviary/variable_info/variable_meta_data.py @@ -777,7 +777,7 @@ add_meta_data( Aircraft.CrewPayload.Design.CARGO_MASS, meta_data=_MetaData, - historical_name={"GASP": None + historical_name={"GASP": None, "FLOPS": None, "LEAPS1": None }, From 777df7b62178b6707b09f114dd4573d774130678 Mon Sep 17 00:00:00 2001 From: cmbenne3 Date: Tue, 10 Dec 2024 11:53:25 -0500 Subject: [PATCH 11/16] updates to load_off_design function to handle num_pax and cargo. WIP -> need to update other off design function for running alternate and fallout missions --- aviary/interface/methods_for_level2.py | 11 +++++++---- .../models/test_aircraft/aircraft_for_bench_GwGm.csv | 2 +- aviary/utils/preprocessors.py | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/aviary/interface/methods_for_level2.py b/aviary/interface/methods_for_level2.py index ab5ec0146..de11b481b 100644 --- a/aviary/interface/methods_for_level2.py +++ b/aviary/interface/methods_for_level2.py @@ -2943,7 +2943,7 @@ def _read_sizing_json(aviary_problem, json_filename): def _load_off_design(json_filename, ProblemType, phase_info, - payload, mission_range, mission_gross_mass): + num_pax, cargo_mass, mission_range, mission_gross_mass): """ This function loads a sized aircraft, and sets up an aviary problem for a specified off design mission. @@ -2956,8 +2956,10 @@ def _load_off_design(json_filename, ProblemType, phase_info, Alternate or Fallout. Alternate requires mission_range input and Fallout requires mission_fuel input phase_info: phase_info dictionary for off design mission - payload: float - Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS + num_pax: integer + Aircraft.CrewPayload.NUM_PASSENGERS + cargo_mass: float + Aircraft.CrewPayload.CARGO_MASS mission_range float Mission.Summary.RANGE 'NM' mission_gross_mass float @@ -2980,7 +2982,8 @@ def _load_off_design(json_filename, ProblemType, phase_info, # Set Payload prob.aviary_inputs.set_val( - Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS, payload, units='lbm') + Aircraft.CrewPayload.NUM_PASSENGERS, num_pax, units='unitless') + prob.aviary_inputs.set_val(Aircraft.CrewPayload.CARGO_MASS, cargo_mass, 'lbm') if ProblemType == ProblemType.ALTERNATE: # Set mission range, aviary will calculate required fuel diff --git a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv index c05f0de09..343d60630 100644 --- a/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv +++ b/aviary/models/test_aircraft/aircraft_for_bench_GwGm.csv @@ -6,7 +6,7 @@ aircraft:controls:cockpit_control_mass_scaler,1,unitless aircraft:controls:control_mass_increment,0,lbm aircraft:controls:stability_augmentation_system_mass,0,lbm aircraft:controls:stability_augmentation_system_mass_scaler,1,unitless -aircraft:crew_and_payload:cargo_mass,0,lbm +aircraft:crew_and_payload:cargo_mass,10040,lbm #aircraft:crew_and_payload:design:cargo_mass,0,lbm #aircraft:crew_and_payload:max_cargo_mass,0,lbm aircraft:crew_and_payload:catering_items_mass_per_passenger,7.6,lbm diff --git a/aviary/utils/preprocessors.py b/aviary/utils/preprocessors.py index 175ff1f24..811d352dc 100644 --- a/aviary/utils/preprocessors.py +++ b/aviary/utils/preprocessors.py @@ -239,8 +239,8 @@ def preprocess_crewpayload(aviary_options: AviaryValues): as_flown_payload = as_flown_passenger_payload_mass + cargo if as_flown_payload > des_payload: print('WARNING! as flown payload > design payload! Please re-design the aircraft!') - raise om.AnalysisError( - f"ERROR: In preprocesssors.py: as_flown payload {as_flown_payload} = passenger_payload_mass {as_flown_passenger_payload_mass} + cargo_mass {cargo} is larger than the design payload {des_payload} = design_passenger_payload {design_passenger_payload_mass} + Design.cargo_mass {des_cargo} : Aricraft must be re-designed") + #raise om.AnalysisError( + # f"ERROR: In preprocesssors.py: as_flown payload {as_flown_payload} = passenger_payload_mass {as_flown_passenger_payload_mass} + cargo_mass {cargo} is larger than the design payload {des_payload} = design_passenger_payload {design_passenger_payload_mass} + Design.cargo_mass {des_cargo} : Aricraft must be re-designed") # set assumed cargo mass variables: aviary_options.set_val(Aircraft.CrewPayload.CARGO_MASS, cargo, 'lbm') From 20416d69f580bf42e98fbfae6037334fcaa08d4f Mon Sep 17 00:00:00 2001 From: Bennett Date: Thu, 12 Dec 2024 12:28:28 -0500 Subject: [PATCH 12/16] rename actual_range as Mission.Summary.Range --- aviary/interface/methods_for_level2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aviary/interface/methods_for_level2.py b/aviary/interface/methods_for_level2.py index 01d141f07..90ce3c070 100644 --- a/aviary/interface/methods_for_level2.py +++ b/aviary/interface/methods_for_level2.py @@ -1498,7 +1498,7 @@ def link_phases(self): connected=true_unless_mpi) self.model.connect(f'traj.{self.regular_phases[-1]}.timeseries.distance', - 'actual_range', + Mission.Summary.Range, src_indices=[-1], flat_src_indices=True) elif self.mission_method is SOLVED_2DOF: @@ -1621,14 +1621,14 @@ def link_phases(self): Mission.Landing.TOUCHDOWN_MASS, src_indices=[-1]) connect_map = { - f"traj.{self.regular_phases[-1]}.timeseries.distance": 'actual_range', + f"traj.{self.regular_phases[-1]}.timeseries.distance": Mission.Summary.RANGE, } else: connect_map = { "taxi.mass": "traj.mass_initial", Mission.Takeoff.ROTATION_VELOCITY: "traj.SGMGroundroll_velocity_trigger", - "traj.distance_final": 'actual_range', + "traj.distance_final": Mission.Summary.Range, "traj.mass_final": Mission.Landing.TOUCHDOWN_MASS, } @@ -2779,7 +2779,7 @@ def _add_objectives(self): "val": self.target_range, "units": "NM"}, ), promotes_inputs=[ - "actual_range", + ("actual_range", Mission.Summary.Range), ("ascent_duration", Mission.Takeoff.ASCENT_DURATION), ], promotes_outputs=[("reg_objective", Mission.Objectives.RANGE)], @@ -2805,8 +2805,8 @@ def _add_objectives(self): range_resid={"val": 30, "units": "NM"}, ), promotes_inputs=[ - "actual_range", - ("target_range", Mission.Summary.RANGE), + ("actual_range", Mission.Summary.RANGE) + "target_range", ], promotes_outputs=[ ("range_resid", Mission.Constraints.RANGE_RESIDUAL)], From aa3baaff71211536b9f111685dfa3ce6f447f676 Mon Sep 17 00:00:00 2001 From: Bennett Date: Thu, 12 Dec 2024 12:40:36 -0500 Subject: [PATCH 13/16] typo fixes --- aviary/interface/methods_for_level2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aviary/interface/methods_for_level2.py b/aviary/interface/methods_for_level2.py index 90ce3c070..71baff01a 100644 --- a/aviary/interface/methods_for_level2.py +++ b/aviary/interface/methods_for_level2.py @@ -2779,7 +2779,7 @@ def _add_objectives(self): "val": self.target_range, "units": "NM"}, ), promotes_inputs=[ - ("actual_range", Mission.Summary.Range), + ("actual_range", Mission.Summary.RANGE), ("ascent_duration", Mission.Takeoff.ASCENT_DURATION), ], promotes_outputs=[("reg_objective", Mission.Objectives.RANGE)], @@ -2805,7 +2805,7 @@ def _add_objectives(self): range_resid={"val": 30, "units": "NM"}, ), promotes_inputs=[ - ("actual_range", Mission.Summary.RANGE) + ("actual_range", Mission.Summary.RANGE), "target_range", ], promotes_outputs=[ From 85ea83aa403cb6cb9ba1ac50e4b5bd3f6d577e82 Mon Sep 17 00:00:00 2001 From: Bennett Date: Thu, 12 Dec 2024 12:49:57 -0500 Subject: [PATCH 14/16] fixing more case sensitive typos --- aviary/interface/methods_for_level2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aviary/interface/methods_for_level2.py b/aviary/interface/methods_for_level2.py index 71baff01a..57ce4f1b3 100644 --- a/aviary/interface/methods_for_level2.py +++ b/aviary/interface/methods_for_level2.py @@ -1498,7 +1498,7 @@ def link_phases(self): connected=true_unless_mpi) self.model.connect(f'traj.{self.regular_phases[-1]}.timeseries.distance', - Mission.Summary.Range, + Mission.Summary.RANGE, src_indices=[-1], flat_src_indices=True) elif self.mission_method is SOLVED_2DOF: @@ -1628,7 +1628,7 @@ def link_phases(self): connect_map = { "taxi.mass": "traj.mass_initial", Mission.Takeoff.ROTATION_VELOCITY: "traj.SGMGroundroll_velocity_trigger", - "traj.distance_final": Mission.Summary.Range, + "traj.distance_final": Mission.Summary.RANGE, "traj.mass_final": Mission.Landing.TOUCHDOWN_MASS, } From eb283a2e461b0084cf60efb42a48a2b8ffcd4fd8 Mon Sep 17 00:00:00 2001 From: Bennett Date: Mon, 13 Jan 2025 11:03:20 -0500 Subject: [PATCH 15/16] update test value of Mission.Summary.Range in GwGm shooting to correct error in test execution --- aviary/validation_cases/benchmark_tests/test_bench_GwGm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py b/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py index 59d823bb7..84c248366 100644 --- a/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py +++ b/aviary/validation_cases/benchmark_tests/test_bench_GwGm.py @@ -212,7 +212,7 @@ def test_bench_GwGm_shooting(self): ) assert_near_equal( - prob.get_val(Mission.Summary.RANGE, units='NM'), 3675.0, tolerance=rtol + prob.get_val(Mission.Summary.RANGE, units='NM'), 3765.48, tolerance=rtol ) assert_near_equal( From 2f04c3d59fcce6c9e42cb0d3a58e343beccac04f Mon Sep 17 00:00:00 2001 From: Bennett Date: Mon, 13 Jan 2025 15:14:47 -0500 Subject: [PATCH 16/16] updates required due to changes made to accessing aviary_options --- aviary/subsystems/mass/gasp_based/fixed.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aviary/subsystems/mass/gasp_based/fixed.py b/aviary/subsystems/mass/gasp_based/fixed.py index 00815c1c4..a93524059 100644 --- a/aviary/subsystems/mass/gasp_based/fixed.py +++ b/aviary/subsystems/mass/gasp_based/fixed.py @@ -253,10 +253,12 @@ def initialize(self): add_aviary_option(self, Aircraft.CrewPayload.NUM_PASSENGERS) add_aviary_option(self, Aircraft.CrewPayload.PASSENGER_MASS_WITH_BAGS, units='lbm') + add_aviary_option(self, Aircraft.CrewPayload.Design.NUM_PASSENGERS) + add_aviary_option(self, Aircraft.CrewPayload.MAX_CARGO_MASS) def setup(self): add_aviary_input(self, Aircraft.CrewPayload.CARGO_MASS, val=10040) - add_aviary_input(self,Aircraft.CrewPayload.Design.CARGO_MASS, val=0) + add_aviary_input(self, Aircraft.CrewPayload.Design.CARGO_MASS, val=0) add_aviary_output(self, Aircraft.CrewPayload.PASSENGER_PAYLOAD_MASS, val=0) add_aviary_output(self, Aircraft.CrewPayload.TOTAL_PAYLOAD_MASS, val=0)