ClimaOcean.jl icon indicating copy to clipboard operation
ClimaOcean.jl copied to clipboard

Handling active and passive tracers in `ocean_simulation`

Open simone-silvestri opened this issue 6 months ago • 8 comments

PR #123 introduces a keyword argument tracers to pass to ocean_simulation. There are some nuances in passing this keyword argument that would be nice to discuss. In particular, the decision is how are we handling active and passive tracers, or in general handling tracers that are required for different modeling choices. These include:

  • :T and :S for density calculation
  • :e for CATKE vertical parameterization
  • biogeochemical tracers for biogeochemistry
  • other active tracers
  • other passive tracers

For the moment, active tracers :T and :S are assumed to be required, and, they are "silently" added if missing from the tracers keyword argument. The same happens if using CATKE: the :e tracer is "silently" added. The main issue brought up using this method is that we want to be "explicit" in what tracers are being passed to the simulation and that tracers should include all tracers. We could have other options:

Option one

add a tracers kwargs in ocean_simulation that defaults to (:T, :S, :e) if no tracers are specified. This has the advantage of being explicit (most of the times) but the disadvantage of leading to "awkward" scripting outcomes. An example is writing an ocean simulation without biogeochemistry

ocean = ocean_simulation(grid)

and having to modify the script as

ocean = ocean_simulation(grid; biogeochemistry, tracers = (:T, :S, :e, biogeochemical_tracers...))

when adding biogeochemistry. i.e. adding biogeochemistry requires a seemingly unrelated change to the arguments of ocean_simulation: adding T, S, and e as tracers that were not required before. The deficiencies here are that the tracers are sometimes explicit and sometimes implied. In my opinion this leaves us in a weird "in-between" situation that probably requires users to hit an argument error before understanding that :T and :S have to be explicitly included when adding seemingly unrelated arguments.

Option two

add a tracers kwarg in ocean_simulation without any defaults. This is the most "explicit" option for users and also probably the cleanest solution. The downside here is that boundary conditions are specified automatically for :T and :S and not for other tracers, but that is what we also do with :e in Oceananigans.

Option three

Add a user_defined_tracers kwarg where users add all the passive tracers they want and automatically add the required tracers inside the ocean_simulation (i.e. check the buoyancy model and biogeochemistry model and make sure all required tracers are added). The main downside of this option is that users could specify reserved tracer names :T and :S or :e as arguments and this option is also less explicit.

Let me know what you think. I would rank the options as 3 -> 2 -> 1 but I m open to different solutions

simone-silvestri avatar Aug 12 '24 20:08 simone-silvestri