Skip to main content
Sandbox Physics

Fluid memory · spectral dynamics

2D Euler Vorticity & Mixing

How can a flow with no viscosity stir dye into fine threads without losing energy or rotation? With no viscosity, the flow carries its rotation along without spreading it out, so energy and enstrophy, the total squared rotation, stay fixed. The same flow stretches and folds the dye into ever finer threads. When those threads blur on a computer grid, that is the numerical method smoothing the dye, not the flow losing rotation.

Watch co-rotating vortex patches, a traveling dipole and a perturbed shear layer evolve in a periodic vorticity solver. Probe the same point in the rotation and dye fields, follow fluid parcels along their paths, and see how energy, enstrophy and the spectra across scales respond.

Interactive model2D Euler Vorticity & Mixing
Simulation time tt00
Energy E/E0E/E_011
Enstrophy Z/Z0Z/Z_011
Dye variance Vc/Vc,0V_c/V_{c,0}11
Probe rotation ωp\omega_p00
Probe dye cpc_p00
Dye mean drift ⟨c⟩−⟨c0⟩\langle c\rangle-\langle c_0\rangle00
Poisson residual εψ\varepsilon_\psi00
Dissipation balance error εE,Z\varepsilon_{E,Z}00
Near-cutoff enstrophy Ztail/ZZ_{\mathrm{tail}}/Z00
Taylor–Green relative errorn/a\mathrm{n/a}
Step cost ms\mathrm{ms}00

Physics tutorial

Euler: stretch a pattern without destroying its rotation

BackgroundIn a two-dimensional fluid, each parcel carries its rotation along with it. The vorticity determines a streamfunction, the streamfunction gives the velocity, and that velocity moves the vorticity around. The Lab solves this loop on a periodic square.

Why it mattersColorful filaments alone cannot tell a fluid solver from an animation. Energy, enstrophy, spectral bandwidth and an exact decay test show what the algorithm actually conserves and what it loses.

Start with the essentials

Focus question
How can the dye fold into ever finer filaments while the inviscid vorticity, as long as the grid resolves it, keeps its quadratic invariants?
One-sentence intuition
At zero viscosity, vorticity is carried along with the fluid, not diffused. The same velocity carries the dye, but the dye scheme uses interpolation, so dye that looks well mixed does not show that ω\omega has physically dissipated.

Core mathematical model

Vorticity feedback loop

∂tω+u⋅∇ω=νΔω,−Δψ=ω,u=(∂yψ,−∂xψ)\partial_t\omega+\mathbf u\cdot\nabla\omega=\nu\Delta\omega,\qquad -\Delta\psi=\omega,\qquad \mathbf u=(\partial_y\psi,-\partial_x\psi)

With zero viscosity these are the Euler equations; with positive viscosity they are the unforced 2D Navier–Stokes equations. In the divergence of the velocity, the two mixed derivatives cancel. A periodic domain requires zero mean vorticity, and the mean velocity is set to zero.

Time stepping in Fourier space, with dealiasing

ψ^k=ω^k∣k∣2,∂tω^k=−PKu⋅∇ω^k−ν∣k∣2ω^k,3K<N\widehat\psi_{\mathbf k}=\frac{\widehat\omega_{\mathbf k}}{|\mathbf k|^2},\quad \partial_t\widehat\omega_{\mathbf k}=-\mathcal P_K\widehat{\mathbf u\cdot\nabla\omega}_{\mathbf k}-\nu|\mathbf k|^2\widehat\omega_{\mathbf k},\quad 3K<N

The zero mode is removed. Derivatives and the Poisson inversion are done in Fourier space; the nonlinear product is computed on the grid and projected back. A rectangular cutoff that meets the strict two-thirds condition keeps aliases of the quadratic term out of the retained modes. RK4 advances the coefficients, and the energy is never renormalized along the way.

Energy and enstrophy balance

E=12⟨∣u∣2⟩,Z=12⟨ω2⟩,dEdt=−2νZ,dZdt=−ν⟨∣∇ω∣2⟩E=\tfrac12\langle|\mathbf u|^2\rangle,\quad Z=\tfrac12\langle\omega^2\rangle,\quad \frac{dE}{dt}=-2\nu Z,\quad \frac{dZ}{dt}=-\nu\langle|\nabla\omega|^2\rangle

Energy and enstrophy are defined as averages over the domain and then normalized. Both stay constant in smooth inviscid flow. With viscosity, the dissipation is integrated alongside RK4 with the same stage weights. The balance error compares the current value plus the accumulated loss with the initial value. Time stepping still leaves a measurable residual.

Dye moved by a separate scheme

∂tc+u⋅∇c=κΔc,Vc=⟨(c−⟨c⟩)2⟩\partial_t c+\mathbf u\cdot\nabla c=\kappa\Delta c,\qquad V_c=\langle(c-\langle c\rangle)^2\rangle

