From a444a0eda806986d563aa705729cbe908cb8ceac Mon Sep 17 00:00:00 2001 From: jkirk5 Date: Fri, 13 Dec 2024 16:26:13 -0500 Subject: [PATCH 1/4] moved n2 file generation to always use openmdao report directory --- aviary/interface/methods_for_level1.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/aviary/interface/methods_for_level1.py b/aviary/interface/methods_for_level1.py index 35b59dc61..c0739b934 100644 --- a/aviary/interface/methods_for_level1.py +++ b/aviary/interface/methods_for_level1.py @@ -110,7 +110,7 @@ def run_aviary(aircraft_filename, phase_info, optimizer=None, def run_level_1( input_deck, - outdir='output', + # outdir='output', optimizer='SNOPT', phase_info=None, max_iter=50, @@ -145,9 +145,8 @@ def run_level_1( prob = run_aviary(input_deck, phase_info, **kwargs) # update n2 diagram after run. + outdir = Path(prob.get_reports_dir()) outfile = os.path.join(outdir, "n2.html") - if outdir != '': - os.makedirs(outdir, exist_ok=True) om.n2( prob, outfile=outfile, @@ -161,15 +160,15 @@ def _setup_level1_parser(parser): def_outdir = os.path.join(os.getcwd(), "output") parser.add_argument('input_deck', metavar='indeck', type=str, nargs=1, help='Name of vehicle input deck file') - parser.add_argument( - "-o", "--outdir", default=def_outdir, help="Directory to write outputs" - ) + # parser.add_argument( + # "-o", "--outdir", default=def_outdir, help="Directory to write outputs" + # ) parser.add_argument( "--optimizer", type=str, - default='SNOPT', + default='IPOPT', help="Name of optimizer", - choices=("SNOPT", "IPOPT", "SLSQP", "None") + choices=("SNOPT", "IPOPT", "SLSQP", "None"), ) parser.add_argument( "--phase_info", @@ -208,14 +207,14 @@ def _exec_level1(args, user_args): if isinstance(args.input_deck, list): args.input_deck = args.input_deck[0] - if args.outdir == os.path.join(os.getcwd(), "output"): - # if default outdir, add the input deck name - file_name_stem = Path(args.input_deck).stem - args.outdir = args.outdir + os.sep + file_name_stem + # if args.outdir == os.path.join(os.getcwd(), "output"): + # # if default outdir, add the input deck name + # file_name_stem = Path(args.input_deck).stem + # args.outdir = args.outdir + os.sep + file_name_stem prob = run_level_1( input_deck=args.input_deck, - outdir=args.outdir, + # outdir=args.outdir, optimizer=args.optimizer, phase_info=args.phase_info, max_iter=args.max_iter, From 1cb30dd972c19293c2b19c27cc32012bd7c08455 Mon Sep 17 00:00:00 2001 From: jkirk5 Date: Fri, 13 Dec 2024 16:40:45 -0500 Subject: [PATCH 2/4] docs cleanup --- aviary/docs/getting_started/onboarding_level1.ipynb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/aviary/docs/getting_started/onboarding_level1.ipynb b/aviary/docs/getting_started/onboarding_level1.ipynb index c6afb1456..43a21ca91 100644 --- a/aviary/docs/getting_started/onboarding_level1.ipynb +++ b/aviary/docs/getting_started/onboarding_level1.ipynb @@ -111,8 +111,6 @@ "source": [ "Let us discuss these in more detail:\n", "\n", - "- `-o ––outdir`: Use specified directory to write output. The default is the current directory.\n", - "\n", "- `--optimizer`: Name of optimizer. Choices are: `SNOPT`, `IPOPT`, `SLSQP`, and `None`. The default is `SNOPT`. If optimizer is `None`, it will be set to `IPOPT` or `SNOPT` depending on the analysis scheme. The optimization objective is fuel burn for level 1 runs. The objective is\n", " - `mission:objectives:fuel` if `mission_method` is `GASP` \n", " - `fuel_burned` if `mission_method` is `FLOPS`.\n", @@ -764,7 +762,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "aviary", "language": "python", "name": "python3" }, @@ -778,7 +776,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.3" } }, "nbformat": 4, From 5c1f242a05a0b6b545ef75d02b67fed2c4aa2e02 Mon Sep 17 00:00:00 2001 From: jkirk5 Date: Fri, 27 Dec 2024 11:56:56 -0500 Subject: [PATCH 3/4] removed commented out lines --- aviary/interface/methods_for_level1.py | 28 ++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/aviary/interface/methods_for_level1.py b/aviary/interface/methods_for_level1.py index c0739b934..3482953fd 100644 --- a/aviary/interface/methods_for_level1.py +++ b/aviary/interface/methods_for_level1.py @@ -110,7 +110,6 @@ def run_aviary(aircraft_filename, phase_info, optimizer=None, def run_level_1( input_deck, - # outdir='output', optimizer='SNOPT', phase_info=None, max_iter=50, @@ -158,11 +157,13 @@ def run_level_1( def _setup_level1_parser(parser): def_outdir = os.path.join(os.getcwd(), "output") - parser.add_argument('input_deck', metavar='indeck', type=str, - nargs=1, help='Name of vehicle input deck file') - # parser.add_argument( - # "-o", "--outdir", default=def_outdir, help="Directory to write outputs" - # ) + parser.add_argument( + 'input_deck', + metavar='indeck', + type=str, + nargs=1, + help='Name of vehicle input deck file', + ) parser.add_argument( "--optimizer", type=str, @@ -177,10 +178,8 @@ def _setup_level1_parser(parser): help="Path to phase info file" ) parser.add_argument( - "--max_iter", - type=int, - default=50, - help="maximum number of iterations") + "--max_iter", type=int, default=50, help="maximum number of iterations" + ) parser.add_argument( "--shooting", action="store_true", @@ -191,7 +190,8 @@ def _setup_level1_parser(parser): type=int, default=1, help="verbosity settings: 0=quiet, 1=brief, 2=verbose, 3=debug", - choices=(0, 1, 2, 3)) + choices=(0, 1, 2, 3), + ) def _exec_level1(args, user_args): @@ -207,14 +207,8 @@ def _exec_level1(args, user_args): if isinstance(args.input_deck, list): args.input_deck = args.input_deck[0] - # if args.outdir == os.path.join(os.getcwd(), "output"): - # # if default outdir, add the input deck name - # file_name_stem = Path(args.input_deck).stem - # args.outdir = args.outdir + os.sep + file_name_stem - prob = run_level_1( input_deck=args.input_deck, - # outdir=args.outdir, optimizer=args.optimizer, phase_info=args.phase_info, max_iter=args.max_iter, From f6f859c9c5b1d3d5b6e7aac2b6c2f5fd341cbbb5 Mon Sep 17 00:00:00 2001 From: Kenneth-T-Moore Date: Tue, 7 Jan 2025 16:33:59 -0500 Subject: [PATCH 4/4] Workaround for problem with the reports subsystem's interaction with env vars when run in a nested subprocess call. --- aviary/interface/methods_for_level1.py | 3 +-- aviary/interface/test/test_cmd_entry_points.py | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/aviary/interface/methods_for_level1.py b/aviary/interface/methods_for_level1.py index 3482953fd..ce3393f99 100644 --- a/aviary/interface/methods_for_level1.py +++ b/aviary/interface/methods_for_level1.py @@ -144,7 +144,7 @@ def run_level_1( prob = run_aviary(input_deck, phase_info, **kwargs) # update n2 diagram after run. - outdir = Path(prob.get_reports_dir()) + outdir = Path(prob.get_reports_dir(force=True)) outfile = os.path.join(outdir, "n2.html") om.n2( prob, @@ -156,7 +156,6 @@ def run_level_1( def _setup_level1_parser(parser): - def_outdir = os.path.join(os.getcwd(), "output") parser.add_argument( 'input_deck', metavar='indeck', diff --git a/aviary/interface/test/test_cmd_entry_points.py b/aviary/interface/test/test_cmd_entry_points.py index c255fe9a2..abcee83db 100644 --- a/aviary/interface/test/test_cmd_entry_points.py +++ b/aviary/interface/test/test_cmd_entry_points.py @@ -35,12 +35,6 @@ def bench_test_IPOPT_cmd(self): cmd = 'aviary run_mission models/test_aircraft/aircraft_for_bench_GwGm.csv --optimizer IPOPT --max_iter 1' self.run_and_test_cmd(cmd) - @require_pyoptsparse(optimizer="IPOPT") - def bench_test_IPOPT_cmd(self): - cmd = 'aviary run_mission models/test_aircraft/aircraft_for_bench_GwGm.csv' \ - ' --optimizer IPOPT --max_iter 1 --shooting' - self.run_and_test_cmd(cmd) - @require_pyoptsparse(optimizer="IPOPT") def bench_test_phase_info_cmd(self): cmd = 'aviary run_mission models/test_aircraft/aircraft_for_bench_GwGm.csv --optimizer IPOPT --max_iter 1' \