diffusion_pde, a Python code which solves the diffusion partial differential equation (PDE) dudt = mu * d2udx2 in one spatial dimension and time, with a constant diffusion coefficient mu, and periodic boundary conditions, using the forward time centered space (FTCS) difference method.
We solve for u(x,t), the solution of the constant-velocity diffusion equation in 1D,
du/dt - mu d2u/dx2 = 0over the interval:
0.0 <= x <= 1.0with constant diffusion coefficient:
mu = 0.5with periodic boundary conditions:
u(0,t) = u(1,t) for all tand initial condition
u(x,0) = (10x-6)^2 (8-10x)^2 for 0.6 <= x <= 0.8 = 0 elsewhere.
We use a method known as FTCS (forward time, centered space):
The information on this web page is distributed under the MIT license.
diffusion_pde is available in a MATLAB version and an Octave version and a Python version.
allen_cahn_pde, a Python code which sets up and solves the Allen-Cahn reaction-diffusion system of partial differential equations (PDE) in 1 space dimension and time.