Skip to content

Refactor state handling and model builder

This is a complete overhaul of the internal state handling system in LandModel.

The main goal was to decouple discretized ("on grid") state variables from the stratigraphy.

Grid variables are now stored and handled separately, allowing for more flexibility in modifying the stratigraphy mid-simulation.

Most notably, layer boundaries are now fully treated as parameters which can be tuned without rebuilding/recompiling the model.

While dynamic grid/stratigraphies are still not directly supported, this new state system provides a better basis for providing this functionality in the future.

There are only a handful of user-facing changes in this PR. Almost everything is internal. However, noteworthy changes include:

  • States passed to layer/process methods are now of type LayerState rather than NamedTuple, and include a type parameter specifying in-place vs out-of-place. This will be used in the future.
  • The z field on LayerState now contains both the upper and lower bounds of the stratigraphy component, not just the upper bound.
  • CryoGridOutput (and also internal state caches) no longer store on-grid variables by layer name. They are exposed as top-level variables. So instead of out.layer.T for temperature, one would now simply reference out.T. Obtaining a slice of the state variable containing only the grid cells in the given stratigraphy component must be done manually for now, though convenience methods will be added in the future.

Merge request reports