Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve duplicate N2 report generation #632

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions aviary/docs/getting_started/onboarding_level1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -764,7 +762,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "aviary",
"language": "python",
"name": "python3"
},
Expand All @@ -778,7 +776,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
32 changes: 12 additions & 20 deletions aviary/interface/methods_for_level1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -145,9 +144,8 @@ def run_level_1(
prob = run_aviary(input_deck, phase_info, **kwargs)

# update n2 diagram after run.
outdir = Path(prob.get_reports_dir(force=True))
outfile = os.path.join(outdir, "n2.html")
if outdir != '':
os.makedirs(outdir, exist_ok=True)
om.n2(
prob,
outfile=outfile,
Expand All @@ -158,18 +156,19 @@ 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"
'input_deck',
metavar='indeck',
type=str,
nargs=1,
help='Name of vehicle input deck file',
)
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",
Expand All @@ -178,10 +177,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",
Expand All @@ -192,7 +189,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):
Expand All @@ -208,14 +206,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,
Expand Down
6 changes: 0 additions & 6 deletions aviary/interface/test/test_cmd_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down
Loading