Convection-Diffusion Equation Simulator Back
Interactive Tool — CFD Numerics

Convection-Diffusion Equation Simulator
(Numerical Stability Visualization)

Compare steady-state solutions using central differencing, upwind differencing, and the QUICK scheme against the analytical solution. Watch how central differencing develops spurious oscillations as the Peclet number increases — an intuitive introduction to CFD numerical schemes.

Flow & Diffusion Parameters
Convection velocity u
m/s
Positive value (left → right)
Diffusion coefficient D
m²/s
Grid spacing Δx
m
Number of cells N = 1.0/Δx
Stable — Pe = 1.00
Numerical Scheme
Boundary Conditions
φ(0) = 1.0
φ(L) = 0.0
Steady-State Solution Comparison Central Differencing
Cd
Numerical Characteristics Summary
Results
Peclet number Pe = uΔx/D
Numerical diffusivity Dnum
Max error |φ_num − φ_exact|

Theory Note — Convection-Diffusion & Numerical Stability

Analytical solution of the steady 1-D convection-diffusion equation (φ(0)=1, φ(L)=0):

$$\phi(x) = \frac{e^{Pe \cdot x/L}- e^{Pe}}{1 - e^{Pe}}, \quad Pe_{total}= \frac{uL}{D}$$

The central differencing scheme produces non-physical oscillations when the cell Peclet number $Pe_{cell}= u\Delta x / D > 2$. The upwind scheme is unconditionally stable but introduces numerical diffusion $D_{num}= u\Delta x/2$. QUICK offers third-order accuracy as a middle ground, though it may still exhibit mild oscillations under certain conditions.

What is Convection-Diffusion?

🙋
What exactly is a 1D convection-diffusion problem? I see the simulator has "convection velocity" and "diffusion coefficient" as inputs.
🎓
Basically, it's a model for how a quantity, like heat or a pollutant, is transported. "Convection" is the bulk movement (carried by a flow, like wind), and "diffusion" is the spreading out due to random motion. In this 1D simulator, you can see how these two physical processes compete. Try setting the convection velocity to a high value and the diffusion coefficient to a low one to see a sharp front form.
🙋
Wait, really? So the "analytical solution" line is the perfect answer, and the other lines are approximations? Why are there different ones like "upwind" and "QUICK"?
🎓
Exactly! The analytical solution is the exact math. But computers can't solve it directly for complex problems, so we use "numerical schemes" to approximate it on a grid. "Central" is simple but can create wiggly, unrealistic results when convection is strong. "Upwind" is more stable but less accurate. "QUICK" tries to be a smarter compromise. Slide the "Grid Spacing" to a larger value to see how a coarse grid makes all the approximations worse.
🙋
That makes sense. So what's this "Pe" number that shows up in the formula? And how do the boundary values φ(0) and φ(L) work in the simulator?
🎓
Great question! The Péclet number (Pe) is the key. It's the ratio of convection strength to diffusion strength. A high Pe means convection dominates (a sharp front); a low Pe means diffusion dominates (a smooth spread). The formula is $Pe_{total}= \frac{uL}{D}$. In the simulator, φ(0) and φ(L) are the fixed values at the left and right ends of your domain. For instance, you could model a pipe where one end has a concentrated dye (φ=1) and the other end is clear water (φ=0). Change these boundary values and watch the profile shift.

Physical Model & Key Equations

The steady-state 1D convection-diffusion equation governs the transport of a scalar quantity φ (like temperature or concentration). It balances the rate of change due to fluid motion (convection) against spreading due to gradients (diffusion).

$$u \frac{d\phi}{dx}= D \frac{d^2\phi}{dx^2}$$

Where:
$u$ is the constant convection velocity [m/s].
$D$ is the constant diffusion coefficient [m²/s].
$\phi$ is the scalar quantity being transported (e.g., temperature, concentration).
The equation says: (Convection) = (Diffusion).

For a domain of length L with fixed boundary values, the analytical solution to this equation is an exponential profile. The shape is entirely controlled by the global Péclet number.

$$\phi(x) = \frac{e^{Pe \cdot x/L}- e^{Pe}}{1 - e^{Pe}}, \quad Pe_{total}= \frac{uL}{D}$$

Where:
$Pe_{total}$ is the dimensionless Péclet number. It's the single most important parameter.
$Pe_{total}\gg 1$: Convection dominates. Solution has a sharp boundary layer.
$Pe_{total} \ll 1$: Diffusion dominates. Solution is nearly a straight line.
This is the exact solution the numerical schemes in the simulator are trying to approximate.

Frequently Asked Questions

When the Péclet number is large, the convective term becomes dominant, and the central difference scheme fails to properly reflect upstream information. As a result, numerical oscillations (non-physical wiggles) occur. Using upwind differencing or the QUICK scheme can suppress these oscillations.
The central difference scheme has high accuracy but oscillates when the Péclet number is large. The upwind difference scheme is stable but introduces significant numerical diffusion, making the solution overly smooth. The QUICK scheme strikes a balance between the two, offering higher-order accuracy and stability, making it a practical choice.
The Péclet number may be too large, or the mesh may be too coarse. Reducing the Péclet number or refining the mesh will bring the numerical solution closer to the analytical one. Also, note that due to the nature of the scheme, the upwind difference tends to overestimate the diffusion term.
Dirichlet boundary conditions are applied: φ=1 at x=0 and φ=0 at x=L. The analytical solution is defined under these conditions, and the numerical solution is computed under the same conditions. If you wish to change the boundary conditions, you need to edit the code directly.

Real-World Applications

Pollutant Dispersion in Rivers: Modeling how a chemical spill (diffusion) is carried downstream by the river current (convection). Engineers use this to predict contamination zones and plan response strategies. The Péclet number tells them if the pollutant will spread widely or remain in a concentrated plume.

Heat Transfer in Electronics Cooling: Analyzing heat from a chip carried away by airflow in a heat sink. Convection is the forced airflow, and diffusion is the thermal conduction within the air and solids. Accurate numerical schemes are crucial for predicting hot spots and preventing failure.

Chemical Vapor Deposition (CVD): A key manufacturing process for semiconductors and coatings. Reactive gases flow over a substrate (convection) while chemical species diffuse to the surface to form a thin film. The balance between flow and diffusion rates determines film uniformity.

Blood Oxygen Transport in Capillaries: Oxygen in blood is carried by flow (convection) and moves into tissue by diffusion across capillary walls. The 1D model simplifies the analysis of how oxygen concentration drops along the capillary length, which is vital for understanding tissue oxygenation.

Common Misconceptions and Points of Caution

Model assumptions: The mathematical model used here relies on simplifying assumptions such as linearity, homogeneity, and isotropy. Always verify that your real system satisfies these assumptions before applying results directly to design decisions.

Units and scale: Many calculation errors arise from unit conversion mistakes or order-of-magnitude errors. Pay close attention to the units shown next to each parameter input.

Validating results: Always sanity-check simulator output against physical intuition or hand calculations. If a result seems unexpected, review your input parameters or verify with an independent method.