Solution (source code)

= Solution

<Potential-vorticity inversion> is the diagnostic recovery of the flow from its advected vortical scalar, using the balance relation and specified <boundary conditions>. Its usefulness is a separation of tasks: transport the scalar by the current <velocity>, invert to find the new <velocity>, and repeat. The inverse is spatially nonlocal even though the transport law is local. The four models differ chiefly in the operator being inverted and the information needed at boundaries.

In <two-dimensional vortex dynamics>, planar <incompressibility> permits $\boldsymbol u=(-\psi_y,\psi_x)$, and vertical <vorticity> is $\zeta=\nabla^2\psi$. The <curl> of inviscid momentum gives
$$
\zeta_t+J(\psi,\zeta)=0,\qquad
J(\psi,\zeta)=\psi_x\zeta_y-\psi_y\zeta_x.
$$
There is no <vortex stretching> in strictly planar motion, so <vorticity> is materially conserved. The <two-dimensional potential-vorticity inversion> is the <Poisson equation> $\nabla^2\psi=\zeta$. On the plane, with suitable integrability and far-field behavior, its <Green's function> is $(2\pi)^{-1}\log|\boldsymbol x-\boldsymbol x'|$, giving
$$
\psi(\boldsymbol x)=\frac1{2\pi}\int\zeta(\boldsymbol x')\log|\boldsymbol x-\boldsymbol x'|\,d^2x'+\psi_h(\boldsymbol x).
$$
Differentiation gives the <planar Biot-Savart kernel>. Here $\psi_h$ is a <harmonic function> fixed by boundary, circulation and far-field data. A rigid impermeable wall is a streamline, so $\psi$ is constant on it; constants or circulations around distinct holes require specification. The <vorticity> alone cannot distinguish two flows differing by a permitted harmonic contribution, such as a uniform current on an unbounded plane. A constant added to $\psi$ has no physical effect.

In <nonrotating layerwise-two-dimensional vortex dynamics>, strong stable <density stratification> constrains motion to almost horizontal layers. In the ideal independent-layer limit, vertical <velocity> vanishes at leading order, $(u,v)=(-\psi_y,\psi_x)$ and
$$
\zeta_t+J(\psi,\zeta)=0,\qquad\nabla_h^2\psi=\zeta
$$
hold separately at each fixed $z$. Height is a parameter: the horizontal inverse <Laplacian> contains no vertical <derivative>. With background buoyancy $N^2z$, the leading <Ertel potential vorticity> is $Q=\boldsymbol\omega\cdot\nabla b\simeq N^2\zeta$, so the materially advected normalized scalar is $Q/N^2\simeq\zeta$. The same horizontal <Poisson equation> is inverted layer by layer, using each layer's boundary data. This is an asymptotic constrained model, not arbitrary three-dimensional Euler motion with vertical <velocity> set to zero: its validity requires small <Froude number> and controlled vertical scales. At finite <buoyancy frequency>, the weak vertical motion and tilted <isopycnals> restore coupling. The inversion may be independent by layer while the reconstructed fields vary with height. The horizontal <Euler equations for an inviscid fluid> determine the <pressure gradient>, while <hydrostatic balance> relates its vertical <derivative> to <buoyancy>.

In <shallow-water quasi-geostrophic inversion>, begin with the exact <shallow-water potential vorticity> $(f+\zeta)/h$. Linearizing its anomaly about depth $H$ gives, after multiplying by $H$, $\zeta-f_0\eta/H$. For small <Rossby number>, <geostrophic balance> gives $\psi=g\eta/f_0$, while $\zeta=\nabla_h^2\psi$. Keeping the <beta plane> background gradient gives
$$
q=\nabla_h^2\psi-\frac{\psi}{L_D^2}+\beta y,\qquad
L_D=\frac{\sqrt{gH}}{|f_0|},\qquad
q_t+J(\psi,q)=0.
$$
Thus $q-\beta y$ is inverted with the <modified Helmholtz equation> $(\nabla_h^2-L_D^{-2})\psi=q-\beta y$, under the specified boundary and far-field conditions. The <velocity> follows from $\psi$ and surface elevation from $\eta=f_0\psi/g$. A horizontal <Fourier mode> of the anomaly satisfies
$$
\widehat\psi=-\frac{\widehat{q-\beta y}}{|\boldsymbol k_h|^2+L_D^{-2}}.
$$
The <Rossby deformation radius> therefore limits the reach of the balanced response. Layer stretching, represented by $-\psi/L_D^2$, is absent from ordinary planar <vorticity> inversion. Unlike the pure <Poisson equation>, the finite-deformation operator also responds to the constant part of $\psi$, which specifies mean elevation rather than an arbitrary streamfunction offset. Specified bottom topography adds a known source to $q$; it is subtracted along with the background before inversion.

In <stratified quasi-geostrophic inversion>, continuously varying vertical displacement replaces the shallow layer's single stretching term. For positive $N^2(z)$ and constant nonzero $f_0$, the <three-dimensional quasi-geostrophic potential vorticity> is
$$
q=\nabla_h^2\psi+\partial_z\left(\frac{f_0^2}{N^2}\psi_z\right)+\beta y,
\qquad q_t+J(\psi,q)=0.
$$
<Geostrophic balance> and <hydrostatic balance> give <velocity> $(-\psi_y,\psi_x)$ and <buoyancy perturbation> $b=f_0\psi_z$. Invert the anisotropic <elliptic boundary value problem> using interior $q$, prescribed top and bottom <buoyancy> as <Neumann boundary conditions>, and the lateral, far-field and global-flow data. Boundary <buoyancy> evolves by its own material conservation when the boundary is impermeable. It cannot be discarded: the <Eady edge wave> in the preceding solution has zero interior <potential vorticity> anomaly but nonzero boundary buoyancy and a nonzero induced flow.

For constant $N,f_0$, the <stretched coordinates for quasi-geostrophic inversion> $Z=Nz/|f_0|$ turn the inversion operator into the three-dimensional <Laplacian>. Its infinite-space <Green's function> is $-1/(4\pi|\boldsymbol X-\boldsymbol X'|)$ in $(x,y,Z)$ coordinates. Hence a horizontal disturbance of scale $L$ communicates vertically over scale $|f_0|L/N$, explicitly coupling layers. In a bounded domain with homogeneous difference data, multiplying the difference of two inversions by its <streamfunction> and applying <integration by parts> gives
$$
\int\left(|\nabla_h\delta\psi|^2+\frac{f_0^2}{N^2}|\delta\psi_z|^2\right)dV=0.
$$
This proves uniqueness up to a constant when the relevant boundary terms vanish; a mean or pressure reference fixes the remaining constant. Compatible boundary fluxes are needed for a purely <Neumann boundary-value problem>.

Across all four models, inversion provides the induced flow, while scalar transport supplies time evolution. The independent horizontal inverse in the first two models becomes a finite-deformation inverse in shallow water and a vertically coupled elliptic inverse in continuous stratification. The principle applies within the stated balance or constrained model. In the unrestricted <Boussinesq equations> or <shallow water equations>, <gravity waves> and divergent motion can share the same <potential vorticity>, so the vortical scalar alone does not reconstruct every possible flow.