neuralqx.hilbert.constraints package¶
- class U1Constraint(gauge_fixing, cutoff, q_min, q_max, q_step)¶
Bases:
DiscreteHilbertConstraintDiscrete Hilbert-space constraint enforcing a U(1) gauge fixing.
This class implements NetKet’s
netket.hilbert.constraint.DiscreteHilbertConstraintAPI for the constrained U(1) Hilbert-space backend. It is constructed with:gauge_fixing: a gauge-fixing specification already preprocessed into the internal JAX-friendly representation expected bycheck_one_state_jax(),q_min,q_max,q_step: range metadata used to perform modular arithmetic consistent with the Hilbert space’s allowed local basis values,cutoff: stored primarily for identity/hashing and for traceability/debugging.
- Batch semantics
NetKet calls the constraint with an array
xof shape(B, N)(batch sizeB, Hilbert sizeN). The constraint must return a boolean array of shape(B,)indicating whether each state satisfies the gauge fixing.- JAX / JIT friendliness
The implementation must be compatible with JAX transformations and JIT compilation. The per-state check is performed by
check_one_state_jax()and vectorized over the batch usingjax.vmap().- PyTree notes
NetKet expects constraint objects to be PyTrees. All stored fields are marked with
struct.field(pytree_node=False)so they are treated as static (non-PyTree) metadata.
- Parameters:
gauge_fixing (
Union[Array,list]) – Gauge-fixing specification in the internal JAX-friendly format consumed bycheck_one_state_jax().cutoff (
Union[float,int]) – Cutoff associated with the Hilbert space using this constraint.q_min (
Union[float,int]) – Minimum allowed local quantum number/value.q_max (
Union[float,int]) – Maximum allowed local quantum number/value.q_step (
Union[float,int]) – Step between consecutive allowed local quantum numbers/values.
- Returns:
None.
- Raises:
None – This class does not intentionally raise exceptions during normal construction.