Matlab code for solving the advection-diffusion equation for a two-dimensional incompressible autonomous cellular flow.
-
Clone the adcell project:
git clone https://github.com/jeanluct/adcell.git
or with SSH
git clone git@github.com:jeanluct/adcell.git
-
After starting Matlab,
cd
to theextern
subfolder of the adcell project, and runmex fft2udotgrad_helper.c
from within Matlab. You might need to use the-largeArrayDims
option if Matlab complains. This will compile a helper function for filling the sparse matrix of the Fourier-space operatoru.grad
in the advection-diffusion equation. -
If you cannot compile the MEX file, you'll be limited to
N=31
Fourier modes in each spatial direction. -
Now
cd ..
to come back to the root folder of the adcell project.
You're now ready to run the program!
-
Run
adcell_demo('demoX')
, whereX
is a number from 1 to 6. The argument specifies which flow and set of parameter values are used. The banner above is the output of'demo1'
,'demo2'
, and'demo3'
at the final time. -
You can add your own run parameters by adding a case in the
switch
statement at the top ofadcell_demo
: you can specify the diffusion coefficient (effectively the inverse Peclet number) and the number of Fourier coefficients in each dimension.N
should be made larger asDiff
is decreased. Another useful parameter isks
, which determines how many cells fill the domain. Forks=4
, there will seem to be 8 cells in each direction, since they come in pairs. -
See the
examples
folder for more sample code. -
You can see a demo of the program with commentary in this lecture.
adcell is released under the MIT License. It uses jlt lib and the Fourier differentiation matrix function fourdif.m written by S. C. Reddy and J. A. C. Weideman.