Surface Integrals
A surface integral adds up a quantity over a curved surface, the way a line integral adds it up along a curve. There are two kinds: the integral of a scalar function (mass of a curved shell, average temperature on a dome) and the flux of a vector field (how much fluid, heat or light passes through the surface). Both reduce to an ordinary double integral over the parameter domain once you have the parametrisation from Parametric Surfaces and Their Areas.
Scalar surface integrals
Chop the surface into patches of area , multiply each by the value of at a sample point, and take the limit. Since a patch has area :
With you get the surface area back. With you get mass; dividing by the area gives the average of over the surface. The answer does not depend on which parametrisation you pick, just as arc length does not depend on how fast you trace the curve.
import sympy as sp
u, v = sp.symbols('u v', real=True)
a = 2
r = sp.Matrix([a*sp.sin(v)*sp.cos(u), a*sp.sin(v)*sp.sin(u), a*sp.cos(v)])
N = r.diff(v).cross(r.diff(u))
dS = a**2 * sp.sin(v) # |N|, since sin v >= 0 on [0, pi]
print("|N|^2 - dS^2 simplifies to", sp.simplify(N.dot(N) - dS**2))
z = r[2]
I = sp.integrate(z**2 * dS, (u, 0, 2*sp.pi), (v, 0, sp.pi))
area = sp.integrate(dS, (u, 0, 2*sp.pi), (v, 0, sp.pi))
print("integral of z^2 over the sphere:", I)
print("area:", area, " average of z^2:", sp.simplify(I / area))|N|^2 - dS^2 simplifies to 0
integral of z^2 over the sphere: 64*pi/3
area: 16*pi average of z^2: 4/3
There is a quick check by symmetry: , and have the same average over a sphere, and they add up to , so each averages .
Oriented surfaces and flux
To ask "how much flows through" a surface, you must say which side is the front. An oriented surface comes with a continuous choice of unit normal . Closed surfaces (spheres, boxes) are oriented outward by convention. A Möbius strip has only one side and cannot be oriented, so flux through it is undefined.
The flux of through is the scalar integral of the normal component :
The in cancels the one hidden in , so you never need to normalise. Just check that points to the side you want; if not, flip the sign. For a graph with upward normal, and for :
Example: the flux of upward through the paraboloid above the -plane. Here and , so the integrand is , and polar coordinates finish the job.
import numpy as np
import sympy as sp
r, th = sp.symbols('r theta', nonnegative=True)
integrand = 2*r**2 + (4 - r**2)**2 # -P g_x - Q g_y + R in polar form
exact = sp.integrate(integrand * r, (r, 0, 2), (th, 0, 2*sp.pi))
print("exact flux:", exact, "≈", round(float(exact), 6))
# numeric check: midpoint rule on the parameter grid (x, y) = (rho cos t, rho sin t)
n = 600
rho = (np.arange(n) + 0.5) * 2 / n
t = (np.arange(n) + 0.5) * 2 * np.pi / n
R, T = np.meshgrid(rho, t)
x, y = R * np.cos(T), R * np.sin(T)
z = 4 - x**2 - y**2
F_dot_n = x * (2 * x) + y * (2 * y) + z**2 # F · <-g_x, -g_y, 1>
print("numeric flux:", round(float(np.sum(F_dot_n * R) * (2 / n) * (2 * np.pi / n)), 6))exact flux: 112*pi/3 ≈ 117.286126
numeric flux: 117.286102
Light through a patch
Irradiance is a flux. A point light at with intensity creates the field , an inverse-square law. The power that lands on a floor patch is the flux of through it with the normal facing the light; contains the cosine of the angle between the light ray and the surface normal, which is Lambert's cosine law. For a light at height over the centre of a disc of radius , the flux has the closed form , the solid angle of the disc as seen from the light.
import numpy as np
h, a, I = 2.0, 1.5, 1.0
n = 2000
rho = (np.arange(n) + 0.5) * a / n
# floor point (x, y, 0), light at (0, 0, h); with normal -k, F·n = I*h / |p - L|^3
F_dot_n = I * h / (rho**2 + h**2) ** 1.5
flux = np.sum(F_dot_n * rho) * (a / n) * 2 * np.pi # theta integral is trivial: symmetry
exact = 2 * np.pi * I * (1 - h / np.hypot(h, a))
print(f"numeric flux {flux:.6f}, closed form {exact:.6f} (= 0.4π)")
inner = np.sum((F_dot_n * rho)[rho < 0.5]) * (a / n) * 2 * np.pi
print(f"share landing within radius 0.5: {inner / flux:.1%} of the area-share {0.5**2 / a**2:.1%}")numeric flux 1.256637, closed form 1.256637 (= 0.4π)
share landing within radius 0.5: 14.9% of the area-share 11.1%
The centre of the disc gets more light per square metre than its area alone suggests: it is closer and faces the light head-on.
In software
- Rendering. The irradiance at a point is an integral of incoming radiance times over the hemisphere; area lights are handled by turning it into a surface integral over the light's surface, with the same factor as above. Path tracers estimate these integrals by Monte Carlo sampling.
- Physically based sound and heat. Acoustic and thermal radiosity solvers compute "form factors", the flux of one patch's emission through another patch, as double surface integrals.
- Simulation. Drag and pressure forces on a body are surface integrals of pressure times the normal over its mesh; finite-volume fluid codes integrate flux over each cell face.
- Meshes. On a triangle mesh, becomes , and flux becomes , the un-normalised face normal.
Exercises
Exercise 1: Average height of a hemisphere
Find the average value of over the upper hemisphere , .
Answer
.
Solution
Half the radius: for a sphere, equal heights get equal area (Archimedes' hat-box theorem), so is uniform on .
Exercise 2: Flux through a tilted square
Find the upward flux of through the part of the plane above the unit square .
Answer
−2.
Solution
Negative: the constant field crosses the tilted plane from its upper side to its lower side.
Exercise 3: Flux out of a cylinder wall
Find the outward flux of through the side , , of a cylinder (not the top or bottom).
Answer
.
Solution
The -component of is parallel to the wall and contributes nothing.
Exercise 4: Light on a square tile (code)
A point light of intensity 1 sits at . Estimate the flux through the floor square (normal facing the light) with a midpoint grid. The exact value is , a sixth of the full , because the square is one face of a cube centred at the light.
Answer
.
Solution
. By symmetry the six faces of the cube each get one sixth of the total flux of an inverse-square field.
import numpy as np
n = 1000
s = -1 + (np.arange(n) + 0.5) * 2 / n
X, Y = np.meshgrid(s, s)
flux = np.sum(1 / (X**2 + Y**2 + 1) ** 1.5) * (2 / n) ** 2
print(round(float(flux), 6), round(2 * np.pi / 3, 6))2.094396 2.094395
Test yourself
Why can't you compute the flux through a Möbius strip?
- It has no area
- It is not orientable: there is no consistent choice of normal
- Its boundary is not closed
- Its parametrisation is not smooth anywhere
In , why is there no factor?
- It is always 1
- It cancels against the length hidden in the unit normal
- It is only needed for scalar integrals over graphs
- It is absorbed into
A constant field passes through a curved surface whose shadow on the -plane has area 3 (upward normal, the surface is a graph). The flux is…
- 7
- 3
- 21
- It depends on the shape of the surface