CliMA / LESbrary.jl

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

Utility function for diagnosing buoyancy flux for convection simulations from the buoyancy content of the column #111

Closed ali-ramadhan closed 3 years ago

ali-ramadhan commented 3 years ago

This PR adds a util diagnose_buoyancy_flux that returns the buoyancy flux (m²/s³) required to extract all the buoyancy from a 1D buoyancy profile b(z) down to some z-coordinate depth (< 0) over a time_period τ (seconds) by integrating the buoyancy profile and converting the integrated buoyancy content to an equivalent buoyancy flux:

          1  ⌠ z_surface
    Qb = --- |           [b(z) - b(depth)] dz
          τ  ⌡ depth

This should be useful for setting up simulations where you only want the mixed layer to deepen to some depth (e.g. H/2) over some amount of time (e.g. 8 days), especially when the buoyancy profile is not constant (e.g. piecewise linear or cubic).

Might be overkill for the simulation suite that @adelinehillier has set up, but I'm hoping to use it to set up simulations for training neural differential equations.

I also added a test to make sure it agrees with the "empirical law of convection" described in Souza et al. (2020), equation (4).

PS: This PR also moves interpolated_profiles.jl from RealisticLESbrary.jl into LESbrary.jl.

glwagner commented 3 years ago

What's RealisticLESbrary.jl?

glwagner commented 3 years ago

This won't work when there's mixing at the base of the boundary layer, right?

ali-ramadhan commented 3 years ago

What's RealisticLESbrary.jl?

https://github.com/CliMA/LESbrary.jl/tree/master/realistic/src

It's a module which contains useful utils for SOSE/ECCO LESbrary simulations

Probably should have just said the RealisticLESbrary module.

This won't work when there's mixing at the base of the boundary layer, right?

The intention is to use diagnose_buoyancy_flux (we probably need a better name) on the initial condition to figure out what constant buoyancy flux to use if you e.g. want the mixed layer to only deepen to half the domain height.

I think it should work even if the buoyancy profile is unstable above z_depth but if it's unstable below z_depth then the answer will be wrong.

The answer is not fully correct (it doesn't account for entrainment) but should give a good estimate for what buoyancy flux to use. If you really don't want the mixed layer to deepen beyond z = -0.5H then you can compute the buoyancy flux that would cause the mixed layer to (naively) deepen to z = -0.4H.

glwagner commented 3 years ago

The answer is not fully correct (it doesn't account for entrainment) but should give a good estimate for what buoyancy flux to use. If you really don't want the mixed layer to deepen beyond z = -0.5H then you can compute the buoyancy flux that would cause the mixed layer to (naively) deepen to z = -0.4H.

Maybe call it an "estimate" or "scaling law". It has a systematic high bias of 20% or more, as you've pointed out. It might be confusing to people who expect entrainment to matter because they might think we've figured out some magical way to calculate this number, or that you're somehow accounting for entrainment...

A more accurate way to arrive at this number might be to run a mixed layer model, but that's a bit more work.

ali-ramadhan commented 3 years ago

Maybe call it an "estimate" or "scaling law". It has a systematic high bias of 20% or more, as you've pointed out. It's confusing to people who expect entrainment to matter because they might think we've figured out some magical way to calculate this number.

True. Should be clear from the integral in the docstring but I can make the point more explicit. How about estimate_buoyancy_flux_for_convection?

A more accurate way to arrive at this number might be to run a mixed layer model, but that's a bit more work.

Yes. I considered it but since this is just a way to setup simulations in a simple consistent matter I didn't want to have to describe/cite e.g. KPP, the parameters I used, the mixed layer depth diagnostic chosen, etc. when I write up this work. I still have to describe this estimate_buoyancy_flux_for_convection process but should only take a couple of lines and one equation.

glwagner commented 3 years ago

estimate_target_convective_buoyancy_flux? (To imply what it'll be used for). But your proposal is good too

glwagner commented 3 years ago

For this particular thing I don't think you need to fully describe KPP to use it to estimate buoyancy flux. Just reporting the buoyancy fluxes that were used is good (eg you could also just "guess"). We aren't giving a full description of LLVM either!

ali-ramadhan commented 3 years ago

Just reporting the buoyancy fluxes that were used is good (eg you could also just "guess"). We aren't giving a full description of LLVM either!

I guess I'm a little uncomfortable guessing and putting down what might feel like magic numbers (to me at least). I'd like to give some context as to how I decided on the buoyancy fluxes. Guessing or trial and error here feels a little too hand-wavy (again, might be me that feels this way).

This also helps with scientific reproducibility in case someone wants to investigate further by generating more data. It's also a nice methodology for generating suites of simulations for training data.

glwagner commented 3 years ago

Agree, if you can describe a simple approach for estimating buoyancy flux for generating datasets that can be independently implemented in another code, that's potentially helpful.

Trial and error is a perfectly legitimate method though!

ali-ramadhan commented 3 years ago

Trial and error is a perfectly legitimate method though!

For sure, although I'm not sure how many simulations I need to run yet so if it turns out to be 10+ then trial and error could take a while.

glwagner commented 3 years ago

Ah yeah. But the relationship between Q and tau is linear for the known empirical relationships, so I think once you have one estimate for a given buoyancy profile you might be able to estimate Q for any Tau for that profile, I think? The advantage of that approach is that you can take into account entrainment.

ali-ramadhan commented 3 years ago

so I think once you have one estimate for a given buoyancy profile you might be able to estimate Q for any Tau for that profile, I think?

True but I'm planning to vary both the buoyancy flux and initial buoyancy profile to make sure the NDE can generalize to different stratifications.