qcd module

Tools for studying cold and dense lattice QCD. This module provides:

  • Subtractions (a class of functions guaranteed to integrate to 0)

  • Yang-Mills action

  • Various Dirac matrices

  • Metropolis and HMC implementations

class qcd.SpecialUnitaryAlgebra(N)[source]

Bases: object

The su(N) Lie algebra.

The basis is orthonormalized (so the normalization differs from that of the Pauli and Gell-Mann bases).

__init__(N)[source]
Parameters

N – number of colors

vector(H)[source]

Obtain a vector from an element of the Lie algebra.

Parameters

H – A traceless Hermitian N-by-N matrix.

Returns

A vector.

class qcd.MLP(*args, **kwargs)[source]

Bases: Module

Multi-layer perceptron.

static activation(x: Any, alpha: Any = 1.0) Any

Continuously-differentiable exponential linear unit activation.

Computes the element-wise function:

\[\begin{split}\mathrm{celu}(x) = \begin{cases} x, & x > 0\\ \alpha \left(\exp(\frac{x}{\alpha}) - 1\right), & x \le 0 \end{cases}\end{split}\]

For more information, see Continuously Differentiable Exponential Linear Units.

Parameters
  • x – input array

  • alpha – array or scalar (default: 1.0)

__init__(key, widths, zero=False)[source]
layers: list
class qcd.ExactForm(*args, **kwargs)[source]

Bases: Module

An exact form on the surface of SU(N)^V.

__init__(key, wscale, hidden, K, N=3, zero=True)[source]
Parameters
  • key – Initial PRNG key.

  • wscale – Scaling of the width.

  • hidden – Number of hidden layers.

  • K – Number of SU(N) degrees of freedom.

  • N – Number of colors.

  • zero – If True, initialize the network so that the output is always 0.

K: int
N: int
algebra: SpecialUnitaryAlgebra
mlp: MLP
vector(U)[source]

The vector field underlying the exact form.

Parameters

U – Point at which to evaluate the vector field.

class qcd.ScaledExactForm(*args, **kwargs)[source]

Bases: Module

An exact form modified by a scalar.

The primary purpose of this class is to have a version of ExactForm that performs well when the Boltzmann factor is exponentially small (or large).

__init__(action, key, wscale, hidden, K, N=3, zero=True)[source]
Parameters
  • action – Action defining the scaling.

  • key – Initial PRNG key.

  • wscale – Scaling of the width.

  • hidden – Number of hidden layers.

  • K – Number of SU(N) degrees of freedom.

  • N – Number of colors.

  • zero – If True, initialize the network so that the output is always 0.

action: Callable
vector(U)[source]

The (unscaled) vector field underlying the exact form.

Parameters

U – Point at which to evaluate the vector field.

qcd.random_hermitian(key, N, sigma, traceless=False)[source]

Generates a random Hermitian matrix.

Parameters
  • key – A PRNG key to consume.

  • N – dimension of the matrix

  • sigma – standard deviation

  • traceless – If True (the default), the traceless part is returned

Returns

An N-by-N Hermitian matrix.

Raises

ValueError – If sigma is not a non-negative real number.

qcd.random_unitary(key, N, sigma, special=True)[source]

Generates a random unitary matrix.

Parameters
  • key – A PRNG key to consume.

  • N – dimension of group

  • sigma – inverse concentration near the identity

  • special – If True (the default), the determinant is constrained to be 1.

Returns

A matrix in the group U(N) or SU(N).

Raises

ValueError – If sigma is not a non-negative real number.

qcd.haar_unitary(key, N, special=True)[source]

Generates a random unitary matrix, sampled from the Haar measure.

Parameters
  • key – A PRNG key to consume.

  • N – dimension of group

  • special – If True (the default), the determinant is constrained to be 1.

Returns

A matrix in the group U(N) or SU(N)

qcd.bootstrap(xs, ws=None, N=100, Bs=50)[source]

Compute bootstrapped error bars.

