In a random conversation I recently had, a question popped up: why do whistles whistle? I had no choice but to reach for the most complex tool available: OpenFOAM .

## All the Trouble

It’s quite straightforward, get a model of a whistle and stick it into a solver. At least it seemed that easy at first.

I discarded the stationary case right away because – you guessed it – the fluctuations are the interesting part, not the steady solution. Then, everything I did converged to a steady solution.

I turns out making such a simulation isn’t as simple as I expected and I did everything wrong. Let me sum up all the mistakes I made to (maybe) keep somebody else from doing it again:

- Use an exact 3D model of a working whistle – a whistle you
**know**is working. I tried some random models I found on the webs but weren’t tested in real life. - Use correct boundary conditions. If you blow too little or too much, it won’t work. I measured the flow in a funny way: empty a plastic bag of known volume through a whistling whistle and time how long it takes to empty the bag. Luckily, the whistle works in a broad range so my
*precise measurements*were accurate enough. Eventually. - Use a correct model: incompressible did not work. I know about the Mach 0.3 limit for incompressible assumptions but I shouldn’t had made that in my case.
- Use a good mesh. In the end, I had to refine the mesh around the sharp edge.
- Store many timesteps with fine spacing.

## The result

I knew the answer to the question before but I managed to complicate things to the extreme and eventually arrive at the same answer.

See the video and follow both images (upper and lower) at the same time *(if you have two eyes, use them both)*.

The upper is the velocity field, the lower is the pressure field. When the high-velocity stream from the mouthpiece enters the cavity, the pressure inside rises and it pushes the stream out. As the cavity empties, the pressure inside lowers and sucks the stream back in, and the process repeats.

Also the time is annotated and if you calculate the difference between two similar states of the system you get 0.47ms which means roughly 2100 Hz.