Skip to content

Components¤

Components select which subset of a domain is being sampled (interior, boundary, fixed-time slices, etc.) and wrap these into DomainComponent objects.

Component markers¤

phydrax.domain.Interior ¤

Marker selecting the interior of a domain factor.

For a geometry factor \(\Omega\subset\mathbb{R}^d\), this corresponds to sampling from \(\Omega\) (volume/area/length measure). For a scalar factor like a time interval \([t_0,t_1]\), this corresponds to sampling from the interval interior.

__init__() ¤

Create an interior component marker.


phydrax.domain.Boundary ¤

Marker selecting the boundary of a domain factor.

For a geometry factor \(\Omega\subset\mathbb{R}^d\), this corresponds to sampling from \(\partial\Omega\) (surface measure). For scalar factors (e.g. time intervals), the "boundary" is the discrete set of endpoints (counting measure).

__init__() ¤

Create a boundary component marker.


phydrax.domain.Fixed ¤

Fix a scalar coordinate to a specific value.

Interpreted as a Dirac measure of unit mass at the fixed value. This is supported for scalar domains (like TimeInterval) and is used for slices such as \(t=t_0\).

Note: Fixing geometry coordinates is not supported by the sampler; use a where mask or construct a lower-dimensional geometry instead.

__init__(value: ArrayLike) ¤

Create a fixed scalar component at the given value.


phydrax.domain.FixedStart ¤

Fix a scalar domain to its start endpoint (e.g. \(t=t_0\)).

__init__() ¤

Create a fixed-start component marker.


phydrax.domain.FixedEnd ¤

Fix a scalar domain to its end endpoint (e.g. \(t=t_1\)).

__init__() ¤

Create a fixed-end component marker.


phydrax.domain.ComponentSpec ¤

Mapping from domain labels to component selectors.

A ComponentSpec assigns each label \(\ell\) in a domain to one of:

  • Interior() : use the interior \(\Omega_\ell\);
  • Boundary() : use the boundary \(\partial\Omega_\ell\) (or endpoints for scalars);
  • FixedStart() / FixedEnd() : fix a scalar domain to its endpoints;
  • Fixed(value) : fix a scalar domain to an arbitrary value.

Any label not explicitly specified defaults to Interior().

__init__(by_label: collections.abc.Mapping[str, phydrax.domain._components._AbstractVarComponent] | None = None) ¤

Create a component specification from a {label: component} mapping.

component_for(label: str) -> _AbstractVarComponent ¤

Return the component selector for label (defaults to Interior()).

Domain components¤

phydrax.domain.DomainComponent ¤

A domain equipped with component selection, filters, and weights.

A DomainComponent represents a product component of a labeled domain. Given a labeled domain \(\Omega = \prod_{\ell\in\mathcal{L}} \Omega_\ell\), and a ComponentSpec selecting a subset/type for each label, the component corresponds to a set (schematically)

\[ \Omega_{\text{comp}} = \prod_{\ell\in\mathcal{L}} \Omega_\ell^{(\text{spec})}, \]

together with its associated product measure. For example:

  • geometry interior \(\Omega_\ell\) uses volume/area/length measure;
  • geometry boundary \(\partial\Omega_\ell\) uses surface measure;
  • scalar interior uses Lebesgue measure on \([a,b]\);
  • scalar boundary uses counting measure on \(\{a,b\}\) (total mass \(2\));
  • fixed scalar slices use a unit-mass Dirac measure.

Additional selection and weighting can be applied via: - where: per-label indicator functions; - where_all: a global indicator DomainFunction; - weight_all: a global weight DomainFunction.

These are incorporated downstream in integral/mean estimators and constraint losses.

__init__(*, domain: _AbstractDomain, spec: phydrax.domain._components.ComponentSpec | None = None, where: collections.abc.Mapping[str, collections.abc.Callable] | None = None, where_all: phydrax.domain._function.DomainFunction | None = None, weight_all: phydrax.domain._function.DomainFunction | None = None) ¤
measure() -> Array ¤

