zoomy_core.numerics package#
Numerical sibling of the symbolic zoomy_core.model layer.
This subpackage holds the numerical setup that the FV / JAX solvers
consume. The central type is NumericalSystemModel, a wrapper
around a zoomy_core.model.models.system_model.SystemModel that
also carries the Riemann-solver class, the LSQ reconstruction spec, the
diffusion scheme, and numerical regularization knobs.
Pipeline: Model → SystemModel → NumericalSystemModel → Solver
- class zoomy_core.numerics.DiffusionSpec(enabled=True, scheme='crank_nicolson', nu=None)#
Bases:
objectDiffusion / viscous-flux configuration.
enabledis honoured by the solver; it is auto-set to False inNumericalSystemModel.from_system_model()when the SystemModel’sdiffusion_matrixis identically zero.nuoverrides the value pulled fromsm.parameter_values['nu'].- Parameters:
enabled (bool) –
scheme (str) –
nu (Optional[float]) –
- enabled: bool = True#
- scheme: str = 'crank_nicolson'#
- nu: Optional[float] = None#
- class zoomy_core.numerics.NumericalSystemModel(sm, riemann=None, reconstruction=<factory>, diffusion=<factory>, regularization=<factory>, source_derivative_specs=None, additional_systems=<factory>, scaled_q_indices=None)#
Bases:
objectNumerical sibling of
SystemModel.Always constructed via
from_system_model(). Direct instantiation is allowed (for tests, manual overrides) but the classmethod is the documented entry point.- Parameters:
sm (SystemModel) –
riemann (Optional[Type[Any]]) –
reconstruction (ReconstructionSpec) –
diffusion (DiffusionSpec) –
regularization (RegularizationSpec) –
source_derivative_specs (Optional[list]) –
additional_systems (list) –
scaled_q_indices (Optional[list]) –
- sm: SystemModel#
- riemann: Optional[Type[Any]] = None#
- reconstruction: ReconstructionSpec#
- diffusion: DiffusionSpec#
- regularization: RegularizationSpec#
- source_derivative_specs: Optional[list] = None#
- additional_systems: list#
- scaled_q_indices: Optional[list] = None#
- classmethod from_system_model(sm, *, riemann=None, reconstruction=None, diffusion=None, regularization=None, additional_systems=None, scaled_q_indices=None)#
Build an NSM from a
SystemModel(or aModel, auto-promoted viaSystemModel.from_model()).- Defaults:
riemann→NonconservativeRusanovreconstruction→ first-order constantdiffusion→ enabled if the SystemModel carries a non-zerodiffusion_matrixand a positivenu; otherwise disabled.regularization→eigenvalue_eps=1e-8
LSQ polynomial degree is always auto-derived (from
sm.aux_registryplus anyadditional_systems) — it is no longer a hand-adjustable knob. Composite solvers passadditional_systems=[sm_press, sm_corr, ...]so the predictor’s mesh stencil is large enough for the co-running sub-systems’ derivatives.- Parameters:
reconstruction (Optional[ReconstructionSpec]) –
diffusion (Optional[DiffusionSpec]) –
regularization (Optional[RegularizationSpec]) –
additional_systems (Optional[list]) –
scaled_q_indices (Optional[list]) –
- Return type:
- resolved_lsq_degree()#
Return the LSQ polynomial degree the mesh should use.
Computed as the max spatial-derivative order across:
self.sm.aux_registry(every SystemModel carries this, populated bySystemModel.from_model()),every entry in
self.additional_systems(composite sub-systems that share the same mesh; bothaux_registryandderivative_specsare consulted — entries may be either Models or SystemModels), andself.source_derivative_specs(captured at promotion when the source was aStructuredDerivativeModel, whoseD.dxx(...)calls are substituted by Symbols beforeSystemModel.from_modelruns — so the source-side declaration is the only signal that survives).
Falls back to 1 when no signal exists. Never user-set.
- Return type:
int
- build_numerics()#
Instantiate the symbolic Riemann numerics over
sm.Threads
self.scaled_q_indicesinto the Riemann constructor when set — the Audusse-HR variants (PositiveRusanovfamily) use it to control which state rows are rescaled byh*/hat face states. Default (None) lets the Riemann class fall back to its own heuristic (excluding onlyhandb).
- build_runtime_numpy()#
Lambdify
sminto a runtime model the NumPy solvers consume (callable.flux/.source/.eigenvalues/.boundary_conditionsetc.).
- class zoomy_core.numerics.ReconstructionSpec(order=1, limiter='venkatakrishnan', free_surface_aware=False)#
Bases:
objectNumerical face-state reconstruction configuration.
order: 1 = piecewise-constant; 2 = LSQ-MUSCL withlimiter.free_surface_aware: when True, use the wet-dry-aware MUSCL variant (clampsh ≥ 0at faces, falls back to first order in dry cells).- Parameters:
order (int) –
limiter (str) –
free_surface_aware (bool) –
- order: int = 1#
- limiter: str = 'venkatakrishnan'#
- free_surface_aware: bool = False#
- class zoomy_core.numerics.RegularizationSpec(eigenvalue_eps=1e-08)#
Bases:
objectNumerical regularization knobs.
eigenvalue_epsis added to the diagonal of the local quasi-linear matrix before eigenvalue decomposition in the numerical-eigenvalue path; without it, dry/near-dry SWE cells yieldA·nmatrices with repeated zero eigenvalues and the LAPACK eigensolve can spike spurious large modes.- Parameters:
eigenvalue_eps (float) –
- eigenvalue_eps: float = 1e-08#