CliMA / LESbrary.jl

📚Generating Oceananigans large eddy simulation (LES) data for calibrating parameterizations
MIT License
28 stars 10 forks source link

Diagnosing terms in the turbulent kinetic energy budget #25

Open glwagner opened 3 years ago

glwagner commented 3 years ago

We'd like the ability to diagnose terms in the turbulent kinetic energy budget and, in particular, to average them in the horizontal and in time and then output them. In light of the current limitation that AveragedFields cannot be used in AbstractOperations on the GPU, this requires hand-writing kernels that calculate each term.

The horizontally-averaged turbulent kinetic energy budget is summarized in the docstring for the function turbulent_kinetic_energy_budget (note this function currently attempts to use AbstractOperations to diagnose these terms, which only works on the CPU as noted above):

The turbulent kinetic energy equation is

`` ∂_t E = - ∂_z ⟨w′e′ + w′p′⟩ - ⟨w′u′⟩ ∂_z U - ⟨w′v′⟩ ∂_z V + ⟨w′b′⟩ - ϵ ``,

where uppercase variables denote a horizontal mean, and primed variables denote deviations from
the horizontal mean.

The terms on the right side of the turbulent kinetic energy equation and their correpsonding keys are

1. `:advective_flux_divergence`, ``∂_z ⟨w′e′⟩``
2. `:pressure_flux_divergence`, ``∂_z ⟨w′p′⟩``
3. `:shear_production`, ``⟨w′u′⟩ ∂_z U``
4. `:buoyancy_flux`, ``⟨w′b′⟩``, where ``b`` is buoyancy
5. `:dissipation`, ``ϵ = ⟨2 νₑ Σᵢⱼ²⟩``, where ``νₑ`` is the subfilter eddy viscosity and ``Σᵢⱼ`` is the strain-rate tensor.

In addition, the return statistics `Dict` includes

6. `:advective_flux`, ``⟨w′e′⟩``
7. `:pressure_flux`, ``⟨w′p′⟩``
8. `:turbulent_kinetic_energy`, ``E = 1/2 (u′² + v′² + w′²)``

One puzzling question is whether the calculation of either the shear production term or the advective flux of turbulent kinetic energy requires considering the advection scheme being used for the simulations, or whether second-order approximations to the various derivatives is sufficient.

@qingli411, any insight?

cc @ali-ramadhan @BrodiePearson

qingli411 commented 3 years ago

@glwagner I think we will need to consider the advection scheme when computing the fluxes. In PALM, they compute the momentum and tracer fluxes in the advection step to make sure these fluxes are consistent with their advection scheme. But the advective flux of TKE is diagnosed from the velocity field. I'm not sure if that was the reason I cannot close the TKE budget from these terms... I need to think about it.

glwagner commented 3 years ago

Hmm, that is definitely interesting. It is not hard to diagnose momentum fluxes using the native advection scheme (we just have to build objects similar to the one we've built for TurbulentKineticEnergy). I'll think of a way to do this without too much code. (EDIT: I opened an issue to discuss this at https://github.com/CliMA/Oceananigans.jl/issues/1073).

I have talked with @ali-ramadhan about building tools for diagnosing exact terms used in the tendency equations (so flux divergences, in addition to fluxes). @christophernhill may be interested in this conversation as well. I think we can design a special field type for this purpose.

For second-order centered advection, the naive flux computations are consistent with the advection scheme. Also, second-order centered advection discretely conserves kinetic energy. So with a second-order advection scheme it should be possible to completely close the TKE budget.

For higher-order advection numerical diffusion can play a role. Presumably we have to consider the discrete variance budget. I'd imagine there are references we might read about this tricky subject...

glwagner commented 3 years ago

@qingli411 are you attempting to close the TKE budget pointwise, or just in the horizontal average?

Perhaps one place to start (before evaluating the TKE budget) is to simply try to evaluate the relative magnitude of numerical dissipation in these simulations.

I wonder what the best way to evaluate this is. One possibility is to develop a volume-integrated measure by which we can compare the predicted or explicit dissipation rate (for each variance individually) with the measured dissipation rate. Measuring the dissipation rate seems a bit challenging through --- for this we need to evaluate c^2 (for example) in adjacent time-steps?

qingli411 commented 3 years ago

@glwagner I've been looking at the horizontal average so far, but a pointwise budge, which perhaps makes more sense to the tracer and momentum budget, may also be useful. Maybe we can have a way to output different tendency terms in the tracer and momentum equations.

I guess we can look at a pure advection case versus a case with both advection and explicit diffusion to evaluate the relative magnitude of numerical dissipation?

glwagner commented 3 years ago

I guess we can look at a pure advection case versus a case with both advection and explicit diffusion to evaluate the relative magnitude of numerical dissipation?

I think that would be interesting, especially for LES. We can turn diffusivities off by setting closure = nothing in Oceananigans.

Another way to decrease numerical dissipation in principle is to decrease resolution. Perhaps studying how the budget depends on resolution will yield insight...

I think there should also be a way to explicitly evaluate how much numerical dissipation is occurring. @sandreza ideas?

I'll ping this issue when I have some results.