|
1 | 1 | @inline tracer_perturbationᶜᶜᶜ(i, j, k, grid, tracer, tracer_mean) = |
2 | 2 | tracer[i, j, k] - tracer_mean[i, j, k] |
3 | 3 | # Only needed for testing |
| 4 | +""" |
| 5 | + function tracer_perturbation(model, tracer) |
| 6 | +Calculate the perturbation of `tracer` from the spatial `tracer` mean. |
| 7 | +""" |
4 | 8 | @inline function tracer_perturbation(model, tracer) |
5 | 9 |
|
6 | 10 | grid = model.grid |
|
11 | 15 |
|
12 | 16 | @inline vtf(i, j, k, grid, tracer, tracer_mean, w) = |
13 | 17 | -ℑzᵃᵃᶜ(i, j, k, w) * tracer_perturbationᶜᶜᶜ(i, j, k, grid, tracer, tracer_mean) |
| 18 | +""" |
| 19 | + function vertical_tracer_flux(model, tracer) |
| 20 | +Calculate the vertical tracer flux of `tracer` from `model`. |
| 21 | +""" |
14 | 22 | @inline function vertical_tracer_flux(model, tracer) |
15 | 23 |
|
16 | 24 | grid = model.grid |
|
19 | 27 |
|
20 | 28 | return KernelFunctionOperation{Center, Center, Center}(vtf, grid, tracer, tracer_mean, w) |
21 | 29 | end |
| 30 | +""" |
| 31 | + function potential_energy(model) |
| 32 | +Calculate the potential energy |
| 33 | +```math |
| 34 | +Eₚ = g∫ᵥρzdV |
| 35 | +``` |
| 36 | +for `model` during a simulation. |
| 37 | +""" |
| 38 | +@inline function potential_energy(model) |
| 39 | + |
| 40 | + grid = model.grid |
| 41 | + ρ = seawater_density(model) |
| 42 | + Z = Oceananigans.Models.model_geopotential_height(model) |
| 43 | + g = tuple(model.buoyancy.model.gravitational_acceleration) |
| 44 | + |
| 45 | + return KernelFunctionOperation{Center, Center, Center}(Ep, grid, ρ, Z, g) |
| 46 | +end |
| 47 | +@inline Ep(i, j, k, grid, ρ, Z, g) = g[1] * ρ[i, j, k] * Z[i, j, k] |
0 commit comments