FD2D_HEAT_STEADY is a Python program which solves the steady state (time independent) heat equation in a 2D rectangular region.
The physical region, and the boundary conditions, are suggested by this diagram:
U = 0, Y = 1.0 +------------------+ | | U = 10 | | U = 100 X = 0.0 | | X = 2.0 +------------------+ U = 0, Y = 0.0
The region is covered with a grid of NX by NY nodes, and an NX by NY array U is used to record the temperature. The correspondence between array indices and locations in the region is suggested by giving the indices of the four corners:
I = NY +------------------+ | | J = 1 | | J = NX | | +------------------+ I = 1
The form of the steady heat equation is
- d/dx K(x,y) du/dx - d/dy K(x,y) du/dy = F(x,y)where K(x,y) is the heat conductivity, and F(x,y) is a heat source term.
By using a simple finite difference approximation, this single equation can be replaced by NX * NY linear equations in NX * NY variables; each equation is associated with one of the nodes in the mesh. Nodes long the boundary generate boundary condition equations, while interior nodes generate equations that approximate the steady heat equation.
The linear system is sparse, and can easily be solved directly in MATLAB.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
FD2D_HEAT_STEADY is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.
FD1D_ADVECTION_LAX_WENDROFF, a Python program which applies the finite difference method (FDM) to solve the time-dependent advection equation ut = - c * ux in one spatial dimension, with a constant velocity, using the Lax-Wendroff method to treat the time derivative.
FD1D_HEAT_EXPLICIT, a Python program which uses the finite difference method (FDM) and explicit time stepping to solve the time dependent heat equation in 1D.
FD1D_HEAT_IMPLICIT, a Python program which uses the finite difference method (FDM) and implicit time stepping to solve the time dependent heat equation in 1D.
You can go up one level to the Python source codes.