import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
set(style="ticks", font_scale=1.5)
sns.from sympy import symbols, diff, solve
from sympy.abc import x
The can problem
question
How does the center of mass of a can of soda vary with the level of the liquid?
The center of mass of the aluminum can does not change, and assuming that the can is perfectly symmetric, its height should be half of the total can height. Calling the total height \(L\), we have that \(r_\text{can} = L/2\).
As the soda level in the can goes down, two things happen at the same time:
- The center of mass of the liquid goes linearly from \(L/2\) to 0.
- The mass of the liquid goes linearly to zero as well.
At the very beginning both centers of mass are at \(L/2\), and so is the center of mass of the whole thing. At the end, the liquid is depleated and does not contribute anything to the center of mass, so again the whole system has its center of mass at \(L/2\). Can we figure out what equation gives us the total center of mass as a function of the liquid level?
The center of mass of the system is given by \[ r_{cm} = \frac{r_\text{can}\cdot m_\text{can} + r_\text{liq}\cdot m_\text{liq}}{m_\text{can} + m_\text{liq}}, \tag{1}\] where
- \(m_\text{can}\) is the mass of the aluminum can,
- \(r_\text{can} = L/2\) is the center of mass of the aluminum can,
- \(r_\text{liq} = h/2\) is the center of mass of the soda,
- \(m_\text{liq} = \rho \cdot \pi R^2 \cdot h\) is the mass of the can,
- \(h\) is the soda level above the table,
- \(R\) is the radius of the can,
- \(\rho\) is the density of the soda.
Substituting these quantities into Equation 1 gives
\[ r_{cm} = \frac{C \frac{L}{2} + \frac{h^2}{2}}{C+h}, \tag{2}\] where the constant \(C\) is \[ C = \frac{m_\text{can}}{\rho \cdot \pi R^2}. \]
I googled the typical values for a soda can, and got the following:
- \(L = 122\) mm
- \(R = 3.31\) mm
- \(m_\text{can} = 14\) g
- \(\rho = 1.026\) g/mL
So how does Equation 2 look like?
Using the values above, we find that the lowest value for the center of mass of the whole system is when the soda has a level of only 6.6 mm! This is when the can should be less likely to topple, because the center of mass is so low (relative the the total mass).
I’ll finish by copying here the Python code I used to produce the graph above.
Import a bunch of packages.
Define the problem parameters, and find the lowest center of mass.
= 122.0 # mm
L = 3.31 # mm
R = 14 # g
Mcan = 1.026 # g/mL
rho_soda = Mcan / (rho_soda * np.pi * R**2)
C = np.linspace(0, L, 1001)
h
def RCM(H):
return (C*L/2 + H**2/2) / (C+H)
= RCM(h)
Rcm
# Convert the function to a symbolic expression
= RCM(x)
expr # Take the derivative
= diff(expr, x)
f_prime # Solve for x where the derivative equals zero
= solve(f_prime, x)
solutions # Print the solutions
print(f"We found {len(solutions):d} solutions: ", solutions)
# choose the physically relevant solution
= solutions[1] h_min
We found 2 solutions: [-7.36225033226790, 6.56937517541552]
Plot.
= plt.subplots(1)
fig, ax =2)
ax.plot(h, Rcm, lwf"can is less likely to topple when\nlevel = {h_min:.1f} mm",
ax.annotate(=(h_min, RCM(h_min)), xycoords='data',
xy=(15, 50), textcoords='data',
xytext=16,
size=dict(arrowstyle="->",
arrowprops="arc3",
connectionstyle="black"),
color
)set(
ax.="soda level (mm)",
xlabel="center of mass (mm)",
ylabel=[0,L/2+5],
ylim="center of mass of a can of soda partially full")
title"can_graph.png", bbox_inches='tight', dpi=300) fig.savefig(