Band-forced two-dimensional turbulence¶
The periodic vorticity equation uses viscosity and the upstream linear drag argument. Its nonlinear transport redistributes power among modes. Runtime depends on the machine. The default runs in a few minutes or less. Set EXPONAX_SPDE_PRESET=smoke for a shorter diagnostic. Figures are written only if SAVE_FIGURES is enabled.
Exact law: linear single-shell OU law¶
Force a single radial shell. Here the streamfunction is proportional to the vorticity, so the advective Jacobian vanishes. With linear damping \(a_k=\nu |k|^2+\mu\) and \(\mu>0\) the shell evolves by exact OU steps. Start each independent ensemble member at its analytic Gaussian stationary law and advance it once. On this shell the enstrophy is \(|k|^2\) times the energy, so one check covers both.
For a field on a square of side \(L\), the raw FFT mode of the white-in-time forcing has quadratic variation rate \(N^4\sigma^2q_k/L^2\). In an rFFT sum, give conjugate partners weight \(w_k=2\) off the zero and Nyquist planes, and \(w_k=1\) on those planes. The enstrophy and energy weights are \(b_k=1\) and \(b_k=1/|k|^2\) respectively, with DC omitted. Each quadratic invariant is \(\sum_k w_k b_k|\hat\omega_k|^2/(2N^4)\), so its Itô injection is \(\sigma^2\sum_k w_k b_k q_k/(2L^2)\). Its dissipation rate uses the same invariant weights multiplied by \(2a_k\). Compare energy dissipation with analytic injection in this exact OU limit. White-in-time forcing is discussed by Novikov (1965).
Two independent circular mode squares contribute equally on this shell. Their sum has CV \(1/\sqrt{2}\). Draw 1,600 independent members for a planned relative SE of 1.8%. Use terminal states from separate keys for the SE.
PASS | linear single-shell OU law | 0.003078243 ± 5.5e-05 SE | target 0.003166287 | 1.60 SE | relative SE 1.79%
Gate: stationary balances with nonlinear transfer¶
The forcing band \(3\leq |k|\leq 5\) on the side-\(2\pi\) square excites eight distinct radial shells. On the half-dealiased Fourier grid, the Galerkin vorticity advection conserves both energy and enstrophy. Applying Itô's formula to either quadratic invariant therefore leaves its injection and dissipation as the only terms in the stationary expected balance.
Use \(N=32\), \(\nu=0.01\), linear drag \(\mu=0.2\) and \(\sigma=2\). Evolve independent members from zero for six drag times, \(T=30\). Each path contributes one terminal measurement to the SE. The two ETDRK4 step sizes check the effect of time discretisation on the balance. Each observed dissipation must agree with its analytic injection within five SEs and have at most 4% relative SE. The sample count comes from independent 1,024-path pilots with a bootstrap upper bound on the CV and a 2.5% relative-SE target. The energy fraction in unforced modes measures nonlinear transfer.
def nonlinear(flow_h, paths, seed):
n, length, nu, drag, sigma, spinup = 32, 2 * np.pi, 0.01, 0.2, 2.0, 30.0
k2, weights, inverse = geometry(n, length)
band = (k2 >= 3**2) & (k2 <= 5**2)
invariants = np.stack((weights * inverse, np.broadcast_to(weights, k2.shape)))
injection = sigma**2 * np.sum(invariants * band, axis=(-2, -1)) / (2 * length**2)
damping = nu * k2 + drag
dissipation = jnp.asarray(invariants * damping / n**4)
energy_weights = jnp.asarray(invariants[0] / (2 * n**4))
unforced_weights = jnp.asarray(energy_weights * ~band)
flow = spde.StochasticNavierStokesVorticity(
2,
length,
n,
flow_h,
diffusivity=nu,
drag=-drag,
sigma=sigma,
order=4,
dealiasing_fraction=0.5,
noise_spectrum=Band(3.0, 5.0),
)
initial = jnp.zeros((1, n, n // 2 + 1), dtype=jnp.complex128)
steps = round(spinup / flow_h)
def member(key):
def advance(i, state):
return flow.step_fourier(state, key=jax.random.fold_in(key, i))
final = jax.lax.fori_loop(0, steps, advance, initial)[0]
power = jnp.abs(final) ** 2
return (
jnp.sum(dissipation * power, axis=(-2, -1)),
jnp.sum(energy_weights * power),
jnp.sum(unforced_weights * power),
)
batch_size = 16
kernel = jax.jit(jax.vmap(member))
keys = jax.random.split(jax.random.key(seed), paths)
batches = [
jax.device_get(kernel(keys[i : i + batch_size]))
for i in range(0, paths, batch_size)
]
budgets, total, outside = (
np.concatenate(parts) for parts in zip(*batches, strict=True)
)
return budgets, injection, outside.sum() / total.sum()
# Both presets use the same frozen precision and the same production keys.
for h_gate, seed in ((0.02, 35110), (0.01, 35111)):
values, target, outside_fraction = nonlinear(h_gate, 64, seed)
print(
f"Transfer | h={h_gate:g} | out-of-band energy fraction {outside_fraction:.3%}"
)
for i, label in enumerate(("energy", "enstrophy")):
check_power(f"stationary {label} at h={h_gate:g}", values[:, i], target[i])
Transfer | h=0.02 | out-of-band energy fraction 25.215% PASS | stationary energy at h=0.02 | 0.1867256 ± 0.0038 SE | target 0.1865647 | 0.04 SE | relative SE 2.06% PASS | stationary enstrophy at h=0.02 | 2.827178 ± 0.058 SE | target 2.836993 | 0.17 SE | relative SE 2.06%
Transfer | h=0.01 | out-of-band energy fraction 26.162% PASS | stationary energy at h=0.01 | 0.1821428 ± 0.0038 SE | target 0.1865647 | 1.17 SE | relative SE 2.07% PASS | stationary enstrophy at h=0.01 | 2.751616 ± 0.06 SE | target 2.836993 | 1.42 SE | relative SE 2.18%
DIAGNOSTIC: redistribution across shells¶
A wider simulation grid lets us illustrate redistribution across more retained modes. The plotted spectrum sums energy in unit-width wavenumber shells and averages independent terminal fields. The guide slopes \(k^{-5/3}\) and \(k^{-3}\) describe the inverse energy and forward enstrophy cascade expectations in scale-separated two-dimensional turbulence. Linear drag removes energy at the largest scales, halting the inverse cascade and flattening the low-wavenumber spectrum. The guide slopes are diagnostic for this finite run. With convection in the explicit drift, ETDRK1 can be unstable in advection-dominated runs, so the nonlinear runs here use ETDRK4. Kraichnan (1967) · Boffetta & Ecke (2012).
n, steps, paths = (48, 150, 3) if SMOKE else (64, 4000, 8)
h, nu, drag, sigma = 0.005, 0.002, 0.08, 6.0
initial = jnp.zeros((1, n, n))
flow = spde.StochasticNavierStokesVorticity(
2,
length,
n,
h,
diffusivity=nu,
drag=-drag,
sigma=sigma,
order=4,
dealiasing_fraction=0.5,
noise_spectrum=Band(7.0, 9.0),
)
states = terminal(flow, initial, steps, jax.random.split(jax.random.key(34202), paths))
k2, weights, inverse = geometry(n, length)
energy = np.mean(abs(states[:, 0]) ** 2, axis=0) * weights * inverse / (2 * n**4)
shell = np.rint(np.sqrt(k2)).astype(int)
cutoff = int(0.5 * (n // 2) - 1)
kx = np.fft.fftfreq(n) * n
ky = np.fft.rfftfreq(n) * n
retained = (abs(kx[:, None]) <= cutoff) & (ky[None, :] <= cutoff)
spectrum = np.bincount(shell[retained], weights=energy[retained])
radii = np.arange(1, cutoff + 1)
low, forced, high = spectrum[1:7].sum(), spectrum[7:10].sum(), spectrum[10:].sum()
print(
f"DIAGNOSTIC | terminal energy | below band {low:.5g} "
f"| band {forced:.5g} | above band {high:.5g}"
)
fig, (field_ax, spectrum_ax) = plt.subplots(
1, 2, figsize=(9, 3.75), layout="constrained"
)
field = np.fft.irfft2(states[0, 0], s=(n, n), axes=(-2, -1))
image = field_ax.imshow(
field.T, extent=(0, length, 0, length), origin="lower", cmap="RdBu_r"
)
field_ax.set(xlabel="x", ylabel="y", title="Terminal vorticity")
fig.colorbar(image, ax=field_ax)
spectrum_ax.loglog(radii, spectrum[radii], ".-", label="Shell energy")
spectrum_ax.axvspan(7, 9, alpha=0.15, color="0.5", label="Forcing")
anchor = spectrum[8]
for exponent, region, label in (
(-5 / 3, radii[radii <= 8], "−5/3 reference"),
(-3, radii[radii >= 8], "−3 reference"),
):
spectrum_ax.loglog(region, anchor * (region / 8) ** exponent, "--", label=label)
spectrum_ax.set(xlabel="Wavenumber", ylabel="Shell energy")
spectrum_ax.legend(fontsize=8)
show(fig, "two_dimensional_turbulence")
DIAGNOSTIC | terminal energy | below band 2.2511 | band 0.33419 | above band 0.20193