The Canonical Ensemble

A canonical ensemble with fixed conserved quantities may be built from the GrandCanonical by projection,

\[\text{tr}[e^{-\beta H}]_{N, S_h} = \text{tr}[ e^{-\beta H} P_N P_{S_h} ]\]

where \(P\) indicates a projection operator of the indicated quantum number to a particular value. A Sector is a choice of for the conserved quantities; one may construct sectors with fixed particle number \(N\), spin projection \(S_h\) or both.

Warning

Canonical projection is very expensive. In addition to the normal measurement cost, the cost scales with an extra factor the spatial volume for every quantum number projected. Constructing multiple Sectors from a Canonical ensemble shares work under the hood and amortizes these costs over the sectors. Accelerated techniques exist [9] but are not (yet?) implemented here, and offer better, but still large, costs!

tdg.ensemble.Canonical

class tdg.ensemble.Canonical(grandCanonical)[source]

Bases: H5able

Whereas the grand-canonical ensemble fixes thermodynamic variables (such chemical potential \(\mu\) or external field \(\vec{h}\)), a canonical ensemble fixes quantum numbers (like total particle number \(N\) or total spin projection along \(\vec{h}\), \(S_\vec{h}\)).

We construct a canonical ensemble from a grand-canonical ensemble by projecting the desired quantum numbers.

\[\begin{split}\begin{align} \left\langle\mathcal{O}\right\rangle_{N, S_h} &= \frac{\text{tr}\left[ e^{-\beta H} \mathcal{O}\right]_{N, S_h}}{\text{tr}\left[ e^{-\beta H}\right]_{N, S_h}} = \frac{\text{tr}\left[ e^{-\beta (H-\mu \hat{N}-h \cdot \hat{S})} \mathcal{O} \right]_{N, S_h}}{\text{tr}\left[ e^{-\beta (H-\mu \hat{N}-h \cdot \hat{S})}\right]_{N, S_h}} \nonumber\\ &= \frac{\text{tr}\left[ e^{-\beta (H-\mu\hat{N}-h\cdot \hat{S})} P_N P_{S_h} \mathcal{O}\right]}{\text{tr}\left[ e^{-\beta (H - \mu \hat{N} - h \cdot \hat{S})} P_N P_{S_h}\right]} = \frac{\left\langle P_N P_{S_h} \mathcal{O}\right\rangle}{\left\langle P_N P_{S_h}\right\rangle} \label{eq:canonical-grand canonical projection} \end{align}\end{split}\]

where the subscripted expectation values are canonical, the unsubscripted ones are grand-canonical, and \(P\) operators are projectors of the respective quantum number to the subscript’s value.

Note that the chemical potential \(\mu\) and external field \(\vec{h}\) do not in principle alter canonical expectation values. However, in practice, if the grand canonical ensemble being projected has a expectation values very different from the sectors of interest you may encounter a numerical overlap problem, where the denominator is very small and noisy. In that sense, well-chosen \(\mu\) and \(\vec{h}\) can provide numerical stabilization.

Sector(Particles, Spin)[source]

A Sector in which to make measurements. Different Sector s generated from the same canonical ensemble reuse intermediate results and can save a lot of computational effort.

Parameters
  • Particles (int or None) – The baryon number \(N\).

  • Spin (half-integer or None) – The spin projection \(S_h\) along the GrandCanonical Action.h (or \(\hat{z}\) if \(\vec{h}=0\)).

Return type

Sector in which to measure observables \(\mathcal{O}\).

tdg.ensemble.Sector

class tdg.ensemble.Sector(canonical, Particles, Spin)[source]

Bases: H5able

A sector is a choice of quantum numbers that specify a particular canonical ensemble. We currently have the capacity to project particle number (Particles) or the spin projected along the external field \(\vec{h}\) (if \(\vec{h}=0\), the z direction).

The constructor checks for consistency between the choices. You cannot, for example, specify an even number of particles and a half-integer spin. Since the particles are spin-half there is no such sector.

Note

Sector has machinery under the hood which allows the user to compute any measurements available in GrandCanonical. So, even though a Sector has no .N to call, you may call it nevertheless, with the options of GrandCanonical.N().

The exception is .Spin, because the construction of the canonical sector requires observables to commute with the projector, so it does not make sense to measure spin along any axis except \(\hat{h}\); therefore, calculate Sh() instead.

For implementation details, see Sector.__getattr__() in the source.

Warning

Sectors should only rarely be constructed manually; typically a user should construct sectors by invoking Canonical.Sector().

Parameters
  • canonical (Canonical) – The ensemble from which to construct the sector.

  • Particles (integer or None) – If an integer, the number of particles to project to. If None no projection of the particle number is performed.

  • Spin (half integer or None) – If a half-integer, the spin projection along \(\vec{h}\). If None no projection of the particle number is performed.

property weight

The projection operator \(\mathbb{P}\) evaluated on each configuration. The exepectation value goes downstairs in the grand-canonical formulation of the Canonical expectation value.

If you wish to perform a resampling analysis (like bootstrap or jackknife) these must be resampled and averaged independently from the projected observable upstairs in the expectation value.

property Sh

The spin projected along \(\vec{h}\). In expectation, you should get the Spin with which the sector was constructed, or 0 if the spin was not projected.

Because the reweighting leverages the GrandCanonical observables, we can test the grand-canonical sampling and observables on small few-body examples where we can calculate exactly. See, for example, sanity-checks/canonical-double-occupancy.py, where we compare an exact two-body spin-0 calculation of the DoubleOccupancy() on a 3×3 lattice at finite temperature.