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 2 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
25 changes: 12 additions & 13 deletions aviary/interface/methods_for_level1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
Loading