From 1a16d79b534bfda24d7906673bf44571144c13d4 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Sun, 15 Sep 2024 08:25:43 -0700 Subject: [PATCH 01/10] for override variables, print values and units --- aviary/variable_info/functions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aviary/variable_info/functions.py b/aviary/variable_info/functions.py index 6dd7bee37..6e91d70b3 100644 --- a/aviary/variable_info/functions.py +++ b/aviary/variable_info/functions.py @@ -146,12 +146,14 @@ def name_filter(name): if overridden_outputs: print("\nThe following variables have been overridden:") for prom_name in sorted(overridden_outputs): - print(f" '{prom_name}") + item = aviary_inputs.get_item(prom_name) + print(f" '{prom_name} {item[0]} {item[1]}") if external_overridden_outputs: print("\nThe following variables have been overridden by an external subsystem:") for prom_name in sorted(external_overridden_outputs): - print(f" '{prom_name}") + item = aviary_inputs.get_item(prom_name) + print(f" '{prom_name} {item[0]} {item[1]}") return overridden_outputs From d67bb32670c22c9a873826e803d24b7bc1ae9b11 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Thu, 19 Sep 2024 08:31:26 -0700 Subject: [PATCH 02/10] do not print values and units for override in an external subsystem --- aviary/variable_info/functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aviary/variable_info/functions.py b/aviary/variable_info/functions.py index 6e91d70b3..0d9854d81 100644 --- a/aviary/variable_info/functions.py +++ b/aviary/variable_info/functions.py @@ -152,8 +152,8 @@ def name_filter(name): if external_overridden_outputs: print("\nThe following variables have been overridden by an external subsystem:") for prom_name in sorted(external_overridden_outputs): - item = aviary_inputs.get_item(prom_name) - print(f" '{prom_name} {item[0]} {item[1]}") + # do not print values because they will be updated later. + print(f" '{prom_name}") return overridden_outputs From abf8c2dbf1ed28ba818c6095e136ab87380f9c15 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Tue, 24 Sep 2024 09:37:17 -0700 Subject: [PATCH 03/10] print only when verbosity > 0 --- aviary/variable_info/functions.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aviary/variable_info/functions.py b/aviary/variable_info/functions.py index 0d9854d81..7ba21ce90 100644 --- a/aviary/variable_info/functions.py +++ b/aviary/variable_info/functions.py @@ -4,6 +4,7 @@ from openmdao.core.component import Component from aviary.utils.aviary_values import AviaryValues +from aviary.variable_info.variables import Settings from aviary.variable_info.variable_meta_data import _MetaData # --------------------------- @@ -144,15 +145,17 @@ def name_filter(name): group.promotes(comp.name, inputs=in_var_names, outputs=comp_promoted_outputs) if overridden_outputs: - print("\nThe following variables have been overridden:") + if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: + print("\nThe following variables have been overridden:") for prom_name in sorted(overridden_outputs): item = aviary_inputs.get_item(prom_name) print(f" '{prom_name} {item[0]} {item[1]}") if external_overridden_outputs: - print("\nThe following variables have been overridden by an external subsystem:") + if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: + print("\nThe following variables have been overridden by an external subsystem:") for prom_name in sorted(external_overridden_outputs): - # do not print values because they will be updated later. + # do not print values because they will be updated by an external subsystem later. print(f" '{prom_name}") return overridden_outputs From de2eebd69f9a8590ad902326355e8bff9a38e77c Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Tue, 24 Sep 2024 14:44:54 -0700 Subject: [PATCH 04/10] indent the 'for' loop --- aviary/variable_info/functions.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aviary/variable_info/functions.py b/aviary/variable_info/functions.py index 7ba21ce90..61c15dcb8 100644 --- a/aviary/variable_info/functions.py +++ b/aviary/variable_info/functions.py @@ -147,16 +147,16 @@ def name_filter(name): if overridden_outputs: if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: print("\nThe following variables have been overridden:") - for prom_name in sorted(overridden_outputs): - item = aviary_inputs.get_item(prom_name) - print(f" '{prom_name} {item[0]} {item[1]}") + for prom_name in sorted(overridden_outputs): + item = aviary_inputs.get_item(prom_name) + print(f" '{prom_name} {item[0]} {item[1]}") if external_overridden_outputs: if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: print("\nThe following variables have been overridden by an external subsystem:") - for prom_name in sorted(external_overridden_outputs): - # do not print values because they will be updated by an external subsystem later. - print(f" '{prom_name}") + for prom_name in sorted(external_overridden_outputs): + # do not print values because they will be updated by an external subsystem later. + print(f" '{prom_name}") return overridden_outputs From 5749929d1a789cb5c21a24f50c7936483937fe17 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Tue, 24 Sep 2024 14:48:46 -0700 Subject: [PATCH 05/10] minor update --- aviary/variable_info/functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aviary/variable_info/functions.py b/aviary/variable_info/functions.py index 61c15dcb8..c280e647d 100644 --- a/aviary/variable_info/functions.py +++ b/aviary/variable_info/functions.py @@ -148,8 +148,8 @@ def name_filter(name): if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: print("\nThe following variables have been overridden:") for prom_name in sorted(overridden_outputs): - item = aviary_inputs.get_item(prom_name) - print(f" '{prom_name} {item[0]} {item[1]}") + val, units = aviary_inputs.get_item(prom_name) + print(f" '{prom_name} {val} {units}") if external_overridden_outputs: if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: From 79e3cc3af522d99979de7b5261d294979b268982 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Thu, 26 Sep 2024 08:38:09 -0700 Subject: [PATCH 06/10] add a comment --- aviary/variable_info/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aviary/variable_info/functions.py b/aviary/variable_info/functions.py index c280e647d..4c95eee50 100644 --- a/aviary/variable_info/functions.py +++ b/aviary/variable_info/functions.py @@ -145,7 +145,7 @@ def name_filter(name): group.promotes(comp.name, inputs=in_var_names, outputs=comp_promoted_outputs) if overridden_outputs: - if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: + if aviary_inputs.get_val(Settings.VERBOSITY).value >= 1: # Verbosity.BRIEF print("\nThe following variables have been overridden:") for prom_name in sorted(overridden_outputs): val, units = aviary_inputs.get_item(prom_name) From 7b785f2d29139312552fea647371d4074b011098 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Thu, 26 Sep 2024 08:38:40 -0700 Subject: [PATCH 07/10] add verbosity check before print --- .../propulsion/propeller/hamilton_standard.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/aviary/subsystems/propulsion/propeller/hamilton_standard.py b/aviary/subsystems/propulsion/propeller/hamilton_standard.py index 67e7e0ae1..fbc15924c 100644 --- a/aviary/subsystems/propulsion/propeller/hamilton_standard.py +++ b/aviary/subsystems/propulsion/propeller/hamilton_standard.py @@ -723,7 +723,7 @@ def compute(self, inputs, outputs): CP_CLi_table[CL_tab_idx][:cli_len], XPCLI[CL_tab_idx], CPE1X) if (run_flag == 1): ichck = ichck + 1 - if verbosity == Verbosity.DEBUG or ichck <= Verbosity.BRIEF: + if verbosity >= Verbosity.DEBUG or ichck <= 1: if (run_flag == 1): warnings.warn( f"Mach,VTMACH,J,power_coefficient,CP_Eff =: {inputs[Dynamic.Mission.MACH][i_node]},{inputs['tip_mach'][i_node]},{inputs['advance_ratio'][i_node]},{power_coefficient},{CP_Eff}") @@ -756,10 +756,11 @@ def compute(self, inputs, outputs): except IndexError: raise om.AnalysisError( "interp failed for CTT (thrust coefficient) in hamilton_standard.py") - if (run_flag > 1): + if run_flag > 1: NERPT = 2 - print( - f"ERROR IN PROP. PERF.-- NERPT={NERPT}, run_flag={run_flag}") + if verbosity >= Verbosity.DEBUG: + print( + f"ERROR IN PROP. PERF.-- NERPT={NERPT}, run_flag={run_flag}") BLLL[ibb], run_flag = _unint( advance_ratio_array[J_begin:J_begin+4], BLL[J_begin:J_begin+4], inputs['advance_ratio'][i_node]) @@ -793,8 +794,9 @@ def compute(self, inputs, outputs): NERPT = 5 if (run_flag == 1): # off lower bound only. - print( - f"ERROR IN PROP. PERF.-- NERPT={NERPT}, run_flag={run_flag}, il = {il}, kl = {kl}") + if verbosity >= Verbosity.DEBUG: + print( + f"ERROR IN PROP. PERF.-- NERPT={NERPT}, run_flag={run_flag}, il = {il}, kl = {kl}") if (inputs['advance_ratio'][i_node] != 0.0): ZMCRT, run_flag = _unint( advance_ratio_array2, mach_corr_table[CL_tab_idx], inputs['advance_ratio'][i_node]) @@ -848,7 +850,7 @@ def compute(self, inputs, outputs): xft, run_flag = _unint(num_blades_arr, XXXFT, num_blades) # NOTE this could be handled via the metamodel comps (extrapolate flag) - if ichck > 0: + if verbosity >= Verbosity.DEBUG and ichck > 0: print(f" table look-up error = {ichck} (if you go outside the tables.)") outputs['thrust_coefficient'][i_node] = ct From ff710bcf5631292832e4545ec730e6cfc917d657 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Thu, 26 Sep 2024 17:54:00 -0700 Subject: [PATCH 08/10] print warning only if verbosity >= 1 in mass/gasp_based/fuel.py --- aviary/subsystems/mass/gasp_based/fuel.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aviary/subsystems/mass/gasp_based/fuel.py b/aviary/subsystems/mass/gasp_based/fuel.py index df1734897..f0ac2adcf 100644 --- a/aviary/subsystems/mass/gasp_based/fuel.py +++ b/aviary/subsystems/mass/gasp_based/fuel.py @@ -4,8 +4,9 @@ from aviary.constants import GRAV_ENGLISH_LBM from aviary.utils.aviary_values import AviaryValues +from aviary.variable_info.enums import Verbosity from aviary.variable_info.functions import add_aviary_input, add_aviary_output -from aviary.variable_info.variables import Aircraft, Mission +from aviary.variable_info.variables import Aircraft, Mission, Settings check = 1 @@ -136,10 +137,12 @@ def compute(self, inputs, outputs): design_fuel_vol - geometric_fuel_vol ) - if (req_fuel_wt > max_wingfuel_wt) and (design_fuel_vol > max_wingfuel_vol): - print("Warning: req_fuel_mass > max_wingfuel_mass, adding a body tank") - if (req_fuel_wt < max_wingfuel_wt) and (design_fuel_vol > max_wingfuel_vol): - print("Warning: design_fuel_vol > max_wingfuel_vol, adding a body tank") + verbosity = self.options['aviary_options'].get_val(Settings.VERBOSITY) + if verbosity >= Verbosity.BRIEF: + if (req_fuel_wt > max_wingfuel_wt) and (design_fuel_vol > max_wingfuel_vol): + print("Warning: req_fuel_mass > max_wingfuel_mass, adding a body tank") + if (req_fuel_wt < max_wingfuel_wt) and (design_fuel_vol > max_wingfuel_vol): + print("Warning: design_fuel_vol > max_wingfuel_vol, adding a body tank") extra_fuel_wt = req_fuel_wt - max_wingfuel_wt if smooth: From e25a5bbaa6f993ebb1ca7fe264d3f709aea0e4d9 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Fri, 27 Sep 2024 10:07:55 -0700 Subject: [PATCH 09/10] print warning only if verbosity >= 1 in geometry/gasp_based/fuselage.py --- aviary/subsystems/geometry/gasp_based/fuselage.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/aviary/subsystems/geometry/gasp_based/fuselage.py b/aviary/subsystems/geometry/gasp_based/fuselage.py index 8fcb23859..724fe20fd 100644 --- a/aviary/subsystems/geometry/gasp_based/fuselage.py +++ b/aviary/subsystems/geometry/gasp_based/fuselage.py @@ -2,9 +2,9 @@ import openmdao.api as om from aviary.utils.aviary_values import AviaryValues -from aviary.variable_info.options import get_option_defaults +from aviary.variable_info.enums import Verbosity from aviary.variable_info.functions import add_aviary_input, add_aviary_output -from aviary.variable_info.variables import Aircraft +from aviary.variable_info.variables import Aircraft, Settings def sigX(x): @@ -51,6 +51,7 @@ def setup(self): ) def compute(self, inputs, outputs): + verbosity = self.options['aviary_options'].get_val(Settings.VERBOSITY) aviary_options: AviaryValues = self.options['aviary_options'] seats_abreast = aviary_options.get_val(Aircraft.Fuselage.NUM_SEATS_ABREAST) seat_width = aviary_options.get_val(Aircraft.Fuselage.SEAT_WIDTH, units='inch') @@ -63,8 +64,9 @@ def compute(self, inputs, outputs): cabin_width = seats_abreast * seat_width + num_aisle * aisle_width + 12 - if PAX < 1: - print("Warning: you have not specified at least one passenger") + if PAX < 1: + if verbosity >= Verbosity.BRIEF: + print("Warning: you have not specified at least one passenger") # single seat across cabin_len_a = PAX * seat_pitch / 12 From ebf8da407dfa7e828fdec3668b3d83ddace422da Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Fri, 27 Sep 2024 12:01:33 -0700 Subject: [PATCH 10/10] Update fuselage.py --- aviary/subsystems/geometry/gasp_based/fuselage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aviary/subsystems/geometry/gasp_based/fuselage.py b/aviary/subsystems/geometry/gasp_based/fuselage.py index 724fe20fd..e6d7ea1f6 100644 --- a/aviary/subsystems/geometry/gasp_based/fuselage.py +++ b/aviary/subsystems/geometry/gasp_based/fuselage.py @@ -64,7 +64,7 @@ def compute(self, inputs, outputs): cabin_width = seats_abreast * seat_width + num_aisle * aisle_width + 12 - if PAX < 1: + if PAX < 1: if verbosity >= Verbosity.BRIEF: print("Warning: you have not specified at least one passenger")