-
Notifications
You must be signed in to change notification settings - Fork 110
Level 3 Example Shooting #866
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
Open
kaushikponnapalli
wants to merge
1
commit into
OpenMDAO:main
Choose a base branch
from
kaushikponnapalli:level3_shooting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,13 +106,22 @@ def initialize(self): | |
|
|
||
| ##### | ||
| # prob.add_phases() | ||
| phases = ['climb', 'cruise', 'descent'] | ||
| phase_list = ['climb', 'cruise', 'descent'] | ||
| prob.traj = prob.model.add_subsystem('traj', dm.Trajectory()) | ||
| default_mission_subsystems = [ | ||
| prob.model.core_subsystems['aerodynamics'], | ||
| prob.model.core_subsystems['propulsion'], | ||
| ] | ||
| for phase_idx, phase_name in enumerate(phases): | ||
| phases = {} | ||
|
|
||
| seg_ends, _ = dm.utils.lgl.lgl(5 + 1) | ||
| transcription = dm.Radau( | ||
| num_segments=5, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This transcription isn't used. |
||
| order=3, | ||
| segment_ends=seg_ends, | ||
| ) | ||
|
|
||
| for phase_idx, phase_name in enumerate(phase_list): | ||
| base_phase_options = prob.model.phase_info[phase_name] | ||
| phase_options = {} | ||
| for key, val in base_phase_options.items(): | ||
|
|
@@ -126,6 +135,11 @@ def initialize(self): | |
| ) | ||
| phase = phase_object.build_phase(aviary_options=aviary_inputs) | ||
| prob.traj.add_phase(phase_name, phase) | ||
| phases[phase_name] = phase | ||
|
|
||
| climb = phases['climb'] | ||
| cruise = phases['cruise'] | ||
| descent = phases['descent'] | ||
|
|
||
| externs = {'climb': {}, 'cruise': {}, 'descent': {}} | ||
| for default_subsys in default_mission_subsystems: | ||
|
|
@@ -151,28 +165,24 @@ def initialize(self): | |
| promotes_outputs=['*'], | ||
| ) | ||
|
|
||
| prob.traj._phases['climb'].set_state_options( | ||
| Dynamic.Vehicle.MASS, fix_initial=False, input_initial=False | ||
| ) | ||
| climb.set_state_options(Dynamic.Vehicle.MASS, fix_initial=False, input_initial=False) | ||
|
|
||
| prob.traj._phases['climb'].set_state_options( | ||
| Dynamic.Mission.DISTANCE, fix_initial=True, input_initial=False | ||
| ) | ||
| climb.set_state_options(Dynamic.Mission.DISTANCE, fix_initial=True, input_initial=False) | ||
|
|
||
| prob.traj._phases['climb'].set_time_options( | ||
| climb.set_time_options( | ||
| fix_initial=False, | ||
| initial_bounds=(0, 0), | ||
| initial_ref=600, | ||
| duration_bounds=(3840, 11520), | ||
| duration_ref=7680.0, | ||
| ) | ||
|
|
||
| prob.traj._phases['cruise'].set_time_options( | ||
| cruise.set_time_options( | ||
| duration_bounds=(3390, 10170), | ||
| duration_ref=6780.0, | ||
| ) | ||
|
|
||
| prob.traj._phases['descent'].set_time_options( | ||
| descent.set_time_options( | ||
| duration_bounds=(1740, 5220), | ||
| duration_ref=3480.0, | ||
| ) | ||
|
|
@@ -186,7 +196,7 @@ def initialize(self): | |
| eq.add_eq_output('mass', eq_units='lbm', normalize=False, ref=100000.0, add_constraint=True) | ||
|
|
||
| prob.model.connect( | ||
| f'traj.climb.states:mass', | ||
| f'traj.climb.timeseries.mass', | ||
| f'link_climb_mass.lhs:mass', | ||
| src_indices=[0], | ||
| flat_src_indices=True, | ||
|
|
@@ -308,10 +318,9 @@ def initialize(self): | |
| all_subsystems = [] | ||
| all_subsystems.append(prob.model.core_subsystems['propulsion']) | ||
|
|
||
| phases = list(prob.model.phase_info.keys()) | ||
| prob.traj.link_phases(phases, ['time'], ref=None, connected=True) | ||
| prob.traj.link_phases(phases, [Dynamic.Vehicle.MASS], ref=None, connected=True) | ||
| prob.traj.link_phases(phases, [Dynamic.Mission.DISTANCE], ref=None, connected=True) | ||
| prob.traj.link_phases(phase_list, ['time'], ref=None, connected=False) | ||
| prob.traj.link_phases(phase_list, [Dynamic.Vehicle.MASS], ref=None, connected=False) | ||
| prob.traj.link_phases(phase_list, [Dynamic.Mission.DISTANCE], ref=None, connected=False) | ||
|
|
||
| prob.model.connect( | ||
| f'traj.descent.timeseries.distance', | ||
|
|
@@ -331,7 +340,7 @@ def initialize(self): | |
| prob.driver.options['tol'] = 1e-9 | ||
| prob.driver.options['maxiter'] = 50 | ||
|
|
||
| # IPOPT Optimizer Settings | ||
| # # IPOPT Optimizer Settings | ||
| # prob.driver.opt_settings['print_user_options'] = 'no' | ||
| # prob.driver.opt_settings['print_frequency_iter'] = 10 | ||
| # prob.driver.opt_settings['print_level'] = 3 | ||
|
|
@@ -345,7 +354,9 @@ def initialize(self): | |
| # prob.driver.opt_settings['iSumm'] = 6 | ||
| # prob.driver.opt_settings['iPrint'] = 0 | ||
|
|
||
| # SNOPT Optimizer Settings # | ||
| # # SNOPT Optimizer Settings # | ||
| # prob.driver = om.pyOptSparseDriver() | ||
| # prob.driver.options['optimizer'] = 'SNOPT' | ||
| # prob.driver.opt_settings['Major iterations limit'] = 50 | ||
| # prob.driver.opt_settings['Major optimality tolerance'] = 1e-4 | ||
| # prob.driver.opt_settings['Major feasibility tolerance'] = 1e-7 | ||
|
|
@@ -435,47 +446,59 @@ def initialize(self): | |
| guesses['altitude_descent'] = ([34000.0, 500.0], 'ft') | ||
| guesses['time_descent'] = ([7230.0, 1740.0], 's') | ||
|
|
||
| prob.set_val('traj.climb.t_initial', guesses['time_climb'][0][0], units='s') | ||
| prob.set_val('traj.climb.t_duration', guesses['time_climb'][0][1], units='s') | ||
| prob.set_val( | ||
| 'traj.climb.controls:mach', | ||
| prob.model.traj.phases.climb.interp('mach', xs=[-1, 1], ys=guesses['mach_climb'][0]), | ||
| climb.set_time_val( | ||
| initial=guesses['time_climb'][0][0], duration=guesses['time_climb'][0][1], units='s' | ||
| ) | ||
| climb.set_control_val( | ||
| 'mach', | ||
| vals=guesses['mach_climb'][0], | ||
| time_vals=[-1, 1], | ||
| units='unitless', | ||
| ) | ||
| prob.set_val( | ||
| 'traj.climb.controls:altitude', | ||
| prob.model.traj.phases.climb.interp('altitude', xs=[-1, 1], ys=guesses['altitude_climb'][0]), | ||
| climb.set_control_val( | ||
| 'altitude', | ||
| vals=guesses['altitude_climb'][0], | ||
| time_vals=[-1, 1], | ||
| units='ft', | ||
| ) | ||
|
|
||
| prob.set_val('traj.cruise.t_initial', guesses['time_cruise'][0][0], units='s') | ||
| prob.set_val('traj.cruise.t_duration', guesses['time_cruise'][0][1], units='s') | ||
| prob.set_val( | ||
| 'traj.cruise.controls:mach', | ||
| prob.model.traj.phases.cruise.interp('mach', xs=[-1, 1], ys=guesses['mach_cruise'][0]), | ||
| climb.set_state_val('mass', 125000, units='lbm') | ||
|
|
||
| cruise.set_time_val( | ||
| initial=guesses['time_cruise'][0][0], duration=guesses['time_cruise'][0][1], units='s' | ||
| ) | ||
| cruise.set_control_val( | ||
| 'mach', | ||
| vals=guesses['mach_cruise'][0], | ||
| time_vals=[-1, 1], | ||
| units='unitless', | ||
| ) | ||
| prob.set_val( | ||
| 'traj.cruise.controls:altitude', | ||
| prob.model.traj.phases.cruise.interp('altitude', xs=[-1, 1], ys=guesses['altitude_cruise'][0]), | ||
| cruise.set_control_val( | ||
| 'altitude', | ||
| vals=guesses['altitude_cruise'][0], | ||
| time_vals=[-1, 1], | ||
| units='ft', | ||
| ) | ||
|
|
||
| prob.set_val('traj.descent.t_initial', guesses['time_descent'][0][0], units='s') | ||
| prob.set_val('traj.descent.t_duration', guesses['time_descent'][0][1], units='s') | ||
| prob.set_val( | ||
| 'traj.descent.controls:mach', | ||
| prob.model.traj.phases.climb.interp('mach', xs=[-1, 1], ys=guesses['mach_descent'][0]), | ||
| cruise.set_state_val('mass', 125000, units='lbm') | ||
|
|
||
| descent.set_time_val( | ||
| initial=guesses['time_descent'][0][0], duration=guesses['time_descent'][0][1], units='s' | ||
| ) | ||
| descent.set_control_val( | ||
| 'mach', | ||
| vals=guesses['mach_descent'][0], | ||
| time_vals=[-1, 1], | ||
| units='unitless', | ||
| ) | ||
| prob.set_val( | ||
| 'traj.descent.controls:altitude', | ||
| prob.model.traj.phases.climb.interp('altitude', xs=[-1, 1], ys=guesses['altitude_descent'][0]), | ||
| descent.set_control_val( | ||
| 'altitude', | ||
| vals=guesses['altitude_descent'][0], | ||
| time_vals=[-1, 1], | ||
| units='ft', | ||
| ) | ||
| prob.set_val('traj.climb.states:mass', 125000, units='lbm') | ||
| prob.set_val('traj.cruise.states:mass', 125000, units='lbm') | ||
| prob.set_val('traj.descent.states:mass', 125000, units='lbm') | ||
|
|
||
| descent.set_state_val('mass', 125000, units='lbm') | ||
|
|
||
| prob.set_val(Mission.Design.GROSS_MASS, 175400, units='lbm') | ||
| prob.set_val(Mission.Summary.GROSS_MASS, 175400, units='lbm') | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be leftover code from some other work, or maybe it is the start of supporting Shooting in level 2. The level3 example doesn't use aviary_group.