Barotropic Vorticity Equation


Here is a barotropic vorticity equation, written purely in python. It is a spectral, doubly-periodic code. It uses numpy and scipy routines, and has no external dependencies. Nevertheless, it is still quite speedy (for a single-threaded code) becaue the FFTs are fast. You can run it on a laptop at 512x512. If you wish. There are a couple of references to more complete codes in the source below.
It's main use is to illustrate the formation of vorticies (if beta = 0) and jets (if beta is nonzero) as illustrated in the AOFD book, Chapter 12.
With just a little work the reader can add forcing. With just a little more work the reader could add multiple layers.
The code is not especially well documented. However, it is simple enough to read, and should not be used as a black box.

Code: click to download zip file of code.

Click to download code, baro_vort.py, directly.

Code: click to view


Sample PDF output: click to download