Skip to content

Commit

Permalink
Merge branch 'main' into issue_587
Browse files Browse the repository at this point in the history
  • Loading branch information
jkirk5 authored Jan 8, 2025
2 parents 6747dd2 + 394fb52 commit 74e2fef
Show file tree
Hide file tree
Showing 202 changed files with 2,582 additions and 2,496 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
10 changes: 5 additions & 5 deletions aviary/docs/examples/modified_aircraft.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ aircraft:canard:aspect_ratio,0.0,unitless
aircraft:canard:thickness_to_chord,0.0,unitless
aircraft:crew_and_payload:baggage_mass_per_passenger,45.0,lbm
aircraft:crew_and_payload:cargo_container_mass_scaler,1.0,unitless
aircraft:crew_and_payload:design:num_business_class,0,unitless
aircraft:crew_and_payload:design:num_first_class,11,unitless
aircraft:crew_and_payload:design:num_passengers,169,unitless
aircraft:crew_and_payload:design:num_tourist_class,158,unitless
aircraft:crew_and_payload:flight_crew_mass_scaler,1.0,unitless
aircraft:crew_and_payload:mass_per_passenger,180.0,lbm
aircraft:crew_and_payload:misc_cargo,0.0,lbm
aircraft:crew_and_payload:non_flight_crew_mass_scaler,1.0,unitless
aircraft:crew_and_payload:num_business_class,0,unitless
aircraft:crew_and_payload:num_first_class,11,unitless
aircraft:crew_and_payload:num_flight_attendants,3,unitless
aircraft:crew_and_payload:num_flight_crew,2,unitless
aircraft:crew_and_payload:num_galley_crew,0,unitless
aircraft:crew_and_payload:num_passengers,169,unitless
aircraft:crew_and_payload:num_tourist_class,158,unitless
aircraft:crew_and_payload:passenger_service_mass_scaler,1.0,unitless
aircraft:crew_and_payload:wing_cargo,0.0,lbm
aircraft:design:base_area,0.0,ft**2
Expand Down 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
2 changes: 1 addition & 1 deletion aviary/docs/getting_started/onboarding_level2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.12.3"
}
},
"nbformat": 4,
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
9 changes: 7 additions & 2 deletions aviary/interface/methods_for_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from aviary.utils.process_input_decks import create_vehicle, update_GASP_options, initialization_guessing

from aviary.variable_info.enums import AnalysisScheme, ProblemType, EquationsOfMotion, 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 @@ -677,7 +677,8 @@ def _add_two_dof_takeoff_systems(self):
# Create options to values
OptionsToValues = create_opts2vals(
[Aircraft.CrewPayload.NUM_PASSENGERS,
Mission.Design.CRUISE_ALTITUDE, ])
Mission.Design.CRUISE_ALTITUDE, ])

add_opts2vals(self.model, OptionsToValues, self.aviary_inputs)

if self.analysis_scheme is AnalysisScheme.SHOOTING:
Expand Down Expand Up @@ -2099,6 +2100,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 @@ -2109,6 +2113,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=""):
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import warnings
import unittest
import importlib

import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal

Expand All @@ -12,13 +16,10 @@
from aviary.utils.process_input_decks import create_vehicle
from aviary.utils.test_utils.default_subsystems import get_default_premission_subsystems
from aviary.variable_info.enums import EquationsOfMotion
from aviary.variable_info.functions import setup_model_options
from aviary.variable_info.variable_meta_data import _MetaData as BaseMetaData
from aviary.variable_info.variables import Aircraft, Dynamic, Mission, Settings

import warnings
import unittest
import importlib


@unittest.skipUnless(importlib.util.find_spec("pyoptsparse") is not None, "pyoptsparse is not installed")
class HE_SGMDescentTestCase(unittest.TestCase):
Expand Down Expand Up @@ -108,6 +109,8 @@ def setup_prob(self, phases) -> om.Problem:

prob.model.add_objective(Mission.Objectives.FUEL, ref=1e4)

