Skip to content

Functional operators¤

phydrax.operators.spatial_inner_product(u: DomainFunction, v: DomainFunction, batch: PointsBatch | CoordSeparableBatch | tuple[PointsBatch, ...], /, *, component: DomainComponent | DomainComponentUnion, quadrature: QuadratureBatch | tuple[QuadratureBatch | None, ...] | None = None, over: str | tuple[str, ...] | None = 'x', key: Key[Array, ''] = jr.key(0), **kwargs: Any) -> cx.Field ¤

Estimate an \(L^2\)-type inner product.

Forms the pointwise Euclidean/Frobenius product and integrates:

\[ \langle u, v \rangle = \int_{\Omega} u(x)\cdot v(x)\,d\mu(x), \]

where u(x)·v(x) is implemented as sum(u * v) over the value dimensions. Domains are joined before evaluation.

Arguments:

  • u, v: Input DomainFunctions.
  • batch, component, quadrature, over, key, kwargs: As in spatial_mean.

Returns:

  • A coordax.Field containing the scalar inner product value.

phydrax.operators.spatial_l2_norm(u: DomainFunction, batch: PointsBatch | CoordSeparableBatch | tuple[PointsBatch, ...], /, *, component: DomainComponent | DomainComponentUnion, quadrature: QuadratureBatch | tuple[QuadratureBatch | None, ...] | None = None, over: str | tuple[str, ...] | None = 'x', key: Key[Array, ''] = jr.key(0), **kwargs: Any) -> cx.Field ¤

Estimate the \(L^2\) norm over space.

Equivalent to spatial_lp_norm(..., p=2).


phydrax.operators.spatial_lp_norm(u: DomainFunction, batch: PointsBatch | CoordSeparableBatch | tuple[PointsBatch, ...], /, *, p: float = 2.0, component: DomainComponent | DomainComponentUnion, quadrature: QuadratureBatch | tuple[QuadratureBatch | None, ...] | None = None, over: str | tuple[str, ...] | None = 'x', key: Key[Array, ''] = jr.key(0), **kwargs: Any) -> cx.Field ¤

Estimate an \(L^p\) norm over space.

Computes

\[ \|u\|_{L^p(\Omega)} = \left(\int_{\Omega} \|u(x)\|_2^p\,d\mu(x)\right)^{1/p}, \]

where \(\|u(x)\|_2\) is the Euclidean norm of the (possibly vector/tensor) value at \(x\), flattened.

Arguments:

  • u: Input DomainFunction.
  • batch, component, quadrature, over, key, kwargs: As in spatial_mean.
  • p: Norm exponent \(p>0\).

Returns:

  • A coordax.Field containing the scalar \(L^p\) norm value.

phydrax.operators.spatial_mean(u: DomainFunction, batch: PointsBatch | CoordSeparableBatch | tuple[PointsBatch, ...], /, *, component: DomainComponent | DomainComponentUnion, quadrature: QuadratureBatch | tuple[QuadratureBatch | None, ...] | None = None, over: str | tuple[str, ...] | None = 'x', key: Key[Array, ''] = jr.key(0), **kwargs: Any) -> cx.Field ¤

Estimate the spatial mean of a field.

Computes the Monte Carlo / quadrature estimate of

\[ \langle u \rangle = \frac{1}{\mu(\Omega)}\int_{\Omega} u(x)\,d\mu(x), \]

where \(\Omega\) is the subset described by component and the integration axes are selected by over (default "x").

Arguments:

  • u: Integrand DomainFunction.
  • batch: PointsBatch/CoordSeparableBatch used for sampling (or a tuple for unions).
  • component: DomainComponent or DomainComponentUnion defining the integration region.
  • quadrature: Optional QuadratureBatch for paired sampling.
  • over: Which axes/labels to reduce over (defaults to "x").
  • key: PRNG key forwarded to callables.
  • kwargs: Extra keyword arguments forwarded to u and component callables.

Returns:

  • A coordax.Field containing the mean value (with remaining named axes, if any).