Skip to content

Commit

Permalink
Merge pull request OpenMDAO#53 from johnjasa/move_tests_to_simple_mis…
Browse files Browse the repository at this point in the history
…sion

Remove FLOPS based mission method
  • Loading branch information
johnjasa authored Jan 19, 2024
2 parents efae42a + 7f9dc5b commit 4f0b3e7
Show file tree
Hide file tree
Showing 65 changed files with 1,020 additions and 7,014 deletions.
8 changes: 2 additions & 6 deletions aviary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
from aviary.utils.data_interpolator_builder import build_data_interpolator
from aviary.variable_info.enums import AlphaModes, AnalysisScheme, ProblemType, SpeedType, GASPEngineType, FlapType, EquationsOfMotion, LegacyCode, Verbosity
from aviary.interface.default_phase_info.two_dof import phase_info as default_2DOF_phase_info
from aviary.interface.default_phase_info.height_energy import phase_info as default_height_energy_phase_info
from aviary.interface.default_phase_info.two_dof_fiti import create_2dof_based_ascent_phases, create_2dof_based_descent_phases
from aviary.interface.default_phase_info.solved import phase_info as default_solved_phase_info
from aviary.interface.default_phase_info.simple import phase_info as default_simple_phase_info
from aviary.interface.default_phase_info.height_energy import phase_info as default_height_energy_phase_info
from aviary.interface.methods_for_level1 import run_level_1
from aviary.interface.methods_for_level1 import run_aviary
from aviary.interface.methods_for_level2 import AviaryProblem
Expand Down Expand Up @@ -68,7 +67,6 @@
from aviary.mission.gasp_based.ode.base_ode import BaseODE
from aviary.mission.flops_based.ode.landing_ode import LandingODE as DetailedLandingODE
from aviary.mission.flops_based.ode.landing_ode import FlareODE as DetailedFlareODE
from aviary.mission.flops_based.ode.mission_ODE import MissionODE as HeightEnergyMissionODE
from aviary.mission.flops_based.ode.takeoff_ode import TakeoffODE as DetailedTakeoffODE
from aviary.mission.gasp_based.ode.accel_ode import AccelODE as TwoDOFAccelerationODE
from aviary.mission.gasp_based.ode.ascent_ode import AscentODE as TwoDOFAscentODE
Expand All @@ -87,12 +85,10 @@
# Phase builders
from aviary.mission.flops_based.phases.phase_builder_base import PhaseBuilderBase
# note that this is only for simplified right now
from aviary.mission.flops_based.phases.energy_phase import EnergyPhase as HeightEnergyPhaseBuilder
from aviary.mission.flops_based.phases.build_landing import Landing as HeightEnergyLandingPhaseBuilder
# note that this is only for simplified right now
from aviary.mission.flops_based.phases.build_takeoff import Takeoff as HeightEnergyTakeoffPhaseBuilder
from aviary.mission.flops_based.phases.climb_phase import Climb as HeightEnergyClimbPhaseBuilder
from aviary.mission.flops_based.phases.cruise_phase import Cruise as HeightEnergyCruisePhaseBuilder
from aviary.mission.flops_based.phases.descent_phase import Descent as HeightEnergyDescentPhaseBuilder
from aviary.mission.flops_based.phases.detailed_landing_phases import LandingApproachToMicP3 as DetailedLandingApproachToMicP3PhaseBuilder
from aviary.mission.flops_based.phases.detailed_landing_phases import LandingMicP3ToObstacle as DetailedLandingMicP3ToObstaclePhaseBuilder
from aviary.mission.flops_based.phases.detailed_landing_phases import LandingObstacleToFlare as DetailedLandingObstacleToFlarePhaseBuilder
Expand Down
1 change: 0 additions & 1 deletion aviary/docs/build_pdf_book.sh

This file was deleted.

