system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why carbonated drinks get "agitated" by shaking

Everybody knows that a bottle of coke will turn into a spray of foam when shaken. But why?
gpt
Ok, this might get a bit complicated.

Carbonated drinks are carbonated because they have something in them called carbon dioxide.  This is a gas, a lot like air.  The carbon dioxide doesn't like being in the drink, and it wants to escape.

Now here's where it gets a little weird.  The carbon dioxide can't easily escape from the drink without an 'escape route'.  Smooth surfaces and a clean drink (without bits in it) don't give it any escape routes.  We call these routes "nucleation sites", but that's a big word that you don't need to worry about.  It's just a place where it's *easy* for bubbles to form.

Now think about a can of coke.  It will be mostly full of coke, but at the top is a small layer of carbon dioxide that has already escaped from the coke.  If you open it, the liquid inside is still clean and the walls are smooth, so most of the carbon dioxide stays in the drink.  It does still slowly escape, which is why you see little itty bitty bubbles.

If you instead shake that can, what you're doing is creating a whole lot of bubbles inside the liquid, and they "stick" to the walls of the can - just like if you pour it in a glass.  Those bubbles create "escape routes" for the carbon dioxide - so now it can escape from the drink much much faster.

But here's the problem, the carbon dioxide is escaping from the drink at the sides and bottom, and there's still drink on top of them.  As the carbon dioxide is bubbles, they try to all rise to the top of the can at once.  This is why you get a big foamy explosion and a flat drink.

Here's how you can use this to save your drink.  You can "fix" a shaken can or bottle by tapping it before opening it - not on the top, but all around the sides and the bottom.  This knocks the bubbles off the walls, and they go back up to the top where they can't help more carbon dioxide escape.