Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/main' into cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jkirk5 committed Jan 14, 2025
2 parents a319a15 + d4cc805 commit bd9caa0
Show file tree
Hide file tree
Showing 206 changed files with 2,693 additions and 2,532 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
jobs:

latest_benchmarks:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 90

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
jobs:

latest_docs:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 90

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

pre_commit:
# run pre-commit checks
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: pre-commit/[email protected]

test_ubuntu:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_workflow_dev_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:

test_ubuntu:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_workflow_no_dev_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:

test_ubuntu_no_dev_install:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

timeout-minutes: 90

Expand Down
2 changes: 1 addition & 1 deletion aviary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from aviary.variable_info.options import get_option_defaults, is_option
from aviary.utils.develop_metadata import add_meta_data, update_meta_data
from aviary.variable_info.variable_meta_data import CoreMetaData
from aviary.variable_info.functions import add_aviary_input, add_aviary_output, get_units, override_aviary_vars, setup_trajectory_params
from aviary.variable_info.functions import add_aviary_input, add_aviary_output, get_units, override_aviary_vars, setup_trajectory_params, setup_model_options
from aviary.utils.merge_hierarchies import merge_hierarchies
from aviary.utils.merge_variable_metadata import merge_meta_data
from aviary.utils.named_values import NamedValues, get_keys, get_items, get_values
Expand Down
24 changes: 0 additions & 24 deletions aviary/docs/developer_guide/doctape.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,41 +82,17 @@
" doctape.glue_variable(key, md_code=True)\n",
" class_list += f'- `{key}` {val}\\n'\n",
"\n",
"# testing_list = ''\n",
"# for key,val in testing_functions.items():\n",
"# testing_list += f'- `{key}` {val}\\n'\n",
"\n",
"utility_list = '```{eval-rst}\\n'\n",
"for key in utility_functions:\n",
" doctape.glue_variable(key, md_code=True)\n",
" utility_list += ' '*4+f'.. autofunction:: aviary.utils.doctape.{key}\\n{\" \"*8}:noindex:\\n\\n'\n",
"utility_list += '```'\n",
"\n",
"# testing_list = '```{eval-rst}\\n'\n",
"# for key in testing_functions:\n",
"# utils.glue_variable(key, md_code=True)\n",
"# testing_list += ' '*4+f'.. autofunction:: aviary.utils.doctape.{key}\\n{\" \"*8}:noindex:\\n\\n'\n",
"# testing_list += '```'\n",
"\n",
"# testing_list = '<details>\\n\\n<summary>Function Docs</summary>\\n\\n'\n",
"testing_list = '```{eval-rst}\\n'\n",
"for key in testing_functions:\n",
" doctape.glue_variable(key, md_code=True)\n",
" testing_list += ' '*4+f'.. autofunction:: aviary.utils.doctape.{key}\\n{\" \"*8}:noindex:\\n\\n'\n",
"testing_list += '```'\n",
"# testing_list += '\\n\\n</details>'\n",
"\n",
"# glue_list = ''\n",
"# for key,val in glue_functions.items():\n",
"# glue_list += f'- `{key}` {key}\\n'\n",
"\n",
"# glue_list = ''\n",
"# for key in glue_functions:\n",
"# # doc_str = inspect.getdoc(imported_functions[key])\n",
"# doc_str = imported_functions[key].__doc__.split('\\n')[1]\n",
"# # doc_str = '\\n'.join([s+' ' for s in imported_functions[key].__doc__.split('\\n')])\n",
"# print(doc_str)\n",
"# glue_list += f'- `{key}`: {doc_str}\\n'\n",
"\n",
"glue_list = '```{eval-rst}\\n'\n",
"for key in glue_functions:\n",
Expand Down
73 changes: 69 additions & 4 deletions aviary/docs/developer_guide/doctape_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,12 @@
"outputs": [],
"source": [
"# Testing Cell\n",
"from aviary.api import Mission\n",
"from aviary.api import Aircraft\n",
"from aviary.utils.doctape import glue_variable, get_previous_line, get_variable_name\n",
"\n",
"glue_variable('value', Mission.Design.MACH, md_code=True)\n",
"glue_variable('value', Aircraft.Design.EMPTY_MASS, md_code=True)\n",
"glue_variable('var_value_code', get_previous_line(), md_code=True)\n",
"glue_variable(get_variable_name(Mission.Design.MACH), md_code=True)\n",
"glue_variable(get_variable_name(Aircraft.Design.EMPTY_MASS), md_code=True)\n",
"glue_variable('var_name_code', get_previous_line(), md_code=True)\n"
]
},
Expand All @@ -423,7 +423,7 @@
"If you want to glue the name of a variable, instead of the value that variable holds, you can use the {glue:md}`get_variable_name` to extract it.\n",
"\n",
"For example:\n",
"Using {glue:md}`var_value_code` will result in {glue:md}`value`, whereas using {glue:md}`var_name_code` will result in {glue:md}`Mission.Design.MACH`\n",
"Using {glue:md}`var_value_code` will result in {glue:md}`value`, whereas using {glue:md}`var_name_code` will result in {glue:md}`Aircraft.Design.EMPTY_MASS`\n",
"\n",
"### {glue:md}`get_attribute_name`\n",
"allows users to get the name of object attributes in order to glue them into documentation. This works well for Enums or Class Variables that have unique values."
Expand Down Expand Up @@ -482,6 +482,71 @@
"p1_alt = get_value(simplified_dict, 'phase1.altitude.val')\n",
"print(p1_alt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-cell"
]
},
"outputs": [],
"source": [
"# Testing Cell\n",
"from aviary.utils.doctape import glue_variable, check_args, get_all_keys, get_previous_line\n",
"from aviary.api import Aircraft, Mission\n",
"\n",
"glue_variable(Aircraft.__name__)\n",
"glue_variable(Mission.__name__)\n",
"\n",
"track_layers = 'track_layers'\n",
"check_args(get_all_keys, track_layers)\n",
"glue_variable(track_layers)\n",
"\n",
"get_all_keys(Mission, track_layers='Mission')\n",
"track_layers_with_name = get_previous_line().split(', ')[1].split(')')[0]\n",
"glue_variable('track_layers_with_Mission', track_layers_with_name, display=False)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These can also be used to recursively get all of the attributes from a complex object, like the {glue:md}`Aircraft` or {glue:md}`Mission` hierarchies.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aviary.utils.doctape import get_all_keys, get_value, glue_keys\n",
"from aviary.api import Mission\n",
"\n",
"k1=get_all_keys(Mission)\n",
"print(k1[:5]) # Display the first 5 keys in Mission\n",
"k2=get_all_keys(Mission, track_layers=True)\n",
"print(k2[:5]) # Display the first 5 keys in Mission\n",
"k3=get_all_keys(Mission, track_layers='Mission')\n",
"print(k3[:5]) # Display the first 5 keys in Mission\n",
"\n",
"glue_keys(Mission, False)\n",
"\n",
"print(get_value(Mission,'Constraints.GEARBOX_SHAFT_POWER_RESIDUAL'))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If {glue:md}`get_all_keys` is used on an object like {glue:md}`Mission` without specifying a value for {glue:md}`track_layers` will return all of the uniquely named attributes of the object (such as {glue:md}GEARBOX_SHAFT_POWER_RESIDUAL). Setting {glue:md}`track_layers` to `True` will get all of the attributes in dot notation, but will not include the name of the original object ({glue:md}Constraints.GEARBOX_SHAFT_POWER_RESIDUAL). If you want the full name of the attribute, including the name of the original object, you can use that name as the value of {glue:md}`track_layers` (using {glue:md}track_layers_with_Mission gives us access to {glue:md}Mission.Constraints.GEARBOX_SHAFT_POWER_RESIDUAL)\n",
"\n",
"Using {glue:md}`glue_keys` handles this for us automatically by using the `__name__` attribute of the object passed to it as the value of {glue:md}`track_layers`.\n",
"\n",
"As with the dict_of_dicts, we can recusively get the value of an attribute using the full path along with {glue:md}`get_value`."
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion aviary/docs/examples/modified_aircraft.csv
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ aircraft:wing:aeroelastic_tailoring_factor,0.0,unitless
aircraft:wing:airfoil_technology,1.92669766647637,unitless
aircraft:wing:area,1370.0,ft**2
aircraft:wing:aspect_ratio,11.02091,unitless
aircraft:wing:bending_material_mass_scaler,1.0,unitless
aircraft:wing:BENDING_MATERIAL_MASS_SCALER,1.0,unitless
aircraft:wing:chord_per_semispan,0.31,0.23,0.084,unitless
aircraft:wing:composite_fraction,0.2,unitless
aircraft:wing:control_surface_area,137,ft**2
Expand Down
5 changes: 4 additions & 1 deletion aviary/docs/getting_started/onboarding_level3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"\n",
"import aviary.api as av\n",
"from aviary.validation_cases.validation_tests import get_flops_inputs\n",
"from aviary.variable_info.functions import setup_model_options\n",
"\n",
"\n",
"prob = om.Problem(model=om.Group())\n",
Expand Down Expand Up @@ -459,6 +460,8 @@
"]\n",
"av.set_aviary_input_defaults(prob.model, varnames, aviary_inputs)\n",
"\n",
"av.setup_model_options(prob, aviary_inputs)\n",
"\n",
"prob.setup(force_alloc_complex=True)\n",
"\n",
"av.set_aviary_initial_values(prob, aviary_inputs)\n",
Expand Down Expand Up @@ -709,7 +712,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@
"]\n",
"av.set_aviary_input_defaults(prob.model, varnames, aviary_inputs)\n",
"\n",
"av.setup_model_options(prob, aviary_inputs)\n",
"\n",
"prob.setup(force_alloc_complex=True)\n",
"\n",
"av.set_aviary_initial_values(prob, aviary_inputs)\n",
Expand Down Expand Up @@ -505,7 +507,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
5 changes: 3 additions & 2 deletions aviary/docs/user_guide/variable_metadata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
" 'option': False,\n",
" 'types': None,\n",
" 'historical_name': None,\n",
" 'multivalue': False,\n",
" }\n",
"\n",
"meta_data = {}\n",
Expand Down Expand Up @@ -447,7 +448,7 @@
"hash": "e6c7471802ed76737b16357fb02af5587f3a4cbee5ea7658f3f9a6981469039b"
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -461,7 +462,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.12.3"
},
"orphan": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ def compute(self, inputs, outputs):
prob.driver = om.ScipyOptimizeDriver()
prob.driver.options['optimizer'] = 'SLSQP'
prob.driver.options['tol'] = 1e-8

