Algorithmadvanced
Vortex particle method
Also called vortex blob method.
Represents an incompressible flow by particles that carry vorticity and moves them with the velocity from the Biot-Savart law, often summed by a tree or FMM.
- Time
- Θ(N^2) worst
- Space
- Θ(N) extra
- Where
- N = the number of vortex particles
- Model
- Real RAM
- Properties
- conservativedeterministic
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Alexandre J. Chorin, 1973
A vortex particle method simulates an incompressible flow with particles that carry vorticity, the local spin of the fluid, instead of a velocity grid. The velocity at any point is the sum of the swirls induced by all the particles (the Biot-Savart law), each swirl smoothed over a small core so that it stays finite, and the particles simply move with that velocity. There is no pressure solve, no grid, and no numerical diffusion from advection, and the particles go only where the flow has vorticity, so wakes, vortex rings and mixing layers are cheap to follow. In computer graphics, vortex particles are added to a grid fluid solver to keep small swirls in smoke and fire, close to what vorticity confinement does; the method on this page is the full flow solver, with a smoothed kernel whose error goes to zero as the cores and the spacing shrink, and with viscosity added by particle strength exchange.
In plain words
Think of the flow as many small whirlpools. Each whirlpool is a particle that knows how strong it is and which way it turns. Every whirlpool pushes every other one around it, more strongly when they are close. To move the flow forward, add up the push from all the whirlpools at each particle, move each particle a little, and repeat. A whirlpool keeps its strength as it moves, as long as the fluid has no friction. To stop two whirlpools from flinging each other away when they come very close, each one is a soft blob with a small round core.
The problem
In 2D, an incompressible inviscid flow with velocity has the scalar vorticity , and the Euler equations become the transport equation
where the second equation is the Biot-Savart law for a flow in the whole plane that is at rest at infinity. So vorticity is carried by the flow: each fluid element keeps its vorticity.
The method writes the vorticity as a sum of blobs, , with the circulations from the initial vorticity on a lattice of spacing , and the Gaussian core . The velocity of this field is the sum over the smoothed kernel
and the particles solve with fixed . The code on this page uses direct summation and the explicit midpoint rule in time.
The algorithm
VORTEX-STEP(x, Γ, δ, h)- 1
for each particle p do - 2
u_p ← Σ_{q ≠ p} Γ_q K_δ(x_p - x_q) ▷ Biot-Savart law with the blob kernel - 3
x_p* ← x_p + (h / 2) u_p for every p ▷ half step - 4
u_p* ← Σ_{q ≠ p} Γ_q K_δ(x_p* - x_q*) for every p ▷ velocity at the midpoint - 5
x_p ← x_p + h u_p* for every p - 6
return x; the circulations Γ_p do not change
Lines L1 and L2 are an N-body sum like gravity, with the kernel turned by 90 degrees. The code visits each pair once and uses to add the two contributions. , so a particle does not move itself. Lines L3 to L5 are the explicit midpoint method. For viscous flow, a diffusion step changes the after line L5, for example by particle strength exchange.
Example
A pair of equal blobs. Put at and at , with . Line L2 gives the right particle the velocity and the left one . The pair turns counterclockwise about its centre at , a little slower than the of two point vortices at distance . The code reproduces this rotation over 200 steps.
The Lamb-Oseen vortex. The vorticity has the azimuthal velocity , and every radial vorticity is a steady solution of the Euler equations. Take , , a lattice with cut to the disc (437 particles, total circulation 0.99984) and . A Gaussian blob of size convolved with a Gaussian vorticity of size is a Gaussian of size , so the blob field should be the Lamb-Oseen vortex at the later time . The measured velocity at radii 0.05 to 0.5 matches that vortex within ; against the vortex at time the error is 0.065, and with it is 0.018, close to the ratio 4 of a second order smoothing error (measurements; the largest speed is 0.51). In a run of 20 midpoint steps of with (109 particles) and , every particle stays on its circle within and turns at the predicted rate.
Correctness
The proofs of the facts below about the kernel, the Lamb-Oseen check and the invariants are in the correctness proof.
The method conserves the invariants of 2D Euler flow (theorems for the particle equations ). Write . Since , the linear impulse has the derivative . Since also , the angular impulse has the derivative . The total circulation is constant because no changes. The particle system is also Hamiltonian, with the interaction energy of the blobs as the Hamiltonian, and that energy is conserved. Each stage of the midpoint rule moves the points by a sum of the same antisymmetric terms, so the linear impulse stays exact to rounding; the angular impulse and the energy change by per step.
The velocity field is exact for the blob vorticity. , so is the divergence free velocity whose curl is (a theorem; the tests check both by finite differences).
Convergence. The error of the method has two parts: the smoothing error, from replacing by , which is for the Gaussian, and the quadrature error of the lattice sum, which is very small while the blobs overlap (). Beale and Majda (1982) proved that for smooth flows over a finite time the blob method converges with the order of the kernel, if goes to zero faster than ; kernels of higher order give higher orders. Over long times the particles spread unevenly, the overlap is lost and the error grows, which is why practical codes remesh.
Proof: The blob velocity is the exact velocity of the blob vorticity, and the particle equations conserve circulation, linear impulse and angular impulsefull
We work in the plane with , the Gaussian core and the kernel
Write , so . As , , so is continuous and smooth at 0.
Claim 1 (the velocity of one blob). is divergence free, and its curl is .
Proof. with for any radial with , since . A field of the form has divergence and curl . For a radial function, , and , whose derivative is . Dividing by gives .
By linearity, is divergence free with curl . It also tends to 0 at infinity, like , so it is the velocity that the Biot-Savart law gives for .
Claim 2 (the Lamb-Oseen check). If is the Lamb-Oseen vorticity with , then with , whose velocity is the Lamb-Oseen velocity at time .
Proof. is the density of a 2D normal law with variance in each coordinate. The convolution of two such densities is the density of the sum of independent variables, which is normal with variance , that is . By Claim 1 with replaced by , its velocity is , with azimuthal component , and .
So the lattice sum on the page approximates with no smoothing error, and only the quadrature and truncation errors remain; the test checks this to .
Claim 3 (invariants). Let solve with constant . Then the circulation , the linear impulse and the angular impulse are constant.
Proof. The circulations do not change, so neither does their sum. Write . The kernel is odd, , so
because the terms and cancel and the terms with are 0. For ,
Swapping the names and and using shows that the same sum equals . Adding the two forms, , since is a multiple of and .
Claim 4 (the midpoint rule keeps the linear impulse). One step of lines L1 to L5 leaves unchanged in exact arithmetic.
Proof. Line L3 changes by for the old positions, and line L5 changes it by , which is the same antisymmetric double sum at the midpoint positions, and so is 0 as in Claim 3.
The midpoint rule does not keep exactly, since the second form of uses the positions at which the velocity was computed; its error per step is the local error of the method.
Complexity
In the real-RAM model, line L2 costs for particles, done twice per step, so one step costs time and extra space. A Barnes-Hut tree brings a step to and the fast multipole method to for a fixed accuracy; both are standard in vortex codes. The vortex-in-cell variant solves the Poisson equation for the stream function on a grid instead, at for grid nodes. The time step is limited by accuracy, not by a CFL condition on a grid: should be small against the turnover time .
Properties
- Lagrangian and grid free. Advection is exact for the particles, so there is no numerical diffusion from the transport term.
- Compact support of the work. Particles are needed only where , which is a small part of the domain in many flows.
- Divergence free by construction. The velocity comes from the Biot-Savart law, so exactly, with no projection step.
- Boundary conditions at infinity are exact. The kernel already has the flow at rest at infinity, so no artificial outer boundary is needed.
- Conservation. Circulation and linear impulse are exact, angular impulse and energy are conserved by the ODE.
- Loss of overlap. Strain stretches the particle distribution, and in time the blobs no longer overlap and the accuracy drops.
Variants and improvements
- Point vortices. gives the singular point vortex model of Helmholtz and Kirchhoff; it is a Hamiltonian system but it does not converge to smooth Euler flow without a core.
- Kernels of higher order. Beale and Majda built kernels with vanishing moments that give smoothing errors.
- Viscous diffusion. Chorin's random walk, core spreading, particle strength exchange, and the diffusion velocity method add the term .
- Remeshing. Interpolating the circulations back to a regular lattice every few steps restores the overlap; it is what makes long runs accurate.
- 3D vortex particles. In 3D the particles carry a vector strength, and the stretching term changes it; the vorticity can then lose its divergence free property, which needs a correction.
- Vortex-in-cell. A hybrid that puts the vorticity on a grid, solves for the stream function by FFT, and moves the particles with the grid velocity.
- Boundaries. Panels or a boundary element method enforce no flow through a wall, and the vorticity created at the wall is released as new particles.
When to use it
Use a vortex particle method for flows dominated by compact vortical structures in large or unbounded domains: wakes of bluff bodies, rotor and wind turbine wakes, vortex rings, jets and mixing layers, and studies of vortex dynamics. Prefer a grid solver, such as the vorticity-streamfunction formulation or a projection method, for confined flows with complex walls, for turbulence that fills the domain, and for compressible flow. In graphics, a few vortex particles on top of a grid solver are a cheap way to keep swirls; a full vortex method is worth it when the flow itself must be right.
Pitfalls
- Blobs that do not overlap. With for the particle spacing , the lattice sum no longer approximates the convolution, and the velocity becomes noisy. Keep above 1, and remesh.
- Point vortices for smooth flow. Without a core, close pairs get huge velocities and the time step collapses.
- Truncating the vortex. Cutting the vorticity to a finite disc drops circulation; check against the exact total.
- Errors of the fast summation. A tree or FMM with a loose accuracy parameter can spoil the conservation of the impulses, which direct summation keeps.
- 3D divergence. In 3D, the particle vorticity field is not divergence free after stretching; ignoring this lets spurious vorticity grow.
- Wrong sign convention. The 2D kernel turns the separation by +90 degrees for counterclockwise vorticity; with the wrong sign the vortices spin backwards.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/vortex-particle-method/. The authors are listed in prov/4WPAHS.jsonl.
"""The 2D vortex blob method for the incompressible Euler equations.
Particle p sits at (x_p, y_p) and carries the circulation g_p. The vorticity
is the sum of Gaussian blobs of core size delta,
omega(x) = sum_p g_p zeta(x - x_p), zeta(x) = exp(-|x|^2 / delta^2) / (pi delta^2),
and the Biot-Savart law gives the velocity with the smoothed kernel
K(x, y) = (-y, x) (1 - exp(-r^2 / delta^2)) / (2 pi r^2), r^2 = x^2 + y^2.
The particles move with this velocity (explicit midpoint rule) and keep their
circulations, since vorticity is carried by an inviscid 2D flow.
Cost: Theta(N^2) time per velocity evaluation by direct summation.
"""
import math
def kernel(dx: float, dy: float, delta: float) -> tuple[float, float]:
"""The blob kernel K_delta(dx, dy); K(0, 0) = (0, 0)."""
r2 = dx * dx + dy * dy
if r2 == 0.0:
return 0.0, 0.0
s = -math.expm1(-r2 / (delta * delta)) / (2 * math.pi * r2)
return -dy * s, dx * s
def velocity_at(x: float, y: float, xs: list[float], ys: list[float], gs: list[float], delta: float):
"""The velocity of the blob field at the point (x, y)."""
u = v = 0.0
for xq, yq, g in zip(xs, ys, gs):
ku, kv = kernel(x - xq, y - yq, delta)
u += g * ku
v += g * kv
return u, v
def velocities(xs: list[float], ys: list[float], gs: list[float], delta: float):
"""u_p = sum_q g_q K(x_p - x_q) for every particle, by direct summation over the pairs."""
n = len(xs)
us, vs = [0.0] * n, [0.0] * n
for p in range(n): # @line L1
for q in range(p + 1, n): # @line L2
ku, kv = kernel(xs[p] - xs[q], ys[p] - ys[q], delta) # @line L2
us[p] += gs[q] * ku # @line L2
vs[p] += gs[q] * kv # @line L2
us[q] -= gs[p] * ku # @line L2
vs[q] -= gs[p] * kv # @line L2
return us, vs
def vortex_step(xs: list[float], ys: list[float], gs: list[float], delta: float, h: float):
"""One explicit midpoint step of dx_p/dt = u(x_p); the circulations do not change."""
us, vs = velocities(xs, ys, gs, delta)
xm = [x + 0.5 * h * u for x, u in zip(xs, us)] # @line L3
ym = [y + 0.5 * h * v for y, v in zip(ys, vs)] # @line L3
us, vs = velocities(xm, ym, gs, delta) # @line L4
xs = [x + h * u for x, u in zip(xs, us)] # @line L5
ys = [y + h * v for y, v in zip(ys, vs)] # @line L5
return xs, ys # @line L6
def lamb_oseen_vorticity(r: float, gamma: float, nu: float, t: float) -> float:
"""omega = gamma / (4 pi nu t) exp(-r^2 / (4 nu t))."""
return gamma / (4 * math.pi * nu * t) * math.exp(-r * r / (4 * nu * t))
def lamb_oseen_speed(r: float, gamma: float, nu: float, t: float) -> float:
"""The azimuthal velocity gamma / (2 pi r) (1 - exp(-r^2 / (4 nu t)))."""
return -gamma * math.expm1(-r * r / (4 * nu * t)) / (2 * math.pi * r)
def lattice_particles(omega, spacing: float, radius: float):
"""Particles on a square lattice inside the disc of the given radius, with g_p = omega(r_p) spacing^2."""
xs, ys, gs = [], [], []
k = int(radius / spacing)
for i in range(-k, k + 1):
for j in range(-k, k + 1):
x, y = i * spacing, j * spacing
if x * x + y * y <= radius * radius:
xs.append(x)
ys.append(y)
gs.append(omega(math.hypot(x, y)) * spacing * spacing)
return xs, ys, gs
test_vortex_particle_method.py 126 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/vortex-particle-method/. The authors are listed in prov/4WPAHS.jsonl.
import math
import random
import pytest
from vortex_particle_method import (kernel, lamb_oseen_speed, lamb_oseen_vorticity, lattice_particles, velocities,
velocity_at, vortex_step)
def blob_vorticity(x, y, xs, ys, gs, delta):
return sum(g * math.exp(-((x - a) ** 2 + (y - b) ** 2) / delta ** 2) for a, b, g in zip(xs, ys, gs)) / (
math.pi * delta ** 2)
def test_page_example_pair_velocities():
us, vs = velocities([-0.5, 0.5], [0.0, 0.0], [2 * math.pi, 2 * math.pi], 0.5)
w = 1 - math.exp(-4)
assert us == pytest.approx([0.0, 0.0], abs=1e-15)
assert vs == pytest.approx([-w, w], abs=1e-15)
assert w == pytest.approx(0.981684, abs=1e-6)
def test_direct_sum_matches_the_pointwise_sum_and_has_no_self_velocity():
rng = random.Random(1)
xs = [rng.uniform(-1, 1) for _ in range(40)]
ys = [rng.uniform(-1, 1) for _ in range(40)]
gs = [rng.uniform(-1, 1) for _ in range(40)]
us, vs = velocities(xs, ys, gs, 0.3)
for p in range(40):
u, v = velocity_at(xs[p], ys[p], xs, ys, gs, 0.3)
assert (us[p], vs[p]) == pytest.approx((u, v), abs=1e-12)
assert velocities([0.3], [0.7], [5.0], 0.2) == ([0.0], [0.0])
def test_velocity_is_divergence_free_and_its_curl_is_the_blob_vorticity():
rng = random.Random(2)
xs = [rng.uniform(-1, 1) for _ in range(10)]
ys = [rng.uniform(-1, 1) for _ in range(10)]
gs = [rng.uniform(-1, 1) for _ in range(10)]
delta, e = 0.4, 1e-4
for _ in range(20):
x, y = rng.uniform(-1, 1), rng.uniform(-1, 1)
ue, ve = velocity_at(x + e, y, xs, ys, gs, delta)
uw, vw = velocity_at(x - e, y, xs, ys, gs, delta)
un, vn = velocity_at(x, y + e, xs, ys, gs, delta)
us, vs = velocity_at(x, y - e, xs, ys, gs, delta)
div = (ue - uw + vn - vs) / (2 * e)
curl = (ve - vw - (un - us)) / (2 * e)
assert div == pytest.approx(0, abs=1e-6)
assert curl == pytest.approx(blob_vorticity(x, y, xs, ys, gs, delta), abs=1e-5)
def test_far_field_is_the_point_vortex():
u, v = kernel(0.0, 3.0, 0.1)
assert u == pytest.approx(-1 / (2 * math.pi * 3.0), rel=1e-12) and v == 0.0
def test_co_rotating_pair_rotates_at_the_predicted_rate():
d, delta, g = 1.0, 0.5, 1.0
omega = g * (1 - math.exp(-d * d / delta ** 2)) / (math.pi * d * d)
xs, ys, gs = [-d / 2, d / 2], [0.0, 0.0], [g, g]
h, steps = 0.05, 200
for _ in range(steps):
xs, ys = vortex_step(xs, ys, gs, delta, h)
assert math.hypot(xs[1] - xs[0], ys[1] - ys[0]) == pytest.approx(d, abs=1e-3)
angle = math.atan2(ys[1], xs[1])
expected = (omega * h * steps + math.pi) % (2 * math.pi) - math.pi
assert angle == pytest.approx(expected, abs=2e-3)
def test_linear_impulse_is_exact_and_angular_impulse_is_nearly_conserved():
rng = random.Random(3)
n = 30
xs = [rng.uniform(-1, 1) for _ in range(n)]
ys = [rng.uniform(-1, 1) for _ in range(n)]
gs = [rng.uniform(-1, 1) for _ in range(n)]
def impulses(xs, ys):
return (sum(g * x for g, x in zip(gs, xs)), sum(g * y for g, y in zip(gs, ys)),
sum(g * (x * x + y * y) for g, x, y in zip(gs, xs, ys)))
i0 = impulses(xs, ys)
for _ in range(50):
xs, ys = vortex_step(xs, ys, gs, 0.2, 0.01)
i1 = impulses(xs, ys)
assert i1[0] == pytest.approx(i0[0], abs=1e-12) and i1[1] == pytest.approx(i0[1], abs=1e-12)
assert i1[2] == pytest.approx(i0[2], abs=1e-4)
def test_lamb_oseen_velocity_is_reproduced():
# Gaussian blobs smear the vortex: the blob field is the Lamb-Oseen vortex at t + delta^2 / (4 nu)
g, nu, t = 1.0, 0.01, 1.0
xs, ys, gs = lattice_particles(lambda r: lamb_oseen_vorticity(r, g, nu, t), 0.05, 0.6)
assert len(xs) <= 500
assert sum(gs) == pytest.approx(g, abs=1e-3)
errors = {}
for delta in (0.1, 0.05):
smeared, exact = 0.0, 0.0
for r in (0.05, 0.1, 0.2, 0.3, 0.5):
for a in (0.3, 1.1):
u, v = velocity_at(r * math.cos(a), r * math.sin(a), xs, ys, gs, delta)
ut = -u * math.sin(a) + v * math.cos(a)
smeared = max(smeared, abs(ut - lamb_oseen_speed(r, g, nu, t + delta * delta / (4 * nu))))
exact = max(exact, abs(ut - lamb_oseen_speed(r, g, nu, t)))
assert smeared < 1e-4
errors[delta] = exact
# the smoothing error is second order in delta
assert 3.0 < errors[0.1] / errors[0.05] < 4.5
def test_lamb_oseen_vortex_is_a_steady_rotation():
g, nu, t, delta = 1.0, 0.01, 1.0, 0.15
xs, ys, gs = lattice_particles(lambda r: lamb_oseen_vorticity(r, g, nu, t), 0.1, 0.6)
r0 = [math.hypot(x, y) for x, y in zip(xs, ys)]
a0 = [math.atan2(y, x) for x, y in zip(xs, ys)]
h, steps = 0.05, 20
for _ in range(steps):
xs, ys = vortex_step(xs, ys, gs, delta, h)
for x, y, r, a in zip(xs, ys, r0, a0):
assert math.hypot(x, y) == pytest.approx(r, abs=5e-4)
if r > 0:
w = lamb_oseen_speed(r, g, nu, t + delta * delta / (4 * nu)) / r
turn = (math.atan2(y, x) - a - w * h * steps + math.pi) % (2 * math.pi) - math.pi
assert abs(turn) < 5e-3
History
Rosenhead (1931) followed the roll-up of a vortex sheet with point vortices by hand, and the instability of that computation stopped progress for decades. Chorin (1973) smoothed the core of each vortex into a blob and added viscosity with a random walk, which made the method a practical solver for slightly viscous flow. Hald (1979) and Beale and Majda (1982) proved convergence for the blob method. Fast summation with trees and the fast multipole method of Greengard and Rokhlin (1987), together with remeshing and particle strength exchange, made large and accurate simulations possible; Cottet and Koumoutsakos (2000) give the theory and the practice.
References
- Georges-Henri Cottet and Petros D. Koumoutsakos, Vortex Methods, Theory and Practice, Cambridge University Press, 2000, the 2D vortex blob method, its convergence, viscous vortex methods and remeshing
- Alexandre Joel Chorin, Numerical study of slightly viscous flow, Journal of Fluid Mechanics 57(4), 1973, 785-796, the vortex blobs and the random walk for the viscous term
- J. Thomas Beale and Andrew Majda, Vortex methods. II. Higher order accuracy in two and three dimensions, Mathematics of Computation 39(159), 1982, 29-52, the convergence of the blob method and kernels of higher order
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 4WPAHS Edit this page History Report an error Markdown