Commit 7ef789b8 authored by Jussi Enkovaara's avatar Jussi Enkovaara
Browse files

Describe the heat equation in a bit more detail

parent e4a395dc
Two dimensional heat equation
This folder contains a code which solves two dimensional heat equation
with MPI parallelization. The code features non-blocking point-to-point
communication, user defined datatypes, collective communication,
and parallel I/O with MPI I/O.
Heat (or diffusion) equation is
<!-- Equation
\frac{\partial u}{\partial t} = \alpha \nabla^2 u
where **u(x, y, t)** is the temperature field that varies in space and time,
and α is thermal diffusivity constant. The two dimensional Laplacian can be
discretized with finite differences as
<!-- Equation
\nabla^2 u &= \frac{u(i-1,j)-2u(i,j)+u(i+1,j)}{(\Delta x)^2} \\
&+ \frac{u(i,j-1)-2u(i,j)+u(i,j+1)}{(\Delta y)^2}
Given an initial condition (u(t=0) = u0) one can follow the time dependence of
the temperature field with explicit time evolution method:
<!-- Equation
u^{m+1}(i,j) = u^m(i,j) + \Delta t \alpha \nabla^2 u^m(i,j)
Note: Algorithm is stable only when
<!-- Equation
\Delta t < \frac{1}{2 \alpha} \frac{(\Delta x \Delta y)^2}{(\Delta x)^2 (\Delta y)^2}
The two dimensional grid is decomposed along both dimensions, and the
communication of boundary data is overlapped with computation. Restart files
are written and read with MPI I/O.
Compilation instructions
For building and running the example one needs to have the
[libpng]( library installed. In
addition, working MPI environment is required. For Python version mpi4py and
matplotlib are needed.
Move to proper subfolder (C or Fortran) and modify the top of the **Makefile**
according to your environment (proper compiler commands and compiler flags).
Code can be build simple with **make**
How to run
The number of MPI ranks has to be a factor of the grid dimension (default
dimension is 200). The default initial temperature field is a disk. Initial
temperature field can be read also from a file, the provided **bottle.dat**
illustrates what happens to a cold soda bottle in sauna.
* Running with defaults: mpirun -np 4 ./heat_mpi
* Initial field from a file: mpirun -np 4 ./heat_mpi bottle.dat
* Initial field from a file, given number of time steps:
mpirun -np 4 ./heat_mpi bottle.dat 1000
* Defauls pattern with given dimensions and time steps:
mpirun -np 4 ./heat_mpi 800 800 1000
The program produces a series of heat_XXXX.png files which show the
time development of the temperature field
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment