Skip to content
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

Added a FunctionComp example #710

Merged
merged 11 commits into from
Feb 1, 2022
8 changes: 5 additions & 3 deletions .github/workflows/dymos_tests_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
DOCS: 0

# oldest supported versions
- PY: 3.6
- PY: 3.7
NUMPY: 1.16
SCIPY: 1.2
PETSc: 3.10.2
Expand Down Expand Up @@ -258,6 +258,7 @@ jobs:

- name: Build docs
if: ${{ matrix.DOCS == '1' || matrix.DOCS == '2' }}
id: build_docs
shell: bash -l {0}
run: |
echo "============================================================="
Expand All @@ -269,9 +270,10 @@ jobs:
python copy_build_artifacts.py

- name: Display doc build reports
if: failure() && matrix.DOCS == '1' && steps.build_docs.outcome == 'failure'
continue-on-error: True
if: failure() && (matrix.DOCS == '1' || matrix.DOCS == '2') && steps.build_docs.outcome == 'failure'
run: |
for f in /home/runner/work/OpenMDAO/dymos/docs/dymos_book/_build/html/reports/*; do
for f in /home/runner/work/dymos/dymos/docs/dymos_book/_build/html/reports/*; do
echo "============================================================="
echo $f
echo "============================================================="
Expand Down
1 change: 1 addition & 0 deletions docs/dymos_book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ parts:
- file: examples/brachistochrone/brachistochrone_upstream_init_duration_states
- file: examples/vanderpol/vanderpol
- file: examples/balanced_field/balanced_field
- file: examples/balanced_field/balanced_field_funccomp
- file: examples/bryson_denham/bryson_denham
- file: examples/commercial_aircraft/commercial_aircraft
- file: examples/double_integrator/double_integrator
Expand Down
75 changes: 17 additions & 58 deletions docs/dymos_book/examples/balanced_field/balanced_field.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"(examples:balanced_field)=\n",
"\n",
"# Aircraft Balanced Field Length Calculation\n",
"\n",
"```{admonition} Things you'll learn through this example\n",
Expand Down Expand Up @@ -225,7 +228,7 @@
"|S |aerodynamic reference area |$m^2$ | 124.7 |\n",
"|CD0 |zero-lift drag coefficient |- | 0.03 |\n",
"|AR |wing aspect ratio |- | 9.45 |\n",
"|e |Oswald's wing efficiency |- | 801 |\n",
"|e |Oswald's wing efficiency |- | 0.801 |\n",
"|span |wingspan |$m$ | 35.7 |\n",
"|h_w |height of wing above CoG |$m$ | 1.0 |\n",
"|CL0 |aerodynamic reference area |- | 0.5 |\n",
Expand Down Expand Up @@ -443,7 +446,10 @@
"p.driver.options['print_results'] = False\n",
"if optimizer == 'IPOPT':\n",
" p.driver.opt_settings['print_level'] = 5\n",
" p.driver.opt_settings['derivative_test'] = 'first-order'"
" p.driver.opt_settings['mu_strategy'] = 'adaptive'\n",
" p.driver.opt_settings['bound_mult_init_method'] = 'mu-based'\n",
" p.driver.opt_settings['mu_init'] = 0.01\n",
" p.driver.opt_settings['nlp_scaling_method'] = 'gradient-based'"
]
},
{
Expand Down Expand Up @@ -520,7 +526,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In the next part of our script we define the trajectory-level parameters. We assign these to their corresponding targets in the various phases of the trajectory."
"In the next part of our script we define the trajectory-level parameters. We assign these to their corresponding targets in the various phases of the trajectory.\n",
"\n",
"We're omitting a lot of the scalar inputs to the ODE and letting them assume their default values for the sake of brevity."
]
},
{
Expand All @@ -529,13 +537,15 @@
"metadata": {},
"outputs": [],
"source": [
"all_phases = ['br_to_v1', 'v1_to_vr', 'rto', 'rotate', 'climb']\n",
"groundroll_phases = ['br_to_v1', 'v1_to_vr', 'rto', 'rotate']\n",
"\n",
"# Add parameters common to multiple phases to the trajectory\n",
"traj.add_parameter('m', val=174200., opt=False, units='lbm',\n",
" desc='aircraft mass',\n",
" targets={'br_to_v1': ['m'], 'v1_to_vr': ['m'], 'rto': ['m'],\n",
" 'rotate': ['m'], 'climb': ['m']})\n",
" targets={phase: ['m'] for phase in all_phases})\n",
"\n",
"# Handle parameters which change from phase to phase.\n",
"traj.add_parameter('T_nominal', val=27000 * 2, opt=False, units='lbf', static_target=True,\n",
" desc='nominal aircraft thrust',\n",
" targets={'br_to_v1': ['T']})\n",
Expand All @@ -558,58 +568,7 @@
"\n",
"traj.add_parameter('h_runway', val=0., opt=False, units='ft',\n",
" desc='runway altitude',\n",
" targets={'br_to_v1': ['h'], 'v1_to_vr': ['h'], 'rto': ['h'],\n",
" 'rotate': ['h']})\n",
"\n",
"traj.add_parameter('rho', val=1.225, opt=False, units='kg/m**3', static_target=True,\n",
" desc='atmospheric density',\n",
" targets={'br_to_v1': ['rho'], 'v1_to_vr': ['rho'], 'rto': ['rho'],\n",
" 'rotate': ['rho']})\n",
"\n",
"traj.add_parameter('S', val=124.7, opt=False, units='m**2', static_target=True,\n",
" desc='aerodynamic reference area',\n",
" targets={'br_to_v1': ['S'], 'v1_to_vr': ['S'], 'rto': ['S'],\n",
" 'rotate': ['S'], 'climb': ['S']})\n",
"\n",
"traj.add_parameter('CD0', val=0.03, opt=False, units=None, static_target=True,\n",
" desc='zero-lift drag coefficient',\n",
" targets={f'{phase}': ['CD0'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('AR', val=9.45, opt=False, units=None, static_target=True,\n",
" desc='wing aspect ratio',\n",
" targets={f'{phase}': ['AR'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('e', val=801, opt=False, units=None, static_target=True,\n",
" desc='Oswald span efficiency factor',\n",
" targets={f'{phase}': ['e'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('span', val=35.7, opt=False, units='m', static_target=True,\n",
" desc='wingspan',\n",
" targets={f'{phase}': ['span'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('h_w', val=1.0, opt=False, units='m', static_target=True,\n",
" desc='height of wing above CG',\n",
" targets={f'{phase}': ['h_w'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('CL0', val=0.5, opt=False, units=None, static_target=True,\n",
" desc='zero-alpha lift coefficient',\n",
" targets={f'{phase}': ['CL0'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('CL_max', val=2.0, opt=False, units=None, static_target=True,\n",
" desc='maximum lift coefficient for linear fit',\n",
" targets={f'{phase}': ['CL_max'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})\n",
"\n",
"traj.add_parameter('alpha_max', val=10.0, opt=False, units='deg', static_target=True,\n",
" desc='angle of attack at maximum lift',\n",
" targets={f'{phase}': ['alpha_max'] for phase in ['br_to_v1', 'v1_to_vr',\n",
" 'rto', 'rotate' 'climb']})"
" targets={phase: ['h'] for phase in groundroll_phases})"
]
},
{
Expand Down Expand Up @@ -804,7 +763,7 @@
"source": [
"from openmdao.utils.assert_utils import assert_near_equal\n",
"\n",
"assert_near_equal(p.get_val('traj.rto.states:r')[-1], 2188.2, tolerance=0.01)"
"assert_near_equal(p.get_val('traj.rto.states:r')[-1], 2197.7, tolerance=0.01)"
]
},
{
Expand Down
Loading