In the autumn I have some new teaching: a small project to simulate a problem — von Karman streets — in the physics of fluid flow (see earlier post). I will be showing the students how a simple Lattice Boltzmann code can simulate a fluid flowing past a cylinder, and creating what is known as a von Karman street of vortices downstream of this cylinder. The code is on github, and works great on linux machines. In particular it can show the flow around the cylinder evolving in realtime as the simulation runs. This is useful as you can see straightaway – while the simulation is running – if vortices are forming and being shed from the back of the cylinder*.
However, this visualisation on the fly only worked nicely on linux machines, not Windows. This irked me. It will not be helpful for the students, many of whom will have Windows laptops they will want to use to work at home.
So, after more hours of messing around than I am willing to admit to in public, I finally got it to work as a streamlit app (this was nt ). At the time of writing it is pretty rough but one plus with streamlit apps is that not only can you run them locally on your machine (linux, Windows or Mac) but they can run on the web, courtesy of streamlit.
You can see for yourself here (code on github here). Just click on the link and you can run your very own Lattice Boltzmann simulation. Just select a Reynolds number (Re) of around 100, say no to a fin at the back, and watch the vortices form at the back of the disc, then detach from the disc and fall back downstream (to the right in the simulation). No programming required. Or set Re to 10 and then run again to see that for this value of the Reynolds number there is no von Karman street of vortices.
You can also say yes to the fin and see how this inhibits the formation and detachment of vortices. At time of writing (will tweak it later, eg tell user that colour in the plot shows the flow speed) the streamlit app is a bit rough, but it looks like a nice way to demonstrate the simulation of a von Karman street. The students should be able to play around with it – regardless of what machine they have – and get a feel for some of the physics, before they do their own coding.
* Strictly speaking disc as simulation is in two dimensions, so is of cross-section through a cylinder, which is a disc.