quantax.sampler.NeighborExchange#

class quantax.sampler.NeighborExchange#

Bases: Metropolis

Generate Monte Carlo samples by exchanging neighbor spins or fermions. In fermion systems, it is similar to quantax.sampler.ParticleHop, but different to quantax.sampler.SiteExchange.

__init__(state: State, nsamples: int, reweight: float = 2.0, thermal_steps: int | None = None, sweep_steps: int | None = None, initial_spins: Array | None = None, n_neighbor: int | Sequence[int] = 1)#
Parameters:
  • state – The state used for computing the wave function and probability. Since exchanging neighbor spins doesn’t change the total Sz, the state must have quantax.symmetry.ParticleConserve symmetry to specify the symmetry sector.

  • nsamples – Number of samples generated per iteration. It should be a multiple of the total number of machines to allow samples to be equally distributed on different machines.

  • reweight – The reweight factor n defining the sample probability \(|\psi|^n\), default to 2.0.

  • thermal_steps – The number of thermalization steps in the beginning of each Markov chain, default to be 20 * fock state length.

  • sweep_steps – The number of steps for generating new samples, default to be 2 * fock state length.

  • initial_spins – The initial spins for every Markov chain before the thermalization steps, default to be random spins.

  • n_neighbor – The neighbors to be considered by exchanges, default to nearest neighbors.

property nflips: int#

The number of flips in new proposal.

property is_balanced: bool#

Whether the sampler has balanced proposal rate \(P(s'|s) = P(s|s')\), default to True

property nsamples: int#

Number of samples generated per iteration

reset() None#

Reset all Markov chains to initial_spins and thermalize them

property reweight: float#

The reweight factor n defining the sample probability \(|\psi|^n\)

property state: State#

The state used for computing the wave function and probability

sweep(nsweeps: int | None = None) Samples#

Generate new samples

Parameters:

nsweeps – Number of sweeps for generating the new samples, default to be self._sweep_steps