The dye is advanced by tracing back along the flow with a midpoint rule, interpolating bilinearly on the periodic grid and then applying an explicit five-point diffusion step. The interpolation smooths the dye even at zero diffusivity and does not conserve dye mass exactly. The dye does not affect the velocity. Tracer paths come from interpolated velocity and midpoint integration, so they only approximate the true paths of fluid parcels.

Taylor–Green vortex as an exact check

ω=Asin⁡xsin⁡y e−2νt,ψ=A2sin⁡xsin⁡y e−2νt,EE0=ZZ0=e−4νt\omega=A\sin x\sin y\,e^{-2\nu t},\quad \psi=\frac{A}{2}\sin x\sin y\,e^{-2\nu t},\quad \frac{E}{E_0}=\frac{Z}{Z_0}=e^{-4\nu t}

This flow is a single eigenfunction of the Laplacian, so its nonlinear advection term is zero. Its vorticity decays at a known rate, and the relative error compares the solver with this independent formula, including the inviscid case where the pattern does not change. Patch width and separation play no role here, so they are disabled.

Common difficulties

Two different kinds of mixing

Typical misconceptionThe dye variance is falling, so the Euler flow must be losing enstrophy.

Better mental modelVorticity and dye are computed by different algorithms. The dye folds into ever smaller structures, and its interpolation smooths them out. Check energy and enstrophy on their own, change the dye diffusivity, and repeat on a finer grid. At zero viscosity the Euler equations have no physical diffusion.

An accurate Poisson solve does not mean the flow is resolved

Typical misconceptionA tiny Poisson residual proves every fine filament is accurate.

Better mental modelThe Poisson residual checks that the Fourier inversion and the round trip between grid and spectrum agree algebraically; it does not measure truncation error. The near-cutoff enstrophy counts modes with either wavenumber component in the top fifth of the retained square. If that tail is large, compare with another resolution. The two shell spectra are each scaled to their own peak, so compare their shapes, not their bar heights against each other.

Periodic patches are not isolated vortices

Typical misconceptionThe dipole and same-sign patches move exactly like isolated point vortices.

Better mental modelThese patches are smooth, have finite width and repeat periodically. Same-sign patches need a uniform background to balance them. A finite Fourier truncation can produce ringing, and it conserves only the two quadratic invariants checked here, not the vorticity of every fluid parcel or every Casimir. This is not a 3D turbulence simulation, and it is not evidence for a universal cascade.

Run the experiment

  1. 01

    Follow rotation and dye together

    Start with Co-rotating patches. Turn on Velocity vectors, pause, and advance one solver step at a time. Click a point in either field to probe the same spot in both.

    What to observe: Streamlines show the velocity at this instant; tracer tails show where the fluid has recently been. The dye folds while the inviscid energy and enstrophy stay close to their starting values. The same-sign patches orbit each other and deform, but the model does not guarantee that they merge for good.
  2. 02

    Separate viscosity from numerical loss

    Run a patch experiment with zero viscosity, then with positive viscosity. Change the dye diffusivity separately. Every change to a physical parameter restarts from the same initial state.

    What to observe: Viscosity lowers both quadratic invariants, and the integrated dissipation can still account for the loss accurately. Dye diffusion smooths only the dye. A small balance error says nothing about whether dye mass is conserved.
  3. 03

    Test the resolution

    Compare Perturbed shear at 32, 64 and 128 cells per side at the same simulation time. Then lower the retained bandwidth; dealiasing always stays on.

    What to observe: Fine structure and dye loss both change with resolution. The near-cutoff tail and the spectra show what the truncation leaves out. An animation that runs faster in real time does not mean a smaller physical time step.
  4. 04

    Check an exact solution

    Select Exact decay test, step forward, and change viscosity. Compare the Taylor–Green relative error and both invariant ratios.

    What to observe: The error is computed from the Fourier coefficients the solver actually evolved. At zero viscosity the vorticity pattern stays still while the dye and tracers keep moving.
  5. 05

    Scientific basis and inspiration

    Numerical basis: Trefethen, Spectral Methods in MATLAB (SIAM, 2000), people.maths.ox.ac.uk/trefethen/spectral.html; Bardos and Tadmor, Stability and spectral convergence of Fourier method for nonlinear problems (2013), arXiv:1308.5314. Taylor–Green reference: IncompressibleNavierStokes.jl, TaylorGreenVortex2D validation example.

    What to observe: Inspired by the Euler equations, vortices and pathlines at bugman123.com/FluidMotion/. All code and graphics are original. Automated tests check FFT normalization, the invariant balance of the nonlinear term, exact viscous decay, periodic dye transport, and refinement of the grid and time step.

Conceptual inspiration: FluidMotion. Original simulations and graphics; the model limits are described above.

FeedbackSomething broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy