Description
Thanks for this great package! This is more a discussion/question than an issue.
With Oceananigans.jl v0.89 a seawater_density
function was added.
In my own work, one way I used this was to calculate the gravitational potential energy as a KernelFunctionOperation
during a simulation
using Oceananigans: Models.seawater_density
@inline function potential_energy(model)
grid = model.grid
ρ = seawater_density(model)
Z = Oceananigans.Models.model_geopotential_height(model)
g = tuple(model.buoyancy.model.gravitational_acceleration)
return KernelFunctionOperation{Center, Center, Center}(Ep, grid, ρ, Z, g)
end
@inline Ep(i, j, k, grid, ρ, Z, g) = g[1] * ρ[i, j, k] * Z[i, j, k]
The volume integral of this can then be saved during a simulation
Eₚ = potential_energy(model)
∫Eₚ = Integral(Eₚ)
This is a bit rough around the edges but if it is something that you think would fit in to this package let me know and I can tidy it up and add some tests. No problem at all if you think this package is not the place for it though!
My goal with this was to calculate the LHS terms in the energy budget for a closed system using equations (21), (22), (23) from Winters et al. (1995), your KineticEnergy
function and the above potential energy function. One thing I could not quite get to work was calculating a background state for the potential energy (equation (22)) which depends on a resorting and scalar indexing on GPU's. Being able to calculate the energy budget like in Winters et al. (1995) would be a neat functionality though!