Browse Source

testing vpython

rorist 7 months ago
parent
commit
18cdd90ca0
2 changed files with 43 additions and 199 deletions
  1. 2 2
      requirements.txt
  2. 41 197
      slides.ipynb

+ 2 - 2
requirements.txt

@@ -1,2 +1,2 @@
-jupyter==1.0.0
-bash-kernel==0.7.1
+jupyter
+vpython

+ 41 - 197
slides.ipynb

@@ -1,207 +1,52 @@
 {
  "cells": [
   {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "slide"
-    }
-   },
-   "source": [
-    "# Aerodynamics"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "fragment"
-    }
-   },
-   "source": [
-    "### May the forces be with you!\n",
-    "![](./images/Aeroforces.svg)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "slide"
-    }
-   },
-   "source": [
-    "## Newton's laws of motion\n",
-    "\n",
-    "### Net force is zero\n",
-    "\\begin{equation}\n",
-    "\\mathbf{\\sum {F}} = 0\n",
-    "\\end{equation}\n",
-    "\n",
-    "### Change of momentum\n",
-    "\\begin{equation}\n",
-    "\\mathbf{\\vec{F}} = m\\vec{a}\n",
-    "\\end{equation}\n",
-    "\n",
-    "### For every action, there is an equal and opposite reaction\n",
-    "\\begin{equation}\n",
-    "F_{A} = -F_{B}\n",
-    "\\end{equation}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "notes"
-    }
-   },
-   "source": [
-    "First law:\tIn an inertial frame of reference, an object either remains at rest or continues to move at a constant velocity, unless acted upon by a force.\n",
-    "\n",
-    "Second law:\tIn an inertial frame of reference, the vector sum of the forces F on an object is equal to the mass m of that object multiplied by the acceleration a of the object: F = ma.\n",
-    "\n",
-    "Third law:\tWhen one body exerts a force on a second body, the second body simultaneously exerts a force equal in magnitude and opposite in direction on the first body."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "slide"
-    }
-   },
-   "source": [
-    "## Euler's laws of motion\n",
-    "### Linear momentum\n",
-    "\\begin{equation}\n",
-    "\\mathbf{p} = m{v} _{cm}\\\\\n",
-    "\\end{equation}\n",
-    "\n",
-    "\\begin{align}\n",
-    "\\textrm{with,}&\\\\\n",
-    "{p} &= \\textrm{Linear momentum}\\\\\n",
-    "m &= \\textrm{Mass of the object}\\\\\n",
-    "{v} _{\\rm {cm}} &= \\textrm{Velocity of its center of mass}\n",
-    "\\end{align}\n",
-    "\n",
-    "### Angular momentum\n",
-    "\n",
-    "\\begin{equation}\n",
-    "\\mathbf{M} = {dL \\over dt}\n",
-    "\\end{equation}\n",
-    "\n",
-    "\\begin{align}\n",
-    "\\textrm{with,}&\\\\\n",
-    "L &= \\textrm{Angular momentum}\\\\\n",
-    "M &= \\textrm{Sum of external moment of Forces}\\\\\n",
-    "t &= \\textrm{Time}\\FIXME\n",
-    "\\end{align}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "slide"
-    }
-   },
-   "source": [
-    "## Lift equation\n",
-    "\\begin{equation}\n",
-    "L = Cl \\frac{r V^2}{2} A\n",
-    "\\end{equation}\n",
-    "\\begin{align}\n",
-    "\\textrm{with,}&\\\\\n",
-    "Cl &= \\textrm{Lift coefficient}\\\\\n",
-    "r  &= \\textrm{Air density}\\\\\n",
-    "V  &= \\textrm{Velocity between object and air}\\\\\n",
-    "A  &= \\textrm{Wing area}\n",
-    "\\end{align}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "notes"
-    }
-   },
-   "source": [
-    "Wing Area is not the upper+lower area, it's a projection which is ~ half of the total area\n",
-    "\n",
-    "Cl is defined by:\n",
-    "- Lift force (must be equal to body weight)\n",
-    "- Surface\n",
-    "- dynamic pressure (change in pressure with motion)\n",
-    "- fluid density (air)\n",
-    "- flow speed (~angle of attack? type of airfoil?)\n",
-    "\n",
-    "- misconception\n",
-    "    - bernoulli effect is not THE explaination (faster = lower pressure)\n",
-    "    - It's a combination of effects\n",
-    "        - air compression at the tip of the wing\n",
-    "        - accelerate the air on one side (kind of bernouilli)\n",
-    "        - air is accelerated downward so the wing is pushed up\n",
-    "        -> conservation of mass, momentum and energy"
-   ]
-  },
-  {
    "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {
-    "slideshow": {
-     "slide_type": "fragment"
-    }
-   },
+   "execution_count": 13,
+   "metadata": {},
    "outputs": [
     {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Cl = 19.74\n",
-      "L  = 1088.12 [kN]\n"
-     ]
+     "data": {
+      "text/html": [
+       "<div id=\"glowscript\" class=\"glowscript\"></div>"
+      ],
+      "text/plain": [
+       "<IPython.core.display.HTML object>"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "data": {
+      "application/javascript": [
+       "if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}"
+      ],
+      "text/plain": [
+       "<IPython.core.display.Javascript object>"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
     }
    ],
    "source": [
-    "from math import pi\n",
-    "\n",
-    "angle = 180 * pi/180\n",
-    "Cl = 2*pi*angle\n",
-    "r = 1.225 # kg/m3\n",
-    "V = 30    # m/s =~ 100km/h\n",
-    "A = 100   # m2\n",
-    "\n",
-    "L = Cl*(r*V**2)*0.5*A\n",
-    "\n",
-    "print('Cl = {:.2f}'.format(Cl))\n",
-    "print('L  = {:.2f} [kN]'.format(L/1000))"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {
-    "slideshow": {
-     "slide_type": "slide"
-    }
-   },
-   "source": [
-    "# References\n",
-    "\n",
-    "- https://www.grc.nasa.gov/www/k-12/airplane/geom.html\n",
-    "- https://www.grc.nasa.gov/www/k-12/WindTunnel/Activities/lift_formula.html\n",
-    "- https://www.grc.nasa.gov/www/k-12/airplane/lifteq.html\n",
-    "- https://www.grc.nasa.gov/www/k-12/airplane/newton.html\n",
-    "- https://wright.nasa.gov/airplane/lifteq.html\n",
-    "- https://www.immersionrc.com/rf-range-demystified/\n",
-    "- https://www.immersionrc.com/rf-calculators/\n",
-    "- https://docs.google.com/document/d/1jIdLPUsxGq--vUiLu3uPQAyuZ3QAmq9BBUi5nd7r0nI/edit\n",
-    "- https://fixme.ch/wiki/Multicopter\n",
-    "- https://www.youtube.com/watch?v=gkb11eKXM14\n",
-    "- https://en.wikipedia.org/wiki/Aerodynamics\n",
-    "\n",
-    "TODO: Trier les liens et mettre les titres des pages, etc"
+    "# https://www.glowscript.org/docs/VPythonDocs/VPython_Intro.pdf\n",
+    "from vpython import *\n",
+    "scene = canvas()\n",
+    "\n",
+    "ball = sphere(pos=vector(-5,0,0), radius=0.5, color=color.cyan)\n",
+    "wallR = box(pos=vector(6,0,0), size=vector(0.2,12,12), color=color.green)\n",
+    "wallL = box(pos=vector(-10,0,0), size=vector(0.2,12,12), color=color.green)\n",
+    "ball.velocity = vector(25,0,0)\n",
+    "deltat = 0.005\n",
+    "t = 0 \n",
+    "while t < 3:\n",
+    "    if ball.pos.x > wallR.pos.x or ball.pos.x < wallL.pos.x:\n",
+    "        ball.velocity.x = -ball.velocity.x \n",
+    "    ball.pos = ball.pos + ball.velocity * deltat\n",
+    "    t = t + deltat \n",
+    "    rate(100) "
    ]
   },
   {
@@ -213,7 +58,6 @@
   }
  ],
  "metadata": {
-  "celltoolbar": "Slideshow",
   "kernelspec": {
    "display_name": "Python 3",
    "language": "python",
@@ -229,7 +73,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.6.6"
+   "version": "3.7.2+"
   }
  },
  "nbformat": 4,