{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "# **Stretchy things**" ], "metadata": { "id": "YhH6aukqPlIc" } }, { "cell_type": "markdown", "source": [ "In this lab, we'll test and build models for stretchy things.\n", "\n", "**By the end of this session, you will present to your TA your claim and evidence about the extent to which a stretchy thing can be modeled through Hooke's Law.**" ], "metadata": { "id": "W2J83gOyD5HS" } }, { "cell_type": "markdown", "source": [ "## **Learning goals**\n", "By the end of this unit, you should be able to:\n", "\n", "* Implement practical strategies for mitigating bias when conducting experiments and analyzing data.\n", "* Analyze data using least-squares fitting and residuals.\n", "* Design high-precision experiments to test models, including identifying interesting variables to test, controlling variables, and reducing uncertainty.\n", "* Use prior results to motivate a new research questions.\n", "* Manage time by conducting pilot experiments and plotting as you go.\n" ], "metadata": { "id": "PkHE-Gwy6134" } }, { "cell_type": "code", "source": [ "# Run this code cell to mount your Google Drive.\n", "from google.colab import drive\n", "drive.mount('/content/drive')\n", "\n", "#Fill in the appropriate directory info in the ``...``\n", "%run \"/content/drive/My Drive/.../utilities.ipynb\"" ], "metadata": { "id": "AJdqi2AxPn2q" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## **Group organization**\n", "\n", "We will form new groups for lab this week. To help you get to know each other, and to ensure effective collaboration and fairness, group members should discuss and write down the answers to the following questions in order to establish a “Partner Agreement.”\n", "\n", "Who are your Group Members and how do they prefer to be referred to (nicknames, pronouns, etc.)?\n", "\n", "\n" ], "metadata": { "id": "ejhzLRZY66X3" } }, { "cell_type": "markdown", "source": [ "**[Your group members' info here]**" ], "metadata": { "id": "xvnW6QsU6_FQ" } }, { "cell_type": "markdown", "source": [ "Discuss with your partners what you're personally hoping to get out of this course. How do your goals compare? Discuss how you can support each other's goals. Can you agree on a collective goal for the group (e.g. to have fun, to provide a physics study group)? Establish your collective purpose and record it below.\n", "\n" ], "metadata": { "id": "ammxVFEi7HGB" } }, { "cell_type": "markdown", "source": [ "**[Your collective purpose]**" ], "metadata": { "id": "IXWaiRD07K8A" } }, { "cell_type": "markdown", "source": [ "To complete each lab a number of distinct tasks will need to be completed by individual group members or collaboratively by the group as a whole. These tasks include, but are not necessarily limited to, setting up equipment, collecting data, taking notes, and performing analysis, and managing the group. How will you divide the work fairly in your group?" ], "metadata": { "id": "obAYdZdA7Mmw" } }, { "cell_type": "markdown", "source": [ "**[Your group's plan here]**" ], "metadata": { "id": "K6sEgCP87OYq" } }, { "cell_type": "markdown", "source": [ "## **Session 1: Testing Hooke's law**" ], "metadata": { "id": "rDGybiefEeHv" } }, { "cell_type": "markdown", "source": [ "Hooke's law is a model that describes the relationship between force, $F_y$, and stretch distance, $\\Delta y$, of a stretched spring: $F_y=-k\\Delta y$. This model implies or assumes:\n", "\n", "* A linear relationship ($k$ = constant) between $F_y$ and $\\Delta y$ over some range of values.\n", "* Zero extension $\\Delta y$ corresponds to zero applied force $F_y$.\n", "* There is no time, history, or other dependence in $k$ or the measured values.\n", "\n", "You will be designing experiments to test the validity of this model for a variety of systems under various conditions.\n", "\n", "**By the end of today's lab, you will present to your TA your claim and evidence about the validity of Hooke's law for a particular stretchy thing.**\n" ], "metadata": { "id": "g6vn80J4NBxk" } }, { "cell_type": "markdown", "source": [ "### **A. Getting started**\n", "\n", "We'll start by familiarizing ourselves with analysis methods by testing a single spring system.\n", "\n", "Choose a spring to study for your first investigation.\n" ], "metadata": { "id": "nNsSG_j4Ta-w" } }, { "cell_type": "markdown", "source": [ "**[Describe your spring here - dimensions, material composition, anything else notable]**\n", "\n", "\n", "---\n", "\n" ], "metadata": { "id": "zGO320nGUMEI" } }, { "cell_type": "markdown", "source": [ "Briefly explore a few ways to measure the applied force. For example, you might use the gravitational force from an object with known mass hanging vertically from the end of your spring. Or you might use force probes to measure a horizontally applied force for some distance. Describe which method you will use for your investigation with a brief justification based on the sources of uncertainty, possible systematic effects, or more logistical constraints." ], "metadata": { "id": "zYjfRZjfURzg" } }, { "cell_type": "markdown", "source": [ "**[Your method for measuring force and justification]**\n", "\n", "\n", "---\n", "\n" ], "metadata": { "id": "MxP7fFa6UnHo" } }, { "cell_type": "markdown", "source": [ "Design an investigation that uses linear least squares fitting tools to test whether or when Hooke’s law applies to your system (i.e., is force on your object linearly proportional to its extension?). Include details about the major sources of uncertainty, your strategies for mitigating them, and how you quantified the uncertainty in your measurement." ], "metadata": { "id": "I1RmoJ0YUsBs" } }, { "cell_type": "markdown", "source": [ "**[Your design here]**\n", "\n", "\n", "---\n", "\n" ], "metadata": { "id": "w3pG4YyVVK2h" } }, { "cell_type": "markdown", "source": [ "Carry out your investigation and summarize your data, analysis, and interpretations below.\n", "\n", "We've provided some code starters at the end of this document to get you going. There are multiple ways to set up the analysis, so we've chosen two approaches that are clear, but not efficient. You are welcome to take your own approach and PLEASE delete code for approaches that you decide not to use.\n", "\n", "When copying code, please remember to edit comments, printouts, plot titles, axes labels, and any other artifacts of the code that need to be updated in order to align with whatever you are studying. Your code and code prinouts should be comprehensible to anyone reading your notes and specific to your experiment.\n", "\n", "**Note about efficiency:** You should be able to add data points to your code *as they are collected* so that you can look at your graph as you go. Do NOT wait to run the analysis until you have collected \"all\" your data. You may change what data you are collecting based on what you are seeing as you go." ], "metadata": { "id": "IBYC1stRVOdL" } }, { "cell_type": "markdown", "source": [ "### **B. A new investigation**\n", "\n", "Next, design your own investigation to test the Hooke's Law model under various conditions. For example, you might consider testing:\n", "* the linearity of the relationship for different types (rubber band, hair tie, stretch fabric, etc) or arrangements of stretchy objects,\n", "* the linearity of the relationship for extreme extensions or compressions (check with your TA about over-stretching springs),\n", "* the assumption that there is no time or history dependence in $k$." ], "metadata": { "id": "U14pOwFvfrK-" } }, { "cell_type": "markdown", "source": [ "Articulate a question for your investigation and briefly explain how your current investigation inspired your new question." ], "metadata": { "id": "mqp9Vk9mf-of" } }, { "cell_type": "markdown", "source": [ "**[Your question and evidence-based justification here]**\n", "\n", "\n", "---\n", "\n" ], "metadata": { "id": "pzccGSYZgCmU" } }, { "cell_type": "markdown", "source": [ "Design your experiment, analyze your data, reflect on your results, and iterate as appropriate. Document your process using text and code cells below.\n", "**Be specific, but not overly verbose,** in your documentation. Since you are designing your experiment, we are not providing specific prompts or questions to answer but your notes must include the following:\n", "\n", "* description of the measurement method/apparatus\n", "* discussion of sources of uncertainty and methods to mitigate them\n", "* data/plots\n", "* discussion of analysis methods\n", "* interpretation of results\n", "* potential next steps\n", "\n" ], "metadata": { "id": "ObgrzCKogGlB" } }, { "cell_type": "markdown", "source": [ "**[Add text here]**\n", "\n" ], "metadata": { "id": "DW-sjh4hgRXw" } }, { "cell_type": "code", "source": [ "#Create as many code cells and markdown cells as makes sense" ], "metadata": { "id": "23dhsZi65Wbv" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "By the end of the first session, you should have tested a simple spring system and at least one other system OR an assumption of Hooke's law. You should also have a brief outline for what you will do in the next session.\n" ], "metadata": { "id": "__2qf_UsUKV6" } }, { "cell_type": "markdown", "source": [ "## **Lab check out**\n", "\n", "By the end of the lab session, document below a claim about **the extent to which your stretchy thing(s) can be modeled through Hooke's Law** and briefly summarize your evidence that supports your claim. Present your claim to your TA or (if you are out of time), they will look over these notes to evaluate your claim.\n", "\n", "In the checkout, they will be looking for:\n", "* Whether the claim is supported by evidence,\n", "* Whether that evidence is sufficient, and\n", "* Whether it is clear that you collected the data.\n" ], "metadata": { "id": "Ke-X3_lD4Q9K" } }, { "cell_type": "markdown", "source": [ "**[Your answer here]**\n", "\n", "---\n", "---" ], "metadata": { "id": "JFyRXxBE4oE0" } }, { "cell_type": "markdown", "source": [ "## **Session 2: Keep experimenting**\n", "\n", "Following up on your results from last week, continue your investigation into the behavior of stretchy objects. As always, make sure you document all your decisions, methods, improvements, and results in the space below.\n", "\n", "**By the end of this session, you will present to your TA and other students your claim and and a single graph of evidence about an experiment related to stretchy things.**" ], "metadata": { "id": "_oTcsslBTDkr" } }, { "cell_type": "markdown", "source": [ "## **A. Your investigation**" ], "metadata": { "id": "F4PFkozkIhYH" } }, { "cell_type": "markdown", "source": [ "**[Your methods and interpretations outlined with as many markdown cells as needed]**\n" ], "metadata": { "id": "_7goeYuzg3kX" } }, { "cell_type": "code", "source": [ "#Create as many code cells and markdown cells as makes sense" ], "metadata": { "id": "AHgCZcQ8g30I" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## **B. Share your investigation**\n", "\n", "In lieu of a check out, during the last 30 minutes of the lab session, you will present your claim and **one graph of results** to your TA and peers in a mini poster session:\n", "\n", "* You will display a single graph of results, sufficiently labeled to clearly indicate what was measured, and present it on your lab station monitor as a mini poster!\n", "* Each group member should spend at least 10 minutes standing by their ,mini-poster and at most 20 minutes looking at other groups' mini-posters.\n", "* When presenting your mini-poster, briefly describe the experimental question, how you produced the data in the graph, and how you are interpreting the graph towards developing a claim.\n", "* When viewing another group's mini-poster, ask clarifying questions and offer alternative explanations or claims, or point out missing evidence for supporting the claim.\n" ], "metadata": { "id": "bNG2UUn4g4in" } }, { "cell_type": "markdown", "source": [ "**[Your claim and evidence (in words) here]**" ], "metadata": { "id": "VcVLCNv_Iqkn" } }, { "cell_type": "code", "source": [ "#Your single figure reproduced (or produced) here" ], "metadata": { "id": "QDa6d5qLIvz_" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "\n", "Following the discussion, document below:\n", "\n", "1. What feedback and ideas you received and/or ideas based on your discussion for what you could do differently or next time.\n", "\n", "2. An example of interesting investigation or result from another group.\n", "\n", "3. Examples of feedback and ideas your group offered to other groups." ], "metadata": { "id": "rP7CSlMtIe8o" } }, { "cell_type": "markdown", "source": [ "**[Feedback and ideas received here]**" ], "metadata": { "id": "Ub1AQ7yXDVGp" } }, { "cell_type": "markdown", "source": [ "**[Interesting investigations here]**" ], "metadata": { "id": "2wDCSuu0DYjO" } }, { "cell_type": "markdown", "source": [ "**[Feedback and ideas given]**\n", "\n", "---\n", "---" ], "metadata": { "id": "Lb635rFZDdSS" } }, { "cell_type": "markdown", "source": [ "# **Appendix**\n" ], "metadata": { "id": "Rn94xTP-mCoe" } }, { "cell_type": "markdown", "source": [ "## **Code template to input your data**" ], "metadata": { "id": "pDHj85AB5I3L" } }, { "cell_type": "code", "source": [ "# Example 1: If you are NOT doing repeated trials\n", "\n", "## Enter your ordered extension values:\n", "ext = np.array([...])\n", "\n", "## Enter your ordered force values, such that each entry corresponds to an extension value in the ext array in the same position\n", "## (i.e., the third entry in the force array corresponds to the third extension in the extension array):\n", "force = np.array([...])\n", "\n", "## Enter your estimates of the uncertainty in whichever variable is your dependent variable\n", "## (i.e., what should go on the y-axis), again ordered:\n", "force_unc = np.array([...]) #comment this out if extension is your dependent variable\n", "ext_unc = np.array([...]) #comment this out if force is your dependent variable\n", "\n", "## Print the output to check your work - make sure there are the same number of entries in each array\n", "## (e.g., one force and uncertainty in force corresponding to each extension)\n", "print(\"Extensions:\")\n", "print(ext)\n", "\n", "print(\"Force:\")\n", "print(force)\n", "\n", "print(\"Uncertainty in dependent variable:\")\n", "print(unc)" ], "metadata": { "id": "8wM6uhrTVMeE" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Example 2: If you ARE doing repeated trials and force is your dependent varialbe\n", "# i.e., you are measuring the force required to stretch the spring through various distances\n", "\n", "## Enter your ordered extension values:\n", "ext = np.array([...])\n", "\n", "## Enter your repeated measurements of the force for the first extension value in the ext array:\n", "force_ext1 = np.array([...])\n", "## Enter your repeated measurements of the force for the second extension value in the ext array:\n", "force_ext2 = np.array([...])\n", "## Repeat for all values of extension measured:\n", "...\n", "\n", "## Calculate the mean and standard uncertainty in the mean for the first set of force measurements:\n", "force_ext1_mean = np.mean(force_ext1)\n", "force_ext1_su = standard_unc_of_mean(force_ext1)\n", "## Repeat for all sets of force measurements:\n", "...\n", "\n", "## Create an array of all the means of the force measurements, ordered to align with the extension array:\n", "force = np.array([force_ext1_mean, force_ext2_mean, ...])\n", "## Create an array of all the standard uncertainties of the mean force measurements, ordered to align with the extension array:\n", "force_unc = np.array([force_ext1_su, ...])\n", "\n", "# Print the output to check your work - make sure there are the same number of entries in each array (e.g., one force and uncertainty in force corresponding to each extension)\n", "print(\"Extensions:\")\n", "print(ext)\n", "\n", "print(\"Force:\")\n", "print(force)\n", "\n", "print(\"Uncertainty in force:\")\n", "print(force_unc)" ], "metadata": { "id": "Yvi5aFtq4mV6" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Example 3: If you ARE doing repeated trials and extension is your dependent varialbe\n", "# i.e., you are measuring the extension that results from various applied forces\n", "\n", "## Enter your ordered force values:\n", "force = np.array([...])\n", "\n", "## Enter your repeated measurements of the extension for the first force value in the force array:\n", "ext_force1 = np.array([...])\n", "## Enter your repeated measurements of the extension for the second force value in the force array:\n", "ext_force2 = np.array([...])\n", "## Repeat for all values of force measured:\n", "...\n", "\n", "## Calculate the mean and standard uncertainty in the mean for the first set of extension measurements:\n", "ext_force1_mean = np.mean(ext_force1)\n", "ext_force2_su = standard_unc_of_mean(ext_force2)\n", "## Repeat for all sets of force measurements:\n", "...\n", "\n", "## Create an array of all the means of the extension measurements, ordered to align with the force array:\n", "ext = np.array([ext_force1_mean, ext_force2_mean, ...])\n", "## Create an array of all the standard uncertainties of the mean extension measurements, ordered to align with the force array:\n", "ext_unc = np.array([ext_force1_su, ...])\n", "\n", "# Print the output to check your work - make sure there are the same number of entries in each array (e.g., one force and uncertainty in force corresponding to each extension)\n", "print(\"Force:\")\n", "print(force)\n", "\n", "print(\"Extensions:\")\n", "print(ext)\n", "\n", "print(\"Uncertainty in extension:\")\n", "print(ext_unc)" ], "metadata": { "id": "6QyO7pZomQ4b" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## **Code template to make a plot**" ], "metadata": { "id": "Hs4hRshz5LlE" } }, { "cell_type": "code", "source": [ "# Plot the graph of extension versus force with uncertainties\n", "# Indicate the appropriate units for each axis label where it says [units]\n", "%matplotlib inline\n", "\n", "#If force is the dependent variable, use this code:\n", "#Comment it out if not.\n", "plt.figure()\n", "plt.errorbar(ext,force, force_unc, fmt='.')\n", "plt.plot(ext,force,linestyle='None')\n", "plt.xlabel('Extension ([units])')\n", "plt.ylabel('Force ([units]')\n", "plt.show()\n", "\n", "#If extension is the dependent variable, use this code:\n", "#Comment it out if not.\n", "plt.figure()\n", "plt.errorbar(force, ext, ext_unc, fmt='.')\n", "plt.plot(force,ext,linestyle='None')\n", "plt.xlabel('Force ([units])')\n", "plt.ylabel('Extension ([units]')\n", "plt.show()" ], "metadata": { "id": "yxvLTzDFYyDw" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## **Code template for linear fits**" ], "metadata": { "id": "u21NRhC95Ohs" } }, { "cell_type": "code", "source": [ "# Find the line of best fit\n", "#If force is the dependent variable, use this code:\n", "#Comment it out if not.\n", "autoFit(x=ext, y=force, dy=force_unc, title=\"Force on a [object] stetched to various extensions\", xaxis=\"Extension ([units])\", yaxis=\"Force ([units])\")\n", "\n", "#If extension is the dependent variable, use this code:\n", "#Comment it out if not.\n", "autoFit(x=force, y=ext, dy=ext_unc, title=\"Extension of a [object] due to various applied forces\", xaxis=\"Force ([units])\", yaxis=\"Extension ([units])\")" ], "metadata": { "id": "wJD4HLtvdiK1" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "**[Summarize your results, analysis, and interpretations here. Discuss the relevance of your results to the model you are testing, including how your data provides evidence for or against the assumptions of the model.]**\n", "\n", "\n", "---\n", "\n" ], "metadata": { "id": "Y95t_D80bAMd" } }, { "cell_type": "markdown", "source": [ "\n", "## **Code template for quadratic fits**\n", "The utilities file has a second autofit function that performs quadratic fits. It models functions of the form: `y=mx^2+b`. \n", "\n", "To call the function, use the function call in the code cell below. Enter your raw measurements for `y` and `x`.\n", "\n", "Talk to your TA if you'd like to try other functional forms." ], "metadata": { "id": "aNDajmBiFbg9" } }, { "cell_type": "code", "source": [ "autoFit2(x=..., y=..., dy=..., title=\"...\", xaxis=\"...\", yaxis=\"...\")" ], "metadata": { "id": "ZVIlwBYYk1Zu" }, "execution_count": null, "outputs": [] } ] }