If xs is complex, then the real part of the returned error represents the error on the real part of the mean, and ditto for the imaginary part.

Parameters
  • xs – Samples.

  • ws – Weights.

  • N – Number of resamplings to perform.

  • Bs – Number of blocks to use.

Returns

An ordered pair consisting of the reweighted mean and its estimated standard deviation.

class qcd.Lattice(L: int, D: int = 4)[source]

Bases: object

Lattice geometry.

Parameters
  • L – length of one side of the lattice

  • D – number of spacetime dimensions

L: int
D: int = 4
volume()[source]

Returns the total number of sites in the lattice.

coord(site, mu)[source]

Compute the coordinates of a site.

Parameters
  • site – The index of the site in question.

  • mu – The coordinate to compute.

Returns

The mu coordinate of the specified site.

Raises

ValueError – if mu isn’t a valid direciton

step(site, mu, dist)[source]

Compute the index of one site, from a starting site and an offset.

Parameters
  • site – The site to start from.

  • mu – The direction to walk in.

  • dist – Number of steps (in the positive direction) to walk.

Returns

The index of the specified site.

Raises

ValueError – if mu isn’t a valid direction.

space(t)[source]

Obtain a single spatial slice of the lattice.

Parameters

t – The time coordinate.

Returns

A list of all sites at the given time coordinate.

flat(N)[source]

Produce a flat gauge configuration.

Parameters

N – number of colors

Returns

A rank-4 array containing a gauge configuration consisting only of the identity.

__init__(L: int, D: int = 4) None
qcd.plaquette(lattice, U, site, mu, nu)[source]

Compute the trace of a 1x1 plaquette.

Parameters
  • lattice – The lattice geometry.

  • U – A configuration.

  • site – The site from which the plaquette originates.

  • mu – First axis.

  • nu – Second axis.

Returns

The trace of the plaquette in the fundamental representation.

Raises

ValueError – If any of U, site, mu, nu are incompatible with the lattice geometry, or if mu == nu.

qcd.action_gauge(lattice, U, g, N)[source]

Compute the gauge part of the action.

Parameters
  • lattice – The lattice geometry.

  • U – A gauge configuration.

  • g – The gauge coupling.

  • N – Number of colors.

Returns

The gauge part of the Wilson action.

Raises

ValueError – If the geometry and configuration do not match.

qcd.pauli_matrices()[source]

Obtain Pauli (sigma) matrices.

Returns

A list with four elements—the identity and the three Pauli matrices.

qcd.dirac_matrices()[source]

Obtain Dirac (gamma) matrices.

Returns

A list of 4 gamma matrices.

class qcd.LatticeFermions(lattice)[source]

Bases: ABC

Utility methods for lattice fermions.

Do not instantiate this class directly, but rather use one of the subclasses.

__init__(lattice)[source]
Parameters

lattice – The underlying geometry.

abstract dirac(U)[source]

Obtain the Dirac operator.

Parameters

U – Background gauge configuration.

Returns

The Dirac matrix (inverse propagator) in the given gauge background.

abstract density(Dinv)[source]

Estimate the density.

Parameters

Dinv – inverse Dirac operator

Returns

The average density.

det(U)[source]

Evaluate the determinant of the Dirac matrix.

On reasonably sized lattices this method is likely to yield an overflow, and so slogdet() should be used instead.

Parameters

U – Background gauge configuration.

Returns

A complex number with the determinant of the Dirac matrix.

slogdet(U)[source]

Evaluate the determinant of the Dirac matrix, returning the phase and logarithm.

Parameters

U – Background gauge configuration.

Returns

A pair (z,f), with z a unit-magnitude complex number giving the phase of the determinant, and f the real part of the logarithm of the determinant.

propagator(U)[source]

Evaluate the inverse of the Dirac matrix.

Parameters

U – Background gauge configuration.

Returns

The inverse of the Dirac matrix.

class qcd.NaiveFermions(lattice, N: int, mass: float, mu: float = 0.0)[source]

