← CE 491 / 591 modules
CE 491 / 591 · Groundwater Hydrology · Module 2

Math Toolkit: Fields, Gradients and PDEs

Self-paced · about 5 hours · prerequisites: single-variable calculus (derivatives, chain rule, integrals) and vectors (dot product)

Overview

Groundwater lives in three dimensions and changes in time. Head, pressure and concentration are functions of several variables, \(h(x, y, z, t)\), and the laws that govern them are written with partial derivatives. This module builds the calculus you need for the rest of the course, using groundwater examples throughout: Darcy's law in 3-D (Module 3), the groundwater flow equation, flow to wells, and contaminant transport.

By the end of this module you should be able to:
  1. Tell scalar fields from vector fields, and read contour maps of a scalar field.
  2. Compute partial derivatives analytically, and estimate them numerically from gridded or tabulated data.
  3. Compute the gradient, its magnitude and direction, and the slope of a field in any direction.
  4. Find the hydraulic gradient from three wells (the three-point problem).
  5. Use the total differential to estimate changes, and the chain rule for a moving observer (total and material derivatives).
  6. Explain what a PDE is, recognize Laplace's, the diffusion and the advection equations, and state boundary and initial conditions.
  7. Convert between Cartesian and polar coordinates, convert derivatives and the Laplacian, and reduce radial flow to a well to an ODE.

How to work through it: each section has an animation or video, a reading and an interactive tool. Videos tagged required are part of the module; optional ones go deeper. Then do the practice problems, the Brightspace quiz, and Assignment 2, which you will solve in Excel.

1Scalar and vector fields

requiredAnimation 1: scalar fields and contours, vector fields, and partial derivatives as slopes of slices through a field.
optionalJeffrey Chasnov: Scalar and vector fields (9 min), from his Vector Calculus for Engineers course.

A field is a quantity defined at every point of a region.

Scalar fields in 2-D are drawn as contour maps: curves of constant value. A water-table map is a contour map of \(h(x,y)\), exactly like a topographic map of ground elevation. Where contours are close together the field changes quickly. Vector fields are drawn as arrows, or as flow lines that are tangent to the vectors everywhere.

optional Khan Academy: Vector fields, introduction (5 min).

2Partial derivatives

requiredKhan Academy (presented by Grant Sanderson): Partial derivatives, introduction (11 min).

The partial derivative of \(h(x,y)\) with respect to \(x\) is the ordinary derivative taken while every other variable is held fixed:

\[ \frac{\partial h}{\partial x} = \lim_{\Delta x\to0}\frac{h(x+\Delta x,\,y) - h(x,\,y)}{\Delta x}, \qquad \frac{\partial h}{\partial y} = \lim_{\Delta y\to0}\frac{h(x,\,y+\Delta y) - h(x,\,y)}{\Delta y} \]

Geometrically, \(\partial h/\partial x\) is the slope of the curve you get by slicing the surface \(h(x,y)\) along a line of constant \(y\). Its units are those of \(h\) divided by those of \(x\): a head gradient in m/m is dimensionless.

Rule: differentiate with respect to one variable, treating the others as constants. For \(h = 3x^2y + 5y^3 - 2x\): \(\partial h/\partial x = 6xy - 2\) and \(\partial h/\partial y = 3x^2 + 15y^2\).

Second derivatives. \(\dfrac{\partial^2 h}{\partial x^2}\) measures curvature in \(x\). The mixed derivatives are equal for smooth functions: \(\dfrac{\partial^2 h}{\partial x\,\partial y} = \dfrac{\partial^2 h}{\partial y\,\partial x}\). In the example, \(\partial^2h/\partial x^2 = 6y\), \(\partial^2h/\partial y^2 = 30y\), and \(\partial^2h/\partial x\partial y = 6x\).

Partial derivatives from data: finite differences

In practice head is known only at wells or on a model grid, so derivatives are estimated from differences. With spacing \(\Delta x\):

\[ \underbrace{\frac{h_{i+1}-h_i}{\Delta x}}_{\text{forward, error}\,\propto\,\Delta x} \qquad \underbrace{\frac{h_{i+1}-h_{i-1}}{2\Delta x}}_{\text{central, error}\,\propto\,\Delta x^2} \qquad \frac{\partial^2 h}{\partial x^2}\approx\frac{h_{i+1}-2h_i+h_{i-1}}{\Delta x^2} \]

The central difference is much more accurate for the same spacing. Numerical groundwater models such as MODFLOW, and the OpenHydroQual cells you used in Module 1, are built on exactly these approximations.

Finite-difference explorer

Exact h′(x₀)
Forward difference
Central difference
Forward error
Central error

Secant lines (forward, central) vs. the tangent

Predict, then check: halve Δx. How much smaller does each error get?
The forward error roughly halves (first order); the central error drops about four times (second order). On the log scale of Δx, two steps of the slider is a factor of about 3.

3The gradient and the slope in any direction

requiredAnimation 2: the gradient, why it is perpendicular to contours, the slope in any direction, and the total derivative along a path.
requiredDr. Trefor Bazett: Directional derivatives, what's the slope in any direction? (12 min).

The gradient

The gradient of a scalar field is the vector of its partial derivatives:

\[ \nabla h = \left(\frac{\partial h}{\partial x},\ \frac{\partial h}{\partial y},\ \frac{\partial h}{\partial z}\right), \qquad |\nabla h| = \sqrt{\left(\frac{\partial h}{\partial x}\right)^2 + \left(\frac{\partial h}{\partial y}\right)^2 + \left(\frac{\partial h}{\partial z}\right)^2} \]

The gradient turns a scalar field into a vector field. At every point it points in the direction of steepest increase, its magnitude is that steepest slope, and it is perpendicular to the contour through the point. In hydrogeology \(\nabla h\) is the hydraulic gradient, and Darcy's law in vector form is \(\mathbf{q} = -K\nabla h\): water flows down the gradient, perpendicular to head contours in an isotropic aquifer.

Slope in a direction: the directional derivative

The rate of change of \(h\) per unit distance in the direction of a unit vector \(\mathbf{u} = (\cos\phi, \sin\phi)\) is

\[ D_{\mathbf{u}}h = \nabla h\cdot\mathbf{u} = \frac{\partial h}{\partial x}\cos\phi + \frac{\partial h}{\partial y}\sin\phi = |\nabla h|\cos\alpha \]

where \(\alpha\) is the angle between \(\mathbf{u}\) and \(\nabla h\). It is largest (\(|\nabla h|\)) along the gradient, zero along the contour (\(\alpha = 90°\)), and most negative (\(-|\nabla h|\)) straight downhill. If a direction is given as a vector that is not of unit length, divide it by its length first.

Example. \(h = 50 - 0.004x + 0.002y\) (m, with \(x, y\) in m). Then \(\nabla h = (-0.004,\ 0.002)\) and \(|\nabla h| = 0.00447\). Flow goes along \(-\nabla h = (0.004, -0.002)\), at \(\tan^{-1}(-0.002/0.004) = -26.6°\) from the \(+x\) axis (east-southeast if \(x\) is east). Along a canal running northeast, \(\mathbf{u} = (0.707, 0.707)\), the head changes by \(D_{\mathbf{u}}h = -0.004(0.707) + 0.002(0.707) = -0.00141\) m per m.

Field explorer

Click anywhere on the map to move the point P. Arrows show the flow direction \(-\nabla h\).

P = (x, y)
h(P)
∂h/∂x
∂h/∂y
|∇h|
direction of ∇h (uphill)
flow direction −∇h
slope along u, ∇h·u

Head contours (m), flow arrows, P, ∇h (green) and u (gold)

The three-point problem

The classic field use of the gradient: with heads measured in three wells that are not in a line, assume the water table is locally a plane, \(h = ax + by + c\). The three wells give three linear equations for \(a, b, c\), and then \(\nabla h = (a, b)\).

\[ \begin{bmatrix} x_1 & y_1 & 1\\ x_2 & y_2 & 1\\ x_3 & y_3 & 1 \end{bmatrix}\begin{bmatrix} a\\ b\\ c\end{bmatrix} = \begin{bmatrix} h_1\\ h_2\\ h_3\end{bmatrix} \quad\Rightarrow\quad a = \frac{(h_2-h_1)(y_3-y_1) - (h_3-h_1)(y_2-y_1)}{(x_2-x_1)(y_3-y_1) - (x_3-x_1)(y_2-y_1)} \]

and \(b\) is the same with the roles of \(x\) and \(y\) swapped (and the sign of the denominator reversed): \(b = \dfrac{(h_3-h_1)(x_2-x_1) - (h_2-h_1)(x_3-x_1)}{(x_2-x_1)(y_3-y_1) - (x_3-x_1)(y_2-y_1)}\). In Excel, solve the 3×3 system with MMULT(MINVERSE(…), …) or use the formulas directly.

Three-point solver

a = ∂h/∂x
b = ∂h/∂y
|∇h|
flow direction (from +x)
Darcy flux |q| = K|∇h|

Wells, fitted head contours and the flow direction

4The total differential and the total derivative

If you move a small step \((dx, dy)\), the change in \(h\) is the sum of the changes due to each variable:

\[ dh = \frac{\partial h}{\partial x}dx + \frac{\partial h}{\partial y}dy = \nabla h\cdot d\mathbf{x} \qquad\Rightarrow\qquad \Delta h \approx \frac{\partial h}{\partial x}\Delta x + \frac{\partial h}{\partial y}\Delta y \]

This total differential is the multivariable version of the tangent-line approximation: a tangent plane. It is also how errors propagate. If \(Q = KA\,\Delta h/L\) and \(K\) is uncertain by 30% while \(\Delta h\) is uncertain by 5%, then \(dQ/Q = dK/K + d(\Delta h)/\Delta h\), so the uncertainty in \(Q\) is dominated by \(K\).

Total derivative along a path. If the position changes in time, \(x(t), y(t)\), the chain rule gives the rate of change seen by the traveller:

\[ \frac{dh}{dt} = \frac{\partial h}{\partial x}\frac{dx}{dt} + \frac{\partial h}{\partial y}\frac{dy}{dt} = \nabla h\cdot\mathbf{v} \]

Material derivative. If the field itself also changes in time, \(C(x, y, t)\), a water parcel moving with velocity \(\mathbf{v}\) experiences

\[ \frac{DC}{Dt} = \frac{\partial C}{\partial t} + v_x\frac{\partial C}{\partial x} + v_y\frac{\partial C}{\partial y} = \frac{\partial C}{\partial t} + \mathbf{v}\cdot\nabla C \]

\(\partial C/\partial t\) is what a monitoring well at a fixed point records. \(DC/Dt\) is what a parcel of water carried by the flow experiences. If a contaminant only moves with the water and does not react, \(DC/Dt = 0\): this is the advection equation, the core of the transport module later in the course.

Example. A plume has \(C = 80\,e^{-x/200}\) mg/L at some instant, and the concentration everywhere is rising at 0.5 mg/L per day. Water moves in \(+x\) at \(v = 0.3\) m/day. At \(x = 100\) m: \(\partial C/\partial x = -\tfrac{80}{200}e^{-0.5} = -0.243\) mg/L/m, so \(DC/Dt = 0.5 + 0.3(-0.243) = 0.427\) mg/L/day. A fixed well sees 0.5 mg/L/day; the moving parcel sees less, because it is carried toward lower concentration.

5An introduction to partial differential equations

requiredAnimation 3: what a PDE is, deriving the steady groundwater flow equation, boundary conditions, polar coordinates and radial flow to a well.
required3Blue1Brown: But what is a partial differential equation? (18 min). The heat equation, which is mathematically the same as transient groundwater flow.