2 changes: 1 addition & 1 deletion aviary/docs/examples/OAS_subsystem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
"if use_OAS:\n",
" phase_info['pre_mission']['external_subsystems'] = [wing_weight_builder]\n",
"\n",
"aircraft_definition_file = 'models/test_aircraft/aircraft_for_bench_FwFm_simple.csv'\n",
"aircraft_definition_file = 'models/test_aircraft/aircraft_for_bench_FwFm.csv'\n",
"mission_method = 'simple'\n",
"mass_method = 'FLOPS'\n",
"make_plots = False\n",
Expand Down
2 changes: 1 addition & 1 deletion aviary/docs/examples/additional_flight_phases.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"source": [
"import aviary.api as av\n",
"\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv',\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm.csv',\n",
" phase_info, optimizer=\"SLSQP\", make_plots=True)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"source": [
"import aviary.api as av\n",
"\n",
"aircraft_filename = 'models/test_aircraft/aircraft_for_bench_FwFm_simple.csv'\n",
"aircraft_filename = 'models/test_aircraft/aircraft_for_bench_FwFm.csv'\n",
"optimizer = \"IPOPT\"\n",
"make_plots = True\n",
"max_iter = 200\n",
Expand Down
6 changes: 3 additions & 3 deletions aviary/docs/examples/more_advanced_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"source": [
"import aviary.api as av\n",
"\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv',\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm.csv',\n",
" phase_info, optimizer=\"SLSQP\", make_plots=True)"
]
},
Expand Down Expand Up @@ -188,7 +188,7 @@
"source": [
"import csv\n",
"\n",
"filename = 'models/test_aircraft/aircraft_for_bench_FwFm_simple.csv'\n",
"filename = 'models/test_aircraft/aircraft_for_bench_FwFm.csv'\n",
"filename = av.get_path(filename)\n",
"\n",
"# Read the file\n",
Expand Down Expand Up @@ -279,7 +279,7 @@
"phase_info['cruise']['user_options']['polynomial_control_order'] = 1\n",
"phase_info['descent_1']['user_options']['polynomial_control_order'] = 3\n",
"\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv',\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm.csv',\n",
" phase_info, optimizer=\"IPOPT\", make_plots=True)"
]
},
Expand Down
6 changes: 3 additions & 3 deletions aviary/docs/examples/simple_mission_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"* value: the user-defined value of the variable\n",
"* units: the units of the variable\n",
"\n",
"Let's take a look at the first few lines of an example aircraft file, `aircraft_for_bench_FwFm_simple.csv`.\n",
"Let's take a look at the first few lines of an example aircraft file, `aircraft_for_bench_FwFm.csv`.\n",
"This aircraft is a commercial single-aisle aircraft with two conventional turbofan engines.\n",
"Think of it in the same class as a Boeing 737 or Airbus A320.\n",
"\n",
Expand All @@ -40,7 +40,7 @@
"source": [
"import aviary.api as av\n",
"\n",
"filename = 'models/test_aircraft/aircraft_for_bench_FwFm_simple.csv'\n",
"filename = 'models/test_aircraft/aircraft_for_bench_FwFm.csv'\n",
"filename = av.get_path(filename)\n",
"\n",
"with open(filename, 'r') as file:\n",
Expand Down Expand Up @@ -279,7 +279,7 @@
"source": [
"import aviary.api as av\n",
"\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv',\n",
"prob = av.run_aviary('models/test_aircraft/aircraft_for_bench_FwFm.csv',\n",
" phase_info, optimizer=\"SLSQP\", make_plots=True)"
]
},
Expand Down
10 changes: 5 additions & 5 deletions aviary/docs/getting_started/onboarding_ext_subsystem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@
"\n",
"# Max iterations set to 1 to reduce runtime of example\n",
"max_iter = 1\n",
"phase_info = deepcopy(av.default_simple_phase_info)\n",
"phase_info = deepcopy(av.default_height_energy_phase_info)\n",
"# Here we just add the simple weight system to only the pre-mission\n",
"phase_info['pre_mission']['external_subsystems'] = [WingWeightBuilder(name=\"wing_external\")]\n",
"\n",
"prob = av.AviaryProblem()\n",
"\n",
"# Load aircraft and options data from user\n",
"# Allow for user overrides here\n",
"prob.load_inputs('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv', phase_info)\n",
"prob.load_inputs('models/test_aircraft/aircraft_for_bench_FwFm.csv', phase_info)\n",
"\n",
"# Have checks for clashing user inputs\n",
"# Raise warnings or errors depending on how clashing the issues are\n",
Expand Down Expand Up @@ -119,7 +119,7 @@
"\n",
"# Load aircraft and options data from user\n",
"# Allow for user overrides here\n",
"prob.load_inputs('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv', av.default_simple_phase_info)\n",
"prob.load_inputs('models/test_aircraft/aircraft_for_bench_FwFm.csv', av.default_height_energy_phase_info)\n",
"\n",
"# Have checks for clashing user inputs\n",
"# Raise warnings or errors depending on how clashing the issues are\n",
Expand Down Expand Up @@ -231,7 +231,7 @@
"source": [
"prob = av.AviaryProblem()\n",
"\n",
"prob.load_inputs('models/test_aircraft/aircraft_for_bench_FwFm_simple.csv', phase_info)"
"prob.load_inputs('models/test_aircraft/aircraft_for_bench_FwFm.csv', phase_info)"
]
},
{
Expand Down Expand Up @@ -622,7 +622,7 @@
"metadata": {},
"outputs": [],
"source": [
"aircraft_definition_file = 'models/test_aircraft/aircraft_for_bench_FwFm_simple.csv'\n",
"aircraft_definition_file = 'models/test_aircraft/aircraft_for_bench_FwFm.csv'\n",
"make_plots = False\n",
"max_iter = 0\n",
"optimizer = 'SNOPT'\n",
Expand Down
2 changes: 1 addition & 1 deletion aviary/docs/getting_started/onboarding_level1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
" - `mission:objectives:fuel` if `mission_method` is `GASP` \n",
" - `fuel_burned` if `mission_method` is `FLOPS`.\n",
"\n",
"- `--phase_info`: Path to phase info file. If not provided, it is `default_phase_info/gasp.py` if Mission origin is `2DOF` and `default_phase_info/flops.py` for `height_energy`.\n",
"- `--phase_info`: Path to phase info file. If not provided, it is `default_phase_info/gasp.py` if Mission origin is `2DOF` and `default_phase_info/flops.py` for `simple`.\n",
"\n",
"- `--n2`: Generate an n2 diagram after the analysis. “[N2](https://openmdao.org/newdocs/versions/latest/features/model_visualization/n2_basics/n2_basics.html)” diagram is an OpenMDAO helper to visualize the model (see [details](https://openmdao.org/newdocs/versions/latest/features/model_visualization/n2_details/n2_details.html) too and [tutorial](https://www.youtube.com/watch?v=42VtbX6CX3A)). It is highly recommended that this option is turned on for new users.\n",
"\n",
Expand Down
79 changes: 24 additions & 55 deletions aviary/docs/getting_started/onboarding_level2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
"id": "0c8038df",
"metadata": {},
"source": [
"Similar to pre-mission, it adds a landing phase if `include_landing` key of `post_mission` has value of `True`. If user chooses to define a `post_mission`, it will override the default. For `2dof` missions, landing is defined in [mission/gasp_based/phases/landing_group.py](https://github.com/OpenMDAO/Aviary/blob/main/aviary/mission/gasp_based/phases/landing_group.py). For `height_energy` mission, landing means a [simplified landing](https://github.com/OpenMDAO/Aviary/blob/main/aviary/mission/flops_based/phases/simplified_landing.py). Note that the `solved` method currently doesn't have any post mission systems.\n",
"Similar to pre-mission, it adds a landing phase if `include_landing` key of `post_mission` has value of `True`. If user chooses to define a `post_mission`, it will override the default. For `2dof` missions, landing is defined in [mission/gasp_based/phases/landing_group.py](https://github.com/OpenMDAO/Aviary/blob/main/aviary/mission/gasp_based/phases/landing_group.py). For `simple` mission, landing means a [simplified landing](https://github.com/OpenMDAO/Aviary/blob/main/aviary/mission/flops_based/phases/simplified_landing.py). Note that the `solved` method currently doesn't have any post mission systems.\n",
"\n",
"The next line is"
]
Expand All @@ -336,7 +336,7 @@
"source": [
"This is important for allowing each phase of flight to pass to the next without discontinuities in the parameters. Consider Dymos' [Aircraft Balanced Field Length Calculation](https://openmdao.github.io/dymos/examples/balanced_field/balanced_field.html) example. In that example, we see separate nonlinear boundary constraints, nonlinear path constraints, and phase continuity constraints between phases. We don't want to go deeper in this function call, but just point out that each individual link can be set via dymos function `link_phases`. See [dymos API](https://openmdao.github.io/dymos/api/trajectory_api.html) for more details.\n",
"\n",
"The code blocks in this function (namely, `link_phases()`) are for `2DOF`, `height_energy`, and `solved` missions. The links are set up based on physical principals (e.g. you can’t have instantaneous changes in mass, velocity, position etc.). Special care is required if the user selects a different or unusual set of phases. \n",
"The code blocks in this function (namely, `link_phases()`) are for `2DOF`, `simple`, and `solved` missions. The links are set up based on physical principals (e.g. you can’t have instantaneous changes in mass, velocity, position etc.). Special care is required if the user selects a different or unusual set of phases. \n",
"\n",
"Now, our aircraft and the mission are fully defined. We are ready to define an optimization problem. This is achieved by adding an optimization driver, adding design variables, and an objective. \n",
"\n",
Expand Down Expand Up @@ -512,7 +512,7 @@
"id": "57986647",
"metadata": {},
"source": [
"For `height_energy` and `2DOF` missions, this method performs several calls to `set_val` on the trajectory for states and controls to seed the problem with reasonable initial guesses using `initial_guesses` within corresponding phases (e.g. `default_flops_phases.py` and `default_gasp_phases.py`). For `solved` missions, it performs similar tasks but for hard-coded state parameters. This is reasonable because a `solved` mission is actually a level 3 Aviary approach. We will cover it in [level 3 onboarding doc](onboarding_level3.ipynb) in the next page. Note that initial guesses for all phases are especially important for collocation methods.\n",
"For `simple` and `2DOF` missions, this method performs several calls to `set_val` on the trajectory for states and controls to seed the problem with reasonable initial guesses using `initial_guesses` within corresponding phases (e.g. `default_flops_phases.py` and `default_gasp_phases.py`). For `solved` missions, it performs similar tasks but for hard-coded state parameters. This is reasonable because a `solved` mission is actually a level 3 Aviary approach. We will cover it in [level 3 onboarding doc](onboarding_level3.ipynb) in the next page. Note that initial guesses for all phases are especially important for collocation methods.\n",
"\n",
"The last line is to run the problem we just set up:"
]
Expand Down Expand Up @@ -636,32 +636,26 @@
" 'core_aerodynamics': {'method': 'computed'}\n",
" },\n",
" 'user_options': {\n",
" 'fix_initial': False,\n",
" 'fix_duration': True,\n",
" 'num_segments': 1,\n",
" 'optimize_mach': False,\n",
" 'optimize_altitude': False,\n",
" 'polynomial_control_order': 1,\n",
" 'num_segments': 2,\n",
" 'order': 3,\n",
" 'initial_bounds': ((500., 4000.), 's'),\n",
" 'initial_ref': (1., 's'),\n",
" 'duration_ref': (24370.8, 's'),\n",
" 'duration_bounds': ((726., 48741.6), 's'),\n",
" 'min_altitude': (10.668e3, 'm'),\n",
" 'max_altitude': (10.668e3, 'm'),\n",
" 'min_mach': 0.79,\n",
" 'max_mach': 0.79,\n",
" 'fix_final': False,\n",
" 'required_available_climb_rate': (1.524, 'm/s'),\n",
" 'mass_f_cruise': (1.e4, 'lbm'),\n",
" 'distance_f_cruise': (1.e6, 'm'),\n",
" 'solve_for_distance': False,\n",
" 'initial_mach': (0.72, 'unitless'),\n",
" 'final_mach': (0.72, 'unitless'),\n",
" 'mach_bounds': ((0.7, 0.74), 'unitless'),\n",
" 'initial_altitude': (35000.0, 'ft'),\n",
" 'final_altitude': (35000.0, 'ft'),\n",
" 'altitude_bounds': ((23000.0, 38000.0), 'ft'),\n",
" 'throttle_enforcement': 'boundary_constraint',\n",
" 'fix_initial': True,\n",
" 'constrain_final': False,\n",
" 'fix_duration': False,\n",
" 'initial_bounds': ((0.0, 0.0), 'min'),\n",
" 'duration_bounds': ((10., 30.), 'min'),\n",
" },\n",
" 'initial_guesses': {\n",
" 'times': ([26.2, 406.18], 'min'),\n",
" 'altitude': ([35.e3, 35.e3], 'ft'),\n",
" 'velocity': ([455.49, 455.49], 'kn'),\n",
" 'mass': ([165.e3, 140.e3], 'lbm'),\n",
" 'distance': ([160.3, 3243.9], 'nmi'),\n",
" 'velocity_rate': ([0., 0.], 'm/s**2'),\n",
" 'throttle': ([0.95, 0.9], 'unitless'),\n",
" }\n",
" 'initial_guesses': {'times': ([0, 30], 'min')},\n",
" },\n",
" 'post_mission': {\n",
" 'include_landing': False,\n",
Expand All @@ -670,7 +664,7 @@
"\n",
"# inputs that run_aviary() requires\n",
"aircraft_filename = \"models/test_aircraft/aircraft_for_bench_FwFm.csv\"\n",
"mission_method = \"FLOPS\"\n",
"mission_method = \"height_energy_energy\"\n",
"mass_method = \"FLOPS\"\n",
"optimizer = \"SLSQP\"\n",
"analysis_scheme = av.AnalysisScheme.COLLOCATION\n",
Expand Down Expand Up @@ -723,33 +717,8 @@
"\n",
"We will see more details for what users can do in [level 3](onboarding_level3.ipynb).\n",
"\n",
"Level 2 is where you can integrate user-defined [external subsystems](https://github.com/OpenMDAO/Aviary/blob/main/aviary/docs/user_guide/subsystems.md), which is one of the main features of the Aviary tool. [Examples](https://github.com/OpenMDAO/Aviary/blob/main/aviary/docs/user_guide/using_external_subsystems.md) of external subsystems are: acoustics, battery modeling, etc.\n",
"Assume that you already have an external subsystem that you want to incorporate it into your model. We show how to add external subsystems via `external_subsystems` key in `phase_info`. External subsystems can be added in all phases. For example, we can have:\n",
"\n",
"```\n",
"from aviary.subsystems.test.test_dummy_subsystem import PreOnlyBuilder, PostOnlyBuilder, \\\n",
" ArrayGuessSubsystemBuilder, AdditionalArrayGuessSubsystemBuilder\n",
"\n",
"phase_info = {\n",
"\t'pre_mission': {\n",
"\t\t'include_takeoff': True,\n",
"\t\t'external_subsystems': [ArrayGuessSubsystemBuilder()],\n",
"\t\t'optimize_mass': False,\n",
"\t},\n",
"\t'cruise': {\n",
"\t\t...\n",
" 'external_subsystems': \n",
" [\n",
" ArrayGuessSubsystemBuilder(),\n",
" AdditionalArrayGuessSubsystemBuilder()\n",
" ],\n",
"\t},\n",
"\t'post_mission': {\n",
"\t\t'include_landing': False,\n",
"\t\t'external_subsystems': [PostOnlyBuilder()],\n",
"\t}\n",
"}\n",
"```\n",
"Level 2 is where you can integrate user-defined [external subsystems](../user_guide/subsystems.md), which is one of the main features of the Aviary tool. [Examples](../user_guide/using_external_subsystems.md) of external subsystems are: acoustics, battery modeling, etc.\n",
"Assume that you already have an external subsystem that you want to incorporate it into your model. We show how to add external subsystems via `external_subsystems` key in `phase_info`.\n",
"\n",
"We will cover external subsystems in details in [Models with External Subsystems](onboarding_ext_subsystem.ipynb) page.\n"
]
Expand Down
Loading

0 comments on commit 4f0b3e7

Please sign in to comment.