Constraints
constraints
Constraint enforcement for gauge theories.
This module provides comprehensive tools for:
- Computing Gauss law constraint violations
- Projecting fields onto constraint manifold
- Gauge transformations
- Baumgarte-Shapiro constraint stabilization
- Diagnostic utilities
All Jacobians computed automatically via JAX autodiff.
Note on Gauss Constraint Implementations
The canonical implementations are:
-
Pure gauge (no sources):
jaxlatt.operators.gauge.gauss_constraintSignature: (links, E, dx) -> G = div(E) -
With scalar sources:
jaxlatt.operators.coupled.gauss_constraint_with_sourceSignature: (links, E, phi, pi, dx) -> G = div(E) + Im(phi* pi)/dx
This module re-exports these for convenience and provides additional constraint enforcement tools (projection, gauge transformations, etc.).
gauss_constraint_with_source(links, E, phi, pi, dx)
Compute Gauss constraint with scalar field source.
This is the canonical implementation for coupled scalar-gauge systems. Gauss law:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
Array
|
Gauge links (not used, kept for interface consistency) |
required |
E
|
Array
|
Electric field |
required |
phi
|
Array
|
Complex scalar field |
required |
pi
|
Array
|
Conjugate momentum |
required |
dx
|
float
|
Lattice spacing |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Gauss constraint violation \(G\), shape |
See Also
jaxlatt.operators.coupled.gauss_constraint_with_source
Source code in jaxlatt/core/constraints.py
project_gauss_constraint(E, phi, pi, dx, tolerance=1e-10, max_iterations=100)
Project electric field to satisfy Gauss constraint \(\nabla \cdot E + \mathrm{Im}(\phi^*\pi)/dx = 0\).
Uses iterative Jacobi method to solve Poisson equation:
This ensures Gauss law is satisfied to numerical precision without changing the transverse part of \(E\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E
|
Array
|
Electric field to project, shape |
required |
phi
|
Array
|
Scalar field \(\phi\), shape |
required |
pi
|
Array
|
Conjugate momentum \(\pi\), shape |
required |
dx
|
float
|
Lattice spacing. |
required |
tolerance
|
float
|
Convergence tolerance for the iterative solver. |
1e-10
|
max_iterations
|
int
|
Maximum number of Jacobi iterations. |
100
|
Returns:
| Type | Description |
|---|---|
Array
|
Electric field satisfying Gauss constraint, shape |
Source code in jaxlatt/core/constraints.py
project_gauss_coupled_lattice(lattice, tolerance=1e-10, max_iterations=100)
Project electric field in coupled lattice to satisfy Gauss constraint.
Creates a new lattice with \(E\) corrected to enforce \(\nabla \cdot E + g\rho = 0\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lattice
|
CoupledLattice
|
Lattice to project. |
required |
tolerance
|
float
|
Convergence tolerance. |
1e-10
|
max_iterations
|
int
|
Maximum iterations for solver. |
100
|
Returns:
| Type | Description |
|---|---|
CoupledLattice
|
|
Source code in jaxlatt/core/constraints.py
stabilized_constraint_evolution(G, dG_dt, alpha=0.1, beta=0.01)
Baumgarte-Shapiro constraint damping.
Instead of enforcing \(dG/dt = 0\), enforce:
This exponentially damps constraint violations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
Array
|
Current constraint violation |
required |
dG_dt
|
Array
|
Time derivative of constraint |
required |
alpha
|
float
|
Linear damping coefficient \(\alpha\) |
0.1
|
beta
|
float
|
Constraint restoring coefficient \(\beta\) |
0.01
|
Returns:
| Type | Description |
|---|---|
Array
|
Modified \(d^2 G/dt^2\) with damping |
Source code in jaxlatt/core/constraints.py
gauge_transform_scalar(phi, alpha, g)
Apply gauge transformation to scalar field.
Under a U(1) gauge transformation with phase \(\alpha(x)\):
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phi
|
Array
|
Scalar field \(\phi\), shape |
required |
alpha
|
Array
|
Gauge transformation parameter \(\alpha\), shape |
required |
g
|
float
|
Gauge coupling. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Transformed scalar field. |
Source code in jaxlatt/core/constraints.py
gauge_transform_links(links, alpha, g)
Apply gauge transformation to gauge links.
Under a U(1) gauge transformation:
This keeps the gauge-covariant derivative properly transformed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
Array
|
Gauge links, shape |
required |
alpha
|
Array
|
Gauge transformation parameter \(\alpha\), shape |
required |
g
|
float
|
Gauge coupling. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Transformed gauge links. |
Source code in jaxlatt/core/constraints.py
gauge_transform_coupled_lattice(lattice, alpha)
Apply gauge transformation to entire coupled lattice.
Transforms all fields simultaneously:
- \(\phi \to e^{ig\alpha} \phi\)
- \(\pi \to e^{ig\alpha} \pi\)
- \(U_i(n) \to e^{ig\alpha(n)} U_i(n) e^{-ig\alpha(n+\hat{i})}\)
- \(E\) unchanged (gauge invariant)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lattice
|
CoupledLattice
|
Lattice to transform. |
required |
alpha
|
Array
|
Gauge transformation parameter \(\alpha\), shape |
required |
Returns:
| Type | Description |
|---|---|
CoupledLattice
|
Transformed |
Source code in jaxlatt/core/constraints.py
check_gauge_invariance(observable_before, observable_after, tolerance=1e-10)
Check if an observable is gauge invariant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable_before
|
float
|
Observable value before gauge transformation. |
required |
observable_after
|
float
|
Observable value after gauge transformation. |
required |
tolerance
|
float
|
Allowed numerical tolerance. |
1e-10
|
Returns:
| Type | Description |
|---|---|
Array
|
Boolean JAX scalar indicating whether the observable is gauge invariant. |
Source code in jaxlatt/core/constraints.py
compute_constraint_violation_norm(phi, pi, E, links, dx)
Compute various norms of constraint violation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phi
|
Array
|
Scalar field |
required |
pi
|
Array
|
Conjugate momentum |
required |
E
|
Array
|
Electric field |
required |
links
|
Array
|
Gauge links |
required |
dx
|
float
|
Lattice spacing |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict with L1, L2, Linf norms of G |
Source code in jaxlatt/core/constraints.py
check_constraint_preservation(phi_old, pi_old, E_old, links_old, phi_new, pi_new, E_new, links_new, dx)
Check if time evolution preserves Gauss constraint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phi_old
|
Array
|
Scalar field at previous time. |
required |
pi_old
|
Array
|
Conjugate momentum at previous time. |
required |
E_old
|
Array
|
Electric field at previous time. |
required |
links_old
|
Array
|
Gauge links at previous time. |
required |
phi_new
|
Array
|
Scalar field at current time. |
required |
pi_new
|
Array
|
Conjugate momentum at current time. |
required |
E_new
|
Array
|
Electric field at current time. |
required |
links_new
|
Array
|
Gauge links at current time. |
required |
dx
|
float
|
Lattice spacing. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary containing Gauss-constraint violation metrics before and after |
dict[str, float]
|
the update, including absolute drift and relative drift rate. |
Source code in jaxlatt/core/constraints.py
charge_current_continuity(lattice)
Compute charge and current densities for continuity equation check.
The continuity equation for conserved charge:
where:
- \(\rho = g \, \mathrm{Im}(\phi^* \pi)\) (charge density)
- \(j_i = \frac{g}{2 \, dx} \mathrm{Im}[\phi^*(n) U_i(n) \phi(n+\hat{i})]\) (current density)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lattice
|
CoupledLattice
|
Coupled lattice state. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
Tuple |