Skip to content

Commit

Permalink
Merge pull request OpenMDAO#512 from Kenneth-T-Moore/doc01
Browse files Browse the repository at this point in the history
Fix the broken drag example.
  • Loading branch information
ehariton authored Sep 9, 2024
2 parents 4134100 + 95a7e9d commit 79a9eda
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions aviary/docs/user_guide/external_aero.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
" This component doesn't do anything, except set the drag and lift\n",
" polars from the file we read in.\n",
" \"\"\"\n",
"\n",
" # Your component will compute CD and CL for a grid of altitudes, machs, and\n",
" # angles of attack, and return them in a multidimensional array as described \n",
" # in the example text.\n",
"\n",
" # Because it would be prohibitive to embed something like a vortex lattice\n",
" # code in this example, we are \"cheating\" here by sending a pre-computed\n",
" # drag polar.\n",
" \n",
" outputs['drag_table'] = CD\n",
" outputs['lift_table'] = CL\n",
" \n",
Expand Down Expand Up @@ -156,12 +165,18 @@
" the pre-mission part of the Aviary problem. This includes sizing, design,\n",
" and other non-mission parameters.\n",
" \"\"\"\n",
"\n",
" return ExternalAero(altitude=self.altitude, mach=self.mach, angle_of_attack=self.angle_of_attack)\n",
"\n",
" def mission_outputs(self):\n",
" return [('drag_table', Aircraft.Design.DRAG_POLAR),\n",
" ('lift_table', Aircraft.Design.LIFT_POLAR)]"
" aero_group = om.Group()\n",
" aero = ExternalAero(altitude=self.altitude, mach=self.mach, angle_of_attack=self.angle_of_attack)\n",
" aero_group.add_subsystem(\n",
" 'premission_aero', \n",
" aero,\n",
" promotes_inputs=['*'],\n",
" promotes_outputs=[\n",
" ('drag_table', Aircraft.Design.DRAG_POLAR),\n",
" ('lift_table', Aircraft.Design.LIFT_POLAR)\n",
" ]\n",
" )\n",
" return aero_group"
]
},
{
Expand Down Expand Up @@ -264,7 +279,28 @@
"prob.add_driver(\"SLSQP\")\n",
"prob.add_design_variables()\n",
"prob.add_objective(objective_type=\"mass\", ref=-1e5)\n",
"prob.setup()"
"prob.setup()\n",
"prob.set_initial_guesses()\n",
"\n",
"prob.run_model()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bc8788ba-9b2b-4b81-8251-32db008d3a60",
"metadata": {
"tags": [
"remove-cell"
]
},
"outputs": [],
"source": [
"\n",
"# Make sure we succesfully passed the polar\n",
"from openmdao.utils.assert_utils import assert_near_equal\n",
"om_CD = prob.get_val(Aircraft.Design.DRAG_POLAR)[0, 0, 0]\n",
"assert_near_equal(om_CD, CD[0, 0, 0], 1e-6)"
]
}
],
Expand All @@ -285,7 +321,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.12.3"
},
"orphan": true
},
Expand Down

0 comments on commit 79a9eda

Please sign in to comment.