If you tap the neck of a bottle of beer, it overflows with foam. But where do all these bubbles, which did not exist a split second before, come from? Pierre-François Conzelmann, mechanical engineering student specializing in aero and hydrodynamics, carried out his master's thesis on the subject. The young researcher performed various experiments at the Laboratory of Fluid Mechanics and Instabilities (LFMI) with a high-speed camera capable of recording 35,000 frames per second. He also compared the reactions of beer with those of sparkling water.
Actually, there are very small gas bubbles almost invisible to the naked eye already in the beer before the impact. "They're called cavitation nuclei, explained Conzelmann. Their origins and exceptional stability are not completely understood yet. They also occupy micro glass cracks or cling to very fine dust particles which act as the nucleation sites originating the bubble columns observed in a glass of soft drink."
For the experiments, the student tried to minimize the number of such sites by using a sterile container. Then, he artificially created two of them in the form of tiny incisions so he could observe and film the bubbles nesting there.
The stiff blow to the mouth of the container generates a drop in the pressure inside. This causes micro-bubbles to grow, allowing the CO2 dissolved in the beer to penetrate inside them. Soon, they reach a critical point, implode and then break up into thousands of new bubbles that grow larger and rise more quickly to the surface. This is the same principle of cavitation, thoroughly studied in the field of navigation. The movement of boat propellers creates many bubbles, the bursting of which causes many micro-jets that accelerate the erosion of metal parts.
The same thing happens to sparkling water, said Conzelmann. By using a precision scale, he could establish that the liquid, either water or beer, under similar circumstances loses 20 mg of carbon dioxide with each blow.
"However, in the case of water, the bubbles merge very quickly into a new larger one which then bursts on the surface, whereas in the case of beer, the presence of surfactants prevents smaller bubbles from merging."
Surfactants, also known as amphiphilic compounds, contain both hydrophilic and hydrophobic components. They stabilize the surface tension of each of the bubbles, which as a result are preserved and form a compact cluster. This density, coupled with the heavy pressure exerted by the carbon dioxide towards the top of the bottle, is the reason why even the slightest shock usually provokes the discharge of a large amount of foam.
Source: EPFL 
A mechanical engineering student at EPFL in Switzerland wanted to understand the reason behind the formation of a “foam volcano” after tapping the neck of a bottle of beer. He studied the phenomenon with a high-speed camera and compared it to the outcome of applying the same action to sparkling water. His work offers insights into the behavior of cavitation nuclei.