optional Steve Brunton: Partial differential equations overview (26 min), and 3Blue1Brown: Divergence and curl (16 min).

What a PDE is

A differential equation relates an unknown function to its derivatives. If the function depends on one variable, it is an ordinary differential equation (ODE), such as \(dh/dx = -q/K\). If it depends on several, \(h(x,y,z,t)\), the equation involves partial derivatives and is a partial differential equation (PDE). Its order is the highest derivative that appears. It is linear if the unknown and its derivatives appear only to the first power and are not multiplied together.

Divergence and the continuity equation

The divergence of a vector field measures its net outflow per unit volume at a point:

\[ \nabla\cdot\mathbf{q} = \frac{\partial q_x}{\partial x} + \frac{\partial q_y}{\partial y} + \frac{\partial q_z}{\partial z} \]

Mass balance on a small box of aquifer (Animation 3) says that in steady flow, with no sources inside, as much water leaves as enters: \(\nabla\cdot\mathbf{q} = 0\). Substituting Darcy's law \(\mathbf{q} = -K\nabla h\) with constant \(K\):

\[ \nabla\cdot(\nabla h) = \nabla^2 h = \frac{\partial^2 h}{\partial x^2} + \frac{\partial^2 h}{\partial y^2} + \frac{\partial^2 h}{\partial z^2} = 0 \qquad\text{(Laplace's equation)} \]

\(\nabla^2\), the divergence of the gradient, is called the Laplacian. If storage changes (transient flow), the box gains or loses water and the equation gains a time derivative.

Three PDEs you will meet

Laplace (elliptic)\(\nabla^2 h = 0\). Steady groundwater flow, steady heat conduction. The solution at a point is the average of its surroundings: no maxima or minima inside the domain.
Diffusion (parabolic)\(\dfrac{S}{T}\dfrac{\partial h}{\partial t} = \nabla^2 h\). Transient groundwater flow (Theis), heat, molecular diffusion. Disturbances spread out and smooth over time.
Advection (hyperbolic)\(\dfrac{\partial C}{\partial t} + v\dfrac{\partial C}{\partial x} = 0\). A solute carried by flowing water. Shapes travel without spreading. Adding diffusion gives the advection–dispersion equation of contaminant transport.

Boundary and initial conditions

A PDE has infinitely many solutions; the conditions on the boundary of the domain select the one that describes your aquifer.

Check a solution by substituting it. Is \(h = x^2 - y^2\) a possible steady head field? \(\partial^2h/\partial x^2 = 2\), \(\partial^2h/\partial y^2 = -2\), sum = 0: yes. Is \(h = x^2 + y^2\)? Sum = 4 ≠ 0: no, unless water is being removed everywhere (uniform pumping or evaporation).

6Cartesian vs. radial coordinates

requiredDaniel An: Deriving the polar form of the 2-D Laplacian (10 min). The full chain-rule derivation summarized below.

Cartesian coordinates \((x, y)\) suit rectangular domains. Around a well, everything depends on the distance from the well, so polar coordinates \((r, \theta)\) fit the geometry. In 3-D, adding \(z\) gives cylindrical coordinates. The well is at the origin:

\[ x = r\cos\theta,\quad y = r\sin\theta \qquad\Longleftrightarrow\qquad r = \sqrt{x^2+y^2},\quad \theta = \operatorname{atan2}(y, x) \]

Use ATAN2(x, y) in Excel (note its argument order) to get the correct quadrant; \(\tan^{-1}(y/x)\) alone cannot tell \((1,1)\) from \((-1,-1)\).

Converting derivatives: the chain rule

If \(h\) is written as a function of \(r\) and \(\theta\), it depends on \(x\) through both. From \(r^2 = x^2 + y^2\): \(\partial r/\partial x = x/r = \cos\theta\), \(\partial r/\partial y = \sin\theta\). From \(\tan\theta = y/x\): \(\partial\theta/\partial x = -\sin\theta/r\), \(\partial\theta/\partial y = \cos\theta/r\). Therefore

\[ \frac{\partial h}{\partial x} = \cos\theta\,\frac{\partial h}{\partial r} - \frac{\sin\theta}{r}\frac{\partial h}{\partial\theta}, \qquad \frac{\partial h}{\partial y} = \sin\theta\,\frac{\partial h}{\partial r} + \frac{\cos\theta}{r}\frac{\partial h}{\partial\theta} \]

and the gradient in polar components is \(\nabla h = \dfrac{\partial h}{\partial r}\,\hat{\mathbf{r}} + \dfrac{1}{r}\dfrac{\partial h}{\partial\theta}\,\hat{\boldsymbol{\theta}}\). (The \(1/r\) is there because a change \(d\theta\) moves you a distance \(r\,d\theta\).) Applying the chain rule a second time and adding \(\partial^2 h/\partial x^2 + \partial^2 h/\partial y^2\), the cross terms cancel and \(\sin^2+\cos^2 = 1\) leaves

\[ \nabla^2 h = \frac{\partial^2 h}{\partial r^2} + \frac{1}{r}\frac{\partial h}{\partial r} + \frac{1}{r^2}\frac{\partial^2 h}{\partial\theta^2} = \frac{1}{r}\frac{\partial}{\partial r}\left(r\frac{\partial h}{\partial r}\right) + \frac{1}{r^2}\frac{\partial^2 h}{\partial\theta^2} \]

Radial flow to a well: a PDE becomes an ODE

For a single well in a uniform, isotropic aquifer, nothing depends on \(\theta\). The \(\theta\) term vanishes and steady flow (Laplace) becomes

\[ \frac{1}{r}\frac{d}{dr}\left(r\frac{dh}{dr}\right) = 0 \;\Rightarrow\; r\frac{dh}{dr} = C_1 \;\Rightarrow\; h(r) = C_1\ln r + C_2 \]

Physically, \(r\,dh/dr = C_1\) says the same discharge \(Q = 2\pi r\,b\,K\,dh/dr\) crosses every circle around the well: water converges, so the gradient must grow as \(1/r\) near the well. With \(C_1 = Q/(2\pi T)\) and a known head \(h_0\) at radius \(R\), this is the Thiem equation, \(h = h_0 + \dfrac{Q}{2\pi T}\ln\dfrac{r}{R}\), which you will derive properly in the well hydraulics module. Transient flow to a well gives the radial diffusion equation \(\dfrac{S}{T}\dfrac{\partial h}{\partial t} = \dfrac{1}{r}\dfrac{\partial}{\partial r}\left(r\dfrac{\partial h}{\partial r}\right)\), whose solution is the Theis equation from the pilot module.

Laplacian checker: Cartesian vs. polar

Pick a function and a point. The tool computes \(\nabla^2 h\) two ways: with Cartesian finite differences, and with the polar formula. Both must agree; a function is a possible steady head field only if the result is zero.

r, θ
∂²h/∂x² + ∂²h/∂y² (finite diff.)
h_rr + h_r/r + h_θθ/r² (polar)

Contours of h, with the point and its polar grid lines

7Practice (ungraded)

New numbers every time. Aim for two correct attempts in a row on each type before taking the quiz. Angles are measured counterclockwise from the +x axis, in degrees between −180 and 180.

A · Partial derivatives of a polynomial

B · Finite differences from well data

C · Gradient and directional slope

D · Three-point problem

E · Total differential

F · Material derivative

G · Is it a solution of Laplace's equation?

H · Polar coordinates and radial flow

Concept checks

1. On a water-table map the contours are close together in the east and far apart in the west. What can you conclude?

2. You walk along a contour line of a head map. What is \(D_{\mathbf{u}}h\) in your walking direction, and why?

3. Why does the radial form of Laplace's equation for a single well depend only on \(r\)?

8Graded quiz and Assignment 2