# Set up the problem
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=om.PromotionWarning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
authors: Jatin Soni, Eliot Aretskin
Multi Mission Optimization Example using Aviary
In this example, a monolithic optimization is created by instantiating two aviary problems
using typical AviaryProblem calls like load_inputs(), check_and_preprocess_payload(),
etc. Once those problems are setup and all of their phases are linked together, we copy
those problems as group into a super_problem. We then promote GROSS_MASS, RANGE, and
wing SWEEP from each of those sub-groups (group1 and group2) up to the super_probem so
the optimizer can control them. The fuel_burn results from each of the group1 and group2
In this example, a monolithic optimization is created by instantiating two aviary problems
using typical AviaryProblem calls like load_inputs(), check_and_preprocess_payload(),
etc. Once those problems are setup and all of their phases are linked together, we copy
those problems as group into a super_problem. We then promote GROSS_MASS, RANGE, and
wing SWEEP from each of those sub-groups (group1 and group2) up to the super_probem so
the optimizer can control them. The fuel_burn results from each of the group1 and group2
dymos missions are summed and weighted to create the objective function the optimizer sees.
"""
import copy as copy
from aviary.examples.example_phase_info import phase_info
from aviary.variable_info.functions import setup_model_options
from aviary.variable_info.variables import Mission, Aircraft, Settings
from aviary.variable_info.enums import ProblemType
import aviary.api as av
Expand Down Expand Up @@ -146,11 +147,16 @@ def add_objective(self):

def setup_wrapper(self):
"""Wrapper for om.Problem setup with warning ignoring and setting options"""
for prob in self.probs:
for i, prob in enumerate(self.probs):
prob.model.options['aviary_options'] = prob.aviary_inputs
prob.model.options['aviary_metadata'] = prob.meta_data
prob.model.options['phase_info'] = prob.phase_info

# Use OpenMDAO's model options to pass all options through the system hierarchy.
prefix = self.group_prefix + f'_{i}'
setup_model_options(self, prob.aviary_inputs, prob.meta_data,
prefix=f'{prefix}.')

# Aviary's problem setup wrapper uses these ignored warnings to suppress
# some warnings related to variable promotion. Replicating that here with
# setup for the super problem
Expand Down
10 changes: 9 additions & 1 deletion aviary/interface/methods_for_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@
LegacyCode,
Verbosity,
)
from aviary.variable_info.functions import setup_trajectory_params, override_aviary_vars
from aviary.variable_info.functions import (
setup_trajectory_params,
override_aviary_vars,
setup_model_options,
)
from aviary.variable_info.variables import Aircraft, Mission, Dynamic, Settings
from aviary.variable_info.variable_meta_data import _MetaData as BaseMetaData

Expand Down Expand Up @@ -2506,6 +2510,9 @@ def setup(self, **kwargs):
"""
Lightly wrapped setup() method for the problem.
"""
# Use OpenMDAO's model options to pass all options through the system hierarchy.
setup_model_options(self, self.aviary_inputs, self.meta_data)

# suppress warnings:
# "input variable '...' promoted using '*' was already promoted using 'aircraft:*'
with warnings.catch_warnings():
Expand All @@ -2516,6 +2523,7 @@ def setup(self, **kwargs):

warnings.simplefilter("ignore", om.OpenMDAOWarning)
warnings.simplefilter("ignore", om.PromotionWarning)

super().setup(**kwargs)

def set_initial_guesses(self, parent_prob=None, parent_prefix="", verbosity=None):
Expand Down
1 change: 0 additions & 1 deletion aviary/mission/energy_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from aviary.mission.flight_phase_builder import FlightPhaseBase, register
from aviary.mission.initial_guess_builders import InitialGuessIntegrationVariable, InitialGuessState

from aviary.utils.aviary_values import AviaryValues
from aviary.mission.flops_based.ode.mission_ODE import MissionODE


Expand Down
3 changes: 1 addition & 2 deletions aviary/mission/flops_based/ode/mission_ODE.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ def setup(self):
"throttle_allocator",
ThrottleAllocator(
num_nodes=nn,
aviary_options=aviary_options,
throttle_allocation=self.options['throttle_allocation'],
throttle_allocation=self.options['throttle_allocation']
),
promotes_inputs=['*'],
promotes_outputs=['*'],
Expand Down
Loading

0 comments on commit bd9caa0

Please sign in to comment.