Simulation of advection-diffusion


In this assignment you should use OpenGL to perform a simple 2D-animation of a particle system, simulating advection and diffusion.

Here is one frame of an animation:

A frame

You see a rectangle filled with 10 000 particles. The particles may not leak out from the rectangle nor can they penetrate the red barrier. The particles will move through simulated diffusion and advection. The simulation should continue until you stop it.

Diffusion is a small-scale phenomenon where particles, e.g. atoms or molecules,  move by thermal energy. Advection, on the other hand, occurs on a large-scale, think of water flowing in a river or air transported by the wind. Diffusion and advection can be taking place at the same time. For much more background (not needed for this lab) see the Wikipedia article about diffusion and advection.

Here are the requirements:

Your program does not have to be more fancy than my example code, but you may make a more fancy version provided it fulfills the requirements above.
Hint: read the Linux manual page for rand (to make random numbers in C). Note that rand in my description above is not the same as the rand-function in the C-library.

Back