# Spinning Glass Simulation

I read recently about a question someone got asked in a technical interview for a mechanical engineering position at Apple. It went something like this:

Suppose you had a rotating plate, like a lazy susan, and put a glass of water on it towards the edge of the plate. Suppose the plate started rotating, getting faster and faster, though the acceleration is slow enough that you could consider everything in steady state. Which would happen first: the glass tips over, the glass slides off the plate, or the water spills out of the glass?

I liked this question. It was fun to think about. I think the point of asking it during an interview is just to see how people think about the question — it obviously depends on a number of physical properties and, as I learned, a decent about of math. But I wanted to go further than just thinking through it. I wanted to work out an actual solution to it. So I sat down with my boyfriend and started building a simple python script that would solve it for a bunch of physical parameters.

You can find the script on github here. It could use some work, like a visualization, and there’s plenty of room to make it more complicated and therefore more accurate. Like all good engineers, we made some simplifications.

The glass sliding off the plate is easy: is the centripetal force, a function of the rotational speed and distance from the center of rotation, greater than the frictional force, which is just a function of the weight of the glass + water?

The other two are a little trickier, especially if you think about how they relate to each other. As the glass starts to tip, the water obviously sits differently in the glass. So to keep it simple we considered them separate–if the glass started to tip at all, then the glass tipped first. Independently they’re much more tractable.

The water spilling out is a matter of the shape of the water in the glass. You can read up on a way to calculate this if you look up the bucket argument. Basically the bucket argument says that the slope of the water at any point on its surface is tangential to the resultant force at that point. Since this whole thing is rotating, it’s radially symmetric and we can look at this as a 2D problem.

Find the angle of the resulting force from the centripetal and the gravitational forces, and you have a curve that represents the shape of the water in the glass. (Remember, this is the shape in the radial dimension. It’s radially symmetric.) You need a little bit more to get all the way and figure out the actual height, which is based on the volume of the water in the glass. i.e. We’re looking for h_0. There’s a derivation you can follow here. It wasn’t too hard to follow. It reminded me that, hey, I do know how to do calculus. Woo! Basically you want to integrate this curve we’ve found over the area of the glass to get the volume of the water. This equation will obviously still have h_0 in it, but everything else should be a constant based on the physical properties. By setting this equation equal the volume of water, which we know because it’s a physical property, we can solve for h_0, plug it back into our curve equation, and figure out if the water is spilling out of the glass.

Because we’re working in a rotational frame of reference, integrating over the area means integrating over r, the radial distance, and alpha, the angle. Integrating over a circle looked extremely tricky, as r and alpha vary with regards to each. So instead we picked a much simpler shape. This makes the integration nice and easy.

The glass tipping over is a matter of finding the new center of gravity based on the shape of the water. That gives you the angle of the vector between the center of gravity and the pivot point, which is the outer edge of the glass where it touches the plate. Any forces perpendicular to that vector are rotational — in one direction they cause the glass to tip and in the other they cause the glass to remain on the plate.

You can look at the the components of the gravitational and centripetal force perpendicular to that pivotal angle and see if it’s in the direction of tipping or the direction of restoring. If it’s in the direction of tipping, then you’re tipping! Of course, it might not be enough to totally tip the glass over. As the glass starts to tip the pivotal angle changes and so the components of the forces perpendicular to it change. But as we said at the beginning, we consider any amount of tip tipping. At least for now. Currently I think our script doesn’t take even into account the new shape of the water, but it should eventually. Just like maybe eventually we’ll be more clever about checking if the glass tips all the way over versus lifts up just a tad.

But all in all it’s a nice round-up of mechanical engineering: lots of force diagrams, some calculus, some trigonometry, some conceptual problem-simplification. I think a visualization would be awesome, we’ll see if we ever get to it.