Center of Mass for Point Particles

Developed by Deva O'Neil - Published July 20, 2017

DOI: 10.1119/PICUP.Exercise.CoM

These exercises apply the formula for the position of the center of mass of a system of point particles. The user of the program clicks in the scene window, creating a new point particle with each click. Students program the center of mass of the system to continuously update based on each new point particle. In addition to a printed output that displays the center of mass position as a vector, the center of mass of the system is marked with an X in the scene window, and moves around as the mass distribution changes.
Subject Area Mechanics
Level First Year
Available Implementations Glowscript and Spreadsheet
Learning Objectives
* Students use a while loop to implement a summation (**Exercises 1 and 2**) * Students distinguish between variables that are updated (accumulators) and variables that are recalculated in each iteration of a loop (**Exercises 1 and 2**) * Students calculate the center of mass of a system numerically, and check the output for plausibility. (**Exercise 2**)
Time to Complete 50 min

These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

This program will calculate the center of mass of a collection of point particles. Note that the formula for the position of the center of mass of a system has 2 summations – one in the numerator, and one in the denominator: $\vec{r}_{cm}=\frac{\Sigma ~ m_i \vec{r}_i}{\Sigma ~m_i}$ Before we get to coding the full equation for $\vec{r}_{cm}$, we shall write a program that keeps track of the total mass of the system $\Sigma ~m_i$. #Exercise 1 Open the template for Exercise 1. Test the program by clicking in the black “scene window.” Make sure you can create new balls by clicking. Look in the code for following values: * What is the mass of the red ball? * What is the mass of each added ball? Our goal is to make the program keep a running tally of the total mass of the system. __Predictions__ What should the total mass be before the user clicks? _________ What should it be after the user creates one new ball?_________ What should it be after the user creates two new balls?_________ __Programming__ The while loop executes one time for each click. We’ll define a variable massSum, and update it every time the loop runs. To your program above, do the following: 1. Define massSum to be equal to the mass of the starter ball to begin with (use the variable name, not the number). 2. In the while loop, update massSum: ```python massSum = massSum + smallMass ``` 3. In the while loop, print out the new massSum. Make the program print the correct units also. 4. Test your program to make sure it is correct before continuing by comparing its output to your predictions. __Analysis__ * Discuss what the output would be if instead of massSum = massSum + smallMass, one used massSum = starterMass + smallMass.
* Under what circumstances would the program behave differently?
* Explain the purpose behind putting the variable “massSum” on both sides of the equal sign.
*Important hint* In the next exercise, you’ll be prompted to add lines to an existing program. Pay attention to whether the purpose of a line is to “update” a variable or to (re)calculate it. I use the word “update” in situations where the old value of a variable is used to calculate a new value. For example, this line would update a variable called x: ```python x = x + v*t ``` * Which “x” is the old value? In contrast, this would be a recalculation of x, but I would not call it an update: ```python x= v*t ``` Note that it does not use the old value. * In your while loop, what variable is “updated?” #Exercise 2 Open the template for Exercise 1, creating a new program so that you don't overwrite your previous program. The goal of this program to calculate the center of mass position of the system when the user creates multiple balls. The center of mass position will be marked with a white X on the screen. Every time a new ball is added, the X will move. ![](images/CoM/CoM.png "") The vector that represents the position of the system’s center of mass will be called rcm (meaning $\vec{r}_{cm}$), calculated as follows: $\vec{r}_{cm}=\frac{\Sigma ~ m_i \vec{r}_i}{\Sigma ~m_i}$ * Besides the sum of the masses, what else are you going to need to calculate (and update every loop) to find $\vec{r}_{cm}$? Use the summation symbol to express your answer.
FIll in the blanks provided in the template. ``` rcmNumerator = _______________________ ``` *Use symbols, NOT numerical values.* ``` rcm = rcmNumerator/__________ ``` Inside the while loop, after the existing commands, do the following: 1. Update rcmNumerator 2. Recalculate rcm 3. Print "New center of mass = " with the vector rcm following the text. Make sure that the correct units for rcm are printed out also. __Analysis__ Test your program by placing one new ball. Record the position of this new ball: _____________ * Calculate (without using your computer program) where the center of mass should be:

* Does it match your program’s output? Place more balls and verify visually that the X moves around in a way that makes sense. If your program works for one additional ball but not two, check your calculation of the numerator in the while loop. Does it "update" the variable based on its old value? * Explain how the behavior of the program will change if the masses of the white balls are changed to be the same as the starter ball.
Test your prediction. * Explain, in your own words, the physical significance of the center of mass of a system.

Download Options

Share a Variation

Did you have to edit this material to fit your needs? Share your changes by Creating a Variation

Credits and Licensing

Deva O'Neil, "Center of Mass for Point Particles," Published in the PICUP Collection, July 2017, https://doi.org/10.1119/PICUP.Exercise.CoM.

DOI: 10.1119/PICUP.Exercise.CoM

The instructor materials are ©2017 Deva O'Neil.

The exercises are released under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license