Skip to content

Commit b9fd079

Browse files
Conflict
2 parents 8d7438b + 75c0804 commit b9fd079

File tree

197 files changed

+2576
-2490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+2576
-2490
lines changed

aviary/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from aviary.variable_info.options import get_option_defaults, is_option
2424
from aviary.utils.develop_metadata import add_meta_data, update_meta_data
2525
from aviary.variable_info.variable_meta_data import CoreMetaData
26-
from aviary.variable_info.functions import add_aviary_input, add_aviary_output, get_units, override_aviary_vars, setup_trajectory_params
26+
from aviary.variable_info.functions import add_aviary_input, add_aviary_output, get_units, override_aviary_vars, setup_trajectory_params, setup_model_options
2727
from aviary.utils.merge_hierarchies import merge_hierarchies
2828
from aviary.utils.merge_variable_metadata import merge_meta_data
2929
from aviary.utils.named_values import NamedValues, get_keys, get_items, get_values

aviary/docs/examples/modified_aircraft.csv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ aircraft:canard:aspect_ratio,0.0,unitless
77
aircraft:canard:thickness_to_chord,0.0,unitless
88
aircraft:crew_and_payload:baggage_mass_per_passenger,45.0,lbm
99
aircraft:crew_and_payload:cargo_container_mass_scaler,1.0,unitless
10+
aircraft:crew_and_payload:design:num_business_class,0,unitless
11+
aircraft:crew_and_payload:design:num_first_class,11,unitless
12+
aircraft:crew_and_payload:design:num_passengers,169,unitless
13+
aircraft:crew_and_payload:design:num_tourist_class,158,unitless
1014
aircraft:crew_and_payload:flight_crew_mass_scaler,1.0,unitless
1115
aircraft:crew_and_payload:mass_per_passenger,180.0,lbm
1216
aircraft:crew_and_payload:misc_cargo,0.0,lbm
1317
aircraft:crew_and_payload:non_flight_crew_mass_scaler,1.0,unitless
14-
aircraft:crew_and_payload:num_business_class,0,unitless
15-
aircraft:crew_and_payload:num_first_class,11,unitless
1618
aircraft:crew_and_payload:num_flight_attendants,3,unitless
1719
aircraft:crew_and_payload:num_flight_crew,2,unitless
1820
aircraft:crew_and_payload:num_galley_crew,0,unitless
19-
aircraft:crew_and_payload:num_passengers,169,unitless
20-
aircraft:crew_and_payload:num_tourist_class,158,unitless
2121
aircraft:crew_and_payload:passenger_service_mass_scaler,1.0,unitless
2222
aircraft:crew_and_payload:wing_cargo,0.0,lbm
2323
aircraft:design:base_area,0.0,ft**2
@@ -114,7 +114,7 @@ aircraft:wing:aeroelastic_tailoring_factor,0.0,unitless
114114
aircraft:wing:airfoil_technology,1.92669766647637,unitless
115115
aircraft:wing:area,1370.0,ft**2
116116
aircraft:wing:aspect_ratio,11.02091,unitless
117-
aircraft:wing:bending_material_mass_scaler,1.0,unitless
117+
aircraft:wing:BENDING_MATERIAL_MASS_SCALER,1.0,unitless
118118
aircraft:wing:chord_per_semispan,0.31,0.23,0.084,unitless
119119
aircraft:wing:composite_fraction,0.2,unitless
120120
aircraft:wing:control_surface_area,137,ft**2

aviary/docs/getting_started/onboarding_level2.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@
10201020
"name": "python",
10211021
"nbconvert_exporter": "python",
10221022
"pygments_lexer": "ipython3",
1023-
"version": "3.10.13"
1023+
"version": "3.12.3"
10241024
}
10251025
},
10261026
"nbformat": 4,

aviary/docs/getting_started/onboarding_level3.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"\n",
9696
"import aviary.api as av\n",
9797
"from aviary.validation_cases.validation_tests import get_flops_inputs\n",
98+
"from aviary.variable_info.functions import setup_model_options\n",
9899
"\n",
99100
"\n",
100101
"prob = om.Problem(model=om.Group())\n",
@@ -459,6 +460,8 @@
459460
"]\n",
460461
"av.set_aviary_input_defaults(prob.model, varnames, aviary_inputs)\n",
461462
"\n",
463+
"av.setup_model_options(prob, aviary_inputs)\n",
464+
"\n",
462465
"prob.setup(force_alloc_complex=True)\n",
463466
"\n",
464467
"av.set_aviary_initial_values(prob, aviary_inputs)\n",
@@ -709,7 +712,7 @@
709712
"name": "python",
710713
"nbconvert_exporter": "python",
711714
"pygments_lexer": "ipython3",
712-
"version": "3.10.13"
715+
"version": "3.12.3"
713716
}
714717
},
715718
"nbformat": 4,

