Skip to content

Functions¤

DomainFunction wraps callables with explicit domain metadata, so that operators and constraints can compose without losing coordinate meaning.

phydrax.domain.DomainFunction ¤

A callable with explicit domain and coordinate semantics.

A DomainFunction represents a mathematical map

\[ u:\Omega \to \mathbb{R}^m, \]

where the domain \(\Omega\) is a phydrax.domain object carrying labeled factors (e.g. a space-time domain \(\Omega = \Omega_x \times \Omega_t\) with labels "x" and "t"). The tuple deps specifies which labels the function actually depends on.

Phydrax operators (gradients, divergences, integrals, etc.) act on DomainFunction objects, and constraints evaluate them on sampled batches.

Algebra

DomainFunction implements pointwise arithmetic. For example, for compatible domains,

\[ (u+v)(z)=u(z)+v(z),\qquad (uv)(z)=u(z)v(z), \]

and when combining functions with different domains, the domains are joined and both functions are promoted to the joined domain.

Notes

  • If func is array-like, it is treated as a constant function on \(\Omega\).
  • If func is callable, Phydrax passes randomness through a keyword-only key argument (when provided by downstream sampling/solvers).
  • Evaluation returns a coordax.Field whose named axes are inferred from the sampling structure (paired blocks and/or coord-separable axes).
T property ¤

Transpose the last two array axes of the output.

If \(u(z)\in\mathbb{R}^{m\times n}\) then \((u^T)(z)=u(z)^T\).

__init__(*, domain: _AbstractDomain, deps: collections.abc.Sequence[str], func: collections.abc.Callable | ArrayLike | None, metadata: collections.abc.Mapping[str, typing.Any] | None = None) ¤
depends_on(var: str) -> bool ¤

Return whether this function depends on the labeled variable var.

promote(new_domain: _AbstractDomain) -> DomainFunction ¤

View this function as defined on a larger domain.

If \(\Omega\subseteq\Omega'\), then promotion constructs \(u':\Omega'\to\mathbb{R}^m\) by ignoring the extra coordinates:

\[ u'(z) = u(z|_{\Omega}). \]

In practice this means that all labels of the current domain must appear in new_domain.labels, and the underlying callable is reused unchanged.

with_metadata(**metadata: typing.Any) -> DomainFunction ¤

Return a copy with metadata merged into the existing metadata.

__call__(points: phydrax.domain._structure.PointsBatch | phydrax.domain._structure.CoordSeparableBatch | phydrax._frozendict.frozendict[str, PyTree[coordax.Field]], *, key: Key[Array, ''] = jr.key(0), **kwargs: typing.Any) -> Field ¤