Solving the Diffusion-Advection-Reaction Equation in 1D Using Finite Differences

This Demonstration shows the solution of the diffusion-advection-reaction partial differential equation (PDE) in one dimension. The domain is discretized in space and for each time step the solution at time is found by solving for from . The boundary conditions supported are periodic, Dirichlet, and Neumann. The solution can be viewed in 3D as well as in 2D. You can select the source term and the initial conditions from the menus in the main display. Selected preconfigured test cases are available from the dropdown menu. In the above PDE represents the diffusion, represents the advection, and the reaction.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The discretized system can be formulated by the matrix equation . The matrices and and the vector take different forms depending on the boundary conditions. The following equations show the full expression of the above equation for the five possible combinations of the boundary conditions: periodic boundary conditions, Dirichlet on both sides of the domain, Dirichlet on the left side and Neumann on the right side, Neumann on the left side and Dirichlet on the right side, and finally Neumann on both sides. The following four variables are used to simplify the writing of expressions shown below in the matrix equation
The left boundary condition is given by and the right boundary conditions by . For example, if the left side has Dirichlet boundary conditions then , while if it has Neumann boundary conditions then , and similarly for the right side. For periodic boundary conditions where is the first node on the left side and is the last node on the right side. is the time step and is the grid spacing. and are the parameters of the PDE itself taken from .
Periodic boundary conditions:
Dirichlet boundary conditions on both ends:
Dirichlet boundary conditions on the left side and Neumann boundary conditions on the right side:
Dirichlet boundary conditions on the right side and Neumann boundary conditions on the left side:
Neumann boundary conditions on both sides:
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+