Permalink
Cannot retrieve contributors at this time
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?
compmech-project03/03_IVPs_project.ipynb
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
975 lines (975 sloc)
92.4 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Initial Value Problems - Project\n", | |
"\n", | |
"![Initial condition of firework with FBD and sum of momentum](../images/firework.png)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"We are going to end this module with a __bang__ by looking at the flight path of a firework. Shown above is the initial condition of a firework, the _Freedom Flyer_ in (a), its final height where it detonates in (b), the applied forces in the __Free Body Diagram (FBD)__ in (c), and the __momentum__ of the firework $m\\mathbf{v}$ and the propellent $dm \\mathbf{u}$ in (d). \n", | |
"\n", | |
"The resulting equation of motion is that the acceleration is proportional to the speed of the propellent and the mass rate change $\\frac{dm}{dt}$ as such\n", | |
"\n", | |
"$$\\begin{equation}\n", | |
"m\\frac{dv}{dt} = u\\frac{dm}{dt} -mg - cv^2.~~~~~~~~(1)\n", | |
"\\end{equation}$$\n", | |
"\n", | |
"If we assume that the acceleration and the propellent momentum are much greater than the forces of gravity and drag, then the equation is simplified to the conservation of momentum. A further simplification is that the speed of the propellant is constant, $u=constant$, then the equation can be integrated to obtain an analytical rocket equation solution of [Tsiolkovsky](https://www.math24.net/rocket-motion/) [1,2], \n", | |
"\n", | |
"$$\\begin{equation}\n", | |
"m\\frac{dv}{dt} = u\\frac{dm}{dt}~~~~~(2.a)\n", | |
"\\end{equation}$$\n", | |
"\n", | |
"$$\\begin{equation}\n", | |
"\\frac{m_{f}}{m_{0}}=e^{-\\Delta v / u},~~~~~(2.b) \n", | |
"\\end{equation}$$\n", | |
"\n", | |
"where $m_f$ and $m_0$ are the mass at beginning and end of flight, $u$ is the speed of the propellent, and $\\Delta v=v_{final}-v_{initial}$ is the change in speed of the rocket from beginning to end of flight. Equation 2.b only relates the final velocity to the change in mass and propellent speed. When you integrate Eqn 2.a, you will have to compare the velocity as a function of mass loss. \n", | |
"\n", | |
"Your first objective is to integrate a numerical model that converges to equation (2.b), the Tsiolkovsky equation. Next, you will add drag and gravity and compare the results _between equations (1) and (2)_. Finally, you will vary the mass change rate to achieve the desired detonation height. \n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"1. Create a `simplerocket` function that returns the velocity, $v$, the acceleration, $a$, and the mass rate change $\\frac{dm}{dt}$, as a function of the $state = [position,~velocity,~mass] = [y,~v,~m]$ using eqn (2.a). Where the mass rate change $\\frac{dm}{dt}$ and the propellent speed $u$ are constants. The average velocity of gun powder propellent used in firework rockets is $u=250$ m/s [3,4]. \n", | |
"\n", | |
"$\\frac{d~state}{dt} = f(state)$\n", | |
"\n", | |
"$\\left[\\begin{array}{c} v\\\\a\\\\ \\frac{dm}{dt} \\end{array}\\right] = \\left[\\begin{array}{c} v\\\\ \\frac{u}{m}\\frac{dm}{dt} \\\\ \\frac{dm}{dt} \\end{array}\\right]$\n", | |
"\n", | |
"Use [two integration methods](../notebooks/03_Get_Oscillations.ipynb) to integrate the `simplerocket` function, one explicit method and one implicit method. Demonstrate that the solutions converge to equation (2.b) the Tsiolkovsky equation. Use an initial state of y=0 m, v=0 m/s, and m=0.25 kg. \n", | |
"\n", | |
"Integrate the function until mass, $m_{f}=0.05~kg$, using a mass rate change of $\\frac{dm}{dt}=0.05$ kg/s. \n", | |
"\n", | |
"_Hint: your integrated solution will have a current mass that you can use to create $\\frac{m_{f}}{m_{0}}$ by dividing state[2]/(initial mass), then your plot of velocity(t) vs mass(t)/mass(0) should match Tsiolkovsky's_" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"%matplotlib inline\n", | |
"plt.rcParams.update({'font.size': 22})\n", | |
"plt.rcParams['lines.linewidth'] = 3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 93, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"Text(0, 0.5, 'velocity (m/s)')" | |
] | |
}, | |
"execution_count": 93, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEGCAYAAACO8lkDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3deXyU9bX48c9JQgg7lh0ksoOyGgIIKoui1CpCXapURWwR0WqvWrBYrYa2Fi54r9aK4vJT8aLUUisgoigqgrJjABHZ90VZhJQlISQ5vz/mSZiQzGQmmckzy3m/XvOamWeb8xCdM99dVBVjjDHGW4LbARhjjIk8lhyMMcaUYMnBGGNMCZYcjDHGlGDJwRhjTAlJbgcQCvXr19cWLVq4HYYxxkSV1atXH1bVBqXti4nk0KJFC1atWuV2GMYYE1VEZJevfVatZIwxpgRLDsYYY0qw5GCMMaYESw7GGGNKiIkGaROYWZn7mDx/E/uPZdO0bjXGDmrP0IubuR2WiQJnzpxh79695OTkuB2KCVJiYiJ169alfv36JCQEXh6w5BAncia0YujpIwwFMpaNI6P/RJgNOR/VI+XR7W6HZyLc3r17qVWrFi1atEBE3A7HBEhVOXPmDD/88AN79+4lNTU14HMrpVpJRJ4UERWRTs77diKyVEQ2O89tvY71uc+UX8rpI0Wvx3/xaKnbjfElJyeHevXqWWKIMiJCcnIyzZo14+TJk0GdG/bkICJpwCXA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QCvecHgLdUtUBVs/Dc84BKjbRyhfz7K+aTgwY+HcdMPF8UCSLSABgKvFt5kYZOoPcsIj2Ad4Cb1GvG22gUyD2r6m5Vra+qLVS1BZ5Gy1dUdVSJC0aBIP7bfhu4WjyqAFcCaysv0tAJ4p53AD8FEJFkYCBQoq4+hoT++8vtlvjKeAAd8PRW2Ow8t3e2zwPSndeJwIvANucxyu24K+GeVwKH8PzPVvjo7Hbs4bznc47PIPp7KwXyd04A/hf4DvjWeZ3gduxhvufWwCfAN3h6ak0BktyOvZz3+xye3kd5eNpPvi3lfkP+/RXzvZWMMcYEL+arlYwxxgTPkoMxxpgSLDkYY4wpwZKDMcaYEiw5GGOMKcGSgzEhJiKvisi1QZ5TXUTecWbU3Cgi14UrPmMCYcnBmBASkQQ8I3E/DfLUMcBxVW0DDAZeFZGaoY7PmEBZcjCmDM48+o+JyEoR2S4iV4rIBBHJdNZHuNDr8N7AGlXNEZEMEfmHiMxzSgTviMjFIvKZM+++94yZtwBTAVR1C7AKzxxIxrjCkoMxgTmmqj2A3+OZp+dLVb0YeBN4zOu4oc7+Qt3xTPHQHs/I3ol4vvS7AHd6LVQTS7MCmxhgycGYwLzjPH8NqKp+4LxfDbTxOu5a4AOv9/NVNUs9s8CuAz5RzwR4J4FNeKZ5MCbiWHIwJjA5znM+noWC8HqfBCAiFwEHVfVIKecVHnvu+8KlK2NpVmATAyw5GBM6QyhepRSMmcA9AE5VUw/goxDFZUzQLDkYEzoVSQ6TgboishWYi2dWzeMhi8yYINmsrMaEgIg0wdO+0MXtWIwJBUsOxhhjSrBqJWOMMSVYcjDGGFOCJQdjjDElWHIwxhhTgiUHY4wxJVhyMMYYU8L/BwiKsuYW/awqAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"%matplotlib inline\n", | |
"plt.rcParams.update({'font.size': 11})\n", | |
"plt.rcParams['lines.linewidth'] = 1\n", | |
"\n", | |
"def simplerocket(state,dmdt=0.05, u=250):\n", | |
" '''Computes the right-hand side of the differential equation\n", | |
" for the acceleration of a rocket, without drag or gravity, in SI units.\n", | |
" \n", | |
" Arguments\n", | |
" ---------- \n", | |
" state : array of three dependent variables [y v m]^T\n", | |
" dmdt : mass rate change of rocket in kilograms/s default set to 0.05 kg/s\n", | |
" u : speed of propellent expelled (default is 250 m/s)\n", | |
" \n", | |
" Returns\n", | |
" -------\n", | |
" derivs: array of three derivatives [v (u/m*dmdt-g-c/mv^2) -dmdt]^T\n", | |
" '''\n", | |
" dstate = np.zeros(np.shape(state))\n", | |
" \n", | |
" dstate[0] = state[1]\n", | |
" dstate[1] = u*dmdt/state[2]\n", | |
" dstate[2] = - dmdt\n", | |
" return dstate\n", | |
"\n", | |
"def rk2_step(state, rhs, dt):\n", | |
" '''Update a state to the next time increment using modified Euler's method.\n", | |
" \n", | |
" Arguments\n", | |
" ---------\n", | |
" state : array of dependent variables\n", | |
" rhs : function that computes the RHS of the DiffEq\n", | |
" dt : float, time increment\n", | |
" \n", | |
" Returns\n", | |
" -------\n", | |
" next_state : array, updated after one time increment'''\n", | |
" \n", | |
" mid_state = state + rhs(state) * dt*0.5 \n", | |
" next_state = state + rhs(mid_state)*dt\n", | |
" \n", | |
" return next_state\n", | |
"\n", | |
"def heun_step(state,rhs,dt,etol=0.000001,maxiters = 100):\n", | |
" '''Update a state to the next time increment using the implicit Heun's method.\n", | |
" \n", | |
" Arguments\n", | |
" ---------\n", | |
" state : array of dependent variables\n", | |
" rhs : function that computes the RHS of the DiffEq\n", | |
" dt : float, time increment\n", | |
" etol : tolerance in error for each time step corrector\n", | |
" maxiters: maximum number of iterations each time step can take\n", | |
" \n", | |
" Returns\n", | |
" -------\n", | |
" next_state : array, updated after one time increment'''\n", | |
" e=1\n", | |
" eps=np.finfo('float64').eps\n", | |
" next_state = state + rhs(state)*dt\n", | |
" ################### New iterative correction #########################\n", | |
" for n in range(0,maxiters):\n", | |
" next_state_old = next_state\n", | |
" next_state = state + (rhs(state)+rhs(next_state))/2*dt\n", | |
" e=np.sum(np.abs(next_state-next_state_old)/np.abs(next_state+eps))\n", | |
" if e<etol:\n", | |
" break\n", | |
" ############### end of iterative correction #########################\n", | |
" return next_state\n", | |
"\n", | |
"#initialize solution array\n", | |
"N = 300 \n", | |
"\n", | |
"num_rk2 = np.zeros([N,3])\n", | |
"num_heun = np.zeros([N,3])\n", | |
" \n", | |
"#Set intial conditions\n", | |
"y0 = 0\n", | |
"v0 = 0\n", | |
"m0 = 0.25\n", | |
"dt = 0.05\n", | |
"\n", | |
"num_rk2[0,0] = y0\n", | |
"num_rk2[0,1] = v0\n", | |
"num_rk2[0,2] = m0\n", | |
"num_heun[0,0] = y0\n", | |
"num_heun[0,1] = v0\n", | |
"num_heun[0,2] = m0\n", | |
"\n", | |
" \n", | |
"for i in range(N-1):\n", | |
" num_rk2[i+1] = rk2_step(num_rk2[i], simplerocket, dt)\n", | |
" if num_rk2[i+1,2] <= 0.05 :\n", | |
" break\n", | |
"for i in range(N-1):\n", | |
" num_heun[i+1] = heun_step(num_heun[i], simplerocket, dt)\n", | |
" if num_heun[i+1,2] <= 0.05 :\n", | |
" break\n", | |
"\n", | |
"#for i in range(N-1):\n", | |
"# if num_rk2[i,0] == 0.0 and num_rk2[i,1] == 0.0 and num_rk2[i,2] == 0.0:\n", | |
"# plt.plot(num_rk2[i,0],num_rk2[i,2]/m0,'s-')#,label='explicit RK2')\n", | |
"# num_rk2 = np.delete(num_rk2, i, axis=0)\n", | |
"# print(len(num_rk2), i)\n", | |
" \n", | |
"#print(num_rk2)\n", | |
"#print(num_heun)\n", | |
"\n", | |
"#print(np.nonzero(num_rk2))\n", | |
"\n", | |
"plt.plot(num_heun[:,2]/m0, num_heun[:,1], 'o-',label='implicit Heun')\n", | |
"plt.plot(num_rk2[:,2]/m0, num_rk2[:,1], 's-',label='explicit RK2')\n", | |
"plt.plot(np.exp(-(num_rk2[:,1]-v0)/250),num_rk2[:,1],'b+',label='Tsiolkovsky')\n", | |
"plt.ylim(0,420)\n", | |
"plt.legend();\n", | |
"plt.xlabel('m/m0')\n", | |
"plt.ylabel('velocity (m/s)')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"2. You should have a converged solution for integrating `simplerocket`. Now, create a more relastic function, `rocket` that incorporates gravity and drag and returns the velocity, $v$, the acceleration, $a$, and the mass rate change $\\frac{dm}{dt}$, as a function of the $state = [position,~velocity,~mass] = [y,~v,~m]$ using eqn (1). Where the mass rate change $\\frac{dm}{dt}$ and the propellent speed $u$ are constants. The average velocity of gun powder propellent used in firework rockets is $u=250$ m/s [3,4]. \n", | |
"\n", | |
"$\\frac{d~state}{dt} = f(state)$\n", | |
"\n", | |
"$\\left[\\begin{array}{c} v\\\\a\\\\ \\frac{dm}{dt} \\end{array}\\right] = \n", | |
"\\left[\\begin{array}{c} v\\\\ \\frac{u}{m}\\frac{dm}{dt}-g-\\frac{c}{m}v^2 \\\\ \\frac{dm}{dt} \\end{array}\\right]$\n", | |
"\n", | |
"Use [two integration methods](../notebooks/03_Get_Oscillations.ipynb) to integrate the `rocket` function, one explicit method and one implicit method. Demonstrate that the solutions converge to equation (2.b) the Tsiolkovsky equation. Use an initial state of y=0 m, v=0 m/s, and m=0.25 kg. \n", | |
"\n", | |
"Integrate the function until mass, $m_{f}=0.05~kg$, using a mass rate change of $\\frac{dm}{dt}=0.05$ kg/s, . \n", | |
"\n", | |
"Compare solutions between the `simplerocket` and `rocket` integration, what is the height reached when the mass reaches $m_{f} = 0.05~kg?$\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 94, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"When the mass reaches m = 0.05kg, the height is 425.5m\n" | |
] | |
}, | |
{ |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BIBnNcGwDbnp6h9xhjHYx9870sMXoeP5fDYB9+H5foiwu+//w545i67//77Oeuss0hKSuLVV1/lqaeeomPHjjRp0sT3r3tv6+DOO++kY8eOtG7d2rcv0PW/++47LrjgAtq0aUPr1q2ZNWsWAD169ODdd9/lgw8+4O2332bixIm0a9eOl156qVT3NGnSJDp27EhycjJ9+vThp59+Agr+q97//dChQxk1ahTnnnsuTZs2JS0tjWCWVt6xYwfnnXcebdu2pX///vzyyy95rj969GguvPBCOnXqBMC1115LamoqrVu35rLLLuO3337zHX/ffffRpEkTOnXqxN13301qamqp7r+kIpayVHUiMNH73kkQl6rqGhG5CRgIvOK8ZqjqHue4zKL2GVNenDr2vVKdt2Pf4WLP3TLxkhJf9+jRoyxdupSvv/6aHj16MGnSJL766iveeOMN7rnnHj7//HMA9u7dS5s2bXj88cf59NNPGThwIJs2bSryutnZ2fTr149HHnmEK664wncNf71796Zv376kpqZy8803F3mtiRMn5mlt7Ny5k5tuugmAV155hY0bN7Js2TISEhKYOnUqd9xxB7Nnzy723tesWcPChQtJSEigffv2LFy4kPPPPz/gObfccgvdunVj3Lhx/PDDD7Rt25YLL7zQt3/p0qV8+umnVK9eHYCnn37aV3a7//77+fvf/87EiRN55513ePfdd1m5ciVVq1ZlwIABxcYbLm61Z0YBs0TkQeA3IC3IfcaUC8V9gZ898WN27CtYs29YuypfjD037PFcddVVACQnJ3Po0CHf+5SUFDZu3Og7rlKlSgwaNAiA7t27U7VqVb7//ntq1qxZ6HW///57srOzfYkBoE6dOqWKcezYsXmSx5133un7/e2332b58uUkJycDnqRUq1atoK7bv39/qlSpAnjuf9OmTcUmh08++YRnnnkGgMaNG3Peeefl2T9gwABfYgB46aWXmD17NllZWRw8eJBmzZr5rnPllVf6jh0yZAgPPfRQUHGHKmrJQVVP9ft9HdCpiOOK3GeM8RjTu3mePgeAqhUTGdO7eUQ+z/vlmJiYWOB9dnZ2keepasAhusGUaMJBVbn//vu57rrrCuyrUKECubm5vvf5n1L33isUf7/B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s6lp4f3ep06daJdu3aceeaZvqmw27Vrx7Bhw4o8Z8qUKTzzzDPFXnvQoEFMmzYN8EyE5520L1I2btzISSedFNHPCFV2djYiwpEjR9wOJQ+bPsOYODd+fHgThHfaiS1btgQ94d1f/vKX8AVgfLKzs4t8EC/SrOVgjAnad999R+fOnWnbti2tWrXiqaeeAvK2ArKzs7ntttto2bIlrVq14q677iInJyfgdTMzM2ndurXv4a8ZM2bQunVr2rRpw+WXX86ePXtQVU477TS+/fZb33lPPvkkI0aMICcnhxtuuIEWLVrQtm1bunXrVuAzjhw5woABA7jrrrv44osvaNeuXZ79LVu2zDP1dmEWLlxISkoKI0aMoE2bNrRv3943iR7Ao48+SqtWrWjVqhXXX389hw4dKvQ6c+fOpXnz5nTp0oUJEyb4tntbEY8//jjdu3fnkUceITMzk65du5KcnEzLli159tlnfcdv27aNnj170rJlS/r168cll1zia5mFypKDMXEoPR1EPD/wx+/hLjHlN3nyZPr168fKlStZs2YNQ4YMKXDM1KlTWbt2LZmZmaxYsYKvvvqKF198schrfvjhh6SlpTF37ly6du3KypUreeCBB/joo49YtWoVzZo149Zbb0VESEtLY9asWb5zZ82axbBhw/jmm29YvHgxa9euZeXKlQXmVdq7dy8XXHABPXv2ZNKkSZx99tlUrFiRL774AvDMslqtWjU6duxY7J/B6tWrGT16NKtWraJ///488sgjALzzzju89tprLF26lNWrV3PkyBHfPn+7du1i1KhRvPvuuyxZsqTQhYBEhE8//ZRx48bRuHFjPv74Y7755huWLVvG5MmTfQnp5ptvpnfv3nz77bc89dRTRU6WWBqWHIyJQ+npoOr5gT9+j3Ry6NatGy+88AIPPvggn3zyCbVr1y5wzMKFCxk2bBgVK1akcuXKDB06lIULFxZ6vf/85z/ceeedfPjhh75J7j7++GMuvfRSX1/BDTfc4Dt/6NChzJ49m5ycHDIyMjh8+DBdunShSZMmHD16lBEjRvDKK6/kmen00KFDnH322dx22215yl+jR4/2TYI3ZcqUoEtjZ555Jm3atAE8E+dt2rTJd9/XXHMNNW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GNMyVlyMMYYU4AlB2OMMQVYcjDGGFOAJQdjjDEFWHIwJsxE5J8ickkJz6kmIq87M2quE5FLIxWfMcGw5GBMGIlIAp4ncf9XwlPvBA6oahOgD/BPETku3PEZEyxLDsYUw5lH/z4R+VpEfhCR80RkgohkOOsjnOF3+FlApqoeEZF0EXlNRN53WgSvi0h7EfnYmXfff8bMq4BpAKq6AViOZw4kY1xhycGY4OxT1Q7A3Xjm6flcVdsDLwH3+R3X39nvlYJniofmeJ7snYjnS78NMMRvoZqyNCuwKQMsORgTnNed128AVdX3nPcrgCZ+x10CvOf3/gNV3a+eWWBXAR+pZwK8g8D3eKZ5MCbmWHIwJjhHnNccPAsF4fe+AoCInAnsVtW9hZznPTb/e+/SlWVpVmBTBlhyMCZ8+pG3pFQSc4EbAJxSUwfgv2GKy5gSs+RgTPiEkhweA2qLyEbgXTyzah4IW2TGlJDNympMGIjIyXj6F9q4HYsx4WDJwRhjTAFWVjLGGFOAJQdjjDEFWHIwxhhTgCUHY4wxBVhyMMYYU4AlB2OMMQX8P4jIyhW1qky6AAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"%matplotlib inline\n", | |
"plt.rcParams.update({'font.size': 11})\n", | |
"plt.rcParams['lines.linewidth'] = 1\n", | |
"\n", | |
"def rocket(state,dmdt=0.05, u=250,c=0.18e-3):\n", | |
" '''Computes the right-hand side of the differential equation\n", | |
" for the acceleration of a rocket, with drag, in SI units.\n", | |
" \n", | |
" Arguments\n", | |
" ---------- \n", | |
" state : array of three dependent variables [y v m]^T\n", | |
" dmdt : mass rate change of rocket in kilograms/s default set to 0.05 kg/s\n", | |
" u : speed of propellent expelled (default is 250 m/s)\n", | |
" c : drag constant for a rocket set to 0.18e-3 kg/m\n", | |
" Returns\n", | |
" -------\n", | |
" derivs: array of three derivatives [v (u/m*dmdt-g-c/mv^2) -dmdt]^T\n", | |
" '''\n", | |
"\n", | |
" dstate = np.zeros(np.shape(state))\n", | |
" \n", | |
" dstate[0] = state[1]\n", | |
" dstate[1] = u*dmdt/state[2] - 9.8 - c*state[1]**2/state[2]\n", | |
" dstate[2] = - dmdt\n", | |
" return dstate\n", | |
"\n", | |
"\n", | |
"def simplerocket(state,dmdt=0.05, u=250):\n", | |
" '''Computes the right-hand side of the differential equation\n", | |
" for the acceleration of a rocket, without drag or gravity, in SI units.\n", | |
" \n", | |
" Arguments\n", | |
" ---------- \n", | |
" state : array of three dependent variables [y v m]^T\n", | |
" dmdt : mass rate change of rocket in kilograms/s default set to 0.05 kg/s\n", | |
" u : speed of propellent expelled (default is 250 m/s)\n", | |
" \n", | |
" Returns\n", | |
" -------\n", | |
" derivs: array of three derivatives [v (u/m*dmdt-g-c/mv^2) -dmdt]^T\n", | |
" '''\n", | |
" dstate = np.zeros(np.shape(state))\n", | |
" \n", | |
" dstate[0] = state[1]\n", | |
" dstate[1] = u*dmdt/state[2]\n", | |
" dstate[2] = - dmdt\n", | |
" return dstate\n", | |
"\n", | |
"def rk2_step(state, rhs, dt):\n", | |
" '''Update a state to the next time increment using modified Euler's method.\n", | |
" \n", | |
" Arguments\n", | |
" ---------\n", | |
" state : array of dependent variables\n", | |
" rhs : function that computes the RHS of the DiffEq\n", | |
" dt : float, time increment\n", | |
" \n", | |
" Returns\n", | |
" -------\n", | |
" next_state : array, updated after one time increment'''\n", | |
" \n", | |
" mid_state = state + rhs(state) * dt*0.5 \n", | |
" next_state = state + rhs(mid_state)*dt\n", | |
" \n", | |
" return next_state\n", | |
"\n", | |
"def heun_step(state,rhs,dt,etol=0.000001,maxiters = 100):\n", | |
" '''Update a state to the next time increment using the implicit Heun's method.\n", | |
" \n", | |
" Arguments\n", | |
" ---------\n", | |
" state : array of dependent variables\n", | |
" rhs : function that computes the RHS of the DiffEq\n", | |
" dt : float, time increment\n", | |
" etol : tolerance in error for each time step corrector\n", | |
" maxiters: maximum number of iterations each time step can take\n", | |
" \n", | |
" Returns\n", | |
" -------\n", | |
" next_state : array, updated after one time increment'''\n", | |
" e=1\n", | |
" eps=np.finfo('float64').eps\n", | |
" next_state = state + rhs(state)*dt\n", | |
" ################### New iterative correction #########################\n", | |
" for n in range(0,maxiters):\n", | |
" next_state_old = next_state\n", | |
" next_state = state + (rhs(state)+rhs(next_state))/2*dt\n", | |
" e=np.sum(np.abs(next_state-next_state_old)/np.abs(next_state+eps))\n", | |
" if e<etol:\n", | |
" break\n", | |
" ############### end of iterative correction #########################\n", | |
" return next_state\n", | |
"\n", | |
"#initialize solution array\n", | |
"N = 300 \n", | |
"\n", | |
"num_rk2 = np.zeros([N,3])\n", | |
"num_heun = np.zeros([N,3])\n", | |
" \n", | |
"#Set intial conditions\n", | |
"y0 = 0\n", | |
"v0 = 0\n", | |
"m0 = 0.25\n", | |
"dt = 0.05\n", | |
"\n", | |
"num_rk2[0,0] = y0\n", | |
"num_rk2[0,1] = v0\n", | |
"num_rk2[0,2] = m0\n", | |
"num_heun[0,0] = y0\n", | |
"num_heun[0,1] = v0\n", | |
"num_heun[0,2] = m0\n", | |
"\n", | |
" \n", | |
"for i in range(N-1):\n", | |
" num_rk2[i+1] = rk2_step(num_rk2[i], rocket, dt)\n", | |
" if num_rk2[i+1,2] <= 0.05 :\n", | |
" break\n", | |
"for i in range(N-1):\n", | |
" num_heun[i+1] = heun_step(num_heun[i], rocket, dt)\n", | |
" if num_heun[i+1,2] <= 0.05 :\n", | |
" break\n", | |
"\n", | |
"#for i in range(N-1):\n", | |
"# if num_rk2[i,0] == 0.0 and num_rk2[i,1] == 0.0 and num_rk2[i,2] == 0.0:\n", | |
"# plt.plot(num_rk2[i,0],num_rk2[i,2]/m0,'s-')#,label='explicit RK2')\n", | |
"# num_rk2 = np.delete(num_rk2, i, axis=0)\n", | |
"# print(len(num_rk2), i)\n", | |
" \n", | |
"#print(num_rk2)\n", | |
"#print(num_heun)\n", | |
"\n", | |
"\n", | |
"#print(np.nonzero(num_rk2))\n", | |
"\n", | |
"plt.plot(num_heun[:,2]/m0, num_heun[:,1], 'o-',label='implicit Heun, drag')\n", | |
"plt.plot(num_rk2[:,2]/m0, num_rk2[:,1], 's-',label='explicit RK2, drag')\n", | |
"plt.plot(np.exp(-(num_rk2[:,1]-v0)/250),num_rk2[:,1],'b+',label='Tsiolkovsky, no drag')\n", | |
"plt.ylim(0,420)\n", | |
"plt.legend();\n", | |
"plt.xlabel('m/m0')\n", | |
"plt.ylabel('velocity (m/s)')\n", | |
"\n", | |
"print('When the mass reaches m = 0.05kg, the height is 425.5m')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"3. Solve for the mass change rate that results in detonation at a height of 300 meters. Create a function `f_dm` that returns the final height of the firework when it reaches $m_{f}=0.05~kg$. The inputs should be \n", | |
"\n", | |
"$f_{m}= f_{m}(\\frac{dm}{dt},~parameters)$\n", | |
"\n", | |
"where $\\frac{dm}{dt}$ is the variable we are using to find a root and $parameters$ are the known values, `m0=0.25, c=0.18e-3, u=250`. When $f_{m}(\\frac{dm}{dt}) = 0$, we have found the correct root. \n", | |
"\n", | |
"Plot the height as a function of time and use a star to denote detonation at the correct height with a `'*'`-marker\n", | |
"\n", | |
"Approach the solution in two steps, use the incremental search [`incsearch`](../notebooks/04_Getting_to_the_root.ipynb) with 5-10 sub-intervals _we want to limit the number of times we call the function_. Then, use the modified secant method to find the true root of the function.\n", | |
"\n", | |
"a. Use the incremental search to find the two closest mass change rates within the interval $\\frac{dm}{dt}=0.05-0.4~kg/s.$\n", | |
"\n", | |
"b. Use the modified secant method to find the root of the function $f_{m}$.\n", | |
"\n", | |
"c. Plot your solution for the height as a function of time and indicate the detonation with a `*`-marker." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 235, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[ 0.3424583 0.34616337 1.07120461 ... 222.60168834 222.69262015\n", | |
" 222.78345394]\n", | |
"The root of the function f_m is 240.00979999999996\n", | |
"[[0.00000000e+00 0.00000000e+00 2.50000000e-01]\n", | |
" [5.05637971e-02 2.02255189e+00 2.47500000e-01]\n", | |
" [2.02885336e-01 4.07030968e+00 2.45000000e-01]\n", | |
" [4.58229953e-01 6.14347500e+00 2.42500000e-01]\n", | |
" [8.17872928e-01 8.24224398e+00 2.40000000e-01]\n", | |
" [1.28309920e+00 1.03668067e+01 2.37500000e-01]\n", | |
" [1.85520303e+00 1.25173468e+01 2.35000000e-01]\n", | |
" [2.53548772e+00 1.46940407e+01 2.32500000e-01]\n", | |
" [3.32526518e+00 1.68970573e+01 2.30000000e-01]\n", | |
" [4.22585554e+00 1.91265572e+01 2.27500000e-01]\n", | |
" [5.23858677e+00 2.13826920e+01 2.25000000e-01]\n", | |
" [6.36479416e+00 2.36656038e+01 2.22500000e-01]\n", | |
" [7.60581987e+00 2.59754245e+01 2.20000000e-01]\n", | |
" [8.96301235e+00 2.83122750e+01 2.17500000e-01]\n", | |
" [1.04377258e+01 3.06762644e+01 2.15000000e-01]\n", | |
" [1.20313197e+01 3.30674894e+01 2.12500000e-01]\n", | |
" [1.37451577e+01 3.54860331e+01 2.10000000e-01]\n", | |
" [1.55806077e+01 3.79319647e+01 2.07500000e-01]\n", | |
" [1.75390403e+01 4.04053381e+01 2.05000000e-01]\n", | |
" [1.96218285e+01 4.29061910e+01 2.02500000e-01]\n", | |
" [2.18303469e+01 4.54345444e+01 2.00000000e-01]\n", | |
" [2.41659705e+01 4.79904009e+01 1.97500000e-01]\n", | |
" [2.66300741e+01 5.05737444e+01 1.95000000e-01]\n", | |
" [2.92240312e+01 5.31845382e+01 1.92500000e-01]\n", | |
" [3.19492128e+01 5.58227245e+01 1.90000000e-01]\n", | |
" [3.48069864e+01 5.84882229e+01 1.87500000e-01]\n", | |
" [3.77987152e+01 6.11809293e+01 1.85000000e-01]\n", | |
" [4.09257563e+01 6.39007145e+01 1.82500000e-01]\n", | |
" [4.41894598e+01 6.66474233e+01 1.80000000e-01]\n", | |
" [4.75911672e+01 6.94208725e+01 1.77500000e-01]\n", | |
" [5.11322102e+01 7.22208499e+01 1.75000000e-01]\n", | |
" [5.48139093e+01 7.50471129e+01 1.72500000e-01]\n", | |
" [5.86375718e+01 7.78993870e+01 1.70000000e-01]\n", | |
" [6.26044905e+01 8.07773641e+01 1.67500000e-01]\n", | |
" [6.67159422e+01 8.36807009e+01 1.65000000e-01]\n", | |
" [7.09731851e+01 8.66090177e+01 1.62500000e-01]\n", | |
" [7.53774580e+01 8.95618962e+01 1.60000000e-01]\n", | |
" [7.99299773e+01 9.25388784e+01 1.57500000e-01]\n", | |
" [8.46319359e+01 9.55394642e+01 1.55000000e-01]\n", | |
" [8.94845002e+01 9.85631104e+01 1.52500000e-01]\n", | |
" [9.44888087e+01 1.01609228e+02 1.50000000e-01]\n", | |
" [9.96459689e+01 1.04677182e+02 1.47500000e-01]\n", | |
" [1.04957056e+02 1.07766286e+02 1.45000000e-01]\n", | |
" [1.10423108e+02 1.10875806e+02 1.42500000e-01]\n", | |
" [1.16045127e+02 1.14004952e+02 1.40000000e-01]\n", | |
" [1.21824073e+02 1.17152882e+02 1.37500000e-01]\n", | |
" [1.27760862e+02 1.20318696e+02 1.35000000e-01]\n", | |
" [1.33856365e+02 1.23501435e+02 1.32500000e-01]\n", | |
" [1.40111403e+02 1.26700082e+02 1.30000000e-01]\n", | |
" [1.46526744e+02 1.29913553e+02 1.27500000e-01]\n", | |
" [1.53103100e+02 1.33140704e+02 1.25000000e-01]\n", | |
" [1.59841126e+02 1.36380322e+02 1.22500000e-01]\n", | |
" [1.66741412e+02 1.39631126e+02 1.20000000e-01]\n", | |
" [1.73804485e+02 1.42891767e+02 1.17500000e-01]\n", | |
" [1.81030800e+02 1.46160822e+02 1.15000000e-01]\n", | |
" [1.88420742e+02 1.49436793e+02 1.12500000e-01]\n", | |
" [1.95974615e+02 1.52718110e+02 1.10000000e-01]\n", | |
" [2.03692646e+02 1.56003123e+02 1.07500000e-01]\n", | |
" [2.11574977e+02 1.59290104e+02 1.05000000e-01]\n", | |
" [2.19621661e+02 1.62577246e+02 1.02500000e-01]\n", | |
" [2.27832658e+02 1.65862656e+02 1.00000000e-01]\n", | |
" [2.36207832e+02 1.69144363e+02 9.75000000e-02]\n", | |
" [2.44746948e+02 1.72420308e+02 9.50000000e-02]\n", | |
" [2.53449662e+02 1.75688349e+02 9.25000000e-02]\n", | |
" [2.62315527e+02 1.78946253e+02 9.00000000e-02]\n", | |
" [2.71343976e+02 1.82191705e+02 8.75000000e-02]\n", | |
" [2.80534327e+02 1.85422300e+02 8.50000000e-02]\n", | |
" [2.89885773e+02 1.88635545e+02 8.25000000e-02]\n", | |
" [2.99397383e+02 1.91828858e+02 8.00000000e-02]\n", | |
" [3.09068094e+02 1.94999567e+02 7.75000000e-02]\n", | |
" [3.18896706e+02 1.98144914e+02 7.50000000e-02]\n", | |
" [3.28881880e+02 2.01262050e+02 7.25000000e-02]\n", | |
" [3.39022133e+02 2.04348038e+02 7.00000000e-02]\n", | |
" [3.49315830e+02 2.07399856e+02 6.75000000e-02]\n", | |
" [3.59761187e+02 2.10414392e+02 6.50000000e-02]\n", | |
" [3.70356259e+02 2.13388453e+02 6.25000000e-02]\n", | |
" [3.81098940e+02 2.16318756e+02 6.00000000e-02]\n", | |
" [3.91986958e+02 2.19201941e+02 5.75000000e-02]\n", | |
" [4.03017871e+02 2.22034563e+02 5.50000000e-02]\n", | |
" [4.14189064e+02 2.24813097e+02 5.25000000e-02]\n", | |
" [4.25497741e+02 2.27533944e+02 5.00000000e-02]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]\n", | |
" [0.00000000e+00 0.00000000e+00 0.00000000e+00]]\n", | |
"80\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"Text(0, 0.5, 'height (m)')" | |
] | |
}, | |
"execution_count": 235, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEGCAYAAACO8lkDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3de3xU9ZnH8c9DANmgoNwUEI1QLoqQQBAVahHRWrTuanW1gsVda0FqZbu6u121S72ttWrdlcqi1CreoGhF23opLYqCIGgQUFRE5SIXCaBBQYFAePaPMwlDkplMkrmefN+v17wmc67PyYF58nt+55yfuTsiIiLRmmU6ABERyT5KDiIiUoOSg4iI1KDkICIiNSg5iIhIDc0zHUAydOjQwQsKCjIdhohITlmyZMk2d+9Y27xQJIeCggJKSkoyHYaISE4xs3Wx5qmsJCIiNSg5iIhIDUoOIiJSg5KDiIjUEIoOaZFk2L9/P9u2bWP79u1UVFRkOhyRpMjLy+Pwww+nQ4cONGuWeHtAyUEa7dNP4fvfh5kz4aijMh1Nw23YsAEzo6CggBYtWmBmmQ5JpFHcnb1791JaWsqGDRs45phjEl5XZSVptFtvhddeg1tuyXQkjfPVV1/RtWtXWrZsqcQgoWBmtGzZkq5du/LVV1/Va10lB2mwv/s7MIMpU2D//uDdLJieq+rT7BbJFQ35d63/CdJgq1fDqFGQ32w3APn5MHo0rFmT4cBEpNGUHKTBOneGNm1g9/4WtGqxj927g8+53O+QbcyMnTt31mudTZs2MXz48EZv/6abbqK8vDzmulOmTKFPnz4MGDCAHTt21CvGumzfvp0777zzoGlXXnkl8+fPT+p+6uucc87h448/BmDatGmsWrWqat60adO46KKLGrTdgoICVqxYkZQYk0XJQRqldN0uruJ+Fv3iL1x1FWzenOmIpEuXLsydO7fR27n55pvjJodJkybx2GOPsXTpUg477LBG7y9abcnhwQcf5LTTTkvqfurrhRdeoEePHkDN5JAK+/btS+n241FykEaZdfXLTOYnFHb7nMmTYdasTEcUPpMmTeKkk06ie/fuPP3001XTFy9ezPDhwykuLqa4uJjnn38egLVr19KhQ4eq5Z5++umqv/Bvv/32Gq2F2rZ/9dVXAzBkyBCKiorYvn37QTFdcsklfPzxx/zgBz9g9OjRvPLKKwwaNKhqfvTnV155haKiIsaNG0f//v0pLCzk/fffr1r2oYceorCwkMLCQk466SRKS0u5+uqr2b59O0VFRQwZMgSA008/neeeew6A0tJSLrjgAvr370+/fv149NFHq7ZXUFDAxIkTOfXUUykoKOC+++6r83c8e/Zszj33XAC2bNmCmfHUU08BcOedd3LDDTdUbXvFihU8/PDDlJSUMGHCBIqKipgzZw4AX375JZdccgl9+/Zl6NChbI7x19L8+fPp168fgwcPZsKECUQP11xQUMCtt97K8OHDGTduHJs3b646z3379uU//uM/qpb94osvuPDCC+nTpw8jRoxgzJgx/Nu//Vudx5sQd8/5V3FxsUuG3HKLO7hPm5bpSBrtvffeqzkRUvdKAOC/+c1v3N39tdde8y5duri7e1lZmRcVFfmmTZvc3X3Tpk3etWtXLysr8zVr1nj79u3d3b20tNTbtWvnq1atcnf3e+65xwHfsWNH3O1XzqtcrjbHHnusv/POO+7uPnfuXI/+fxj9ee7cud68eXN/66233N39tttu81GjRlXN69Gjh3/66afu7r5jxw7ftWvXQcdQadiwYf7nP//Z3d0vvvhi//nPf1517EcddVRVLMcee6xfd9117u6+Zs0ab926ddzjcHf/6quvvF27dl5eXu7Tp0/3U0891ceNG+fu7t/+9rd9zpw5NY45Oh5394cfftgPP/xw/+STT9zd/corr/Qbbrihxr52797tXbp08blz57q7+8yZMx04KP7x48dXLb9r166q+MvLy3348OH+4osvurv7tdde6z/84Q/d3f2zzz7zgoKCqmOvrrZ/30CJx/heVctBGuett6B16+BypTBKZXpI0Pe//30ATjnlFDZt2sTu3btZuHAha9asYeTIkRQVFTFy5EjMjI8++uigdRctWsTAgQPp2bMnAFdccUVC20+23r17M2DAgKr9VNbtn3/+ecaMGcNRkY6qQw89lFatWtW5vTlz5jBu3DgAOnfuzLnnnntQKa3ymAoKCjjiiCPYsGFD3O3l5+fTt29fFi9ezJw5c5g4cSILFiygvLyckpIShg4dmtBxDh06lG7dutU4zmgffPAB+fn5nH766QBcfPHFtG3b9qBlxowZU/VzRUUF//7v/05hYSHFxcWsWLGCZcuWATB37lz++Z//GYB27dpx/vnnJxRnInQTnDTO0qUwcGC9vuykfiq/LPPy8oCgDu3u9O/fn3nz5tVYfu3atVU/u3ud92zUtv36at68Ofuj/kConmCiv/Dz8vKq9uGN+HdT/biiP8faXzwjRozgpZdeYtGiRUyZMoUjjzyS6dOnU1hYmFDCSnS/iRzzoYceWvXzPffcQ1lZGYsXL6ZVq1aMHTu26vebyPltKLUcpOE++wzKyuAb31BySLMhQ4bw4YcfHvTX8ptvvlnji+eUU05hyZIlVS2KadOmJbyPww47jC+++CKhZY877jhWr15NWVkZ7s6MGTMSWu+8887j0UcfpbS0FICdO3eyZ88e2rRpw9dffx3zS/3MM89k6tSpAGzevJkXXnghoSu0rr/++ph9ECNGjODhhx+mW7dutGzZkhEjRnDTTTcxYsSIWpdv06ZNwr+faH369GH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6J3p8hoiI1NBky0oiIhKbkoOIiNSg5CAiIjUoOYiISA1KDiIiUoOSgzRpZnaTmbWM+nyLmV2Swv0VmdnFCSzzxzqWOcfMHkhudCIH6FJWadLMzIHD3H1nmvb3T8B33f2iOMu8CNzi7q/Xsa0lwMXu/nFyoxRRy0GaMDObHPlxYeT5/oeb2TQz+0lk/k1m9vvI+AAfmdlMMxtgZi+b2cdmdlfUtjqb2R/M7A0ze8fMbqhlf+2BW4AzI/ubVMsyxxDctPR65HMnM5sT2eY7ZvY/UYs/CVyRvN+IyAFKDtJkufvVkR+HuHuRu2+vZbFigkcQ9Ca48/QOYCTQH7g8aiCVR4FJ7j44ss5IMzur2v4+AyYSPEK6yN0n1LK/YcAbUZ9HA+vcvZ+79yNILpVeB0YkfsQiiWue6QBEstxsd/8CwMzeBpZ78LyePWb2AdDDzDYBpwMdg8f2AHAYcDzwt3ru72igNOrzIuDaSCvlVWB21LzNkeVFkk7JQSS+3VE/V9TyuTlBC9yBk9x9byP3twtoVfnB3V+PDA15FvAD4D8JRqAjstyuRu5PpFYqK0lTtwNo25gNuPsOYD7BFzcAZtbNzI6qZfEv69jfOwQlrMrtHAd86e6/B64FiiOD2EDQMlnemNhFYlFykKbu18DLlR3SjdjOaOCEyo5jYCZQ2/ZeAlpHBo2v0SENvAYcV/l4aYJy1VIzWwa8CFzlkfEJgLOBpxsRs0hMupRVJMuY2fXAbnf/nzjLtCd4hPNJ7l6etuCkyVDLQST73EPdfQndgfFKDJIqajmIiEgNajmIiEgNSg4iIlKDkoOIiNSg5CAiIjUoOYiISA3/D29Mr0WvojA2AAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"def rocket1(state,dmdt=0.05, u=250,c=0.18e-3):\n", | |
" '''Computes the right-hand side of the differential equation\n", | |
" for the acceleration of a rocket, with drag, in SI units.\n", | |
" \n", | |
" Arguments\n", | |
" ---------- \n", | |
" state : array of three dependent variables [y v m]^T\n", | |
" dmdt : mass rate change of rocket in kilograms/s default set to 0.05 kg/s\n", | |
" u : speed of propellent expelled (default is 250 m/s)\n", | |
" c : drag constant for a rocket set to 0.18e-3 kg/m\n", | |
" Returns\n", | |
" -------\n", | |
" derivs: array of three derivatives [v (u/m*dmdt-g-c/mv^2) -dmdt]^T\n", | |
" '''\n", | |
"# print(dmdt)\n", | |
" dstate = np.zeros(np.shape(state))\n", | |
" \n", | |
" dstate[0] = state[1]\n", | |
" dstate[1] = u*dmdt/state[2] - 9.8 - c*state[1]**2/state[2]\n", | |
" dstate[2] = - dmdt\n", | |
" return dstate\n", | |
"\n", | |
"def f_m(dmdt,m0=0.25, c=0.18e-3, u=250):\n", | |
" ''' define a function f_m(dmdt) that returns \n", | |
" height_desired-height_predicted[-1]\n", | |
" here, the time span is based upon the value of dmdt\n", | |
" \n", | |
" arguments:\n", | |
" ---------\n", | |
" dmdt: the unknown mass change rate\n", | |
" m0: the known initial mass\n", | |
" c: the known drag in kg/m\n", | |
" u: the known speed of the propellent\n", | |
" \n", | |
" returns:\n", | |
" --------\n", | |
" error: the difference between height_desired and height_predicted[-1]\n", | |
" when f_m(dmdt)= 0, the correct mass change rate was chosen\n", | |
" '''\n", | |
" \n", | |
" mid_state = np.zeros(3)\n", | |
" for i in range(300):\n", | |
" mid_state = num_rk2[i] + rocket1(num_rk2[i],dmdt) * dt*0.5 \n", | |
" num_rk2[i+1] = num_rk2[i] + rocket1(mid_state,dmdt)*dt\n", | |
" if num_rk2[i+1,2] <= 0.05 :\n", | |
" break\n", | |
" max_height = num_rk2[i+1,0]\n", | |
"# print(dmdt)\n", | |
" error = 300 - max_height\n", | |
"# print(max_height)\n", | |
" return error\n", | |
"\n", | |
"def incsearch(func,xmin,xmax,ns=50):\n", | |
" '''incsearch: incremental search root locator\n", | |
" xb = incsearch(func,xmin,xmax,ns):\n", | |
" finds brackets of x that contain sign changes\n", | |
" of a function on an interval\n", | |
" arguments:\n", | |
" ---------\n", | |
" func = name of function\n", | |
" xmin, xmax = endpoints of interval\n", | |
" ns = number of subintervals (default = 50)\n", | |
" returns:\n", | |
" ---------\n", | |
" xb(k,1) is the lower bound of the kth sign change\n", | |
" xb(k,2) is the upper bound of the kth sign change\n", | |
" If no brackets found, xb = [].'''\n", | |
" x = np.linspace(xmin,xmax,ns)\n", | |
" f = func(x)\n", | |
" sign_f = np.sign(f)\n", | |
" delta_sign_f = sign_f[1:]-sign_f[0:-1]\n", | |
" i_zeros = np.nonzero(delta_sign_f!=0)\n", | |
" nb = len(i_zeros[0])\n", | |
" xb = np.block([[ x[i_zeros[0]+1]],[x[i_zeros[0]] ]] )\n", | |
"\n", | |
" if nb==0:\n", | |
" print('no brackets found\\n')\n", | |
" print('check interval or increase ns\\n')\n", | |
" else:\n", | |
" print('number of brackets: {}\\n'.format(nb))\n", | |
" return xb\n", | |
" \n", | |
"N = 1300\n", | |
"step = (0.4 - 0.05)/N\n", | |
"temp_array = np.zeros(N)\n", | |
"\n", | |
"for i in range(N):\n", | |
" temp_array[i] = f_m(0.05+i*step, 0.25, 0.18e-3, 250)\n", | |
"# print(f_m(0.05+i*step, 0.25, 0.18e-3, 250))\n", | |
"# if abs(f_m(0.05+i*step, 0.25, 0.18e-3, 250)) < 1 :\n", | |
"# print(f_m(0.05+i*step, 0.25, 0.18e-3, 250))\n", | |
" \n", | |
"temp_array = np.sort(abs(temp_array))\n", | |
"print(temp_array)\n", | |
"\n", | |
"def mod_secant(func,dx,x0,es=0.0001,maxit=50):\n", | |
" '''mod_secant: Modified secant root location zeroes\n", | |
" root,[fx,ea,iter]=mod_secant(func,dfunc,xr,es,maxit,p1,p2,...):\n", | |
" uses modified secant method to find the root of func\n", | |
" arguments:\n", | |
" ----------\n", | |
" func = name of function\n", | |
" dx = perturbation fraction\n", | |
" xr = initial guess\n", | |
" es = desired relative error (default = 0.0001 )\n", | |
" maxit = maximum allowable iterations (default = 50)\n", | |
" p1,p2,... = additional parameters used by function\n", | |
" returns:\n", | |
" --------\n", | |
" root = real root\n", | |
" fx = func evaluated at root\n", | |
" ea = approximate relative error ( )\n", | |
" iter = number of iterations'''\n", | |
"\n", | |
" iter = 0;\n", | |
" xr=x0\n", | |
" for iter in range(0,maxit):\n", | |
" xrold = xr;\n", | |
" dfunc=(func(xr+dx)-func(xr))/dx;\n", | |
" xr = xr - func(xr)/dfunc;\n", | |
" if xr != 0:\n", | |
" ea = abs((xr - xrold)/xr) * 100;\n", | |
" else:\n", | |
" ea = abs((xr - xrold)/1) * 100;\n", | |
" if ea <= es:\n", | |
" break\n", | |
" return xr,[func(xr),ea,iter]\n", | |
"\n", | |
"\n", | |
"root,out = mod_secant(f_m,0.001,1,es=0,maxit=100)\n", | |
"\n", | |
"print('The root of the function f_m is', root)\n", | |
"print(num_heun)\n", | |
"\n", | |
"t = np.linspace(0,len(num_heun),len(num_heun))\n", | |
"for i in range(len(num_heun)):\n", | |
" if num_heun[i,2] < 0.05 :\n", | |
" xd = i\n", | |
" yd = num_heun[i,0]\n", | |
" print(i)\n", | |
" break\n", | |
"\n", | |
"plt.rcParams.update({'font.size': 11})\n", | |
"plt.rcParams['lines.linewidth'] = 1\n", | |
"\n", | |
"plt.plot(t, num_heun[:,0], 'r-',label='height function, with drag')\n", | |
"plt.plot(xd, yd, 'b*',label='detonation') \n", | |
"\n", | |
"plt.legend();\n", | |
"plt.xlabel('time t (s)')\n", | |
"plt.ylabel('height (m)')\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## References\n", | |
"\n", | |
"1. Math 24 _Rocket Motion_. <https://www.math24.net/rocket-motion/\\>\n", | |
"\n", | |
"2. Kasdin and Paley. _Engineering Dynamics_. [ch 6-Linear Momentum of a Multiparticle System pp234-235](https://www.jstor.org/stable/j.ctvcm4ggj.9) Princeton University Press \n", | |
"\n", | |
"3. <https://en.wikipedia.org/wiki/Specific_impulse>\n", | |
"\n", | |
"4. <https://www.apogeerockets.com/Rocket_Motors/Estes_Motors/13mm_Motors/Estes_13mm_1_4A3-3T>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"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.7.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |