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

Glue Variables in User_Guide #615

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open

Conversation

xjjiang
Copy link
Contributor

@xjjiang xjjiang commented Nov 28, 2024

Summary

Glue variables in user_guide and misc_resources folders.

Related Issues

  • Resolves #

Backwards incompatibilities

None

New Dependencies

None

@xjjiang xjjiang marked this pull request as draft November 28, 2024 01:54
xjjiang and others added 28 commits November 27, 2024 18:12
…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.
@xjjiang xjjiang marked this pull request as ready for review December 18, 2024 19:20
@xjjiang xjjiang requested a review from crecine December 18, 2024 19:21
@xjjiang xjjiang requested a review from jkirk5 December 31, 2024 19:17
aviary/docs/misc_resources/modeling_exercise.ipynb Outdated Show resolved Hide resolved
aviary/docs/misc_resources/modeling_exercise.ipynb Outdated Show resolved Hide resolved
aviary/docs/misc_resources/modeling_exercise.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/SGM_capabilities.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/aerodynamics.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/aviary_commands.ipynb Show resolved Hide resolved
aviary/docs/user_guide/aviary_commands.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/aviary_commands.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/aviary_commands.ipynb Outdated Show resolved Hide resolved
aviary/docs/misc_resources/modeling_exercise.ipynb Outdated Show resolved Hide resolved
aviary/docs/misc_resources/modeling_exercise.ipynb Outdated Show resolved Hide resolved
Comment on lines 674 to 686
"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"
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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/reserve_missions.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/reserve_missions.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/step_by_step_external_guide.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/variable_hierarchy.ipynb Outdated Show resolved Hide resolved
aviary/docs/user_guide/variable_hierarchy.ipynb Outdated Show resolved Hide resolved
Comment on lines +39 to +49
"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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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)"

Comment on lines +127 to +140
"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",
Copy link
Contributor

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)

Comment on lines +188 to +201
"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",
Copy link
Contributor

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",
Copy link
Contributor

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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",

Comment on lines +354 to +355
"glue_variable(OutMachType.HELICAL_MACH.name.title(), md_code=True)\n",
"glue_variable(OutMachType.MACH.name.title(), md_code=True)\n",
Copy link
Contributor

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

Suggested change
"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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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",

Comment on lines +28 to +30
"fallout_snippet = '```\\n'\n",
"fallout_snippet += str_problem_type + ',' + str_fallout\n",
"fallout_snippet +='\\n```'\n",
Copy link
Contributor

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"parser = argparse.ArgumentParser()\n",
"_dashboard_setup_parser(parser)\n",
"glueing_arguments = ['problem_recorder', 'driver_recorder', 'save', 'force']\n",
"for action in parser._actions:\n",
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants