Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions aviary/examples/run_level2_with_detailed_landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@

prob.setup()

# set the start-of-landing mass to mission:summary:gross_mass
prob.set_val('mission:summary:gross_mass', 120000, units='lbm')

prob.run_aviary_problem()

try:
Expand Down
30 changes: 19 additions & 11 deletions aviary/examples/run_level2_with_detailed_takeoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@

mach_optimize = True
altitude_optimize = True
optimizer = 'SLSQP'
optimizer = 'IPOPT'
num_segments = 2

phase_info = {
'pre_mission': {'include_takeoff': False, 'optimize_mass': False},
'AB': {
'user_options': {
'num_segments': 5,
'num_segments': num_segments,
'order': 3,
'ground_roll': True,
'time_duration_ref': (100.0, 'kn'),
Expand All @@ -50,7 +51,7 @@
},
'rotate': {
'user_options': {
'num_segments': 5,
'num_segments': num_segments,
'order': 3,
'ground_roll': True,
'clean': False,
Expand Down Expand Up @@ -88,7 +89,7 @@
},
'BC': {
'user_options': {
'num_segments': 5,
'num_segments': num_segments,
'order': 3,
'clean': False,
'time_initial_ref': (1.0e3, 'ft'),
Expand All @@ -115,7 +116,7 @@
},
'CD_to_P2': {
'user_options': {
'num_segments': 4,
'num_segments': num_segments,
'order': 3,
'clean': False,
'time_initial_ref': (1.0e3, 'ft'),
Expand Down Expand Up @@ -150,7 +151,7 @@
},
'P2_to_DE': {
'user_options': {
'num_segments': 4,
'num_segments': num_segments,
'order': 3,
'clean': False,
'time_initial_ref': (1.0e3, 'ft'),
Expand Down Expand Up @@ -185,7 +186,7 @@
},
'DE': {
'user_options': {
'num_segments': 3,
'num_segments': num_segments,
'order': 3,
'clean': False,
'time_initial_ref': (1.0e3, 'ft'),
Expand Down Expand Up @@ -219,7 +220,7 @@
},
'EF_to_P1': {
'user_options': {
'num_segments': 3,
'num_segments': num_segments,
'order': 3,
'clean': False,
'time_initial_ref': (1.0e3, 'ft'),
Expand Down Expand Up @@ -260,7 +261,7 @@
},
'EF_past_P1': {
'user_options': {
'num_segments': 5,
'num_segments': num_segments,
'order': 3,
'clean': False,
'time_initial_ref': (1.0e3, 'ft'),
Expand Down Expand Up @@ -317,16 +318,23 @@

prob.build_model()

prob.add_driver(optimizer, max_iter=25)
prob.add_driver(optimizer, max_iter=200, verbosity=2)
# custom optimizer seettings
prob.driver.opt_settings['mu_init'] = 1.0
prob.driver.opt_settings['nlp_scaling_method'] = 'none'
prob.driver.opt_settings['limited_memory_max_history'] = 50

prob.add_design_variables()

# Load optimization problem formulation
# Detail which variables the optimizer can control
prob.add_objective('mass')
prob.add_objective('mass') # maximize final mass (i.e. minimize fuel burn)

prob.setup()

# set takeoff (initial) mass
prob.set_val('mission:summary:gross_mass', 175000, units='lbm')

prob.run_aviary_problem(suppress_solver_print=True)

try:
Expand Down
28 changes: 26 additions & 2 deletions aviary/mission/solved_two_dof_problem_configurator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import openmdao.api as om

from aviary.mission.flops_based.phases.groundroll_phase import (
GroundrollPhase as GroundrollPhaseVelocityIntegrated,
)
Expand Down Expand Up @@ -246,7 +248,7 @@ def check_trajectory(self, aviary_group):
"""
pass

def add_post_mission_systems(self, model):
def add_post_mission_systems(self, aviary_group):
"""
Add any post mission systems.

Expand All @@ -259,7 +261,29 @@ def add_post_mission_systems(self, model):
aviary_group : AviaryGroup
Aviary model that owns this configurator.
"""
pass
# Add a mass equality constraint to set mission:summary:gross_mass = initial mass state
first_flight_phase_name = list(aviary_group.phase_info.keys())[0]
first_flight_phase = aviary_group.traj._phases[first_flight_phase_name]
first_flight_phase.set_state_options(
Dynamic.Vehicle.MASS, fix_initial=False, input_initial=False
)

# connect summary mass to the initial guess of mass in the first phase
eq = aviary_group.add_subsystem(
f'link_{first_flight_phase_name}_mass',
om.EQConstraintComp(),
promotes_inputs=[('rhs:mass', Mission.Summary.GROSS_MASS)],
)

# TODO: replace hard_coded ref for this constraint.
eq.add_eq_output('mass', eq_units='lbm', normalize=False, ref=100000.0, add_constraint=True)

aviary_group.connect(
f'traj.{first_flight_phase_name}.states:mass',
f'link_{first_flight_phase_name}_mass.lhs:mass',
src_indices=[0],
flat_src_indices=True,
)

def set_phase_initial_guesses(
self, aviary_group, phase_name, phase, guesses, target_prob, parent_prefix
Expand Down
Loading