zoomy_core.model.kernel_functions

zoomy_core.model.kernel_functions#

Opaque SymPy functions (eigensystem, solve, pick, conditional, …) that every backend realises numerically. Each kernel must be registered in the backend’s function table (NumPy, JAX, C).

Module Contents#

Classes#

eigensystem

Opaque full eigendecomposition [lambda, R, L=R^-1] of the row-major n*n matrix A_flat, packed in one vector. Components are read through pick(eigensystem(*a), idx); used by the Roe scheme.

spectral_radius

Opaque estimate of rho(A) by k power-iteration steps on A^2 (no eigendecomposition, runs on any device). Used as the wave-speed bound of the symbolic solvers.

eigenvalues

Opaque eigenvalue-only spectrum of the row-major n*n matrix A_flat, read through pick(eigenvalues(*a), idx). Cheaper companion of eigensystem for wave-speed bounds when no closed-form spectrum exists.

solve

Opaque per-cell linear solve A^-1 b, called as solve(*A_flat, *b_flat) and read through pick(solve(*a), idx). Used by the point-implicit source treatment of the NumericalSystemModel.

pick

Component idx of a packed opaque-kernel result (eigensystem, eigenvalues, solve). Per-component backends restore K(idx, *a) through lower_pick_to_component.

compute_derivative

Opaque non-local spatial derivative compute_derivative(field, *multi_index); (h, 1, 0) is d h / d x. The solver injects the backend’s LSQ-gradient implementation; it is emitted by expose_aux into update_aux_variables.

conditional

Vector-aware differentiable conditional(c, t, f): a symbolic node for scalars, a ZArray of nodes for vector branches. Differentiation follows the active branch and ignores the jump at the condition.

Functions#

lower_pick_to_component

Rewrite pick(K(*a), idx) into the per-component form K(idx, *a) required by the C/C++ and UFL printers.

Data#

API#

class zoomy_core.model.kernel_functions.eigensystem#

Bases: sympy.Function

Opaque full eigendecomposition [lambda, R, L=R^-1] of the row-major n*n matrix A_flat, packed in one vector. Components are read through pick(eigensystem(*a), idx); used by the Roe scheme.

Args

  • A_flat: the n*n matrix entries, row-major.

is_commutative#

True

is_real#

True

classmethod eval(*args)#

Keep the call unevaluated.

class zoomy_core.model.kernel_functions.spectral_radius#

Bases: sympy.Function

Opaque estimate of rho(A) by k power-iteration steps on A^2 (no eigendecomposition, runs on any device). Used as the wave-speed bound of the symbolic solvers.

Args

  • k: number of power-iteration steps.

  • safety: multiplicative safety factor on the estimate.

  • A_flat: the n*n matrix entries, row-major.

References

  • Golub & Van Loan 2013, https://doi.org/10.56021/9781421407944

is_commutative#

True

is_real#

True

classmethod eval(*args)#

Keep the call unevaluated.

class zoomy_core.model.kernel_functions.eigenvalues#

Bases: sympy.Function

Opaque eigenvalue-only spectrum of the row-major n*n matrix A_flat, read through pick(eigenvalues(*a), idx). Cheaper companion of eigensystem for wave-speed bounds when no closed-form spectrum exists.

is_commutative#

True

is_real#

True

classmethod eval(*args)#

Keep the call unevaluated.

class zoomy_core.model.kernel_functions.solve#

Bases: sympy.Function

Opaque per-cell linear solve A^-1 b, called as solve(*A_flat, *b_flat) and read through pick(solve(*a), idx). Used by the point-implicit source treatment of the NumericalSystemModel.

is_commutative#

True

is_real#

True

classmethod eval(*args)#

Keep the call unevaluated.

class zoomy_core.model.kernel_functions.pick#

Bases: sympy.Function

Component idx of a packed opaque-kernel result (eigensystem, eigenvalues, solve). Per-component backends restore K(idx, *a) through lower_pick_to_component.

is_commutative#

True

is_real#

True

classmethod eval(*args)#

Keep the call unevaluated.

zoomy_core.model.kernel_functions.lower_pick_to_component(expr)#

Rewrite pick(K(*a), idx) into the per-component form K(idx, *a) required by the C/C++ and UFL printers.

Returns

The expression (or array/matrix) with every pick of a per-component kernel swapped structurally.

class zoomy_core.model.kernel_functions.compute_derivative#

Bases: sympy.Function

Opaque non-local spatial derivative compute_derivative(field, *multi_index); (h, 1, 0) is d h / d x. The solver injects the backend’s LSQ-gradient implementation; it is emitted by expose_aux into update_aux_variables.

is_commutative#

True

is_real#

True

classmethod eval(*args)#

Keep the call unevaluated.

class zoomy_core.model.kernel_functions.conditional#

Bases: sympy.Function

Vector-aware differentiable conditional(c, t, f): a symbolic node for scalars, a ZArray of nodes for vector branches. Differentiation follows the active branch and ignores the jump at the condition.

nargs#

3

is_commutative#

True

zoomy_core.model.kernel_functions.REQUIRED_KERNELS#

‘frozenset(…)’