{ "cells": [ { "cell_type": "markdown", "metadata": { "toc-hr-collapsed": true }, "source": [ "\n", "# Workshop \"Teaching Sciences and Engineering with Jupyter Notebooks\" 2021\n", "C. Hardebolle, [CC-BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)\n", "\n", "
shift + enter
. Figure 1: The suspended jeans situation
\n", "\n", "\n", "The activities below allow you to find out the answer to this question by exploring how the counterweight affects the position of the jeans suspended on the cable. " ] }, { "cell_type": "markdown", "metadata": { "toc-hr-collapsed": false }, "source": [ "Figure 2: Simplified suspended jeans situation
\n", "\n", "\n", "Therefore we are in a situation which is **identical to the one seen in the mini-lecture**.Figure 3: Angle and forces in the suspended jeans situation
\n", "\n", "\n", "We can therefore **use the equation seen in the mini-lecture, which gives the tension in the cable** depending on the mass $m$ of the suspended object, the angle $\\alpha$ that the cable makes with the horizon and the gravity of earth $g$:\n", "\n", "$\n", "\\begin{align}\n", "\\lvert\\vec{T}\\rvert = \\frac{\\frac{1}{2}.m.g}{sin(\\alpha)}\n", "\\end{align}\n", "$\n", "\n", "Computing the tension in the cable will help us figure out the counterweight necessary to maintain the cable taught: intuitively, we can predict that **the higher the tension in the cable, the heavier the counterweight needed** to keep the cable taught. " ] }, { "cell_type": "markdown", "metadata": { "toc-hr-collapsed": false }, "source": [ "## How does the angle $\\alpha$ influence the forces on the jeans?\n", "\n", "\n", "Now, we know that the mass of the jeans is $m =$ 3kg and that the gravity of earth is $g =$ 9.81m.s$^{-2}$, but we don't know the value of $\\alpha$. \n", "From the sketch in the original question in [Figure 1 above](#fig1), we can guess that $\\alpha$ is probably quite small, but how small?\n", "\n", "In the following, we are going to use the ``suspendedobjects`` library to visualize concretely what a particular value for $\\alpha$ means. \n", "For this, we need to import some useful Python libraries. \n", "\n", "def tension_norm(g, m, alpha):\n",
" tension = (1/2 * m * g) / np.sin(alpha)\n",
" return tension\n",
"
\n",
"\n",
"m_cw = T / g
\n",
" \n",
"Of course, if you are at ease with Python you can write this as a function, which could also call the ``tension_norm`` function defined earlier instead of using ``T``...\n",
"T = tension_norm(g, m, 0)
\n",
" \n",
"When you execute this code, two things happen:\n",
"* You get a warning message which says `RuntimeWarning: divide by zero encountered in double_scalars`\n",
"* The function nonetheless returns a value which is `inf`\n",
"\n",
"When the angle $\\alpha$ = 0 then $sin(\\alpha)$ = 0 and therefore we divide `(.5 * jeans_mass * gravity)` by 0 so on one hand, mathematically speaking, we know that the result should be $+\\infty$. On the other hand, we also know that usually division by 0 is not well supported by computers.\n",
"\n",
"Actually, division by 0 is not supported in standard Python. \n",
"You can create a code cell (click on the `+` icon in the toolbar above) and try to execute the following computation to see what happens: ``(0.5 * 3 * 9.81)/0``\n",
" \n",
"Now, because in the calculation we use the function `np.sin()` from the Numpy library, our data is automatically converted to Numpy types, which support division by zero and returns the \"real\" result which is $+\\infty$. \n",
"By convention, Numpy also generates a warning message but this can be deactivated when not necessary. \n",
"If you are curious, you can take a look at [the errors generated by Numpy for floating-point calculations](https://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html#numpy.seterr).\n",
"\n",
"def tension_norm_degrees(g, m, alpha):\n",
" apha_rad = degrees_to_radians(alpha)\n",
" tension = tension_norm(g, m, apha_rad)\n",
" return tension\n",
"
\n",
"\n",
"Of course the three lines in this function can be combined into just one: \n",
"\n",
"def tension_norm_degrees(g, m, alpha):\n",
" return tension_norm(g, m, degrees_to_radians(alpha))\n",
"
\n",
" \n",
"