Lecture 21: Advection-Diffusion - part 2
Overview
Diffusion is modeled as the smoothing of concentration differences, with the 1D equation ∂u/∂t = D∂²u/∂x² explored through uPDE simulations and analytical solutions. The lecture shows that sine-wave modes decay as e^(−Dk²t), connects diffusion timescales to length scales and numerical stiffness, explains why Fourier components smooth sharp edges first, and clarifies how uPDE defines Neumann conditions using the outward normal.
Key takeaways
- For a constant-diffusivity mode sin(kx), the exact decay is e^(−Dk²t), so doubling the wavenumber makes the decay rate four times larger.
- A diffusion timescale over a characteristic length L scales as L²/D; short-wavelength details fade sooner than domain-scale structure.
- The grid spacing Δx creates a numerical diffusion timescale proportional to Δx²/D, making explicit schemes increasingly stiff as spatial resolution is refined.
- Fourier decomposition explains rapid edge smoothing: sharp transitions contain high-frequency modes, and diffusion damps those modes before low-frequency components.
- In uPDE, Neumann values are outward-normal derivatives; on a 1D left boundary, a specified value of +1 means ∂φ/∂x = −1, while on the right it means ∂φ/∂x = +1.
Chapters
- The 1D random-walk model gives each particle an equal chance of stepping left or right, even when the particle density is uneven.
- Across many particles, net transport runs from high to low concentration because the more evenly distributed state has more possible arrangements and higher entropy.
- The resulting macroscopic model is the diffusion equation, ∂u/∂t = D∂²u/∂x².
- Dimensional consistency in ∂u/∂t = D∂²u/∂x² requires D to have units of length²/time, or m²/s in SI units.
- The lecture uses Dirichlet or Neumann boundaries for diffusion rather than the periodic boundaries used for the earlier advection example.
- A zero Dirichlet condition fixes the field at the boundary; the initial pulse is set to zero there.
- The numerical workflow follows uPDE's define, constrain, and solve pattern, adding diffusion through a diffusivity parameter.
- The initial example uses a constant diffusivity of 0.5, then discusses using a spatially varying diffusivity function.
- A Gaussian pulse and a Heaviside step are selected as initial conditions for comparison.
- The notebook imports NumPy, Matplotlib, and the PDE interface, then defines a 1D domain from 0 to 3 with 250 spatial points.
- The equation uses diffusivity 1.0 and zero Dirichlet values at both ends.
- The solve call samples 100 times over a 0-to-5-second interval and uses the implicit BDF method, which is suitable for stiff diffusion calculations.
- The solution object stores time in `solve.t` and the field in `solve.u`; the field array is organized by spatial point and time.
- Plots and animations show both a Gaussian pulse and a step profile spreading and flattening under the same diffusivity and boundary conditions.
- The step profile's sharp transition smooths quickly, motivating a closer look at which parts of a signal diffuse fastest.
- Reducing the simulation interval from 5 seconds to 0.5 seconds with 100 output times makes the initial transient easier to inspect.
- The Heaviside profile's steep edge smooths first, while its later shape becomes more rounded and Gaussian-like.
- The observed difference between the step and Gaussian suggests that spatial frequency, not just the overall profile, controls the decay rate.
- On a domain of length π, three otherwise identical simulations start from sin(x), sin(2x), and sin(3x).
- After the same number of time steps, the sin(3x) mode has nearly vanished, sin(2x) has decayed substantially, and sin(x) retains more amplitude.
- The comparison indicates that higher-frequency, shorter-wavelength modes dissipate faster under the same diffusion coefficient.
- For constant D, assume a separated solution u(x,t) = f(t)sin(kx), keeping spatial shape and temporal amplitude in separate factors.
- Since the second spatial derivative of sin(kx) is −k²sin(kx), substitution yields the ODE f′(t) = −Dk²f(t).
- The resulting solution u(x,t) = e^(−Dk²t)sin(kx) shows that each sine mode retains its shape while its amplitude decays.
- The decay exponent Dk²t is dimensionless because D has units m²/s and k has units 1/m.
- The characteristic time for a mode is τ = 1/(Dk²); increasing D or k reduces τ and speeds up decay.
- After one time constant, a mode retains e⁻¹, about 37%, of its initial amplitude; after five time constants, it retains less than 1%.
- A sine mode's wavelength is λ = 2π/k, so its diffusion time is proportional to λ²/D, ignoring constant factors such as 2π.
- For a complicated signal, different features have different length scales and therefore different diffusion times.
- Short-scale noise fades before a long-scale background variation; estimating a timescale requires choosing the feature relevant to the question.
- A physical diffusion time over domain length L scales as L²/D, while the discretized grid introduces a fast numerical scale proportional to Δx²/D.
- The ratio of these scales grows like L²/Δx², so refining the grid can make an explicit calculation much stiffer.
- Increasing D alone shortens diffusion times, but stiffness requires widely separated timescales; an implicit method such as BDF avoids the severe explicit time-step restriction.
- Because the diffusion equation is linear, a cosine mode and a sine mode are each solutions, and their weighted sum is also a solution.
- A signal containing several wavenumbers evolves as a sum of modes, with each component receiving its own factor e^(−Dk²t).
- The lecture frames this sum as an eigenfunction expansion, where modes with larger k decay more rapidly.
- A Fourier series represents a piecewise signal, such as a zero-one step, as a sum of sine and cosine modes across many frequencies.
- Sharp corners require substantial high-frequency content, and the factors e^(−Dk²t) suppress those high-frequency modes first.
- As high-frequency contributions disappear, the step's corners smooth rapidly while broader, lower-frequency structure persists longer.
- In uPDE, a Neumann condition specifies ∇φ·n, the gradient projected onto the outward unit normal, rather than always specifying ∂φ/∂x directly.
- At the left boundary of a 1D domain, n = −eₓ, so a Neumann value of +1 means −∂φ/∂x = 1 and therefore ∂φ/∂x = −1.
- At the right boundary, n = +eₓ, so the specified value corresponds directly to ∂φ/∂x; the sign convention supports boundaries that are not aligned with coordinate axes.
- The demonstration sets a left Neumann condition and a right Dirichlet condition of zero, then observes the resulting boundary slope during a 5-second solve.
- Changing the left Neumann value from +1 to −1 reverses the slope because the left outward normal points in the negative x direction.
- A Neumann condition fixes slope or flux rather than field value, so the solution's boundary value can shift while retaining the prescribed gradient.
Transcript excerpt
0:02 Let's begin. Last time we finished off talking about advection uh and uh we explained how advection moves moves things. We did a quick analytical solution for the linear advection equation. The non-linear advection equation is a little harder to solve analytically. There are a few cases where you can get an analytical solution, but in general you cannot. So we switched to solving these numerically and for all practical purposes you will be approaching the solution of these conservation laws and PDEs. They're non-linear, they're complicated. You're going to be solving them numerically, but you need to understand at least some of the physics around them to make sure that your numerical solutions make sense um and they are as
0:52 expected. Okay? So the next item we want to talk about is diffusion. I call that the great equilibrator. Um when Einstein um observed actually proved that there's atoms was like this um Brownian or random walk motion looking at the um at the at the pollen in a in a dish um and saw them moving etc. Um the idea of diffusion came out from um that thought and Einstein actually derived in his dissertation derived the formula for what the diffusion coefficient should be etc. from um a can statistical not so much statistical, but this is what I'm showing here is a statistical um uh
1:40 interpretation of diffusion. And what I have is two compartments. Um one compartment on the left um with a histogram of particles. It's a uniform distribution. Okay? Uniform distribution, particle density, and this compartment is full. So think of this domain length going from 100 to 100 units, all right? And half of it is full of particles there, all about kind of the same height. Um, I couldn't get the
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Professor Saad Explains.