Vorticity feedback loop
Viscosity zero gives Euler; positive viscosity gives unforced 2D Navier–Stokes. The two velocity derivatives cancel in the divergence. Periodicity requires zero mean vorticity; the mean velocity is set to zero.
Fluid memory · spectral dynamics
Co-rotating patches, a traveling dipole, and a perturbed shear layer evolve in a real periodic vorticity solver. Inspect the same point in the rotation and dye fields, follow material paths, and watch energy, enstrophy, and scale spectra respond.
Physics tutorial
BackgroundA two-dimensional fluid carries its local rotation with it. The rotation field generates a streamfunction, which generates the velocity that transports the original field. This closed feedback loop is solved here on a periodic square.
Why it mattersColored filaments alone cannot distinguish a genuine fluid solver from an animation. Energy, enstrophy, spectral bandwidth, and an exact decay test let you inspect what the algorithm actually preserves and loses.
Start with the essentials
Viscosity zero gives Euler; positive viscosity gives unforced 2D Navier–Stokes. The two velocity derivatives cancel in the divergence. Periodicity requires zero mean vorticity; the mean velocity is set to zero.
The zero mode is removed. Derivatives and the Poisson inversion are spectral; the nonlinear product is computed on the grid and projected back. A rectangular cutoff obeying the strict two-thirds condition prevents quadratic aliases entering retained modes. RK4 advances the coefficients without energy renormalization.
Spatial averages define normalized energy and enstrophy. Both are constant for smooth inviscid flow. With viscosity, the stage-weighted dissipation is integrated alongside RK4; the ledger error compares current invariant plus integrated loss with the initial value. Time integration still introduces a measurable residual.
Dye uses midpoint backward tracing, periodic bilinear interpolation, and an explicit five-point diffusion pass. Interpolation is dissipative even with zero diffusivity and is not exactly mass-conservative. The field does not feed back into velocity. Tracer paths use interpolated velocity and midpoint integration, not exact material trajectories.
This single Laplacian eigenfunction has zero nonlinear advection. Its vorticity decays at a known rate, so the relative error tests the implemented solver against an independent formula, including the inviscid stationary limit. Patch width and separation are irrelevant and disabled in this scenario.
Typical misconceptionDye variance falling proves the Euler flow is losing enstrophy.
Better mental modelThe vorticity and dye algorithms are distinct. Dye folds into smaller structures and its interpolation smooths them. Compare energy and enstrophy separately, vary dye diffusivity, and repeat at higher grid resolution. Euler has no physical diffusion at zero viscosity.
Typical misconceptionA tiny Poisson residual proves every fine filament is accurate.
Better mental modelThat audit measures the algebraic consistency of a Fourier inversion and round-trip, not truncation error. Near-cutoff enstrophy counts modes with either component in the highest fifth of the retained square. A large tail asks for a resolution comparison. Shell spectra have separate peak normalization, so compare their shapes rather than bar heights across the two quantities.
Typical misconceptionThe dipole and same-sign patches move exactly like isolated point vortices.
Better mental modelThese are smooth finite-width fields with periodic copies. Same-sign patches require a uniform compensating background. Finite Fourier truncation can develop ringing and preserves only the audited quadratic invariants, not every material vorticity value or Casimir. This is not a 3D turbulence simulation or evidence for a universal cascade.
Start with Co-rotating patches. Turn velocity vectors on, pause, and single-step. Click a shared position in either field.
What to observe: Streamlines show the current velocity geometry; tracer tails show its recent history. Dye folds while the inviscid energy and enstrophy stay close to their initial values. Same-sign patches orbit and deform; the model does not promise irreversible merger.Repeat a patch experiment with viscosity zero and then positive. Independently vary dye diffusivity. Each physical parameter change restarts the same initial condition.
What to observe: Fluid viscosity lowers both quadratic invariants; their dissipation ledger can remain accurate. Dye diffusion smooths only dye. A low ledger residual says nothing about dye mass conservation.Compare the perturbed shear at 32, 64, and 128 cells per side at the same simulation time. Lower the retained bandwidth without ever disabling dealiasing.
What to observe: Fine structure and dye loss are resolution-sensitive. The near-cutoff tail and spectra expose what the truncation is excluding. A faster wall-clock animation is not a finer physical time step.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 actual evolved Fourier coefficients, not a separate animation. At zero viscosity the vorticity pattern stays stationary while dye and tracers still move.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 checks cover FFT normalization, nonlinear invariant balance, exact viscous decay, periodic dye transport, and grid/time refinement.