Vorticity Operators
Relative vorticity and Jacobian operators on Arakawa C-grids.
finitevolx.Vorticity2D
Bases: Module
2-D vorticity and PV-flux operators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
ArakawaCGrid2D
|
|
required |
Source code in finitevolx/_src/operators/vorticity.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
potential_vorticity(u, v, h, f)
Potential vorticity at X-points (corners).
q[j+1/2, i+1/2] = (zeta[j+1/2, i+1/2] + f_on_q[j+1/2, i+1/2]) / h_on_q[j+1/2, i+1/2]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Float[Array, 'Ny Nx']
|
x-velocity at U-points. |
required |
v
|
Float[Array, 'Ny Nx']
|
y-velocity at V-points. |
required |
h
|
Float[Array, 'Ny Nx']
|
Layer thickness at T-points. |
required |
f
|
Float[Array, 'Ny Nx']
|
Coriolis parameter at T-points. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'Ny Nx']
|
Potential vorticity at X-points. |
Source code in finitevolx/_src/operators/vorticity.py
pv_flux_arakawa_lamb(q, u, v, alpha=1.0 / 3.0)
Arakawa-Lamb PV flux: weighted blend of energy and enstrophy.
flux = alpha * energy_conserving + (1 - alpha) * enstrophy_conserving
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Float[Array, 'Ny Nx']
|
Potential vorticity at X-points. |
required |
u
|
Float[Array, 'Ny Nx']
|
x-velocity at U-points. |
required |
v
|
Float[Array, 'Ny Nx']
|
y-velocity at V-points. |
required |
alpha
|
float
|
Blending weight. Default 1/3 gives Arakawa-Lamb scheme. |
1.0 / 3.0
|
Returns:
| Type | Description |
|---|---|
tuple
|
(qu at U-points, qv at V-points) |
Source code in finitevolx/_src/operators/vorticity.py
pv_flux_energy_conserving(q, u, v)
Energy-conserving PV flux.
Interpolate q and velocity independently to faces, then multiply.
qu[j, i+1/2] = q_on_u[j, i+1/2] * u[j, i+1/2] qv[j+1/2, i] = q_on_v[j+1/2, i] * v[j+1/2, i]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Float[Array, 'Ny Nx']
|
Potential vorticity at X-points. |
required |
u
|
Float[Array, 'Ny Nx']
|
x-velocity at U-points. |
required |
v
|
Float[Array, 'Ny Nx']
|
y-velocity at V-points. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
(qu at U-points, qv at V-points) |
Source code in finitevolx/_src/operators/vorticity.py
pv_flux_enstrophy_conserving(q, u, v)
Enstrophy-conserving PV flux.
Multiply q*u at corners/faces, then interpolate to faces.
qu[j, i+1/2] = X_to_U(q * U_to_X(u)) qv[j+1/2, i] = X_to_V(q * V_to_X(v))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Float[Array, 'Ny Nx']
|
Potential vorticity at X-points. |
required |
u
|
Float[Array, 'Ny Nx']
|
x-velocity at U-points. |
required |
v
|
Float[Array, 'Ny Nx']
|
y-velocity at V-points. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
(qu at U-points, qv at V-points) |
Source code in finitevolx/_src/operators/vorticity.py
relative_vorticity(u, v)
Relative vorticity at X-points (corners).
zeta[j+1/2, i+1/2] = dv_dx[j+1/2, i+1/2] - du_dy[j+1/2, i+1/2] = (v[j+1/2, i+1] - v[j+1/2, i]) / dx - (u[j+1, i+1/2] - u[j, i+1/2]) / dy
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Float[Array, 'Ny Nx']
|
x-velocity at U-points. |
required |
v
|
Float[Array, 'Ny Nx']
|
y-velocity at V-points. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'Ny Nx']
|
Relative vorticity at X-points. |
Source code in finitevolx/_src/operators/vorticity.py
finitevolx.Vorticity3D
Bases: Module
3-D vorticity operators (horizontal plane per z-level).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
ArakawaCGrid3D
|
|
required |
Source code in finitevolx/_src/operators/vorticity.py
relative_vorticity(u, v)
Relative vorticity at X-points over all z-levels.
zeta[k, j+1/2, i+1/2] = (v[k, j+1/2, i+1] - v[k, j+1/2, i]) / dx - (u[k, j+1, i+1/2] - u[k, j, i+1/2]) / dy
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Float[Array, 'Nz Ny Nx']
|
x-velocity at U-points. |
required |
v
|
Float[Array, 'Nz Ny Nx']
|
y-velocity at V-points. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, 'Nz Ny Nx']
|
Relative vorticity at X-points. |
Source code in finitevolx/_src/operators/vorticity.py
Jacobian
finitevolx.arakawa_jacobian(f, g, dx, dy)
Arakawa (1966) discretization of J(f, g).
Computes the Jacobian J(f, g) = ∂f/∂x·∂g/∂y − ∂f/∂y·∂g/∂x using the
energy- and enstrophy-conserving three-term Arakawa scheme on a collocated
grid. The inputs must include a one-point boundary halo on each side so
that the returned interior array has shape (..., Ny-2, Nx-2)
(i.e. Ny_i = Ny - 2, Nx_i = Nx - 2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Float[Array, '... Ny Nx']
|
First scalar field (including one halo cell on each side). |
required |
g
|
Float[Array, '... Ny Nx']
|
Second scalar field (same shape as f). |
required |
dx
|
float
|
Grid spacing in the x-direction (last array axis). |
required |
dy
|
float
|
Grid spacing in the y-direction (second-to-last array axis). |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, '... Ny_i Nx_i']
|
Jacobian evaluated on the interior grid points, where
|
Notes
The Arakawa scheme averages three discrete forms:
- J⁺⁺ (standard centred form):
.. code-block:: text
Jpp[j,i] = ( (f[j,i+1] - f[j,i-1]) * (g[j+1,i] - g[j-1,i])
- (f[j+1,i] - f[j-1,i]) * (g[j,i+1] - g[j,i-1]) ) / (4 dx dy)
- J⁺× (advective form):
.. code-block:: text
Jpx[j,i] = ( f[j,i+1] * (g[j+1,i+1] - g[j-1,i+1])
- f[j,i-1] * (g[j+1,i-1] - g[j-1,i-1])
- f[j+1,i] * (g[j+1,i+1] - g[j+1,i-1])
+ f[j-1,i] * (g[j-1,i+1] - g[j-1,i-1]) ) / (4 dx dy)
- J×⁺ (divergence form):
.. code-block:: text
Jxp[j,i] = ( g[j+1,i] * (f[j+1,i+1] - f[j+1,i-1])
- g[j-1,i] * (f[j-1,i+1] - f[j-1,i-1])
- g[j,i+1] * (f[j+1,i+1] - f[j-1,i+1])
+ g[j,i-1] * (f[j+1,i-1] - f[j-1,i-1]) ) / (4 dx dy)
Together: J = (Jpp + Jpx + Jxp) / 3
This triple average conserves energy (∫∫ f·J dA = 0), enstrophy (∫∫ g·J dA = 0), satisfies J(f, f) = 0, and ∫∫ J(f, g) dA = 0 at the discrete level.
The function is JAX-compatible and jit-able. Batch dimensions
(...) are supported via standard broadcasting.
Examples:
>>> import jax.numpy as jnp
>>> from finitevolx import arakawa_jacobian
>>> Ny, Nx = 12, 10
>>> x = jnp.linspace(0, 1, Nx)
>>> y = jnp.linspace(0, 1, Ny)
>>> dx, dy = x[1] - x[0], y[1] - y[0]
>>> X, Y = jnp.meshgrid(x, y)
>>> J = arakawa_jacobian(X, Y, float(dx), float(dy))
>>> J.shape
(10, 8)
Source code in finitevolx/_src/operators/jacobian.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |