Skip to content

Commit

Permalink
Added atmosphere component to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikponnapalli committed Mar 23, 2023
1 parent 2822281 commit 845f0c1
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion docs/dymos_book/examples/reentry/reentry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,56 @@
"Below is the code for the atmospheric component:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import openmdao.api as om\n",
"\n",
"\n",
"class Atmosphere(om.ExplicitComponent):\n",
" \"\"\"\n",
" Defines the logarithmic atmosphere model for the shuttle reentry problem.\n",
"\n",
" References\n",
" ----------\n",
" .. [1] Betts, John T., Practical Methods for Optimal Control and Estimation Using Nonlinear\n",
" Programming, p. 248, 2010.\n",
" \"\"\"\n",
"\n",
" def initialize(self):\n",
" self.options.declare('num_nodes', types=int)\n",
"\n",
" def setup(self):\n",
" nn = self.options['num_nodes']\n",
" self.add_input('h', val=np.ones(nn), desc='altitude', units='ft')\n",
" self.add_output('rho', val=np.ones(nn), desc='local density', units='slug/ft**3')\n",
" partial_range = np.arange(nn, dtype=int)\n",
" self.declare_partials('rho', 'h', rows=partial_range, cols=partial_range)\n",
"\n",
" def compute(self, inputs, outputs):\n",
" h = inputs['h']\n",
" h_r = 23800\n",
" rho_0 = .002378\n",
" outputs['rho'] = rho_0 * np.exp(-h / h_r)\n",
"\n",
" def compute_partials(self, inputs, partials):\n",
" h = inputs['h']\n",
" h_r = 23800\n",
" rho_0 = .002378\n",
" partials['rho', 'h'] = -1 / h_r * rho_0 * np.exp(-h / h_r)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Below is the code for the aerodynamics component:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -706,7 +756,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.11.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 845f0c1

Please sign in to comment.