Bases: LatticeFermions

Naive lattice fermions, with doublers not treated.

__init__(lattice, N: int, mass: float, mu: float = 0.0)[source]
Parameters
  • lattice – The underlying geometry.

  • N – Number of colors.

  • mass – Bare fermion mass.

  • mu – Chemical potential.

dirac(U)[source]

Obtain the Dirac operator.

Parameters

U – Background gauge configuration.

Returns

The Dirac matrix (inverse propagator) in the given gauge background.

density(Dinv)[source]

Estimate the density.

Parameters

Dinv – inverse Dirac operator

Returns

The average density.

class qcd.StaggeredFermions(lattice, N: int, mass: float, mu: float = 0.0)[source]

Bases: LatticeFermions

Kogut-Susskind staggered fermions.

__init__(lattice, N: int, mass: float, mu: float = 0.0)[source]
Parameters
  • lattice – The underlying geometry.

  • N – Number of colors.

  • mass – Bare fermion mass.

  • mu – Chemical potential.

dirac(U)[source]

Obtain the Dirac operator.

Parameters

U – Background gauge configuration.

Returns

The Dirac matrix (inverse propagator) in the given gauge background.

density(Dinv)[source]

Estimate the density.

Parameters

Dinv – inverse Dirac operator

Returns

The average density.

class qcd.WilsonFermions(lattice, N: int, mass: float, mu: float = 0.0)[source]

Bases: LatticeFermions

Wilson fermions.

__init__(lattice, N: int, mass: float, mu: float = 0.0)[source]
Parameters
  • lattice – The underlying geometry.

  • N – Number of colors.

  • mass – Bare fermion mass.

  • mu – Chemical potential.

dirac(U)[source]

Obtain the Dirac operator.

Parameters

U – Background gauge configuration.

Returns

The Dirac matrix (inverse propagator) in the given gauge background.

density(Dinv)[source]

Estimate the density.

Parameters

Dinv – inverse Dirac operator

Returns

The average density.

class qcd.RootedFermions(flavors, *args)[source]

Bases: LatticeFermions

Rooted staggered fermions.

__init__(flavors, *args)[source]
Parameters
  • flavors – Number of flavors

  • args – Additional arguments used to defined the staggered fermions.

dirac(U)[source]

Obtain the Dirac operator.

Parameters

U – Background gauge configuration.

Returns

The Dirac matrix (inverse propagator) in the given gauge background.

density(Dinv)[source]

Estimate the density.

Parameters

Dinv – inverse Dirac operator

Returns

The average density.

det(U)[source]

Evaluate the determinant of the Dirac matrix.

On reasonably sized lattices this method is likely to yield an overflow, and so slogdet() should be used instead.

Parameters

U – Background gauge configuration.

Returns

A complex number with the determinant of the Dirac matrix.

slogdet(U)[source]

Evaluate the determinant of the Dirac matrix, returning the phase and logarithm.

Parameters

U – Background gauge configuration.

Returns

A pair (z,f), with z a unit-magnitude complex number giving the phase of the determinant, and f the real part of the logarithm of the determinant.

class qcd.Metropolis(x0, action, propose, key)[source]

Bases: object

Markov chain using the Metropolis algorithm.

__init__(x0, action, propose, key)[source]
Parameters
  • x0 – Initial field configuration.

  • action – The action

  • propose – A function for generating proposals.

  • key – PRNG key for generating proposals.

step(N=1)[source]
Parameters

N – The number of steps to take before returning a configuration.

calibrate()[source]

Calibrate the chain, tweaking delta until the acceptance rate lies between 0.3 and 0.55.

acceptance_rate()[source]

Estimates the acceptance rate.

Returns

The acceptance rate over the last 100 steps.

iter(skip=1)[source]

An infinite iterator yielding configurations.

class qcd.HMC[source]

Bases: object

Hamiltonian Monte Carlo.

__init__()[source]

Args:

step(N=1)[source]
iter()[source]
qcd.main(args)[source]