Skip to main content

Crate tpt_sci_ocean

Crate tpt_sci_ocean 

Source
Expand description

§tpt-sci-ocean

Ocean circulation modelling for the tpt-science pillar, built on tpt_sci_cfd_core. It provides:

  • A 2-D shallow-water model (ShallowWater) — the primitive prototype for large-scale circulation: free-surface height h plus depth-averaged velocities u, v, with gravity and Coriolis f. See the examples/ tour (cargo run --example shallow_water -p tpt-sci-ocean).
  • A 3-D z-level ocean core (Ocean3D) — a stack of nz layers with hydrostatic pressure from a linear equation of state, prognostic temperature/salinity tracers, constant-coefficient vertical mixing, and an optional non-hydrostatic pressure-correction (3-D Poisson projection solved with conjugate gradients on a structured grid). See cargo run --example ocean3d -p tpt-sci-ocean.
  • A data assimilation module (nudge, EnsembleKalmanFilter, Var3D) — nudging plus a stochastic EnKF and a 3D-Var-lite analysis.

This crate is reduced-order relative to a full 3-D primitive-equation ocean GCM, but closes out the hydrostatic, non-hydrostatic, and assimilation scope items.

§Example

use tpt_sci_ocean::ShallowWater;

// 64×64 basin, gravity g = 9.81, Coriolis f = 1e-4.
let mut sw = ShallowWater::new(64, 64, 1.0, 1.0, 9.81, 1e-4, 0.001);
// Perturb the free surface; it should evolve without blowing up.
sw.perturb_center(1.0);
for _ in 0..10 {
    sw.step(0.001);
}
assert!(sw.max_speed().is_finite());

Structs§

EnkfResult
Result of an EnsembleKalmanFilter::analyze step.
EnsembleKalmanFilter
A stochastic ensemble Kalman filter (EnKF).
Observation
A single sparse observation: a measured value at flat index, with an optional weight (default 1) scaling how strongly it nudges the state.
Ocean3D
A 3-D z-level ocean model on a uniform tensor-product grid.
ShallowWater
A 2-D shallow-water ocean model on a uniform grid.
Var3D
A 3D-Var-lite analysis with a diagonal background-error covariance.

Enums§

OceanError
Errors raised by the ocean model.

Functions§

nudge
Relax state toward the observations: for each Observation, state[index] ⟵ state[index] + coeff·dt·weight·(value − state[index]).