Lecture 22: advection diffusion reaction equations - Part 3
Overview
The lecture demonstrates how uPDE can model variable-coefficient diffusion, coupled diffusion-reaction systems, steady states, and two-dimensional advection-diffusion using a consistent define, constrain, and solve workflow. Examples include a stepwise diffusivity, the reaction A + B → C with species-specific boundary conditions, and a 32 × 32 tracer-mixing simulation where advection stretches interfaces and diffusion reduces concentration variance.
Key takeaways
- In uPDE, add_diffusion can accept a spatially varying diffusivity function, while callback arguments must put spatial coordinates before time.
- A coupled reaction-diffusion system can be assembled from separate PDE objects, but source-function argument order must match the PDESystem variable order.
- For A + B → C, the reaction source removes A and B at rate k·CA·CB and creates C at the same rate; increasing k sharpens the reaction front.
- A steady-state solve sets time derivatives to zero and computes an equilibrium profile, but it does not reveal the transient time needed to reach that profile.
- Advection promotes mixing indirectly by stretching concentration interfaces, while diffusion smooths them; declining concentration variance provides a quantitative mixing measure.
Chapters
- Zero-Neumann boundary conditions impose zero normal gradient, so they model an insulated or no-diffusive-flux boundary rather than a fixed field value.
- The lecture moves from constant diffusivity to diffusion coefficients that vary in space, time, or with the dependent variable.
- uPDE is presented as a numerical way to inspect transport behavior before attempting an analytical solution.
- The add_diffusion API accepts either a diffusivity array or a Python function such as a lambda.
- Callback arguments must begin with spatial coordinates and then time, followed by any other variables the function needs.
- A discontinuous step in diffusivity is introduced, with a nonzero baseline added to avoid a zero diffusion coefficient.
- A 250-point 1D grid is used with a Heaviside initial condition and a diffusivity jump at x = 1.5.
- The PDE uses Dirichlet values of zero at both ends and is integrated from t = 0 to 2 using BDF.
- The spatially varying coefficient is passed to add_diffusion as a function of x, avoiding a hand-derived finite-difference discretization.
- The region with larger diffusivity smooths more rapidly than the low-diffusivity region, producing a visible kink near the coefficient transition.
- At longer times, the initial step spreads into a pulse and eventually decays toward zero under the fixed zero boundary values.
- Spatial variation in heat-transfer rates can help reveal material differences or defects in applications such as plate imaging.
- A three-species model represents A and B being consumed and C being produced at rate k·CA·CB.
- Each species has its own diffusion coefficient, while the nonlinear reaction source couples the equations.
- The lecture connects diffusion-reaction systems to Alan Turing's work on pattern formation, including zebra-like patterns.
- Each species is declared as a PDE with add_diffusion and add_source, then the equations are collected into a PDESystem.
- Source callbacks must match the dependent-variable order in the system, for example CA, CB, then CC.
- The source terms for A and B are −k·CA·CB, while the source for C is +k·CA·CB.
- The 1D reactor uses a 250-point grid over a unit-length domain and starts with zero concentrations in the interior.
- A is held at 5 on the left and zero on the right; B is zero on the left and held at 3 on the right; C is zero at both ends.
- The example uses DA = 2×10⁻⁴, DB = 1×10⁻⁴, DC = 5×10⁻⁴ m²/s, and solves the coupled system with BDF.
- A and B diffuse toward one another; C appears only where both reactants overlap, then diffuses away from the reaction zone.
- The meeting point shifts with the diffusive flux, which depends on both the diffusion coefficient and the concentration gradient.
- Increasing k from 10 to 100 or 1,000 makes A and B react more sharply on contact and reduces the overlap region.
- The steady-state workflow uses solve_steady instead of time integration with solve and a t_span.
- At steady state, time derivatives are zero, leaving a large nonlinear algebraic system for the concentrations.
- A steady-state solve returns the final profile but not the time required to reach it; transient integration or an event criterion is needed to estimate that time.
- The 2D example models unsteady heat or mass transfer on a square plate with Dirichlet boundary values 1, 0, 2, and −1.
- Separate x and y grids are defined, and nx and ny do not need to be equal.
- The lecture recommends keeping a 2D grid at or below roughly 128 points per direction to limit memory and runtime.
- A field is declared with both x and y coordinates, then add_diffusion supplies the diffusion term.
- A single diffusivity can be provided for both directions; diffusivity_x and diffusivity_y allow anisotropic diffusion.
- The example uses a 32 × 32 grid, zero initial data, and BDF time integration.
- The solution is plotted with contourf using meshgrid coordinates created with NumPy's default matrix, or ij-style, indexing.
- Using the correct coordinate arrays aligns the displayed bottom, left, right, and top edges with their assigned boundary values.
- Raising the contour count to 100 makes the heat distribution easier to inspect; setting diffusivity_y to 3 illustrates faster spreading in y.
- A zero-Neumann condition on the right edge prevents diffusive flux through that boundary.
- The next example isolates a 2D box with zero-Neumann conditions on all sides and introduces a tracer initially split between zero and one.
- A rotating velocity field is added to represent stirring, while diffusion smooths the tracer concentration.
- The rotating-flow function returns two velocity-component arrays evaluated over the 2D mesh.
- A quiver plot visualizes the flow as a vortex; the field is described as incompressible and zero at the boundaries.
- With advection alone, the tracer is transported around the domain; diffusion is required to smooth the stretched concentration patterns.
- NumPy's where function sets the initial tracer to zero for x ≤ 0.5 and one for x > 0.5.
- The velocity components are passed to add_advection as velocity_x and velocity_y, alongside the diffusion coefficient.
- Reducing diffusivity by an order of magnitude makes rotational transport more visible before diffusion smooths the resulting filaments.
- Because half the initial grid has concentration zero and half has concentration one, the expected domain-average equilibrium is 0.5.
- Advection does not directly homogenize concentration, but it stretches interfaces and creates more area for diffusion to act on.
- Mixing is quantified by the variance of the concentration histogram, which falls toward zero as grid values approach 0.5.
- The lecture contrasts gradual variance reduction from diffusion alone with faster homogenization when advection stretches tracer interfaces.
- The time to reach the 0.5 equilibrium depends on both the flow speed and the diffusion coefficient.
- The closing assignment applies these ideas by varying transport parameters and tracking concentration variance.
Transcript excerpt
0:01 Let's begin. Last time we finished off with looking at Newman boundary conditions with UPDE and we did a couple of cases for this diffusion problem. We added Newman conditions on the left on the right just to show you to show you the machinery. Then your homework you're going to have to be doing a human condition on in a box. So the Newman condition for our intents and purposes is going to mimic an isolated um an isolated system. Okay? Because it's not allowing any fluxes to come in rather than dish equals zero. That's that's actually a fixed value. It's providing a specific value. What you want for an isolated system or a um closed system is a Newman condition at
0:50 the boundaries. So that's why this is important the knowing about the human condition. Uh the next thing I want to talk about is uh the machinery is so these lectures are more or less focused on how we solve these differential equations with UPD. Okay? Because this will be helpful for you in the spring when you do transport. You're going to hit the ground running with the governing equations and you're going to be like okay I'm lost. I want to try to do this analytically, but it would be cool if I can do it numerically first to see what's going on and then try to derive a possible analytical solution. So, this is the tool that's going to help you to do this. Um, the next thing I want to show you with UPDE is how to solve a uh an equation with a variable coefficient. We will see later how we we
1:38 can do variable velocity. Actually, we I think I showed it with the burgers equation how we do a variable velocity.
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.