From fff6e534ed9b9a46238ce7b93085a4a5e9043268 Mon Sep 17 00:00:00 2001 From: writewrite <38677426+writewrite@users.noreply.github.com> Date: Mon, 22 Oct 2018 14:31:12 +0100 Subject: [PATCH 1/2] Added tutorial version of problem --- ...tic Fields of Wire with a Narrow Gap.ipynb | 197 ++++++++++++++++-- 1 file changed, 180 insertions(+), 17 deletions(-) diff --git a/exercises/electricityAndMagnetism/Electric and Magnetic Fields of Wire with a Narrow Gap.ipynb b/exercises/electricityAndMagnetism/Electric and Magnetic Fields of Wire with a Narrow Gap.ipynb index 5265690..cfbad70 100644 --- a/exercises/electricityAndMagnetism/Electric and Magnetic Fields of Wire with a Narrow Gap.ipynb +++ b/exercises/electricityAndMagnetism/Electric and Magnetic Fields of Wire with a Narrow Gap.ipynb @@ -6,8 +6,112 @@ "source": [ "# Electric and Magnetic Fields of Wire with a Narrow Gap\n", "\n", - "- **PROGRAM**: Electric and magnetic fields of wire with a narrow gap\n", - "- **CREATED**: 6/3/2018" + "\n", + "Image source: $\\href{http://www.moblerhome.com/brushed-aluminum-drum-table-or-pedestal}{link}$\n", + "\n", + "$Question$\n", + "\n", + "A fat wire of radius $a$ carries a constant current $I$ uniformly distributed over its cross-section. A narrow gap in the wire of width $w << a$ forms a sort of parallel plate capacitor. Assume the wire acts like infinite plates, so that the electric field lines in the gap are parallel.\n", + "\n", + "(a) Find the electric and magnetic fields in the gap as a function of the distance $s$ from the axis and the time $t$. (Assume the charge is zero at $t = 0$).\n", + "\n", + "(b) Find the Poynting vector $\\vec{S}$ in the gap. Pay attention to the direction of $\\vec{S}$.\n", + "\n", + "$Goal$\n", + "\n", + "Plot the electric field $\\vec{E}$ as a function of radius $s$ from the wire's central axis.\n", + "\n", + "Plot the magnetic field $\\vec{B}$ as a function of radius $s$ from the wire's central axis.\n", + "\n", + "Plot the Poynting vector $\\vec{S}$ as a function of radius $s$ from the wire's central axis.\n", + "\n", + "$Equation$\n", + "\n", + "The equation for the electric field in this narrow gap is \n", + "\n", + "
\n", + "$E = \\frac{I t}{\\pi a^2 \\epsilon_{0}} \\hat{z}$. \n", + "
\n", + "\n", + "Notice that $\\vec{E} = \\vec{E}(t)$ is independent of radius $s$ from the central axis of the wire.\n", + "\n", + "The equation for the magnetic field in this narrow gap is \n", + "\n", + "
\n", + "$B = \\frac{\\mu_{0} I s}{2 \\pi a^{2}} \\hat{\\phi}$. \n", + "
\n", + "\n", + "Notice that $\\vec{B} = \\vec{B}(s)$ is independent of time $t$.\n", + "\n", + "The equation for the Poynting vector is \n", + "\n", + "
\n", + "$\\vec{S} = -\\frac{\\mu_{0} I^2 c^2 t s}{2 \\pi^2 a^4} \\hat{s}$.\n", + "
\n", + "\n", + "\n", + "
\n", + "\n", + " Why? \n", + "\n", + "

\n", + "\n", + "The equation for the electric field $\\vec{E}$ comes from the expression for the electric field between two parallel plates with charge density $\\sigma$, \n", + "\n", + "

\n", + "
$E = \\frac{\\sigma}{\\epsilon_0}$.\n", + "
\n", + "\n", + "Assuming the current starts at time $t = 0$, the charge on the plates is $Q(t) = I \\cdot t$. The charge density is \n", + "\n", + "
\n", + "$\\sigma(t) = \\frac{charge}{area} = \\frac{I t}{\\pi a^2}$.\n", + "
\n", + "\n", + "Then\n", + "\n", + "
\n", + "
$E = \\frac{\\sigma(t)}{\\epsilon_0} = \\frac{I t}{\\pi a^2 \\epsilon_{0}}$\n", + "
\n", + "\n", + "is the expression for the electric field in the gap.\n", + "\n", + "\n", + "For the magnetic field $B$, use Maxwell's equation\n", + "
\n", + "$\\vec{\\nabla} \\times \\vec{B} = \\mu_0 \\vec{J} + \\mu_0 \\epsilon_0 \\frac{\\partial \\vec{E}}{\\partial t}$\n", + "
\n", + "and state that $\\vec{J} = 0$ inside the gap to get that\n", + "
\n", + "$\\vec{\\nabla} \\times \\vec{B} = 0 + \\mu_0 \\epsilon_0 (\\frac{I}{\\pi a^2 \\epsilon_0}) = \\frac{\\mu_0 I}{\\pi a^2}$.\n", + "
\n", + "\n", + "Use Stokes' theorem:\n", + "
\n", + "
$\\int{(\\vec{\\nabla} \\times \\vec{B})} \\cdot d\\vec{a} = \\oint{\\vec{B} \\cdot} d\\vec{l}$
\n", + "
$\\frac{\\mu_0 I}{\\pi a^2} (\\pi s^2) = |\\vec{B}| (2 \\pi s)$,
\n", + "
\n", + "so\n", + "
\n", + "$B = \\frac{\\mu_0 I s}{2 \\pi a^2}$.\n", + "
\n", + "\n", + "\n", + "Finally, find the Poynting vector $\\vec{S}$ using the equation\n", + "
\n", + "$S = \\frac{1}{\\mu_0} \\vec{E} \\times \\vec{B}$.\n", + "
\n", + "\n", + "

\n", + "\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Import packages." ] }, { @@ -18,7 +122,19 @@ }, "outputs": [], "source": [ - "import numpy as np" + "# Import numpy.\n", + "import numpy as np\n", + "# Import 3-dimensional plotting package.\n", + "from mpl_toolkits.mplot3d import axes3d" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Define constants.\n", + "- Define constants important to the problem: current $I$, permittivity of free space $\\epsilon_{0}$, permeability of free space $\\mu_{0}$, and the wire radius $a$.\n", + "- For constants $I$ and $a$ that are not given, estimate a reasonable value. Anything \"reasonable\" will do, so long as the specified relationships ($w << a$) can arguably apply." ] }, { @@ -29,23 +145,35 @@ }, "outputs": [], "source": [ - "#Define constants - current, permittivity of free space, permeability of free space, wire radius a.\n", "I = 4\n", "e_0 = 8.85 * 10**(-12)\n", "u_0 = 1.26 * 10**(-6)\n", "a = 0.005" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Electric and Magnetic Field" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Define functions for electric and magnetic field.\n", + "- Define a function for the magnitude of the electric field and magnetic field as a function of time and position. Here the electric field does not depend on position, and the magnetic field does not depend on time." + ] + }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ - "#Define a function for the magnitude of the electric field and magnetic field as a function of time and position.\n", - "#Here the electric field does not depend on position, and the magnetic field does not depend on time.\n", "def E(t):\n", " return (I * t) / (np.pi * a**2 * e_0)\n", "def B(s):\n", @@ -53,15 +181,13 @@ ] }, { - "cell_type": "code", - "execution_count": 5, + "cell_type": "markdown", "metadata": { "collapsed": true }, - "outputs": [], "source": [ - "#Import 3-dimensional plotting package.\n", - "from mpl_toolkits.mplot3d import axes3d" + "### Plot the electric and magnetic fields together.\n", + "- Plot the values for $E(t)$ and $B(s)$ within a circular region of radius $a$ (to represent the wire)." ] }, { @@ -136,6 +262,13 @@ "plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot only the electric field." + ] + }, { "cell_type": "code", "execution_count": 13, @@ -202,6 +335,13 @@ "plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot only the magnetic field." + ] + }, { "cell_type": "code", "execution_count": 12, @@ -268,6 +408,34 @@ "plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Define a function for the Poynting vector." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#Define the Poynting vector as a function of time and position.\n", + "c = 2.99792 * 10**8\n", + "def Poynting(t, s):\n", + " return - (u_0 * I**2 * c**2 * t * s) / (2 * np.pi**2 * a**4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot the Poynting vector." + ] + }, { "cell_type": "code", "execution_count": 34, @@ -305,11 +473,6 @@ "#Choose a time (in seconds) to plot the electric and magnetic fields, since the electric field is changing with time.\n", "t = 0.5\n", "\n", - "#Define the Poynting vector as a function of time and position.\n", - "c = 2.99792 * 10**8\n", - "def Poynting(t, s):\n", - " return - (u_0 * I**2 * c**2 * t * s) / (2 * np.pi**2 * a**4)\n", - "\n", "X = S * np.cos(PHI)\n", "Y = S * np.sin(PHI)\n", "Z = Z\n", From b211261867c9dc5a51e3b507e0f84ae8716f218f Mon Sep 17 00:00:00 2001 From: writewrite <38677426+writewrite@users.noreply.github.com> Date: Mon, 22 Oct 2018 14:33:25 +0100 Subject: [PATCH 2/2] Added tutorial version of problem --- .../Projectile with Air Resistance.ipynb | 92 ++++++++++++++++--- 1 file changed, 77 insertions(+), 15 deletions(-) diff --git a/exercises/classicalMechanics/Projectile with Air Resistance.ipynb b/exercises/classicalMechanics/Projectile with Air Resistance.ipynb index 11fa28d..ac738c1 100644 --- a/exercises/classicalMechanics/Projectile with Air Resistance.ipynb +++ b/exercises/classicalMechanics/Projectile with Air Resistance.ipynb @@ -6,8 +6,71 @@ "source": [ "# Projectile with Air Resistance\n", "\n", - "- **PROGRAM**: Projectile with air resistance\n", - "- **CREATED**: 4/9/2018" + "\n", + "\n", + "$Question$\n", + "\n", + "A projectile of mass $m$ is launched vertically in gravity at speed $v_0$. Gravitational acceleration is $g$. If the air resistance is $kmv^{2}$, directed opposite the velocity vector, what is the speed of the projectile just before it hits the ground?\n", + "\n", + "$Goal$\n", + "\n", + "Solve for the particle's speed just before it hits the ground. \n", + "\n", + "Plot the particle's _velocity_ as a function of _height_ along its entire journey up and back down.\n", + "\n", + "$Equation$\n", + "\n", + "Say the particle is moving in the $y$ direction. The velocity of the particle at any height $y$ is \n", + "\n", + "> $1)$ $v = \\sqrt{\\frac{1}{k}[e^{-2ky}(g + kv_{0}^{2}) - g]}$ on the way up, and\n", + "\n", + "> $2)$ $v = -\\sqrt{\\frac{1}{k}g(1 - e^{2k(y-h)})}$ on the way down, where $h = \\frac{1}{2k}ln(\\frac{kv_{0}^{2}}{g} + 1)$ is the maximum height of the particle.\n", + "\n", + "
\n", + "\n", + " Why? \n", + "\n", + "

\n", + "\n", + "The equations for velocity $v$ as a function of position $y$ come from solving the differential equations\n", + "\n", + "

\n", + "
$1)$ $m\\dot{v} = mv\\frac{dv}{dy} = - mg - kmv^{2}$
\n", + "\n", + "
$\\bullet$ $F_{g} = -mg \\hat{y}$
\n", + "\n", + "
$\\bullet$ $F_{air} = -kmv^{2} \\hat{y}$
\n", + "
\n", + "\n", + "
\n", + "
$2)$ $m\\dot{v} = mv\\frac{dv}{dy} = - mg + kmv^{2}$
\n", + "\n", + "
$\\bullet$ $F_{g} = -mg \\hat{y}$
\n", + "\n", + "
$\\bullet$ $F_{air} = kmv^{2} \\hat{y}$
\n", + "
\n", + "\n", + "
where $m\\dot{v}$ has been transformed into $m\\frac{dv}{dt} = m\\frac{dv}{dy}\\frac{dy}{dt} = m\\frac{dv}{dy}v = mv\\frac{dv}{dy}$.
\n", + "\n", + "

\n", + "\n", + "
" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Solve for the particle's speed just before it hits the ground.\n", + "\n", + "Plug $y = 0$ into equation (2) to get $v_{f} = -\\sqrt{\\frac{1}{k}g(1-e^{-2kh})} = -\\sqrt{\\frac{1}{k}g(1-(\\frac{kv_{0}^{2}}{g} + 1)^{-1})}$ ." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot the particle's velocity as a function of height along its entire journey up and back down." ] }, { @@ -822,7 +885,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -842,19 +905,18 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, "outputs": [ { - "ename": "NameError", - "evalue": "name 'np' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mk\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mh\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv_0\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mg\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mNameError\u001b[0m: name 'np' is not defined" - ] + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -902,7 +964,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "collapsed": true }, @@ -939,7 +1001,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.1" + "version": "3.6.2" } }, "nbformat": 4,