tomchor / Oceanostics.jl

Diagnostics for Oceananigans
https://tomchor.github.io/Oceanostics.jl/
MIT License
24 stars 8 forks source link

Mixed layer depth #79

Open iuryt opened 2 years ago

iuryt commented 2 years ago

I created a new package for biogeochemical models on Oceananigans and, with @glwagner help, I could create a function to estimate the mixed layer depth from a given buoyancy decrease criterium. Although this is working well for the purpose I had in mind, I believe that the mixed layer depth estimator could be better located in a more general repository. While discussing with @glwagner, he suggested me this repository.

We also had some ideas for improving the algorithm, like leaving for the user to define any general criterium for the mixed layer... even those which does not depend on the buoyancy? (but then it would be better called boundary layer? idk...).

What do you think about it and if you think this is a good match to this repo, where should I add it? I could first adapt the language and create a PR, adding it as it is and later create another issue for the enhancements.

glwagner commented 2 years ago

Food for thought to spark some creativity...

You could consider defining a new operand MixedLayerDepthOperand which is associated with compute! so that

const MixedLayerDepthField = Field{<:Any, <:Any, Nothing, <:MixedLayerDepthOperand}

function compute!(mld::MixedLayerDepthField)
    # code that computes this 2D field
end

the next component is to design the MixedLayerDepthOperand struct so that different criteria can be provided. Probably at the minimum you'd want to give it a buoyancy field and velocity fields. In addition, one design might ask for the entire @kernel function itself (with parameters?) eg

struct MixedLayerDepthOperand{B, U, K, P}
    buoyancy_field :: B 
    velocities :: U
    mixed_layer_depth_kernel :: K
    parameters :: P
end

Then the kernel could have a prescribed function signature (eg grid, b, u, v, w, parameters).

tomchor commented 2 years ago

I created a new package for biogeochemical models on Oceananigans and, with @glwagner help, I could create a function to estimate the mixed layer depth from a given buoyancy decrease criterium. Although this is working well for the purpose I had in mind, I believe that the mixed layer depth estimator could be better located in a more general repository. While discussing with @glwagner, he suggested me this repository.

We also had some ideas for improving the algorithm, like leaving for the user to define any general criterium for the mixed layer... even those which does not depend on the buoyancy? (but then it would be better called boundary layer? idk...).

What do you think about it and if you think this is a good match to this repo, where should I add it? I could first adapt the language and create a PR, adding it as it is and later create another issue for the enhancements.

Great start with Bioceananigans! I can definitely see a function like that being a part of this repo.

At the moment I think the best place for such an addition is in FlowDiagnostics. However, pretty much everything there is geared towards point-wise diagnostics (mostly because that's what I had in mind when I created the repo). So if there are plans to include more stuff of this nature it can also be productive to create something like a BulkDiagnostics module where these things could go. (I actually already have a background potential density calculation that would fit nicely there...)

Thoughts? Also, feel free to create a PR and we can try things out over there