aviary/docs/user_guide/examples_of_the_same_mission_at_different_UI_levels.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@
434434
"]\n",
435435
"av.set_aviary_input_defaults(prob.model, varnames, aviary_inputs)\n",
436436
"\n",
437+
"av.setup_model_options(prob, aviary_inputs)\n",
438+
"\n",
437439
"prob.setup(force_alloc_complex=True)\n",
438440
"\n",
439441
"av.set_aviary_initial_values(prob, aviary_inputs)\n",
@@ -505,7 +507,7 @@
505507
"name": "python",
506508
"nbconvert_exporter": "python",
507509
"pygments_lexer": "ipython3",
508-
"version": "3.10.13"
510+
"version": "3.12.3"
509511
}
510512
},
511513
"nbformat": 4,

aviary/docs/user_guide/variable_metadata.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
" 'option': False,\n",
4343
" 'types': None,\n",
4444
" 'historical_name': None,\n",
45+
" 'multivalue': False,\n",
4546
" }\n",
4647
"\n",
4748
"meta_data = {}\n",
@@ -447,7 +448,7 @@
447448
"hash": "e6c7471802ed76737b16357fb02af5587f3a4cbee5ea7658f3f9a6981469039b"
448449
},
449450
"kernelspec": {
450-
"display_name": "Python 3",
451+
"display_name": "Python 3 (ipykernel)",
451452
"language": "python",
452453
"name": "python3"
453454
},
@@ -461,7 +462,7 @@
461462
"name": "python",
462463
"nbconvert_exporter": "python",
463464
"pygments_lexer": "ipython3",
464-
"version": "3.10.13"
465+
"version": "3.12.3"
465466
},
466467
"orphan": true
467468
},

aviary/examples/external_subsystems/OAS_weight/OAS_wing_weight_analysis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ def compute(self, inputs, outputs):
491491
prob.driver = om.ScipyOptimizeDriver()
492492
prob.driver.options['optimizer'] = 'SLSQP'
493493
prob.driver.options['tol'] = 1e-8
494-
495494
# Set up the problem
496495
with warnings.catch_warnings():
497496
warnings.filterwarnings("ignore", category=om.PromotionWarning)

