zoomy_core.model.models.sme module

zoomy_core.model.models.sme module#

SME — Shallow Moment Equations (Kowalski–Torrilhon 2019).

Inherits SigmaReference (which gives the σ-mapped INS reference + KBCs), and extends derive_model with the full SME post-σ pipeline: modal ansatz, Galerkin projection, σ-integration, KBC modal closure, CoV u q/h, opaque-basis resolution, integral evaluation, gravity self-pair fold, higher-mode w closure, mass-matrix inversion.

After derive_model finishes, the equations are in Symbol form (self.variables.h, self.variables.q_0, ) and self._variable_map maps equation names to row indices in the operator-API matrices. SystemModel.from_model(sme) then extracts flux / source / nonconservative_matrix via the basemodel default tag-extraction.

Output equation set matches K&T (4.17).

class zoomy_core.model.models.sme.SME(N=2, *, basis_factory=None, **kwargs)#

Bases: SigmaReference

Shallow Moment Equations at level N.

Default N = 2 matches K&T (4.17): 4 dynamic equations (continuity_0 for h, momentum_x_0..2 for q_0..q_2).

Parameters:
  • N (int) – Per-layer moment level — number of u-modes is N + 1.

  • basis_factory (callable, optional) – basis_factory(level) Basisfunction. Used to construct the u-basis (level N) and the w-basis (level N + 1). Default: Legendre_shifted(level=level). Subclasses such as MLSME swap this for a multi-layer basis (LayeredBasis) without touching the pipeline.

derive_model()#

Build reference equations (via SigmaReference) and run the SME post-σ pipeline. Equations are left in Function form (h(t, x), q_fn(k, t, x)) so optional closures can manipulate them; the Function → Symbol substitution happens in _prepare_for_systemmodel (called automatically by SystemModel.from_model).

project_2d_to_3d()#

Reconstruct the 3D fields (b, h, u, v, w, p) at position self.position[2] = z from the SME modal solution.

Returns a sympy Matrix([b, h, u_3d, v_3d, w_3d, p_3d]).

  • u_3d(t, x, z) = Σ_k (q_k / h) · φ_k(σ) with σ = (z b) / h.

  • v_3d = 0 (SME is 1D-x; multi-D needs the corresponding q_y_k modes — TODO).

  • w_3d reconstructed from depth-integrated continuity ∂_z w = −∂_x u_3d, with w(z = b) = ∂_t b + u(b)·∂_x b.

  • p_3d = ρ · g · z) (hydrostatic — SME’s defining assumption).

apply_slip_newton_friction()#

Close the open τ_xz BC + Integral atoms with the slip-Newton constitutive law.

Substitutions per K&T 2019 §4.3:
  • Newtonian bulk: τ_xz(σ) = (ν/h) · ∂_σ u(σ);

  • Free-surface BC: τ_xz(σ=1) = 0;

  • Navier-slip bottom BC: τ_xz(σ=0) = (ν/λ) · u(σ=0).

Reads ν, λ from the Model’s parameters Zstruct — the caller must declare them at construction:

sme = SME(N=2, parameters={

“g”: 9.81, “rho”: 1.0, “nu”: 1e-3, “lambda”: 1e-2,

}, …) sme.apply_slip_newton_friction()

After this call, the equations carry algebraic friction terms in ν, λ, ρ instead of unresolved Integral(τ_xz, …) atoms. Tags are re-computed; SystemModel.from_model picks up the closed source.

history: list#