Fluid Dynamics: Rayleigh-Bénard Convection

Posted on 16 Feb 2021 in Physics

One problem that piqued my interest early on was that of (you guessed it) Rayleigh-Bénard convection. This is really a rather simple experiment involving a fluid at rest between two solid parallel plates, one heated from below and the other either held at room temperature or cooled. When the temperature difference is low, heat transfers in a linear manner and eventually reaches equilibrium.

2D Convection Hot and Cold

But what if you ramped up the heat? Heat rises and cooler mass elements will come down due to the battle between buoyancy and gravity as microchanges in the localized density profile occur (due to temperature variations). As the theory goes (read more on Wikipedia), this convection leads to characteristic rolls and potential hydrodynamic instabilities as the heat differential (i.e. the dimensionless Rayleigh number) increases.

2D Convection Rolls

In a course I took at UC Santa Cruz with Gary Glatzmaier in 2007 (Physics 227: Advanced Fluid Dynamics), we worked with a Fortran code that we developed over time, first starting with a linear version and built up to one with nonlinear effects. I've cataloged this code here. Glatzmaier also provides instructions in Appendix B of his book on how to produce movies from this code as well:

Introduction to Modeling Convection in Planets and Stars

You can check out the Github repository for this here:

$ git clone https://github.com/pmekhedjian/thermalconvection2d.git

Refer to the README there to run this on your own system.

One magical aspect of this, is that normally you would need to have IDL (the Interactive Data Language) to parse and compile the .pro files, but fortunately, thanks to the GNU Data Language open source project, you won't need to purchase a very expensive license from the L3Harris folks (the makers of IDL). Although virtually unknown in some circles, physicists, astronomers, and remote sensing engineers & analysts have used IDL extensively in the last few decades.

$ git clone https://github.com/gnudatalanguage/gdl.git

Once installed (either via apt, yum, zypper or clean source, you simply need to run gdl in the directory where the Fortran code you compiled earlier produced its PPM image files:

$ gdl

GDL> .r loadct.pro reverse.pro write_ppm.pro cmcongrid.pro ka2.pro
% Compiled module: LOADCT.
% Compiled module: REVERSE.
% Compiled module: WRITE_PPM.
% Compiled module: CMCONGRID.
% Compiled module: LOADDAT.
% Compiled module: MOV.

GDL> mov,1,'mov.000001'