Coriolis Operators
Coriolis force operators for rotating-frame geophysical models on C-grids.
finitevolx.Coriolis2D
Bases: Module
Coriolis force operator for 2-D Arakawa C-grids.
Computes the Coriolis tendency for both velocity components in the energy-conserving corner-product form (Sadourny 1975):
du_cor[j, i+1/2] = +1/2 (P[j+1/2, i+1/2] + P[j-1/2, i+1/2])
dv_cor[j+1/2, i] = -1/2 (Q[j+1/2, i+1/2] + Q[j+1/2, i-1/2])
P = f_X * avg_x(v), Q = f_X * avg_y(u) at X-points,
with f_X the 4-point average of the T-point f. The kinetic-energy
tendency sum(u * du_cor) + sum(v * dv_cor) vanishes to round-off for
any f, including a beta-plane (the f_on_u * V_to_U(v) form used before
289 conserves energy only for uniform f). For uniform f the two forms
coincide.
The corner products are formed on the full arrays (X rows / columns
0 .. N-2), so the first interior row / column reads the south /
west ghost corners built from the caller's ghost cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
CartesianGrid2D
|
The underlying 2-D grid. |
required |
mask
|
Mask2D or None
|
Optional land/ocean mask. When provided, |
required |
Notes
f must be filled on the whole array, ghost ring included (e.g. an
analytic f0 + beta * y evaluated at every T-point): the corner
average f_X on the first / last interior rows reads the ghost rows
of f.
Examples:
>>> import jax.numpy as jnp
>>> from finitevolx import CartesianGrid2D, Coriolis2D
>>> grid = CartesianGrid2D.from_interior(8, 8, 1.0, 1.0)
>>> cor = Coriolis2D(grid=grid)
>>> u = jnp.zeros((grid.Ny, grid.Nx))
>>> v = jnp.ones((grid.Ny, grid.Nx))
>>> f = jnp.ones((grid.Ny, grid.Nx))
>>> du_cor, dv_cor = cor(u, v, f)
Source code in finitevolx/_src/operators/coriolis.py
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 | |
__call__(u, v, f)
Coriolis tendencies (du_cor, dv_cor).
du_cor[j, i+1/2] = +avg_y(f_X * avg_x(v)) dv_cor[j+1/2, i] = -avg_x(f_X * avg_y(u))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
Float[Array, '*batch Ny Nx']
|
x-velocity at U-points (east faces). |
required |
v
|
Float[Array, '*batch Ny Nx']
|
y-velocity at V-points (north faces). |
required |
f
|
Float[Array, '*batch Ny Nx']
|
Coriolis parameter at T-points, ghost ring filled. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Float[Array, '*batch Ny Nx'], Float[Array, '*batch Ny Nx']]
|
|
Source code in finitevolx/_src/operators/coriolis.py
finitevolx.Coriolis3D
Bases: Module
Coriolis force operator for 3-D Arakawa C-grids.
Applies the same horizontal Coriolis stencil as :class:Coriolis2D
independently at each z-level. The Coriolis parameter f is 2-D
(depth-independent) and broadcast over all z-levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
CartesianGrid3D
|
The underlying 3-D grid. |
required |
mask
|
Mask3D or None
|
Optional land/ocean mask. Pattern A (post-compute) — the
inner :class: Takes a :class: |
None
|
Examples:
>>> import jax.numpy as jnp
>>> from finitevolx import CartesianGrid3D, Coriolis3D
>>> grid = CartesianGrid3D.from_interior(6, 6, 4, 1.0, 1.0, 1.0)
>>> cor = Coriolis3D(grid=grid)
>>> u = jnp.zeros((grid.Nz, grid.Ny, grid.Nx))
>>> v = jnp.ones((grid.Nz, grid.Ny, grid.Nx))
>>> f = jnp.ones((grid.Ny, grid.Nx))
>>> du_cor, dv_cor = cor(u, v, f)
Source code in finitevolx/_src/operators/coriolis.py
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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__call__(u, v, f)
Coriolis tendencies over all z-levels.
du_cor[k, j, i+1/2] = +avg_y(f_X * avg_x(v[k])) dv_cor[k, j+1/2, i] = -avg_x(f_X * avg_y(u[k]))
(the energy-conserving form of :class:Coriolis2D at each level)
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 |
f
|
Float[Array, 'Ny Nx']
|
Coriolis parameter at T-points (depth-independent). |
required |
Returns:
| Type | Description |
|---|---|
tuple[Float[Array, 'Nz Ny Nx'], Float[Array, 'Nz Ny Nx']]
|
|