-
Notifications
You must be signed in to change notification settings - Fork 70
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
Glue Variables in User_Guide #615
base: main
Are you sure you want to change the base?
Conversation
…ses problem when I run. Remove a duplicate glue variable --verbosity.
…les_of_the_same_mission_at_different_UI_levels.ipynb
Replace Dynamic.Mission.MACH by Dynamic.Atmosphere.MACH.
Remove Aircraft.Engine.USE_PROPELLER_MAP.
aviary/docs/misc_resources/externally_supported_subsystems.ipynb
Outdated
Show resolved
Hide resolved
"command = 'dashboard'\n", | ||
"parser = argparse.ArgumentParser()\n", | ||
"_command_map[command][0](parser)\n", | ||
"actions = [*parser._get_optional_actions(),*parser._get_positional_actions()]\n", | ||
"for action in actions:\n", | ||
" opt_list = action.option_strings\n", | ||
" for opt in opt_list:\n", | ||
" if opt not in current_opt_vars:\n", | ||
" glue_variable(opt, md_code=True)\n", | ||
" current_opt_vars.append(opt)\n", | ||
" if action.dest not in current_opt_vars:\n", | ||
" glue_variable(action.dest, md_code=True)\n", | ||
" current_opt_vars.append(action.dest)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you are doing this so many times, this might be worth turning into a function, probably in doctape
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a function glue_actions()
but leave it locally. Otherwise, I would have to import _command_map
into utils/doctape.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
importing _command_map
in doctape should be fine
aviary/docs/user_guide/postprocessing_and_visualizing_results.ipynb
Outdated
Show resolved
Hide resolved
"import os\n", | ||
"import aviary.api as av\n", | ||
"av.get_path('examples/run_basic_aviary_example.py')" | ||
"from aviary.utils.doctape import glue_variable\n", | ||
"\n", | ||
"folder = av.get_path('examples')\n", | ||
"examples_dir = folder.relative_to(av.top_dir.parent)\n", | ||
"glue_variable(str(examples_dir), md_code=True)\n", | ||
"\n", | ||
"folder = av.get_path('examples/run_basic_aviary_example.py')\n", | ||
"run_example_dir = os.path.basename(folder)\n", | ||
"glue_variable(run_example_dir, md_code=True)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"import os\n", | |
"import aviary.api as av\n", | |
"av.get_path('examples/run_basic_aviary_example.py')" | |
"from aviary.utils.doctape import glue_variable\n", | |
"\n", | |
"folder = av.get_path('examples')\n", | |
"examples_dir = folder.relative_to(av.top_dir.parent)\n", | |
"glue_variable(str(examples_dir), md_code=True)\n", | |
"\n", | |
"folder = av.get_path('examples/run_basic_aviary_example.py')\n", | |
"run_example_dir = os.path.basename(folder)\n", | |
"glue_variable(run_example_dir, md_code=True)" | |
"import aviary.api as av\n", | |
"from aviary.utils.doctape import glue_variable\n", | |
"\n", | |
"examples_dir = av.get_path('examples').relative_to(av.top_dir.parent)\n", | |
"glue_variable(str(examples_dir), md_code=True)\n", | |
"\n", | |
"basic_example_filepath= av.get_path('examples/run_basic_aviary_example.py')\n", | |
"glue_variable(basic_example_filepath.name, md_code=True)" |
"import os\n", | ||
"import subprocess\n", | ||
"command = 'aviary run_mission models/small_single_aisle/small_single_aisle_GASP.csv'\n", | ||
"import aviary.api as av\n", | ||
"from aviary.utils.doctape import glue_variable\n", | ||
"\n", | ||
"str_folder = 'models/small_single_aisle'\n", | ||
"folder = av.get_path(str_folder)\n", | ||
"model_dir = folder.relative_to(av.top_dir.parent)\n", | ||
"glue_variable(str(model_dir), md_code=True)\n", | ||
"\n", | ||
"str_model = 'small_single_aisle_GASP.csv'\n", | ||
"folder = av.get_path(str_folder) / (str_model)\n", | ||
"file_name = os.path.basename(folder)\n", | ||
"glue_variable(file_name, md_code=False)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for anything returned by av.get_path (eg folder = av.get_path('examples/run_basic_aviary_example.py')
), you can use the name
attribute to get the filename, instead of importing os and using os.path.basename (os.path.basename(folder)
and folder.name
will both return 'run_basic_aviary_example.py'
, but you don't need the additional import)
"def glue_actions(cmd: str, curr_opts: list=[], display=True) -> list:\n", | ||
" parser = argparse.ArgumentParser()\n", | ||
" _command_map[cmd][0](parser)\n", | ||
" actions = [*parser._get_optional_actions(),*parser._get_positional_actions()]\n", | ||
" for action in actions: \n", | ||
" opt_list = action.option_strings\n", | ||
" for opt in opt_list:\n", | ||
" if opt not in curr_opts:\n", | ||
" glue_variable(opt, md_code=display)\n", | ||
" curr_opts.append(opt)\n", | ||
" if action.dest not in curr_opts:\n", | ||
" glue_variable(action.dest, md_code=display)\n", | ||
" curr_opts.append(action.dest)\n", | ||
"\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be part of doctape, instead of just local. I can help with that, if you'd like
"{glue:md}`input_deck` is the path to vehicle input deck .csv file.\n", | ||
"{glue:md}`--optimizer` is the name of the optimizer. The default is `SNOPT`.\n", | ||
"{glue:md}`--shooting` indicates that the integration method is shooting method instead of collocation scheme. The default is collocation.\n", | ||
"{glue:md}`--phase_info` is the path to phase info file. If it is missing, it depends on the integration method (collocation or shooting) and on the mission method (`settings:equations_of_motion` with value of `2DOF` or `height_energy`) which is defined in the .csv input file.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings:equations_of_motion
, 2DOF
, and height_energy
should be glued, in case they change
@@ -296,7 +377,7 @@ | |||
"\n", | |||
"If the output file exists, it will be overwritten.\n", | |||
"\n", | |||
"The engine format is specified by `-f` or `--data_format` with one of `FLOPS`, `GASP`, and `GASP_TS` string. If multiple are specified, the last one will be used.\n", | |||
"The engine format is specified by {glue:md}`-f` or {glue:md}`--data_format` with one of `FLOPS`, `GASP`, and `GASP_TS` string (`TS` stands for turbo shaft). If multiple are specified, the last one will be used.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The engine format is specified by {glue:md}`-f` or {glue:md}`--data_format` with one of `FLOPS`, `GASP`, and `GASP_TS` string (`TS` stands for turbo shaft). If multiple are specified, the last one will be used.\n", | |
"The engine format is specified by {glue:md}`-f` or {glue:md}`--data_format` with one of `FLOPS`, `GASP`, and `GASP_TS` string (`TS` stands for turboshaft). If multiple are specified, the last one will be used.\n", |
"glue_variable(OutMachType.HELICAL_MACH.name.title(), md_code=True)\n", | ||
"glue_variable(OutMachType.MACH.name.title(), md_code=True)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of converting these to title case, the documentation below should be corrected to match the actual values
"glue_variable(OutMachType.HELICAL_MACH.name.title(), md_code=True)\n", | |
"glue_variable(OutMachType.MACH.name.title(), md_code=True)\n", | |
"glue_variable(OutMachType.HELICAL_MACH.value, md_code=True)\n", | |
"glue_variable(OutMachType.MACH.value, md_code=True)\n", |
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Propeller Map Alternative\n", | ||
"\n", | ||
"The Hamilton Standard model has limitations where it can be applied; for model aircraft design, it is possible that users may want to provide their own data tables. Two sample data sets are provided in `models/propellers` folder: `general_aviation.prop` and `PropFan.prop`. In both cases, they are in `.csv` format and are converted from `GASP` maps: `general_aviation.map` and `PropFan.map` (see [Command Line Tools](aviary_commands.ipynb) for details). The difference between these two samples is that the generatl aviation sample uses helical Mach numbers as input while the propfan sample uses the free stream Mach numbers. Helical Mach numbers appear higher, due to the inclusion of the rotational component of the tip velocity. In our example, they range from 0.7 to 0.95. To determine which mach type in a GASP map is used, please look at the first integer of the first line. If it is 1, it uses helical mach; if it is 2, it uses free stream mach. To determin which mach type is an Aviary propeller file is used, please look at the second item in the header. It is either `Helical_Mach` or `Mach`.\n", | ||
"The Hamilton Standard model has limitations where it can be applied; for model aircraft design, it is possible that users may want to provide their own data tables. Two sample data sets are provided in {glue:md}`models/engines/propellers` folder: {glue:md}`general_aviation.prop` and {glue:md}`PropFan.prop`. In both cases, they are in `.csv` format and are converted from `GASP` maps: {glue:md}`general_aviation.map` and {glue:md}`PropFan.map` (see [Command Line Tools](aviary_commands.ipynb) for details). The difference between these two samples is that the generatl aviation sample uses helical Mach numbers as input while the propfan sample uses the free stream Mach numbers. Helical Mach numbers appear higher, due to the inclusion of the rotational component of the tip velocity. In our example, they range from 0.7 to 0.95. To determine which mach type in a GASP map is used, please look at the first integer of the first line. If it is 1, it uses helical mach; if it is 2, it uses free stream mach. To determin which mach type is an Aviary propeller file is used, please look at the second column in the header. It is either {glue:md}`Helical_Mach` or {glue:md}`Mach`.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The Hamilton Standard model has limitations where it can be applied; for model aircraft design, it is possible that users may want to provide their own data tables. Two sample data sets are provided in {glue:md}`models/engines/propellers` folder: {glue:md}`general_aviation.prop` and {glue:md}`PropFan.prop`. In both cases, they are in `.csv` format and are converted from `GASP` maps: {glue:md}`general_aviation.map` and {glue:md}`PropFan.map` (see [Command Line Tools](aviary_commands.ipynb) for details). The difference between these two samples is that the generatl aviation sample uses helical Mach numbers as input while the propfan sample uses the free stream Mach numbers. Helical Mach numbers appear higher, due to the inclusion of the rotational component of the tip velocity. In our example, they range from 0.7 to 0.95. To determine which mach type in a GASP map is used, please look at the first integer of the first line. If it is 1, it uses helical mach; if it is 2, it uses free stream mach. To determin which mach type is an Aviary propeller file is used, please look at the second column in the header. It is either {glue:md}`Helical_Mach` or {glue:md}`Mach`.\n", | |
"The Hamilton Standard model has limitations where it can be applied; for model aircraft design, it is possible that users may want to provide their own data tables. Two sample data sets are provided in {glue:md}`models/engines/propellers` folder: {glue:md}`general_aviation.prop` and {glue:md}`PropFan.prop`. In both cases, they are in `.csv` format and are converted from `GASP` maps: {glue:md}`general_aviation.map` and {glue:md}`PropFan.map` (see [Command Line Tools](aviary_commands.ipynb) for details). The difference between these two samples is that the generatl aviation sample uses helical Mach numbers as input while the propfan sample uses the free stream Mach numbers. Helical Mach numbers appear higher, due to the inclusion of the rotational component of the tip velocity. In our example, they range from 0.7 to 0.95. To determine which mach type in a GASP map is used, please look at the first integer of the first line. If it is 1, it uses helical mach; if it is 2, it uses free stream mach. To determin which mach type is an Aviary propeller file is used, please look at the second column in the header. It is either {glue:md}`helical_mach` or {glue:md}`mach`.\n", |
"fallout_snippet = '```\\n'\n", | ||
"fallout_snippet += str_problem_type + ',' + str_fallout\n", | ||
"fallout_snippet +='\\n```'\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same thing could be done here as well
"glue_variable(run_example_dir, md_code=True)\n", | ||
"\n", | ||
"# Get all functions of class AviaryProblem\n", | ||
"functs = inspect.getmembers(AviaryProblem, predicate=inspect.isfunction)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be useful here as well
https://github.com/OpenMDAO/Aviary/pull/615/files#r1932616258
"parser = argparse.ArgumentParser()\n", | ||
"_dashboard_setup_parser(parser)\n", | ||
"glueing_arguments = ['problem_recorder', 'driver_recorder', 'save', 'force']\n", | ||
"for action in parser._actions:\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's another place glue_actions could be used
Summary
Glue variables in user_guide and misc_resources folders.
Related Issues
Backwards incompatibilities
None
New Dependencies
None