setup_model_options(prob, aviary_options)

with warnings.catch_warnings():

warnings.simplefilter("ignore", om.PromotionWarning)
Expand Down
11 changes: 4 additions & 7 deletions aviary/mission/gasp_based/ode/taxi_eom.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
import openmdao.api as om

from aviary.utils.aviary_values import AviaryValues
from aviary.variable_info.functions import add_aviary_input
from aviary.variable_info.functions import add_aviary_input, add_aviary_option
from aviary.variable_info.variables import Dynamic, Mission


Expand All @@ -12,9 +11,7 @@ class TaxiFuelComponent(om.ExplicitComponent):
"""

def initialize(self):
self.options.declare(
'aviary_options', types=AviaryValues,
desc='collection of Aircraft/Mission specific options')
add_aviary_option(self, Mission.Taxi.DURATION, units='s')

def setup(self):
self.add_input(
Expand Down Expand Up @@ -51,12 +48,12 @@ def setup_partials(self):

def compute(self, inputs, outputs):
fuelflow, takeoff_mass = inputs.values()
dt_taxi = self.options['aviary_options'].get_val(Mission.Taxi.DURATION, 's')
dt_taxi, _ = self.options[Mission.Taxi.DURATION]
outputs["taxi_fuel_consumed"] = -fuelflow * dt_taxi
outputs[Dynamic.Vehicle.MASS] = takeoff_mass - outputs["taxi_fuel_consumed"]

def compute_partials(self, inputs, J):
dt_taxi = self.options['aviary_options'].get_val(Mission.Taxi.DURATION, 's')
dt_taxi, _ = self.options[Mission.Taxi.DURATION]

J[
"taxi_fuel_consumed",
Expand Down
2 changes: 1 addition & 1 deletion aviary/mission/gasp_based/ode/taxi_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def setup(self):
)

self.add_subsystem(
"taxifuel", TaxiFuelComponent(aviary_options=options), promotes=["*"]
"taxifuel", TaxiFuelComponent(), promotes=["*"]
)

ParamPort.set_default_vals(self)
Expand Down
3 changes: 3 additions & 0 deletions aviary/mission/gasp_based/ode/test/test_landing_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from aviary.subsystems.propulsion.utils import build_engine_deck
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
from aviary.variable_info.functions import setup_model_options
from aviary.variable_info.options import get_option_defaults
from aviary.variable_info.variables import Dynamic, Mission

Expand All @@ -32,6 +33,8 @@ def setUp(self):
self.prob.model = LandingSegment(
aviary_options=options, core_subsystems=core_subsystems)

setup_model_options(self.prob, options)

@unittest.skipIf(version.parse(openmdao.__version__) < version.parse("3.26"), "Skipping due to OpenMDAO version being too low (<3.26)")
def test_dland(self):
self.prob.setup(check=False, force_alloc_complex=True)
Expand Down
9 changes: 6 additions & 3 deletions aviary/mission/gasp_based/ode/test/test_taxi_eom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from aviary.utils.aviary_values import AviaryValues
from aviary.mission.gasp_based.ode.taxi_eom import TaxiFuelComponent
from aviary.variable_info.functions import setup_model_options
from aviary.variable_info.variables import Dynamic, Mission


Expand All @@ -15,13 +16,15 @@ class TaxiFuelComponentTestCase(unittest.TestCase):
"""

def setUp(self):
self.prob = om.Problem(model=om.Group())
self.prob = om.Problem()

aviary_options = AviaryValues()
aviary_options.set_val(Mission.Taxi.DURATION, 0.1677, units="h")

self.prob.model.add_subsystem('taxi', TaxiFuelComponent(
aviary_options=aviary_options), promotes=['*'])
self.prob.model.add_subsystem('taxi', TaxiFuelComponent(),
promotes=['*'])

setup_model_options(self.prob, aviary_options)

def test_fuel_consumed(self):
self.prob.setup(force_alloc_complex=True)
Expand Down
Loading

0 comments on commit 74e2fef

Please sign in to comment.