diff --git a/PredictionQuestion/FreeFall.ipynb b/PredictionQuestion/FreeFall.ipynb
index 1b284c3..6ed8450 100644
--- a/PredictionQuestion/FreeFall.ipynb
+++ b/PredictionQuestion/FreeFall.ipynb
@@ -1,337 +1,314 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook is about demonstrating:\n",
"* prediction questions\n",
"* observation questions\n",
"* hiding code\n",
"\n",
- "The example chosen is voluntarily simple so that anyone can understand what is illustrated and focus the pedagogical features of the example."
+ "The example chosen is voluntarily *simple* so that anyone can understand what is illustrated and focus the pedagogical features of the example."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Free fall\n",
"\n",
"An object is dropped from a given height with no initial velocity. We are interested in the movement from the object in the case where *resistance from the air is ignored*.\n",
"\n",
"1. Answer the following prediction questions - be sure to write down your answer on a piece of paper:\n",
" * Which object would reach the ground first: a bowling ball (5 kg) or a tennis ball (0.05 kg)?\n",
" * Why? Describe in words your explanation for this behavior.\n",
" * Sketch your prediction for the *height* of the object as a function of time. Describe in words what this graph means.\n",
" * Sketch your prediction for the *velocity* of the object as a function of time. Describe in words what this graph means.\n",
" * Sketch your prediction for the *acceleartion* of the object as a function of time. Describe in words what this graph means.\n",
"\n",
"\n",
"2. Run the demo and answer the following observation questions :\n",
" * When does the bowling ball reaches the ground (time in seconds)?\n",
" * When does the tennis ball reaches the ground (time in seconds)?\n",
" * When does the ostrich feather reaches the ground (time in seconds)?\n",
"\n",
"\n",
"3. Compare the explanation provided in this notebook with your own explanation.\n",
"\n",
"To be fully convinced, look at the video at the end of this notebook!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Demo"
]
},
{
"cell_type": "code",
- "execution_count": 31,
+ "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",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"plt.style.use('seaborn-whitegrid') # global style for plotting"
]
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Types of objects we have with their weight\n",
- "objects = {'Bowling ball': 5, 'Tennis ball': .050, 'Ostrich feather': .005}\n",
+ "objects = {'Bowling ball': 5.0, 'Tennis ball': .05, 'Ostrich feather': .005}\n",
"\n",
"# Parameters of the problem\n",
"m = objects.get('Bowling ball') # mass in kg of the object\n",
"h_0 = 10 # initial height in m\n",
"v_0 = 0 # initial velocity in m/s\n",
"g = 9.81 # gravity in m/s2\n",
"\n",
"# Time space\n",
- "t = np.linspace(0,3,100) # time scale from 0 to 5 seconds, with 100 points in the interval"
+ "t = np.linspace(0,3,25) # time scale from 0 to 5 seconds, with 100 points in the interval"
]
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Functions representing the equations of the movement as functions of time and the problem parameters\n",
"def accel_time (t, m, h_0, v_0):\n",
" return [-g]*t.size # returning a list of same length as the time list filled with -g\n",
"\n",
"def veloc_time (t, m, h_0, v_0):\n",
" return -g*t+v_0 \n",
"\n",
"def height_time (t, m, h_0, v_0):\n",
- " return -0.5*g*(t**2)+v_0*t+h_0"
+ " return -0.5*g*(t**2)+v_0*t+h_0\n",
+ "\n"
]
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "a22b086609ce4ec3a9a6fb9375d05374",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "VBox(children=(HBox(children=(Label(value='Choice of object(s):'), SelectMultiple(index=(0,), options=('Bowlin…"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"# IHM input elements\n",
"h_label = Label('Initial height ($m$):')\n",
"h_widget = widgets.FloatSlider(min=0,max=30,step=1,value=h_0)\n",
"h_box = HBox([h_label, h_widget])\n",
"\n",
"v_label = Label('Initial velocity ($m.s^{-1}$):')\n",
"v_widget = widgets.FloatSlider(min=0,max=30,step=1,value=v_0)\n",
"v_box = HBox([v_label, v_widget])\n",
"\n",
"m_label = Label('Choice of object(s):')\n",
"m_widget = widgets.SelectMultiple(\n",
" options=objects.keys(),\n",
" value=(next(iter(objects)),),\n",
" disabled=False\n",
")\n",
"m_box = HBox([m_label, m_widget])\n",
"\n",
"# IHM output elements\n",
"output_object = widgets.Output()\n",
"output_graph = widgets.Output()\n",
"\n",
"# Display updated output function\n",
"def display_updated_output(h, v, m):\n",
" # Clear outputs\n",
" output_graph.clear_output(wait=True)\n",
" output_object.clear_output(wait=True)\n",
" \n",
" # Recompute equations with parameters set by the used\n",
" h_t = height_time(t, m, h, v)\n",
" v_t = veloc_time(t, m, h, v)\n",
" a_t = accel_time(t, m, h, v)\n",
" \n",
" # Create the figure\n",
- " fig, ax = plt.subplots(3, 1, sharex='col', figsize=(6, 8))\n",
+ " fig, ax = plt.subplots(1, 3, sharex='col', figsize=(16, 4))\n",
"\n",
" ax[0].set_ylabel('Height ($m$)')\n",
" ax[0].plot(t, h_t, label='Height')\n",
" \n",
" ax[1].set_ylabel('Velocity ($m.s^{-1}$)')\n",
" ax[1].plot(t, v_t, label='Velocity')\n",
" \n",
" ax[2].set_ylabel('Acceleration ($m.s^{-2}$)')\n",
" ax[2].plot(t, a_t, label='Acceleration')\n",
- " ax[2].set_xlabel('Time (s)')\n",
+ " for a in ax:\n",
+ " a.set_xlabel('Time (s)')\n",
"\n",
" fig.tight_layout()\n",
" \n",
" # Display graph \n",
" with output_graph:\n",
" plt.show()\n",
" \n",
" # Display weight of object selected\n",
" with output_object:\n",
" print(\"Weight of the object selected (kg): \", m)\n",
"\n",
"# Event handlers\n",
"def h_event_handler(change):\n",
" display_updated_output(change.new, v_widget.value, m_transform(m_widget.value))\n",
"\n",
"def v_event_handler(change):\n",
" display_updated_output(h_widget.value, change.new, m_transform(m_widget.value))\n",
"\n",
"def m_event_handler(change):\n",
" # TODO manage case of multiple objects selected\n",
" display_updated_output(h_widget.value, v_widget.value, m_transform(change.new))\n",
"\n",
"def m_transform(widget_input):\n",
" # the object sent by the widget is a tuple (unmodifyable list)\n",
" # default value if tuple empty or object not in dictionary\n",
" val = 1\n",
" # if the tuple contains something\n",
" if len(widget_input) > 0:\n",
" # get the weight of the object from our list\n",
" # for the moment we manage only the simple choice (only one element in the list)\n",
" # TODO multiple values in the tuple\n",
" \n",
" if widget_input[0] in objects: \n",
" val = objects.get(widget_input[0]) \n",
" \n",
" return val\n",
" \n",
"\n",
"# Linking widgets to handlers\n",
"h_widget.observe(h_event_handler, names='value')\n",
"v_widget.observe(v_event_handler, names='value')\n",
"m_widget.observe(m_event_handler, names='value')\n",
"\n",
"# Display whole interface with the graph already plotted\n",
- "ihm = VBox([m_box, output_object, h_box, v_box, output_graph])\n",
+ "#ihm = VBox([m_box, output_object, h_box, v_box, output_graph])\n",
+ "v_box_mass = VBox([m_box, output_object])\n",
+ "v_box_h_and_v = VBox([h_box, v_box])\n",
+ "h_box_control = HBox([v_box_mass, v_box_h_and_v])\n",
+ "ihm = VBox([output_graph, h_box_control])\n",
"display(ihm)\n",
"display_updated_output(h_0, v_0, m)\n",
"\n",
"#TODO IHM : \n",
"# - export all functions in an external class\n",
"# - time range\n",
"# - multiple objects\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Additional observation questions: role of the initial velocity\n",
"\n",
"Choose one object. Which initial velocity is it necessary to give it so that it reaches the ground at $t = 2.5 s$?\n",
"\n",
"Choose one object and give it an initial velocity.\n",
"* When does it reaches its maximum height?\n",
"* What is its velocity at that moment? Why?\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Explanation\n",
"\n",
"## What are the forces on the object?\n",
"\n",
"Let's draw a free body diagram.\n",
"\n",
- "![Free Body Diagram](FBD-ball.png) \n",
+ "![Free Body Diagram](Images/FBD-ball.png)\n",
"\n",
"If we ignore the friction from air, the only force applied on the object is the weight: $\\vec p = m \\vec g$\n",
"\n",
"From Newton's second law we can write: $\\sum \\vec F = m \\vec a$\n",
"\n",
"With the weight the only force we have we get: $\\vec p = m \\vec a$\n",
"\n",
"Using the expression of the weight: $m \\vec g = m \\vec a$\n",
"\n",
"Therefore the movement of the object is described by $\\vec a = \\vec g$, which means the ball is under **constant acceleration**.\n",
"\n",
"## Movement of the object in time\n",
"\n",
"To get the equation of acceleration as a function of time, let's project onto our coordinate system: $a = -g$, therefore $a(t) = -g$.\n",
"\n",
"From there we can get the equations for velocity and height by integrating successively:\n",
"\n",
"$\\left\\{\\begin{matrix} a(t) = -g \\\\ v(t) = -g\\,t + v_0 \\\\ h(t) = -\\frac{1}{2}\\,g\\,t^2 + v_0\\,t + h_0\\end{matrix}\\right. $\n",
"\n",
"With the following parameters:\n",
"* the initial height $h_0$ from which the object is dropped\n",
"* the initial velocity of the object $v_0$, with $v_0 = 0$ when the object is dropped with no initial velocity\n",
"* and of course the acceleration due to gravity $g$\n",
"\n",
"We see clearly that **the mass $m$ of the object plays no role at all in the movement**."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# And how does that look in real life?"
]
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "')\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"%%HTML\n",
"')"
+ ""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Other documents\n",
"\n",
"https://www.rentech.com.tr/wp-content/uploads/2017/09/PWV-06-ball_toss.pdf\n",
"\n",
"https://opentextbc.ca/physicstestbook2/chapter/falling-objects/"
]
}
],
"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": 2
}
diff --git a/PredictionQuestion/FBD-ball.png b/PredictionQuestion/Images/FBD-ball.png
similarity index 100%
rename from PredictionQuestion/FBD-ball.png
rename to PredictionQuestion/Images/FBD-ball.png