zoomy_core.systemmodel.operations#
Reusable SystemModel.apply operations (op(sm) callables) that rewrite operator slots:
aux registration, 1/h regularization, eigenvalue guards.
They run on the way from SystemModel to NumericalSystemModel; sweeping operations cover
every slot of OPERATOR_SLOTS unless a slot is explicitly excluded.
Module Contents#
Functions#
Apply |
|
Operation: impose |
|
Kurganov-Petrova desingularized inverse depth |
|
Operation: add the algebraic aux variable |
|
The |
|
Operation: replace every |
|
Operation: multiply each algebraic (zero mass-matrix) row by the minimal power of |
|
Operation: register the |
|
Operation: derive the closed-form spectrum of the normal-projected quasilinear matrix into
|
|
Operation: substitute the Kurganov-Petrova reciprocal inline for every |
|
Operation: register the aux |
|
Operation: replace the base of each negative or fractional power in the source that
involves a |
|
Operation: wrap every fractional power of the depth in |
|
The dt spectrum of a system without closed-form eigenvalues, shape |
|
Operation: publish |
|
Operation: publish a timestep-only spectrum |
|
Operation: shift the base of every fractional power by |
|
Operation (default, before the source linearization): every |
Data#
API#
- zoomy_core.systemmodel.operations.OPERATOR_SLOTS#
(‘flux’, ‘hydrostatic_pressure’, ‘nonconservative_matrix’, ‘source’, ‘source_explicit’, ‘mass_matrix…
- zoomy_core.systemmodel.operations.KERNEL_SLOTS#
(‘boundary_conditions’, ‘aux_boundary_conditions’, ‘boundary_gradients’)
- zoomy_core.systemmodel.operations.map_operator_slots(sm, rewrite, *, exclude=(), skip_rows=None) dict#
Apply
rewrite(expr) -> exprto every slot ofOPERATOR_SLOTSexceptexclude, freezing the lazyquasilinear_matrixfrom the clean primaries first.Args
exclude: slot names to leave alone; a name outsideOPERATOR_SLOTSraisesKeyError.skip_rows:{slot: rows}left untouched inside a swept slot.
Returns
{slot: "rewritten" | "unchanged" | "absent" | "excluded"}.
- zoomy_core.systemmodel.operations.normalize_face_normal(*, exclude=())#
Operation: impose
|n| = 1on every slot (default scopeOPERATOR_SLOTS), which separates the SWE celerity from the1/hof the momentum terms. It is aNumericalSystemModeldefault (normalize_normal=True).
- zoomy_core.systemmodel.operations.kp_hinv(h, eps)#
Kurganov-Petrova desingularized inverse depth
sqrt(2) h / sqrt(h^4 + max(h, eps)^4), equal to1/hforh >= epsand tending to 0 ash -> 0. The numerator is bareh(no clamp), so a negative depth gives a negativehinvand the failure stays visible.Args
h: depth, sympy expression or numpy/jax array.eps: regularization scale.
References
Kurganov, Petrova 2007, https://doi.org/10.4310/CMS.2007.v5.n1.a6
- zoomy_core.systemmodel.operations.register_aux(name: str, formula, **assumptions)#
Operation: add the algebraic aux variable
name = formulatoaux_stateandupdate_aux_variables(identity on existing rows) and refresh the derived operators.**assumptionsgo to the new Symbol (defaultreal=True).
- zoomy_core.systemmodel.operations.wave_speed_inverse_depth(h)#
The
1/hof every wave speed,1/max(1e-14, h), never the KPhinv: large but finite at a wet/dry front (REQ-82). Used byregularize_powand the numerical spectral radius.
- zoomy_core.systemmodel.operations.regularize_pow(field: Union[str, sympy.Symbol], aux_name: str)#
Operation: replace every
field**(-n)in the physical, derived and reconstruction operators byaux_name**n; eigenvalues get a floored plain1/max(1e-14, h)instead. The lazy derived operators are frozen from the clean primaries first, so the exactd(q^2/h)/dhterm survives the substitution.
- zoomy_core.systemmodel.operations.equilibrate_constraint_rows(mode=True)#
Operation: multiply each algebraic (zero mass-matrix) row by the minimal power of
hthat clears its negative powers ofh. This changes the conditioning of the elliptic block, not the constraint manifold, wherever ``h0``.
- zoomy_core.systemmodel.operations.desingularize_hinv(mode='kp')#
Operation: register the
hinvaux with the Kurganov-Petrova inverse depth (eps=wet_dry_eps) and rewrite everyh**(-n)tohinv**n;modeisTrueor"kp", falsy is a no-op. Legacy NSM depth default; the depth-law study usesregularize_depth_direct/regularize_depth_aux.References
Kurganov, Petrova 2007, https://doi.org/10.4310/CMS.2007.v5.n1.a6
- zoomy_core.systemmodel.operations.symbolic_spectrum()#
Operation: derive the closed-form spectrum of the normal-projected quasilinear matrix into
sm.eigenvalues; opt-in because it is expensive for high moment levels.
- zoomy_core.systemmodel.operations.regularize_depth_direct(eps=None, *, field: str = 'h', eigenvalues: str = 'regularize', exclude=())#
Operation: substitute the Kurganov-Petrova reciprocal inline for every
field**(-n)in every slot (the DIRECT path); no aux row is added. Mutually exclusive withregularize_depth_aux.Args
eps: regularization scale (notwet_dry_eps).eigenvalues:"regularize"sweeps the spectrum,"exclude"keeps the exact1/h.exclude: further slots to leave alone (opt out, never opt in).
References
Kurganov, Petrova 2007, https://doi.org/10.4310/CMS.2007.v5.n1.a6
- zoomy_core.systemmodel.operations.regularize_depth_aux(eps=None, *, name: str = 'hinv', field: str = 'h', eigenvalues: str = 'regularize', exclude=())#
Operation: register the aux
namewhose update row is the Kurganov-Petrova reciprocal and rewrite everyfield**(-n)toname**nin every slot (the AUX path). Mutually exclusive withregularize_depth_direct; takes the sameeps/eigenvalues/excludearguments, and the row definingnameis not rewritten.References
Kurganov, Petrova 2007, https://doi.org/10.4310/CMS.2007.v5.n1.a6
- zoomy_core.systemmodel.operations.desingularize_positivity(floor)#
Operation: replace the base of each negative or fractional power in the source that involves a
positive_statesymbol bysqrt(base**2 + floor**2)and re-derive the source Jacobians. A no-op if the model declares nopositive_state.
- zoomy_core.systemmodel.operations.guard_eigenvalue_powers()#
Operation: wrap every fractional power of the depth in
sm.eigenvaluesinMax(., 0)so wave speeds stay real at a transienth < 0(no dry zeroing). Half A of the guard/gate split;gate_eigenvalues_dryis half B.
- zoomy_core.systemmodel.operations.cfl_wave_speed_bound(sm, subs=None)#
The dt spectrum of a system without closed-form eigenvalues, shape
(n_eq, 1): the wave-speed bound ofA_nin the face’s normal frame (system_model.wave_speed_bound, the Riemann speeds’ bound) in row 0, zeros below (the consumers takemax |.|), or withSpectralRadius.eigthe numerical eigenvalues ofA_n;subsreplaces aux symbols first (the CFL inverse depth).
- zoomy_core.systemmodel.operations.bound_wave_speed()#
Operation: publish
cfl_wave_speed_boundintosm.eigenvalues_cflfor a system without closed-form eigenvalues whose dt spectrum no dry gate published (no depth, or nogateguard), so the cells rule takes the same bound as the Riemann speeds; a no-op with a closed form or a published dt spectrum.
- zoomy_core.systemmodel.operations.gate_eigenvalues_dry(eps=None)#
Operation: publish a timestep-only spectrum
conditional(h <= eps, 0, e)intosm.eigenvalues_cfl, leavingsm.eigenvaluesphysical (with its power guard) for the Riemann dissipation.epsdefaults to 0: a cell without water (h <= 0) has no wave speed, but every cell with h > 0 moves mass with its own velocity (the Audusse states keep it), so its speed bounds the step however thin it is (ANALYSIS 52). The dry gate carries the power guard because a branchless backend evaluates both arms; without a closed formeis the Riemann speeds’ bound (cfl_wave_speed_bound) ofA_nwithhinv->1/max(1e-14, h)(wave_speed_inverse_depth). Idempotent.
- zoomy_core.systemmodel.operations.regularize_fractional_powers(eps, *, exclude=())#
Operation: shift the base of every fractional power by
eps**2(b**r -> (b + eps**2)**r) so the operators stay differentiable atb = 0under AD. Opt-in and idempotent;epsmust be positive, and the value changes byO(eps**2)away fromb = 0.
- zoomy_core.systemmodel.operations.norm_derivative_at_zero()#
Operation (default, before the source linearization): every
S**rin the source slots withS >= 0a scaled squared Euclidean norm (_nonnegative) and rationalr >= 1/2not an integer (|u| = (u.u)**(1/2)of a friction law) becomesconditional(S > 0, conditional(S > 0, S, 1)**r, S): the same value, and the derivative 0 atS = 0(S has its minimum there,dS = 0) instead ofdS / (2 sqrt(S)) = 0/0= NaN. That is the derivative ofS**rforr > 1/2and the least-norm subgradient forr = 1/2; the Newton Jacobian of an implicit friction source (JAX: AD) and the point-implicitsource_jacobian_*stay finite at rest. No regularization: values are unchanged.