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

Fixed missing component in Re-entry docs #914

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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