{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "

Projectile Motion with Air Resistance

\n", "

\n", " The equations of motion are are solved for a projectile experience air resistance proportional to n power of velocity\n", " \n", " $$\n", "\\frac{d^2 x}{dt^2} = - k\\, v_x^n \\, \\frac{v_x}{|v|}, \\quad\n", "\\frac{d^2 y}{dt^2} = -g -k \\,v_y^n\\, \\frac{v_y}{|v|},\\quad |v|\n", "=\\sqrt{v_x^2+v_y^2}.\n", " $$" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") {require.undef(\"nbextensions/vpython_libraries/glow.min\");}else{element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") {require.undef(\"nbextensions/vpython_libraries/glowcomm\");}else{element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") {require.undef(\"nbextensions/vpython_libraries/jquery-ui.custom.min\");}else{element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") {require([\"nbextensions/vpython_libraries/glow.min\"], function(){console.log(\"GLOW LOADED\");});}else{element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") {require([\"nbextensions/vpython_libraries/glowcomm\"], function(){console.log(\"GLOWCOMM LOADED\");});}else{element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "if (typeof Jupyter !== \"undefined\") {require([\"nbextensions/vpython_libraries/jquery-ui.custom.min\"], function(){console.log(\"JQUERY LOADED\");});}else{element.textContent = ' ';}" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "\"\"\" From \"COMPUTATIONAL PHYSICS\" & \"COMPUTER PROBLEMS in PHYSICS\"\n", " by RH Landau, MJ Paez, and CC Bordeianu (deceased)\n", " Copyright R Landau, Oregon State Unv, MJ Paez, Univ Antioquia, \n", " C Bordeianu, Univ Bucharest, 2020. \n", " Please respect copyright & acknowledge our work.\"\"\"\n", "\n", "# ProjectileAir.py: Order dt^2 projectile trajectory + drag\n", "\n", "from vpython import *\n", "import numpy as np\n", "\n", "v0 = 22.; angle = 34.; g = 9.8; kf = 0.4; N = 25\n", "v0x = v0*cos(angle*pi/180.); v0y = v0*sin(angle*pi/180.)\n", "T = 2.*v0y/g; H = v0y*v0y/2./g; R = 2.*v0x*v0y/g\n", "escene = graph(width=500, height=200, \n", " title='Projectile with & without Drag',\n", " xtitle='x', ytitle='y', xmax=R, xmin=-R/20.,ymax=8,ymin=0.0)\n", "funct = gcurve(color=color.red)\n", "funct1 = gcurve(color=color.blue) " ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "def plotNumeric(k):\n", " vx = v0*cos(angle*pi/180.)\n", " vy = v0*sin(angle*pi/180.)\n", " x = 0.0\n", " y = 0.0\n", " dt = vy/g/N/2. \n", " for i in range(3*N):\n", " vx = vx - k*vx*dt\n", " vy = vy - g*dt - k*vy*dt\n", " x = x + vx*dt\n", " y = y + vy*dt\n", " funct.plot(pos=(x,y)) \n", "\n", "def plotAnalytic():\n", " v0x = v0*cos(angle*pi/180.)\n", " v0y = v0*sin(angle*pi/180.)\n", " dt = 2.*v0y/g/N)\n", " for i in range(N):\n", " rate(30)\n", " t = i*dt\n", " x = v0x*t\n", " y = v0y*t -g*t*t/2.\n", " funct1.plot(pos=(x,y))\n", " \n", "kf = 0.3 \n", "plotNumeric(kf)\n", "plotAnalytic()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.13" } }, "nbformat": 4, "nbformat_minor": 2 }