diff --git a/TeachingExamples/SuspendedObjects-exercise.ipynb b/TeachingExamples/SuspendedObjects-exercise.ipynb index fc96e85..6469592 100644 --- a/TeachingExamples/SuspendedObjects-exercise.ipynb +++ b/TeachingExamples/SuspendedObjects-exercise.ipynb @@ -1,241 +1,241 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

Use case scenario
\n", " This notebook is made to be used by students as an assignment or exercise, in autonomy (at home or in an exercise session).

\n", "

Features
\n", " This notebook embeds auto-corrected quizzes to engage students with the virtual demonstration and uses different types of visualisations to help students understand the phenomena.
\n", " The example chosen is voluntarily simple so that anyone can understand what is illustrated and focus the pedagogical features of the example.

\n", "

More information on using notebooks for exercises or assignements.

\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Suspended objects\n", "\n", "We consider a clothesline made of two poles and a cable.\n", "The cable is fixed on one pole. A pulley on the other pole allows to attach a counterweight to pull the cable taut. \n", "\n", "\n", "\n", "## Exercise 1\n", "Execute the cell below to activate the interactive quiz and answer the question." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import IFrame\n", "IFrame('https://moodle.epfl.ch/mod/hvp/embed.php?id=1028285', 1024, 450)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 2\n", "\n", "The virtual lab below allows you to experiment with different counterweights to see how it affects the position of the object suspended on the clothesline. \n", "Execute the cell below to launch the virtual lab, then *answer the questions in the quiz below*." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "from lib.suspendedobjects import *\n", "SuspendedObjectsLab();\n", "IFrame('https://h5p.org/h5p/embed/584119', 1024, 350)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*If you wonder how the virtual lab works and would like to see the code, [you can have a look at it at the end of this notebook](#How-does-the-virtual-lab-work%3F).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 3\n", "\n", "1. Give the expression of the **mass of the counterweight $m_{cw}$ as a function of the other parameters of the problem**.\n", "2. Application: what counterweight allows to suspend wet jeans ($m = 3 kg$) on the cable so that the cable is taut at an angle of $1.5^\\circ = \\frac{\\pi}{120}$ with the horizon?\n", "3. Why is it impossible to pull the cable taut completely horizontally?\n", "\n", " \n", "\n", "## Solution\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 tention $\\vec T_r = 2.\\vec T$\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", "$T = \\frac{m_j.g}{2.sin(\\alpha)}$\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 line: 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", "$\\left\\{\\begin{matrix}T = \\frac{m_j.g}{2.sin(\\alpha)} \\\\ T = m_{cw}.g\\end{matrix}\\right. $\n", "\n", "These two equations combined give us:\n", "\n", "$\\frac{m_j.g}{2.sin(\\alpha)} = m_{cw}.g$\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 line makes with the horizon*: \n", "\n", "$\\boxed{m_{cw} = \\frac{m_j}{2.sin(\\alpha)}}$\n", "\n", "\n", " \n", "\n", "### Application\n", "\n", "For a pair of wet jeans of $3 kg$ and 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": [ "mcw = 3 / (2 * np.sin(np.pi / 120))\n", "print(mcw)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can **check that you get a similar result** with the virtual lab above!\n", "\n", "\n", "### Conclusion\n", "\n", "For the line to be taut completely horizontal, $\\alpha$ has to be really small i.e. really close to zero. \n", "This means that $sin(\\alpha)$ will also be close to zero, which means in turn that $m_{cw}$ will be very big.\n", "Actually, **the more we want the line to be close to the horizon, the bigger $m_{cw}$ we will need!**\n", "In fact, it is impossible to get the line taut so that it is absolutely straight...\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "---\n", "\n", "# How does the virtual lab work?\n", "\n", "If you wonder how the virtual lab works: \n", "* You can have a look at the code of the virtual lab by [opening this python file](lib/suspendedobjects.py).\n", "* You can see the documentation by executing the cell below:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "SuspendedObjectsLab?" ] } ], "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 } diff --git a/TeachingExamples/SuspendedObjects-textbook.ipynb b/TeachingExamples/SuspendedObjects-textbook.ipynb index ce670e5..0eb1526 100644 --- a/TeachingExamples/SuspendedObjects-textbook.ipynb +++ b/TeachingExamples/SuspendedObjects-textbook.ipynb @@ -1,288 +1,288 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " WORK IN PROGRESS  This notebook is under development, please bear with us...\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "from ipywidgets import interact, interactive, fixed, interact_manual\n", "from ipywidgets import HBox, VBox, Label\n", "import ipywidgets as widgets\n", "\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "plt.style.use('seaborn-whitegrid') # global style for plotting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Suspended objects\n", "\n", "**Question:** Estimate which counterweight allows to suspend wet jeans (3kg) on the cable so that the cable is taut as shown on the diagram below? \n", "\n", "\n", "\n", "Select your answer below, then use the virtual lab to determine *order of magnitude* of the mass necessary for the counterweight." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f = lambda w: \"Choice registered: \"+str(w)\n", "interact(f, w=[('1,5 kg', 1.5), ('3 kg', 3), ('6 kg', 6), ('20 kg', 20), ('50 kg or more', 50)]);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Virtual lab" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Parameters of the situation\n", "m_jeans = 3 # mass of the wet jeans, in kg\n", "\n", "distance = 5 # distance between the poles, in m\n", "height = 1.5 # height of the poles, in m\n", "\n", "x_origin = 0 # x coordinate of point of origin of the figure = x position of the left pole, in m\n", "y_origin = 0 # y coordinate of point of origin of the figure = y position of the lower point (ground), in m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Compute the angle that the line makes with the horizon depending on the counterweight chosen\n", "def get_alpha_from_masses(m_jeans, m_counterweight):\n", " # default angle value \n", " alpha = np.pi / 2\n", " \n", " # let's check that there is actually a counterweight\n", " if m_counterweight > 0:\n", " # then we compute the ratio of masses\n", " ratio = 0.5 * m_jeans / m_counterweight\n", "\n", " # we check if the ratio of masses is in the domaine of validity of arcsin ([-1;1]) and compute the angle\n", " if ratio >= -1 and ratio <= 1:\n", " alpha = np.arcsin(ratio)\n", " \n", " return alpha\n", "\n", "# Update the position of the jean from the angle\n", "def update_jeans(angle, x_origin, y_origin, distance, height):\n", " # the jean is midway between the poles\n", " x_jeans = x_origin + 0.5 * distance\n", " \n", " # default y value: the jean is on the ground \n", " y_jeans = y_origin \n", " \n", " # we check that the angle is comprised between horizontal (greater than 0) and vertical (smaller than pi/2)\n", " if angle > 0 and angle < (np.pi / 2): \n", " # we compute the delta between the horizon and the point given by the angle\n", " delta = (0.5 * distance * np.tan(angle))\n", " # we check that the delta is smaller than the height of the poles (otherwise it just means the jean is on the ground)\n", " if delta <= height:\n", " y_jeans = y_origin + height - delta\n", " \n", " print(\"height of the point at which the jeans are hanged:\", y_jeans) \n", " \n", " return [x_jeans, y_jeans]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create visualisation\n", "def create_graph(m_counterweight = 0):\n", " # get angle of line then coordinates of jean\n", " alpha = get_alpha_from_masses(m_jeans, m_counterweight)\n", " coord_jeans = update_jeans(alpha, x_origin, y_origin, distance, height)\n", "\n", " # Create the figure\n", " fig, ax = plt.subplots(1, figsize=(12, 4))\n", " \n", " # Fix graph to problem boundaries\n", " ax.set_ylim(bottom = y_origin) # limit bottom of y axis to ground\n", " ax.set_ylim(top = y_origin + height + .2) # limit top of y axis to values just above height\n", "\n", " # Draw poles\n", " x_pole1 = np.array([x_origin, x_origin])\n", " y_pole1 = np.array([y_origin, y_origin+height])\n", " ax.plot(x_pole1, y_pole1, \"b-\")\n", " x_pole2 = np.array([x_origin+distance, x_origin+distance])\n", " y_pole2 = np.array([y_origin, y_origin+height])\n", " ax.plot(x_pole2, y_pole2, \"b-\")\n", "\n", " # Draw the hanging line\n", " x = np.array([x_origin, coord_jeans[0], x_origin+distance])\n", " y = np.array([y_origin+height, coord_jeans[1], y_origin+height])\n", " ax.plot(x, y, \"ro-\")\n", "\n", "\n", "# Launch interactive visualisation\n", "interact(create_graph, m_counterweight=(0, 100, .5)); \n", "## TODO ideas : draw the forces (tension in cable, resulting tension)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conceptual explanation\n", "\n", "TODO" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analytic explanation\n", "\n", "### Hypotheses and simplifications:\n", "\n", "* the jeans are exactly mid-way between the poles so the tension is equal on both sides of the cable\n", "* we represent the jeasn by the point at which they are suspended\n", "* the cable is considered as rigid (not bended)\n", "* we consider the static equilibrium obtained after changing the weight, once the system is stabilized\n", "\n", "### Resolution\n", "\n", "We are looking for the expression of the mass of the counterweight as a function of the other parameters of the problem.\n", "\n", "\n", "\n", "The forces applied on the *jeans* are the following:\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 tention $\\vec T_r = 2.\\vec T$\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", "\n", "With the forces: $\\vec F_j + \\vec T_r = 0$\n", "\n", "Using the fact that the tension is equal on both sides of the jeans: $\\vec F_j + 2.\\vec T = 0$\n", "\n", "If we project on $x$ and $y$ axes, we get:\n", "\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", "\n", "$\\left\\{\\begin{matrix} T_x = 0 \\\\ F_{jy} + 2.T_y = 0\\end{matrix}\\right. $\n", "\n", "NB: $T_x = 0$ means that the tension on each side of the jeans cancel out.\n", "\n", "The component of the weight on the y axis is $F_{jy} = - m_j.g$, which gives us:\n", "\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", "So we get:\n", "\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$:\n", "\n", "$T = \\frac{m_j.g}{2.sin(\\alpha)}$ $(1)$\n", "\n", "\n", "On the other hand, the forces applied on the *counterweight* are following:\n", "* the weight: $\\vec F_{cw} = m_{cw} \\vec g$ \n", "* the force exerted by the line: 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", "\n", "With the forces: $\\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", "\n", "With the detail of the weight: $-m_{cw}.g + T = 0$\n", "\n", "Which gives us $T = m_{cw}.g$ $(2)$\n", "\n", "From equations $(1)$ and $(2)$ we get:\n", "\n", "$\\left\\{\\begin{matrix}T = \\frac{m_j.g}{2.sin(\\alpha)} \\\\ T = m_{cw}.g\\end{matrix}\\right. $\n", "\n", "Which allows us to find the mass of the counterweight as a function of the *mass of the jeans* and of the *angle that the line makes with the horizon*:\n", "\n", "$m_{cw} = \\frac{m_j}{2.sin(\\alpha)}$\n", "\n", "For the line to be taut as show on the figure, $\\alpha$ has to be really small i.e. close to zero. \n", "This means that $sin(\\alpha)$ will also be close to zero, which means in turn that $m_{cw}$ will be very big.\n", "Actually, **the more we want the line to be close to the horizon, the bigger $m_{cw}$ we will need!**\n", "In fact, it is impossible to get the line taut so that it is absolutely straight...\n", "\n", "### Application\n", "\n", "For a pair of wet jeans of $3 kg$ and an angle of $4^\\circ = \\frac{\\pi}{45}$, which is approximately like depicted on the figure, we need to put a counterweight of more than 20 kg!\n", "\n", "You can try out the manual calculation below and check that you get a similar result with the virtual lab above:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_j = 3\n", "alpha = np.pi / 45\n", "\n", "m_cw = m_j / (2 * np.sin(alpha))\n", "print(m_cw)" ] } ], "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 }