Return the total measure of this component.

This computes the product of the per-label component measures, e.g.

\[ \mu(\Omega_{\text{comp}})=\prod_{\ell\in\mathcal{L}} \mu_\ell\left(\Omega_\ell^{(\text{spec})}\right). \]

For scalar boundaries \(\{a,b\}\) this uses counting measure (mass \(2\)), and for fixed slices uses unit mass.

sample(num_points: int | tuple[int, ...], *, structure: ProductStructure, sampler: str = 'latin_hypercube', key: Key[Array, ''] = jr.key(0)) -> PointsBatch ¤
sample_coord_separable(coord_separable: collections.abc.Mapping[str, int | collections.abc.Sequence[int] | phydrax.domain._grid.AbstractAxisSpec | collections.abc.Sequence[phydrax.domain._grid.AbstractAxisSpec] | phydrax.domain._grid.GridSpec], /, *, num_points: int | tuple[int, ...] = (), dense_structure: phydrax.domain._structure.ProductStructure | None = None, sampler: str = 'latin_hypercube', key: Key[Array, ''] = jr.key(0)) -> CoordSeparableBatch ¤

Sample a coordinate-separable batch.

For selected unary labels, this samples each coordinate axis independently, producing coordinate arrays (and an associated boolean mask) suitable for grid-like evaluation. Any remaining (non-fixed, non-separable) labels are sampled using dense_structure.

coord_separable values may be: - counts (int or Sequence[int]), using the configured random sampler; - axis specs (AbstractAxisSpec, Sequence[AbstractAxisSpec], or GridSpec), producing deterministic grid nodes and attaching per-axis discretization metadata for quadrature/operators.

This is useful when an operator factorizes across coordinate axes, or when a Cartesian grid is desired for quadrature-like reductions.

normals(points: phydrax.domain._structure.PointsBatch | phydrax._frozendict.frozendict[str, PyTree[coordax.Field]], /, *, var: str) -> Field ¤

Compute outward unit normals on a geometry boundary.

For a geometry label var with boundary component, this returns the unit normal field \(n(x)\) on \(\partial\Omega\).

The returned coordax.Field has the same named axes as the provided boundary points.

normal(*, var: str) -> DomainFunction ¤

Return a DomainFunction representing the outward unit normal \(n(x)\).

This is a convenience wrapper that returns a DomainFunction with deps=(var,). For geometry labels, it is typically used in Neumann-type conditions involving \(\partial u/\partial n\).

sdf(*, var: str) -> DomainFunction ¤

Return a DomainFunction for the signed distance field \(\phi(x)\).

The sign convention is geometry-dependent but typically:

  • \(\phi(x) < 0\) inside \(\Omega\),
  • \(\phi(x) = 0\) on \(\partial\Omega\),
  • \(\phi(x) > 0\) outside \(\Omega\).

phydrax.domain.DomainComponentUnion ¤

A finite union of DomainComponent terms.

This is used to represent components that are naturally unions, e.g. for a time interval \([t_0,t_1]\) the boundary is \(\{t=t_0\}\cup\{t=t_1\}\).

The total measure is the sum of term measures, and sampling allocates points across terms.

__init__(terms: tuple[phydrax.domain._components.DomainComponent, ...]) ¤

Create a union from non-empty terms.

measure() -> Array ¤

Return the total measure \(\mu(\cup_i \Omega_i)=\sum_i \mu(\Omega_i)\).

sample(num_points: int | tuple[typing.Any, ...], *, structure: ProductStructure, sampler: str = 'latin_hypercube', key: Key[Array, ''] = jr.key(0), min_points_per_term: int = 1) -> tuple[phydrax.domain._structure.PointsBatch, ...] ¤

Sample each union term and return a tuple of PointsBatch values.