API Reference#
States#
SpinState#
tachys.lattice.spins.spin_state
class SpinState(spins, Ns)
Batched spin-½ configurations on a lattice. Extends flax.struct.PyTreeNode.
Field |
Type |
Description |
|---|---|---|
|
|
Shape |
|
|
Number of lattice sites. |
init_config_fixed_magn#
tachys.lattice.spins.spin_state
init_config_fixed_magn(key, N, sz=0, N_mc=1)
Sample random spin configurations with a fixed total magnetization.
Parameter |
Type |
Description |
|---|---|---|
|
|
JAX random key. |
|
|
Number of spins. |
|
|
Target magnetization. Default |
|
|
Number of configurations to generate. |
Returns jnp.ndarray, shape (N_mc, N), values in {−1, +1}.
FermionState#
tachys.lattice.fermions.fermion_state
class FermionState(occupations, Ns, Ne, Nbands=2)
Batched fermionic occupation-number configurations. Extends flax.struct.PyTreeNode.
Modes are ordered as (site 0 ↑, site 0 ↓, site 1 ↑, site 1 ↓, …).
Ne and Nbands are static (non-pytree) fields.
Field |
Type |
Description |
|---|---|---|
|
|
Shape |
|
|
Number of lattice sites. |
|
|
Total number of electrons. Must be fixed at construction. |
|
|
Number of bands. Default |
init_config_spinful#
tachys.lattice.fermions.fermion_state
init_config_spinful(key, Ns, Ne, sz=0, N_mc=1, particle_hole=False)
Sample random spinful fermionic configurations with fixed particle number and spin magnetization.
Parameter |
Type |
Description |
|---|---|---|
|
|
JAX random key. |
|
|
Number of lattice sites. |
|
|
Number of electrons. Must be even. |
|
|
Spin-magnetization offset. Default |
|
|
Number of configurations. |
|
|
Apply particle-hole transformation to the spin-down band. |
Returns (config, N_up, N_down). config has shape (N_mc, 2·Ns).
Operators#
_Operator#
tachys.lattice.operator.base
class _Operator(coupling=1.0)
Abstract base for all operators. Subclass it and implement apply(state).
Calling an instance automatically wraps apply in jax.vmap over the batch axis.
Member |
Type |
Description |
|---|---|---|
|
|
Scalar prefactor applied to all matrix elements. |
|
|
Vectorized application over the batch axis. |
|
|
Per-sample application. Override in subclasses. |
|
|
Returns |
|
scalar or |
Scalar: rescales coupling. Operator: returns |
Sz#
tachys.lattice.spins.spin_operators
class Sz(site, coupling=1.0)
Diagonal spin-z operator. Returns DiagonalResult with element 0.5 · coupling · σ_z.
Parameter |
Type |
Description |
|---|---|---|
|
|
Lattice site index. |
|
|
Prefactor. Default |
Splus#
tachys.lattice.spins.spin_operators
class Splus(site, coupling=1.0)
Raising operator S⁺ = (σ_x + iσ_y)/2. Flips the spin at site from ↓ to ↑.
Returns OffdiagonalResult; mask=False when the spin is already ↑.
Sminus#
tachys.lattice.spins.spin_operators
class Sminus(site, coupling=1.0)
Lowering operator S⁻ = (σ_x − iσ_y)/2. Flips the spin at site from ↑ to ↓.
Returns OffdiagonalResult; mask=False when the spin is already ↓.
XYExchange#
tachys.lattice.spins.spin_operators
class XYExchange(i, j, coupling=1.0)
Two-body term S⁺ᵢS⁻ⱼ + S⁻ᵢS⁺ⱼ. Non-zero only when spins at sites i and j
are antiparallel. Returns OffdiagonalResult.
Parameter |
Type |
Description |
|---|---|---|
|
|
First site. |
|
|
Second site. |
|
|
Prefactor. Default |
C#
tachys.lattice.fermions.fermion_operators
class C(site, band=1, coupling=1.0)
Fermionic annihilation operator c_{i,σ}. Removes an electron at site in band
(0 = ↑, 1 = ↓), including the Jordan-Wigner fermionic sign.
Returns OffdiagonalResult.
Convenience subclasses: Cup(site) sets band=0; Cdn(site) sets band=1.
Parameter |
Type |
Description |
|---|---|---|
|
|
Lattice site index. |
|
|
Band index: 0 = spin-up, 1 = spin-down. |
|
|
Prefactor. Default |
C_dag#
tachys.lattice.fermions.fermion_operators
class C_dag(site, band=1, coupling=1.0)
Fermionic creation operator c†_{i,σ}. Adds an electron at site in band,
including Jordan-Wigner sign. Returns OffdiagonalResult.
Convenience subclasses: Cup_dag(site) and Cdn_dag(site).
N#
tachys.lattice.fermions.fermion_operators
class N(site, band=1, coupling=1.0)
Number operator n_{i,σ} = c†{i,σ} c{i,σ}. Returns DiagonalResult.
Convenience subclasses: Nup(site) (band=0) and Ndn(site) (band=1).
Hamiltonians#
heisenberg_square_pbc#
tachys.lattice.spins.hamiltonians.heisenberg
heisenberg_square_pbc(L, J=1.0)
Heisenberg model on an L×L square lattice with periodic boundary conditions.
Sites are indexed row-major: site at (x, y) maps to x·L + y.
$$ H = J \sum_{\langle i,j \rangle} \left[ S^z_i S^z_j + \tfrac{1}{2}(S^+_i S^-_j + S^-_i S^+_j) \right] $$
Parameter |
Type |
Description |
|---|---|---|
|
|
Linear dimension. Total sites N = L². |
|
|
Exchange coupling. Positive = antiferromagnetic. |
Returns _OperatorSum.
hubbard_square_pbc#
tachys.lattice.fermions.hamiltonians.hubbard
hubbard_square_pbc(L, t=1.0, U=0.0)
Hubbard model on an L×L square lattice with periodic boundary conditions. Two bands (spin-up / spin-down) with nearest-neighbor hopping and on-site Coulomb repulsion.
$$ H = -t \sum_{\langle i,j \rangle, \sigma} (c^\dagger_{i\sigma} c_{j\sigma} + \text{h.c.}) + U \sum_i n_{i\uparrow} n_{i\downarrow} $$
Parameter |
Type |
Description |
|---|---|---|
|
|
Linear dimension. Total sites N = L². |
|
|
Hopping amplitude. |
|
|
On-site Coulomb repulsion. |
Returns _OperatorSum.
Exact diagonalization#
exact_diag#
tachys.lattice.exact_diag
exact_diag(state_full_hilbert, H, pack, k=1)
Build the sparse Hamiltonian matrix and compute its k lowest eigenvalues.
Internally: applies H to every basis state, assembles a COO sparse matrix
from diagonal and off-diagonal results, and calls scipy.sparse.linalg.eigsh.
Parameter |
Type |
Description |
|---|---|---|
|
|
Batch containing every basis state in the Hilbert space. |
|
|
Hamiltonian operator. Must return |
|
|
Maps a state batch to a 1-D integer index array. Must be injective. |
|
|
Number of lowest eigenvalues to compute. Default |
Returns (eigenvalues, eigenvectors).
Shapes: eigenvalues is (k,) in ascending order; eigenvectors is (n_states, k).
spins_hilbert_space#
tachys.lattice.exact_diag
spins_hilbert_space(N, values=(-1, 1))
Generate the complete Hilbert space for N spin-½ sites as all 2^N basis states.
Parameter |
Type |
Description |
|---|---|---|
|
|
Number of spins. |
|
|
|
Returns np.ndarray, shape (2^N, N).
fermions_hilbert_space#
tachys.lattice.exact_diag
fermions_hilbert_space(Ns, Ne, Nbands=2)
Generate all valid fermionic occupation configurations: all ways to place Ne
electrons on Ns × Nbands modes.
Parameter |
Type |
Description |
|---|---|---|
|
|
Number of lattice sites. |
|
|
Number of electrons. |
|
|
Number of bands. Default |
Returns np.ndarray, shape (C(Ns·Nbands, Ne), Ns·Nbands) of binary
occupation vectors.