Lattice
lattice
Core lattice structures for scalar and gauge fields.
This module defines the fundamental lattice data structures:
- Lattice: Simple scalar field (1D, 2D, 3D)
- CoupledLattice: Scalar + U(1) gauge (Abelian Higgs model)
- GaugeLattice: Pure U(1) gauge field
Lattice(size, length, field=None, field_dot=None)
Bases: Module
Represents a scalar field on a periodic lattice (supports 1D, 2D, 3D).
Attributes:
| Name | Type | Description |
|---|---|---|
field |
Array
|
Scalar field values (shape matches size tuple) |
field_dot |
Array
|
Time derivative of the field (same shape) |
dx |
float
|
Lattice spacing (assumed uniform, taken from first dimension) |
size |
tuple[int, ...]
|
Tuple of lattice grid counts per dimension (always a tuple internally) |
length |
tuple[float, ...]
|
Tuple of physical lengths per dimension (always a tuple internally) |
ndim |
int
|
Number of spatial dimensions |
Initialize a lattice with given size and physical length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int | tuple[int, ...]
|
Number of grid points (int for 1D, tuple for 2D) |
required |
length
|
float | tuple[float, ...]
|
Physical length (float for 1D, tuple for 2D) |
required |
field
|
Array | None
|
Initial field values (if None, initialized to zeros) |
None
|
field_dot
|
Array | None
|
Initial time derivative (if None, initialized to zeros) |
None
|
Source code in jaxlatt/core/lattice.py
volume
property
Compute the total physical lattice volume.
Returns:
| Type | Description |
|---|---|
float
|
Product of all box lengths. |
dV
property
Compute the volume element for one grid cell.
Returns:
| Type | Description |
|---|---|
float
|
Physical volume associated with a single lattice site. |
copy()
Create a deep copy of the lattice state.
Uses type(self) so a subclass copies to its own type rather than
being silently downcast to Lattice.
Returns:
| Type | Description |
|---|---|
Lattice
|
New instance of the same class, with independent array buffers. |
Source code in jaxlatt/core/lattice.py
update(field, field_dot)
Create a new lattice with updated field values.
Uses type(self), so a subclass keeps its own type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
Array
|
New field values |
required |
field_dot
|
Array
|
New field time derivative |
required |
Returns:
| Type | Description |
|---|---|
Lattice
|
New instance of the same class, with updated values |
Source code in jaxlatt/core/lattice.py
replace(**kwargs)
Create a new lattice with selected dynamic attributes replaced.
Supports the dynamic fields field and field_dot. Static fields
(size, length, dx, ndim) are part of the pytree's
treedef rather than its leaves, so replacing one raises; construct a new
lattice directly instead.
CoupledLattice uses dataclasses.replace for this, which cannot
work here: Lattice takes a custom __init__ while dx and
ndim are init-eligible dataclass fields, so dataclasses.replace
would try to pass them and raise TypeError. GaugeLattice has the
same constraint and resolves it the same way, via eqx.tree_at.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Array
|
Dynamic field values to override. |
{}
|
Returns:
| Type | Description |
|---|---|
Lattice
|
New instance of the same class with the given attributes replaced. |
Source code in jaxlatt/core/lattice.py
CoupledLattice
Bases: Module
Combined scalar and gauge field lattice for Abelian Higgs model.
Attributes:
| Name | Type | Description |
|---|---|---|
phi |
Array
|
Complex scalar field with shape |
pi |
Array
|
Conjugate momentum to |
links |
Array
|
U(1) gauge links with shape |
E |
Array
|
Electric field components with shape |
m |
float
|
Scalar mass parameter. |
lambda_ |
float
|
Scalar self-coupling. |
g |
float
|
Gauge coupling. |
dx |
float
|
Lattice spacing. |
size |
tuple[int, int, int]
|
Lattice dimensions |
length |
tuple[float, float, float]
|
Physical box lengths |
volume
property
Physical volume of the simulation box.
dV
property
Volume element (cell volume).
copy()
Create a deep copy of the coupled lattice.
Returns:
| Type | Description |
|---|---|
CoupledLattice
|
New |
Source code in jaxlatt/core/lattice.py
update(phi, pi, links, E)
Create a new CoupledLattice with updated dynamical fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phi
|
Array
|
New scalar field. |
required |
pi
|
Array
|
New conjugate momentum. |
required |
links
|
Array
|
New gauge links. |
required |
E
|
Array
|
New electric field. |
required |
Returns:
| Type | Description |
|---|---|
CoupledLattice
|
New |
Source code in jaxlatt/core/lattice.py
replace(**kwargs)
Create a new lattice with selected attributes replaced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Field values or parameters to override. |
{}
|
Returns:
| Type | Description |
|---|---|
CoupledLattice
|
New |
Source code in jaxlatt/core/lattice.py
GaugeLattice(size, length, g=1.0, links=None, E=None, a=1.0, H=0.0)
Bases: Module
U(1) gauge fields on a 3D periodic lattice.
Uses compact formulation with link variables \(U_i \in \mathrm{U}(1)\).
Attributes:
| Name | Type | Description |
|---|---|---|
links |
Array
|
Complex link variables |
E |
Array
|
Electric field components |
dx |
float
|
Lattice spacing |
size |
tuple[int, int, int]
|
Lattice dimensions |
length |
tuple[float, float, float]
|
Physical box size |
g |
float
|
Gauge coupling |
a |
Array
|
Scale factor (cosmology) |
H |
Array
|
Conformal Hubble parameter (cosmology) |
Initialize a gauge lattice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
tuple[int, int, int]
|
Lattice dimensions |
required |
length
|
float
|
Physical box length (assumed isotropic). |
required |
g
|
float
|
Gauge coupling. |
1.0
|
links
|
Array | None
|
Optional initial link variables. |
None
|
E
|
Array | None
|
Optional initial electric field. |
None
|
a
|
float
|
Cosmological scale factor. |
1.0
|
H
|
float
|
Conformal Hubble parameter. |
0.0
|
Source code in jaxlatt/core/lattice.py
volume
property
Compute the total physical lattice volume.
Returns:
| Type | Description |
|---|---|
float
|
Total box volume. |
dV
property
Compute the volume element for one lattice site.
Returns:
| Type | Description |
|---|---|
float
|
Cell volume |
copy()
Create a deep copy of the gauge lattice state.
Returns:
| Type | Description |
|---|---|
GaugeLattice
|
New |
Source code in jaxlatt/core/lattice.py
update(links, E, a=None, H=None)
Create a new gauge lattice with updated dynamical variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
Array
|
Updated link variables. |
required |
E
|
Array
|
Updated electric field. |
required |
a
|
Array | None
|
Optional updated scale factor. |
None
|
H
|
Array | None
|
Optional updated Hubble parameter. |
None
|
Returns:
| Type | Description |
|---|---|
GaugeLattice
|
New |
Source code in jaxlatt/core/lattice.py
replace(**kwargs)
Create a new lattice with selected dynamic attributes replaced.
Supports replacing links, E, a, and H.
To change static fields (g, size, length) construct a new
GaugeLattice directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Dynamic field values to override. |
{}
|
Returns:
| Type | Description |
|---|---|
GaugeLattice
|
New |