CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
999 stars 196 forks source link

`cell_diffusion_timescale` is not defined for `CATKEVerticalDiffusivity` #3772

Open ali-ramadhan opened 2 months ago

ali-ramadhan commented 2 months ago

Based on

https://github.com/CliMA/Oceananigans.jl/blob/2e4ba6b36bf012d5dcb89ddc7160a10f774aadbe/src/TurbulenceClosures/turbulence_closure_diagnostics.jl#L67-L69

CATKE should also have an infinite cell diffusion timescale with the default implicit time discretization.

When CATKE is run with explicit time discretization I suppose the cell diffusion timescale should be computed from the maximum viscosity/diffusivity in model.diffusivity_fields.

Happy to add these cell_diffusion_timescale methods.

I know CATKEVerticalDiffusivity is not exported so I'm just opening the issue to document.


MWE:

using Oceananigans
using Oceananigans.TurbulenceClosures: CATKEVerticalDiffusivity

grid = RectilinearGrid(size=(12, 12, 12), extent=(1, 1, 1))
closure = CATKEVerticalDiffusivity()
buoyancy = SeawaterBuoyancy()
tracers = (:T, :S, :e)

model = HydrostaticFreeSurfaceModel(; grid, closure, buoyancy, tracers)

DiffusiveCFL(1.23)(model)

Error:

ERROR: MethodError: no method matching cell_diffusion_timescale(::CATKEVerticalDiffusivity{…}, ::@NamedTuple{…}, ::RectilinearGrid{…})

Closest candidates are:
  cell_diffusion_timescale(::Nothing, ::Any, ::Any)
   @ Oceananigans ~/atdepth/Oceananigans.jl/src/TurbulenceClosures/turbulence_closure_diagnostics.jl:22
  cell_diffusion_timescale(::ScalarBiharmonicDiffusivity{Dir}, ::Any, ::Any) where Dir
   @ Oceananigans ~/atdepth/Oceananigans.jl/src/TurbulenceClosures/turbulence_closure_diagnostics.jl:40
  cell_diffusion_timescale(::SmagorinskyLilly, ::Any, ::Any)
   @ Oceananigans ~/atdepth/Oceananigans.jl/src/TurbulenceClosures/turbulence_closure_diagnostics.jl:47
  ...

Stacktrace:
 [1] cell_diffusion_timescale(model::HydrostaticFreeSurfaceModel{…})
   @ Oceananigans.TurbulenceClosures ~/atdepth/Oceananigans.jl/src/TurbulenceClosures/turbulence_closure_diagnostics.jl:21
 [2] (::CFL{…})(model::HydrostaticFreeSurfaceModel{…})
   @ Oceananigans.Diagnostics ~/atdepth/Oceananigans.jl/src/Diagnostics/cfl.jl:25
 [3] top-level scope
   @ REPL[24]:1
Some type information was truncated. Use `show(err)` to see complete types.
glwagner commented 2 months ago

Honestly, I hadn't considered trying to run CATKE with explicit time-stepping! Yes, this is good to add.