aviary/examples/multi_mission/run_multimission_example_large_single_aisle.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
authors: Jatin Soni, Eliot Aretskin
33
Multi Mission Optimization Example using Aviary
44
5-
In this example, a monolithic optimization is created by instantiating two aviary problems
6-
using typical AviaryProblem calls like load_inputs(), check_and_preprocess_payload(),
7-
etc. Once those problems are setup and all of their phases are linked together, we copy
8-
those problems as group into a super_problem. We then promote GROSS_MASS, RANGE, and
9-
wing SWEEP from each of those sub-groups (group1 and group2) up to the super_probem so
10-
the optimizer can control them. The fuel_burn results from each of the group1 and group2
5+
In this example, a monolithic optimization is created by instantiating two aviary problems
6+
using typical AviaryProblem calls like load_inputs(), check_and_preprocess_payload(),
7+
etc. Once those problems are setup and all of their phases are linked together, we copy
8+
those problems as group into a super_problem. We then promote GROSS_MASS, RANGE, and
9+
wing SWEEP from each of those sub-groups (group1 and group2) up to the super_probem so
10+
the optimizer can control them. The fuel_burn results from each of the group1 and group2
1111
dymos missions are summed and weighted to create the objective function the optimizer sees.
1212
1313
"""
1414
import copy as copy
1515
from aviary.examples.example_phase_info import phase_info
16+
from aviary.variable_info.functions import setup_model_options
1617
from aviary.variable_info.variables import Mission, Aircraft, Settings
1718
from aviary.variable_info.enums import ProblemType
1819
import aviary.api as av
@@ -146,11 +147,16 @@ def add_objective(self):
146147

147148
def setup_wrapper(self):
148149
"""Wrapper for om.Problem setup with warning ignoring and setting options"""
149-
for prob in self.probs:
150+
for i, prob in enumerate(self.probs):
150151
prob.model.options['aviary_options'] = prob.aviary_inputs
151152
prob.model.options['aviary_metadata'] = prob.meta_data
152153
prob.model.options['phase_info'] = prob.phase_info
153154

155+
# Use OpenMDAO's model options to pass all options through the system hierarchy.
156+
prefix = self.group_prefix + f'_{i}'
157+
setup_model_options(self, prob.aviary_inputs, prob.meta_data,
158+
prefix=f'{prefix}.')
159+
154160
# Aviary's problem setup wrapper uses these ignored warnings to suppress
155161
# some warnings related to variable promotion. Replicating that here with
156162
# setup for the super problem

aviary/interface/methods_for_level2.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from aviary.utils.process_input_decks import create_vehicle, update_GASP_options, initialization_guessing
5959

6060
from aviary.variable_info.enums import AnalysisScheme, ProblemType, EquationsOfMotion, LegacyCode, Verbosity
61-
from aviary.variable_info.functions import setup_trajectory_params, override_aviary_vars
61+
from aviary.variable_info.functions import setup_trajectory_params, override_aviary_vars, setup_model_options
6262
from aviary.variable_info.variables import Aircraft, Mission, Dynamic, Settings
6363
from aviary.variable_info.variable_meta_data import _MetaData as BaseMetaData
6464

@@ -677,7 +677,8 @@ def _add_two_dof_takeoff_systems(self):
677677
# Create options to values
678678
OptionsToValues = create_opts2vals(
679679
[Aircraft.CrewPayload.NUM_PASSENGERS,
680-
Mission.Design.CRUISE_ALTITUDE, ])
680+
Mission.Design.CRUISE_ALTITUDE, ])
681+
681682
add_opts2vals(self.model, OptionsToValues, self.aviary_inputs)
682683

683684
if self.analysis_scheme is AnalysisScheme.SHOOTING:
@@ -2099,6 +2100,9 @@ def setup(self, **kwargs):
20992100
"""
21002101
Lightly wrapped setup() method for the problem.
21012102
"""
2103+
# Use OpenMDAO's model options to pass all options through the system hierarchy.
2104+
setup_model_options(self, self.aviary_inputs, self.meta_data)
2105+
21022106
# suppress warnings:
21032107
# "input variable '...' promoted using '*' was already promoted using 'aircraft:*'
21042108
with warnings.catch_warnings():
@@ -2109,6 +2113,7 @@ def setup(self, **kwargs):
21092113

21102114
warnings.simplefilter("ignore", om.OpenMDAOWarning)
21112115
warnings.simplefilter("ignore", om.PromotionWarning)
2116+
21122117
super().setup(**kwargs)
21132118

21142119
def set_initial_guesses(self, parent_prob=None, parent_prefix=""):

aviary/mission/energy_phase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from aviary.mission.flight_phase_builder import FlightPhaseBase, register
44
from aviary.mission.initial_guess_builders import InitialGuessIntegrationVariable, InitialGuessState
55

6-
from aviary.utils.aviary_values import AviaryValues
76
from aviary.mission.flops_based.ode.mission_ODE import MissionODE
87

98

aviary/mission/flops_based/ode/mission_ODE.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ def setup(self):
230230
"throttle_allocator",
231231
ThrottleAllocator(
232232
num_nodes=nn,
233-
aviary_options=aviary_options,
234-
throttle_allocation=self.options['throttle_allocation'],
233+
throttle_allocation=self.options['throttle_allocation']
235234
),
236235
promotes_inputs=['*'],
237236
promotes_outputs=['*'],

aviary/mission/flops_based/phases/test/test_time_integration_phases.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import warnings
2+
import unittest
3+
import importlib
4+
15
import openmdao.api as om
26
from openmdao.utils.assert_utils import assert_near_equal
37

@@ -12,13 +16,10 @@
1216
from aviary.utils.process_input_decks import create_vehicle
1317
from aviary.utils.test_utils.default_subsystems import get_default_premission_subsystems
1418
from aviary.variable_info.enums import EquationsOfMotion
19+
from aviary.variable_info.functions import setup_model_options
1520
from aviary.variable_info.variable_meta_data import _MetaData as BaseMetaData
1621
from aviary.variable_info.variables import Aircraft, Dynamic, Mission, Settings
1722

18-
import warnings
19-
import unittest
20-
import importlib
21-
2223

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

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

112+
setup_model_options(prob, aviary_options)
113+
111114
with warnings.catch_warnings():
112115

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

aviary/mission/gasp_based/ode/taxi_eom.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import numpy as np
22
import openmdao.api as om
33

4-
from aviary.utils.aviary_values import AviaryValues
5-
from aviary.variable_info.functions import add_aviary_input
4+
from aviary.variable_info.functions import add_aviary_input, add_aviary_option
65
from aviary.variable_info.variables import Dynamic, Mission
76

87

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

1413
def initialize(self):
15-
self.options.declare(
16-
'aviary_options', types=AviaryValues,
17-
desc='collection of Aircraft/Mission specific options')
14+
add_aviary_option(self, Mission.Taxi.DURATION, units='s')
1815

1916
def setup(self):
2017
self.add_input(
@@ -51,12 +48,12 @@ def setup_partials(self):
5148

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

5855
def compute_partials(self, inputs, J):
59-
dt_taxi = self.options['aviary_options'].get_val(Mission.Taxi.DURATION, 's')
56+
dt_taxi, _ = self.options[Mission.Taxi.DURATION]
6057

6158
J[
6259
"taxi_fuel_consumed",

aviary/mission/gasp_based/ode/taxi_ode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def setup(self):
8080
)
8181

8282
self.add_subsystem(
83-
"taxifuel", TaxiFuelComponent(aviary_options=options), promotes=["*"]
83+
"taxifuel", TaxiFuelComponent(), promotes=["*"]
8484
)
8585

8686
ParamPort.set_default_vals(self)

aviary/mission/gasp_based/ode/test/test_landing_ode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from aviary.subsystems.propulsion.utils import build_engine_deck
1313
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
1414
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
15+
from aviary.variable_info.functions import setup_model_options
1516
from aviary.variable_info.options import get_option_defaults
1617
from aviary.variable_info.variables import Dynamic, Mission
1718

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

36+
setup_model_options(self.prob, options)
37+
3538
@unittest.skipIf(version.parse(openmdao.__version__) < version.parse("3.26"), "Skipping due to OpenMDAO version being too low (<3.26)")
3639
def test_dland(self):
3740
self.prob.setup(check=False, force_alloc_complex=True)

aviary/mission/gasp_based/ode/test/test_taxi_eom.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from aviary.utils.aviary_values import AviaryValues
88
from aviary.mission.gasp_based.ode.taxi_eom import TaxiFuelComponent
9+
from aviary.variable_info.functions import setup_model_options
910
from aviary.variable_info.variables import Dynamic, Mission
1011

1112

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

1718
def setUp(self):
18-
self.prob = om.Problem(model=om.Group())
19+
self.prob = om.Problem()
1920

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

23-
self.prob.model.add_subsystem('taxi', TaxiFuelComponent(
24-
aviary_options=aviary_options), promotes=['*'])
24+
self.prob.model.add_subsystem('taxi', TaxiFuelComponent(),
25+
promotes=['*'])
26+
27+
setup_model_options(self.prob, aviary_options)
2528

2629
def test_fuel_consumed(self):
2730
self.prob.setup(force_alloc_complex=True)

aviary/mission/gasp_based/ode/test/test_taxi_ode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from aviary.subsystems.propulsion.utils import build_engine_deck
1111
from aviary.utils.test_utils.default_subsystems import get_default_mission_subsystems
1212
from aviary.utils.test_utils.IO_test_util import check_prob_outputs
13+
from aviary.variable_info.functions import setup_model_options
1314
from aviary.variable_info.options import get_option_defaults
1415
from aviary.variable_info.variables import Dynamic, Mission
1516

@@ -33,6 +34,8 @@ def setUp(self):
3334
aviary_options=options, core_subsystems=default_mission_subsystems
3435
)
3536

37+
setup_model_options(self.prob, options)
38+
3639
self.prob.model.set_input_defaults(
3740
Mission.Takeoff.AIRPORT_ALTITUDE,
3841
0.0,

aviary/mission/gasp_based/ode/unsteady_solved/test/test_unsteady_alpha_thrust_iter_group.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def _test_unsteady_alpha_thrust_iter_group(self, ground_roll=False):
4141
g = UnsteadyControlIterGroup(num_nodes=nn,
4242
ground_roll=ground_roll,
4343
clean=True,
44-
aviary_options=get_option_defaults(),
4544
core_subsystems=[aero])
4645

4746
ig = p.model.add_subsystem("iter_group",

aviary/mission/gasp_based/ode/unsteady_solved/unsteady_control_iter_group.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def initialize(self):
2121
"output and adjusts the TAS rate equation.")
2222
self.options.declare("clean", types=bool, default=False,
2323
desc="If true then no flaps or gear are included. Useful for high-speed flight phases.")
24+
2425
self.options.declare(
2526
'aviary_options', types=AviaryValues, default=None,
2627
desc='collection of Aircraft/Mission specific options'

0 commit comments

Comments
 (0)