Skip to content
Permalink
7a4d88b31a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
335 lines (335 sloc) 11.5 KB
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"###### Content under Creative Commons Attribution license CC-BY 4.0, code under MIT license (c)2014 L.A. Barba, G.F. Forsyth."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Coding Assignment: Rocket"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The equations of motion for a rocket in purely vertical flight are given by\n",
"\n",
"\\begin{align}\n",
"\\frac{dh}{dt} &= v\\\\\n",
"(m_s+m_p) \\frac{dv}{dt}& = -(m_s+m_p)g + \\dot{m}_pv_e - \\frac{1}{2}\\rho v|v|AC_D\n",
"\\end{align}\n",
"\n",
"$h$ is the altitude of the rocket\n",
"\n",
"$m_s = 50kg$ is the weight of the rocket shell\n",
"\n",
"$g = 9.81 \\frac{m}{s^2}$\n",
"\n",
"$\\rho = 1.091 \\frac{kg}{m^3}$ is the average air density (assumed constant throughout flight)\n",
"\n",
"$A = \\pi r^2$ is the maximum cross sectional area of the rocket, where $r = 0.5 m$\n",
"\n",
"$v_e = 325 \\frac{m}{s}$ is the exhaust speed\n",
"\n",
"$C_D = 0.15 $ is the drag coefficient\n",
"\n",
"$m_{po} = 100 kg$ at time $t = 0$ is the initial weight of the rocket propellant\n",
"\n",
"The mass of the remaining propellant is given by:\n",
"\n",
"$$m_p = m_{po} - \\int^t_0 \\dot{m}_p d\\tau$$\n",
"\n",
"where $\\dot{m}_p$ is the time-varying burn rate given by the following figure:\n",
"\n",
"Propellant Burn Rate\n",
"\n",
"![burn rate](./burn.rate.png)\n",
"\n",
"Using Euler's method with a timestep of $\\Delta t=0.1s$, create a Python script to calculate the altitude and velocity of the rocket from launch until crash down. \n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Assessment:\n",
"\n",
"To check your answers, you can register for [MAE 6286: Practical Numerical Methods with Python](http://openedx.seas.gwu.edu/courses/GW/MAE6286/2014_fall/about).\n",
"\n",
"1. At time $t=3.2s$, what is the mass (in kg) of rocket propellant remaining in the rocket?\n",
"\n",
"2. What is the maximum speed of the rocket in $\\frac{m}{s}$?\n",
" At what time does this occur (in seconds)? \n",
" What is the altitude at this time (in meters)? \n",
" \n",
"3. What is the rocket's maximum altitude during flight (in meters)? At what time (in seconds) does this occur?\n",
"\n",
"4. At what time (in seconds) does the rocket impact the ground? What is the velocity of the rocket (in $\\frac{m}{s}$) at time of impact?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Derivation of the rocket equations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In case you are kind of confused about the rocket equations, here we show how to get to them. \n",
"\n",
"Newton's second law states that the acceleration of the vehicle times its mass is equal to all the forces acting on it. Therefore,\n",
"\n",
"\\begin{equation}\n",
"(m_s + m_p)\\frac{d\\bf{v}}{dt}=\\sum {\\bf F}.\n",
"\\end{equation}\n",
"In the above formula we have assumed that the propellant inside the rocket and the rocket move at the same velocity (in other words, their relative velocity is negligible). \n",
"\n",
"Two of the external forces acting on the rocket are,\n",
"\n",
"\\begin{align}\n",
"{\\bf F}_g&= (m_s+m_p)\\bf{g} \\quad (\\rm{Gravity}),\\\\\n",
"{\\bf F}_d&= - \\frac{1}{2} \\rho_a \\mathbf{v} |\\mathbf{v}| A C_D \\quad (\\rm{Drag}).\n",
"\\end{align}\n",
"\n",
"We also need to consider the force resulting from the ejection of the propellant. During an interval $dt$, the engine of the rocket ejects downwards a mass of propellant given by $\\dot m_p dt$. Relative to the rocket, the speed of the ejected burning gas is assumed constant and equal to $v_e$ (the exhaust speed). The momentum variation induced on the exhaust gas by the engine during that interval is therefore, $d{\\bf p}_{gas} = \\dot m_p {\\bf v}_e dt$. Again using Newton's second law we conclude that the force applied by the rocket on the gas is,\n",
"\n",
"\\begin{align}\n",
"{\\bf F}_{rocket\\rightarrow gas} = \\frac{d{\\bf p}_{gas}}{dt} = \\dot m_p {\\bf v}_e\n",
"\\end{align}\n",
"\n",
"Using Newton's third law (|action| = |reaction|), the force exerted by the exhaust gas on the rocket is then,\n",
"\n",
"\\begin{align}\n",
"{\\bf F}_{gas\\rightarrow rocket} = -{\\bf F}_{rocket\\rightarrow gas} = -\\dot m_p {\\bf v}_e\n",
"\\end{align}\n",
"\n",
"If we collect all the forces acting on the rocket we finally have:\n",
"\n",
"\\begin{align}\n",
"(m_s + m_p)\\frac{d\\bf{v}}{dt}=(m_s+m_p){\\bf g}- \\frac{1}{2} \\rho_a \\mathbf{v} |v| A C_D -\\dot m_p {\\bf v}_e\n",
"\\end{align}\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"###### The cell below loads the style of the notebook."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=PT+Mono' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=Nixie+One' rel='stylesheet' type='text/css'>\n",
"<style>\n",
"\n",
"@font-face {\n",
" font-family: \"Computer Modern\";\n",
" src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n",
"}\n",
"\n",
"#notebook_panel { /* main background */\n",
" background: rgb(245,245,245);\n",
"}\n",
"\n",
"div.cell { /* set cell width */\n",
" width: 750px;\n",
"}\n",
"\n",
"div #notebook { /* centre the content */\n",
" background: #fff; /* white background for content */\n",
" width: 1000px;\n",
" margin: auto;\n",
" padding-left: 0em;\n",
"}\n",
"\n",
"#notebook li { /* More space between bullet points */\n",
" margin-top:0.8em;\n",
"}\n",
"\n",
"/* draw border around running cells */\n",
"div.cell.border-box-sizing.code_cell.running { \n",
" border: 1px solid #111;\n",
"}\n",
"\n",
"/* Put a solid color box around each cell and its output, visually linking them*/\n",
"div.cell.code_cell {\n",
" background-color: rgb(256,256,256); \n",
" border-radius: 0px; \n",
" padding: 0.5em;\n",
" margin-left:1em;\n",
" margin-top: 1em;\n",
"}\n",
"\n",
"div.text_cell_render{\n",
" font-family: 'Alegreya Sans' sans-serif;\n",
" line-height: 140%;\n",
" font-size: 125%;\n",
" font-weight: 400;\n",
" width:600px;\n",
" margin-left:auto;\n",
" margin-right:auto;\n",
"}\n",
"\n",
"\n",
"/* Formatting for header cells */\n",
".text_cell_render h1 {\n",
" font-family: 'Nixie One', serif;\n",
" font-style:regular;\n",
" font-weight: 400; \n",
" font-size: 45pt;\n",
" line-height: 100%;\n",
" color: rgb(0,51,102);\n",
" margin-bottom: 0.5em;\n",
" margin-top: 0.5em;\n",
" display: block;\n",
"}\n",
"\n",
".text_cell_render h2 {\n",
" font-family: 'Nixie One', serif;\n",
" font-weight: 400;\n",
" font-size: 30pt;\n",
" line-height: 100%;\n",
" color: rgb(0,51,102);\n",
" margin-bottom: 0.1em;\n",
" margin-top: 0.3em;\n",
" display: block;\n",
"}\t\n",
"\n",
".text_cell_render h3 {\n",
" font-family: 'Nixie One', serif;\n",
" margin-top:16px;\n",
" font-size: 22pt;\n",
" font-weight: 600;\n",
" margin-bottom: 3px;\n",
" font-style: regular;\n",
" color: rgb(102,102,0);\n",
"}\n",
"\n",
".text_cell_render h4 { /*Use this for captions*/\n",
" font-family: 'Nixie One', serif;\n",
" font-size: 14pt;\n",
" text-align: center;\n",
" margin-top: 0em;\n",
" margin-bottom: 2em;\n",
" font-style: regular;\n",
"}\n",
"\n",
".text_cell_render h5 { /*Use this for small titles*/\n",
" font-family: 'Nixie One', sans-serif;\n",
" font-weight: 400;\n",
" font-size: 16pt;\n",
" color: rgb(163,0,0);\n",
" font-style: italic;\n",
" margin-bottom: .1em;\n",
" margin-top: 0.8em;\n",
" display: block;\n",
"}\n",
"\n",
".text_cell_render h6 { /*use this for copyright note*/\n",
" font-family: 'PT Mono', sans-serif;\n",
" font-weight: 300;\n",
" font-size: 9pt;\n",
" line-height: 100%;\n",
" color: grey;\n",
" margin-bottom: 1px;\n",
" margin-top: 1px;\n",
"}\n",
"\n",
".CodeMirror{\n",
" font-family: \"PT Mono\";\n",
" font-size: 90%;\n",
"}\n",
"\n",
"</style>\n",
"<script>\n",
" MathJax.Hub.Config({\n",
" TeX: {\n",
" extensions: [\"AMSmath.js\"],\n",
" equationNumbers: { autoNumber: \"AMS\", useLabelIds: true}\n",
" },\n",
" tex2jax: {\n",
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
" displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
" },\n",
" displayAlign: 'center', // Change this to 'center' to center equations.\n",
" \"HTML-CSS\": {\n",
" styles: {'.MathJax_Display': {\"margin\": 4}}\n",
" }\n",
" });\n",
"</script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.core.display import HTML\n",
"css_file = '../../styles/numericalmoocstyle.css'\n",
"HTML(open(css_file, \"r\").read())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}