netket.sampler.MetropolisHamiltonian¶

class netket.sampler.MetropolisHamiltonian(hilbert, hamiltonian, *args, **kwargs)[source]

Sampling based on the off-diagonal elements of a Hamiltonian (or a generic Operator). In this case, the transition matrix is taken to be:

$T( \mathbf{s} \rightarrow \mathbf{s}^\prime) = \frac{1}{\mathcal{N}(\mathbf{s})}\theta(|H_{\mathbf{s},\mathbf{s}^\prime}|),$

where $$\theta(x)$$ is the Heaviside step function, and $$\mathcal{N}(\mathbf{s})$$ is a state-dependent normalization. The effect of this transition probability is then to connect (with uniform probability) a given state $$\mathbf{s}$$ to all those states $$\mathbf{s}^\prime$$ for which the Hamiltonian has finite matrix elements. Notice that this sampler preserves by construction all the symmetries of the Hamiltonian. This is in generally not true for the local samplers instead.

This sampler only works on the CPU. To use the Hamiltonian smapler with GPUs, you should use netket.sampler.MetropolisHamiltonianNumpy

Parameters
• machine – A machine $$\Psi(s)$$ used for the sampling. The probability distribution being sampled from is $$F(\Psi(s))$$, where the function $$F(X)$$, is arbitrary, by default $$F(X)=|X|^2$$.

• hamiltonian – The operator used to perform off-diagonal transition.

• n_chains – The number of Markov Chain to be run in parallel on a single process.

• sweep_size – The number of exchanges that compose a single sweep. If None, sweep_size is equal to the number of degrees of freedom (n_visible).

Examples

Sampling from a RBM machine in a 1D lattice of spin 1/2

>>> import netket as nk
>>>
>>> g=nk.graph.Hypercube(length=10,n_dim=2,pbc=True)
>>> hi=nk.hilbert.Spin(s=0.5, N=g.n_nodes)
>>>
>>> # Transverse-field Ising Hamiltonian
>>> ha = nk.operator.Ising(hilbert=hi, h=1.0, graph=g)
>>>
>>> # Construct a MetropolisExchange Sampler
>>> sa = nk.sampler.MetropolisHamiltonian(hi, hamiltonian=ha)
>>> print(sa)
MetropolisSampler(rule = HamiltonianRule(Ising(J=1.0, h=1.0; dim=100)), n_chains = 16, machine_power = 2, n_sweeps = 100, dtype = <class 'numpy.float64'>)

Return type

MetropolisSampler