zoomy_core.symbolic.primitives_basis module

zoomy_core.symbolic.primitives_basis module#

Basis-projection primitives: the only place we evaluate kernel(ζ̂) dζ̂ for ζ̂ ∈ [0, 1] with kernel containing opaque phi_* calls.

Decomposes the legacy ProjectBasisIntegrals (ins_generator.py:2188) 3-pass operation into separable primitives:

  • canonicalize_phi_derivative_subs() — rewrite Subs(Derivative(phi(ξ), ξ), ξ, val) Derivative(phi(val), val). Pure xreplace; no math change, just normalisation of the chain-rule artifact sympy emits when basis arguments substitute.

  • project_basis_integrand() — for each Integral(kernel, (ζ̂, 0, 1)) whose kernel contains a phi_* call, look up via BasisIntegralCache and substitute the polynomial result.

The legacy operation also bundled zoomy_core.symbolic.primitives_canonical.split_integral_over_add() between Pass 1 and Pass 3, plus an end-of-pipeline Subs.doit() walk (ins_generator.py:2319). The redesigned recipe asks the caller to invoke those primitives explicitly.

zoomy_core.symbolic.primitives_basis.canonicalize_phi_derivative_subs(expr)#

Subs(Derivative(phi_k(ξ), ξ), ξ, val) Derivative(phi_k(val), val).

The chain-rule artefact sympy creates when a phi_k(arg) is substituted into a Derivative context. Recanonicalising as a plain Derivative(phi_k(val), val) makes the pattern visible to downstream basis-cache lookups.

Lifted verbatim from ProjectBasisIntegrals._canon (ins_generator.py:2236). Pure xreplace — no math change.

zoomy_core.symbolic.primitives_basis.project_basis_integrand(expr, basis_cache)#

Look up every Integral(kernel, (ζ̂, 0, 1)) whose kernel contains a phi_* call in the given basis_cache and substitute the polynomial result.

Single-pass: walks the expression once, replacing each matching Integral in place. Outer factors are pulled out structurally: integrand factors that don’t reference the integration variable become an outer coefficient; the rest is the kernel handed to the cache.

Lifted from the Pass-3 _map of ProjectBasisIntegrals (ins_generator.py:2282), with the surrounding fixpoint loop (lines 2339-2344) removed — the caller is expected to compose this primitive with canonicalize_phi_derivative_subs() and zoomy_core.symbolic.primitives_canonical.un_subs() for any boundary-Subs resolution.

zoomy_core.symbolic.primitives_basis.has_phi_call(e)#

True iff e contains any phi_* function call.