diff --git a/KYCW.ipynb b/KYCW.ipynb index c3bb0b1..f265c33 100644 --- a/KYCW.ipynb +++ b/KYCW.ipynb @@ -1,519 +1,516 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " Jupyter Notebooks for Education - KYCW, December 2, 2019
\n", " C. Hardebolle, CC BY-NC-SA 4.0 Int.

\n", " How to use this notebook?
\n", " This notebook is made of text cells and code cells. The code cells have to be executed to see the result of the program. To execute a cell, simply select it and click on the \"play\" button () in the tool bar just above the notebook, or type shift + enter. It is important to execute the code cells in their order of appearance in the notebook.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Activity 1: Experimenting with the virtual lab\n", "\n", "The \"Suspended object\" virtual lab below allows you to **experiment with different counterweights** to see how it affects the position of the object suspended on the cable. \n", "Execute the code cell below (click on it then click on the \"play\" button in the tool bar above) to launch the virtual lab, then answer the questions in the quiz below." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from lib.suspendedobjects import *\n", "SuspendedObjectsLab();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*If you wonder how the virtual lab works, you can have a look at the code in [this python file](lib/suspendedobjects.py).*\n", "\n", "---\n", "\n", "# Activity 2: Looking more closely at the tension in the cable\n", "\n", "In the mini-lecture, we have seen that, in this situation, the value of the tension in the cable (represented by the plain red arrows in the virtual lab above) is defined by:\n", "\n", "$\n", "\\begin{align}\n", "\\lvert\\vec{T}\\rvert = \\frac{\\frac{1}{2}.m.g}{sin(\\alpha)}\n", "\\end{align}\n", - "$\n", - "\n", - "where $m$ is the mass of the suspended object, $\\alpha$ the angle that the cable makes with the horizon and $g$ the gravity of earth.\n", + "$, where $m$ is the mass of the suspended object, $\\alpha$ the angle that the cable makes with the horizon and $g$ the gravity of earth.\n", "\n", "In the following we are going to use Python to **compute the tension in the cable** for **different values of the angle $\\alpha$**.\n", "\n", "## Computing individual values for the tension in the cable" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the above equation we have two constants:\n", - "- the gravity of earth, which is 9.81 m/s\n", - "- the mass of the suspended jeans, which is 3 kg" + "- $g$ the gravity of earth, which is 9.81 m/s\n", + "- $m$ the mass of the suspended object, which is 3 kg in the case of the jeans" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# let's define the value of gravity\n", "gravity = 9.81\n", "\n", "# And the mass of the jeans\n", "jeans_mass = 3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let's define a Python function that represents the equation of the tension and in which we are going to vary $\\alpha$. \n", "The function takes one input parameters, `alpha`, which is the angle that the cable makes with the horizon. \n", "It returns the value of the tension in the cable as computed with the equation above." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def tension_norm(alpha):\n", " return (.5 * jeans_mass * gravity) / np.sin(alpha)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's use this Python function to make calculations. \n", "For an angle of 1.5$^\\circ = \\frac{\\pi}{120}$, the norm of the tension in the cable, expressed in Newtons, will be:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# First choose an angle alpha\n", "alpha = np.pi/120\n", "\n", "# Then compute the tension using our equation\n", "T = tension_norm(alpha)\n", "\n", "# and print the result with a pretty format\n", "display(Math(r'$\\lvert\\vec{T}\\rvert = $'+' {:8.0f} $N $'.format(T)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To get an idea of how big this value is, you can think about our jeans which weight 3 $kg$: the force exerted by earth gravity on the jeans is $\\lvert\\vec{F}\\rvert = $ 29 $N$ only!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Question \n", "What is the value of the tension for an angle of 0.5$^\\circ = \\frac{\\pi}{360}$? \n", "In the code cell above, change the value of `alpha` and re-execute the cell to see the result." ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Type the value you obtain here:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Looking at how the tension in the cable evolves as a function of angle $\\alpha$\n", "\n", "Now we want to look at **how the tension evolves** when the angle $\\alpha$ changes. \n", "In the following code cell, we use our previously defined Python function to plot the tension as a function of the angle. \n", "Execute the code cell below to see the graph.\n", "\n", "*Note:* \n", "Python code for plotting can be quite verbose and not particularly interesting to look at unless you want to learn how to generate plots in Python. \n", "The good news is that you can **hide** a code cell from the notebook by selecting it and clicking on the blue bar which appears on its left. To make the cell visible again, just click again on the blue bar, or on the three \"dots\" which represent the collapsed cell." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# First we generate 100 possible values for the angle alpha between PI/8 (22.5°), the initial angle that our cable makes with the horizon, and 0° (excluded) \n", "a = np.linspace(start=np.pi/8, stop=0, num=100, endpoint = False)\n", "\n", "# Then we compute the value of the tension for all the 100 possible angles alpha using our previously defined function\n", "t = tension_norm(a)\n", "\n", "# And we plot the result\n", "fig, ax = plt.subplots()\n", "ax.set_title('Tension in the cable')\n", "ax.set_ylabel('Tension T (N)')\n", "ax.set_xlabel(r'Angle $\\alpha$ ($^\\circ$)')\n", "a_deg = a * 180 / np.pi # We convert the angle from radian to degrees for a more readable plot\n", "ax.set_xlim(a_deg[0], 0) # We make the angle decreasing for a more readable plot\n", "ax.plot(a_deg, t, color='red')\n", "fig" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Question \n", - "The graph above shows how the value of the tension $\\vec{T}$ in the cable evolves depending on the angle $\\alpha$ that the cable makes with the horizon. \n", "For which angle does the tension reach 500 Newtons, approximately? And 1000 Newtons?" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Type your answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What are the consequences?\n", "\n", - "As you can see, the more the cable is taut, the higher the tension is. Actually, **the tension increases very very fast when the cable approaches the horizon**: what this curve represents is that the value of the tension **tends towards $+\\infty$** when the angle $\\alpha$ approaches 0.\n", + "As you can see, the more the cable is taut, the higher the tension is. Actually, **the tension increases very very fast when the cable approaches the horizon**: what the graph shows is that the value of the tension **tends towards $+\\infty$** when the angle $\\alpha$ approaches 0.\n", "\n", "The problem is that high tension in a cable is quite dangerous, especially when the cable is not well adapted for its intended use (i.e. not strong enough) or when the cable is progressively deteriorating with use. \n", "\n", "Question \n", "Execute the cell below to see the video and watch the first minute (sound is not necessary). \n", "What happens at time 0:53?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import YouTubeVideo\n", "YouTubeVideo('KIbd5zBek5s', 600, 337)" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Type your answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "---\n", "\n", "# Additional exercises (optional)\n", "\n", "## Expressing the tension in 'kilogram-force'\n", "To have a better intuition about how big the tension is, people like to express it in kilograms. The idea is to make a parallel with the force exerted by gravity i.e. the weight, $\\vec{F} = m.\\vec{g}$, and to compute which mass $m$ would create an equivalent force. \n", "To get the value in 'kilogram-force' of a tension, you divide its value in Newtons by the value of gravity: \n", "\n", "$\n", "\\begin{align}\n", "T' = \\frac{T}{g}\n", "\\end{align}\n", "$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Question \n", "Complete the code in the cell below to compute the value in 'kilogram-force' of the tension we have computed above. Then execute the cell to see the result." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# TODO: replace the \"0\" in the line below with the expression of the equation above\n", "T_prime = 0\n", "\n", "# pretty printing of the result\n", "display(Math(r'$\\lvert\\vec{T}\\rvert = $'+' {:8.0f} kg$_F$'.format(T_prime)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To go further, you could transform your code above into a function, which would take `T` as an input parameter and return the value of `T` in 'kilogram-force'." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What happens to the tension when $\\alpha$ = 0?\n", "\n", "What happens with our piece of Python code when we say that the cable it taut completely horizontal, i.e. the angle $\\alpha$ = 0$^\\circ$, which is actually impossible in real life? \n", "\n", "Question \n", "In the cell where we have computed $T$ above, change the value of `alpha` to $0$ and re-execute the cell. \n", "What happens? " ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Type your answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "---\n", "\n", "# Is it possible to pull the cable taut completely horizontally?\n", "\n", "In this section we demonstrate the physical and mathematical reasoning to answer this question.\n", "\n", "### Goal\n", "\n", "For the cable to be taut completely horizontally means that the angle $\\alpha$ that the cable makes with the horizon is 0$^\\circ$. \n", "In other words, the question could be reframed as: which mass $m_{cw}$ should we put as a counterweight to get $\\alpha$ = 0$^\\circ$?\n", - "If we find a 'reasonable' value for the counterweight then it will mean that it is possible to pull the cable taut completely horizontally.\n", + "If we can find a 'reasonable' value for the counterweight then it will mean that it is possible to pull the cable taut completely horizontally.\n", "\n", "To answer this question, we therefore look for an expression relating the **mass of the counterweight $m_{cw}$** and the **angle $\\alpha$** that the cable makes with the horizon.\n", "\n", "\n", "### Method\n", "\n", "Given that the system is in static equilibrium, the sum of external forces exerted on the system will be zero, so using Newton's second law should be easy. The force that the counterweight exerts on the system will involve the mass of the counterweight so we should be able to rewrite Newton's second law to get an expression of the form $m_{cw} = ...$.\n", "\n", "### Hypotheses and simplifications\n", "\n", "We make the following assumptions and simplifications:\n", "* the jeans are considered as positioned exactly mid-way between the poles so the tension is equal on both sides of the cable\n", "* we represent the jeans by the point at which they are suspended\n", "* the cable is considered as rigid (not bended), with a negligible mass\n", "* the pulley is considered as perfect, without mass nor friction\n", "* we consider the static equilibrium obtained after changing the weight, once the system is stabilized\n", "\n", "### Resolution\n", "\n", "First, let's draw a diagram and represent the different forces involved.\n", "\n", "\n", "The *forces applied on the jeans* are:\n", "* the weight: $\\vec F_j = m_j \\vec g$ \n", "* the force exerted by the cable on each side of the jeans: assuming the jeans are suspended at the exact center of the cable, then the tension applied on each of the two sides is is equally distributed $\\vec T$, which combine into a vertical resulting tension $\\vec T_r = 2.\\vec T$\n", "\n", "From Newton's second law in a static equilibrium we can write: $\\sum \\vec F_j = \\vec 0$ \n", "With the forces on the jeans we get: $\\vec F_j + \\vec T_r = 0$ \n", "Using the fact that the tension is equal on both sides of the jeans we get: $\\vec F_j + 2.\\vec T = 0$\n", "\n", "If we project on $x$ and $y$ axes, we get: \n", "$\\left\\{\\begin{matrix} F_{jx} + 2.T_x = 0 \\\\ F_{jy} + 2.T_y = 0\\end{matrix}\\right. $\n", "\n", "Since the weight does not have a component on the x axis, it simplifies into: \n", "$\\left\\{\\begin{matrix} T_x = 0 \\\\ F_{jy} + 2.T_y = 0\\end{matrix}\\right. $\n", "\n", "The component of the weight on the y axis is $F_{jy} = - m_j.g$, which gives us: \n", "$\\left\\{\\begin{matrix} T_x = 0 \\\\ - m_j.g + 2.T_y = 0\\end{matrix}\\right. $\n", "\n", "Using the angle $\\alpha$ we can get the tension $T_y$ expressed as a function of T since $sin(\\alpha) = \\frac{T_y}{T}$, therefore $T_y = T.sin(\\alpha)$\n", "\n", "By replacing $T_y$ by this expression in the above equation we get: \n", "$\\left\\{\\begin{matrix} T_x = 0 \\\\ - m_j.g + 2.T.sin(\\alpha) = 0\\end{matrix}\\right. $\n", "\n", "From there we can get $T$, and this is equation number $(1)$: \n", "\n", "$\n", "\\begin{align}\n", "T = \\frac{m_j.g}{2.sin(\\alpha)}\n", "\\end{align}\n", "$\n", "\n", " \n", "\n", "We now want to make the mass of the counterweight appear in this expression. \n", "So we will now look at the forces applied on the *counterweight*.\n", "\n", " \n", "\n", "The forces applied on the *counterweight* are:\n", "* the weight: $\\vec F_{cw} = m_{cw} \\vec g$ \n", "* the force exerted by the cable: a simple pulley simply changes the direction of the tension so the tension applied on the counterweight is therefore $\\vec T$\n", "\n", "From Newton's second law in a static equilibrium we can write: $\\sum \\vec F_{cw} = \\vec 0$ \n", "With the forces involved in our problem : $\\vec F_{cw} + \\vec T = \\vec 0$ \n", "\n", "All forces being vertical, there is no need to project on $x$ so we get: $- F_{cw} + T = 0$ \n", "We replace the weight by its detailed expression: $-m_{cw}.g + T = 0$ \n", "Now we can express $T$ as a function of the other parameters, which is equation number $(2)$: $T = m_{cw}.g$ \n", "\n", " \n", "\n", "Let's now summarize what we have so far with equations $(1)$ and $(2)$: \n", "\n", "$\n", "\\begin{align}\n", "\\left\\{\\begin{matrix}T = \\frac{m_j.g}{2.sin(\\alpha)} \\\\ T = m_{cw}.g\\end{matrix}\\right. \n", "\\end{align}\n", "$\n", "\n", "These two equations combined give us:\n", "\n", "$\n", "\\begin{align}\n", "\\frac{m_j.g}{2.sin(\\alpha)} = m_{cw}.g\n", "\\end{align}\n", "$\n", "\n", "This allow us to find the mass of the counterweight as a function of the *mass of the jeans* and of the *angle that the cable makes with the horizon*: \n", "\n", "
\n", "\n", "$$m_{cw} = \\frac{m_j}{2.sin(\\alpha)}$$\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Conclusion\n", "\n", "When the cable approaches the horizon, $\\alpha$ is really small i.e. really close to zero. \n", "This means that $sin(\\alpha)$ is also close to zero, which means in turn that $m_{cw}$ is very big.\n", "Therefore, **the more we want the cable to be close to the horizon, the bigger $m_{cw}$ we will need!**\n", "\n", "Mathematically speaking, the limit of the expression defining the mass of the counterweight when alpha tends to 0 is:\n", "\n", "$\n", "\\begin{align}\n", "\\lim_{\\alpha\\to0}m_{cw} = \\lim_{\\alpha\\to0}\\frac{m_j}{2.sin(\\alpha)} = +\\infty\n", "\\end{align}\n", "$\n", "\n", "So basically, we would need to put an **infinitely heavy counterweight** to make the angle null and that is why it is impossible to get the cable taut so that it is absolutely straight (the cable would break before that! :-p)...\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "### Numerical application\n", "\n", "We have already defined above the constant `jeans_mass` which represents the mass of our jeans (3 kg).\n", "\n", "Let's define a Python function that represents the above equation. \n", "The function takes one input parameters, `alpha`, the angle that the cable makes with the horizon. \n", "It returns the mass of the counterweight as computed with the equation above." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def counterweight_mass(alpha):\n", " return jeans_mass / (2 * np.sin(alpha))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For an angle of $1.5^\\circ = \\frac{\\pi}{120}$, we need to put a counterweight of:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Choose a value for angle alpha\n", "alpha = np.pi / 120\n", "\n", "# Computes the mass of the counterweight using our function\n", "mcw = counterweight_mass(alpha)\n", "\n", "# And print the result\n", "print('{:.02f} kg'.format(mcw))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can check that you get a similar result with the virtual lab above.\n", "\n", "You can also check what happens when you put `alpha = 0`...\n", "\n", " " ] } ], "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.6.8" } }, "nbformat": 4, "nbformat_minor": 4 }