qmctorch.sampler.metropolis module

class qmctorch.sampler.metropolis.Metropolis(nwalkers: int = 100, nstep: int = 1000, step_size: float = 0.2, ntherm: int = -1, ndecor: int = 1, nelec: int = 1, ndim: int = 3, init: Dict[KT, VT] = {'max': 5, 'min': -5}, move: Dict[KT, VT] = {'proba': 'normal', 'type': 'all-elec'}, cuda: bool = False)[source]

Bases: qmctorch.sampler.sampler_base.SamplerBase

Metropolis Hasting generator

Parameters:
  • nwalkers (int, optional) – Number of walkers. Defaults to 100.
  • nstep (int, optional) – Number of steps. Defaults to 1000.
  • step_size (int, optional) – length of the step. Defaults to 0.2.
  • nelec (int, optional) – total number of electrons. Defaults to 1.
  • ntherm (int, optional) – number of mc step to thermalize. Defaults to -1, i.e. keep only the last position
  • ndecor (int, optional) – number of mc step for decorelation. Defauts to 1.
  • ndim (int, optional) – total number of dimension. Defaults to 3.
  • init (dict, optional) – method to init the positions of the walkers. See Molecule.domain()
  • move (dict, optional) –

    method to move the electrons. default(‘all-elec’,’normal’)

    ’type’:
    ’one-elec’: move a single electron per iteration

    ’all-elec’: move all electrons at the same time

    ’all-elec-iter’: move all electrons by iterating through single elec moves

    ’proba’ :
    ’uniform’: uniform in a cube

    ’normal’: gussian in a sphere

  • cuda (bool, optional) – turn CUDA ON/OFF. Defaults to False.
Examples::
>>> mol = Molecule('h2.xyz')
>>> wf = SlaterJastrow(mol)
>>> sampler = Metropolis(nwalkers=100, nelec=wf.nelec)
>>> pos = sampler(wf.pdf)
log_data()[source]

log data about the sampler.

configure_move(move: Dict[KT, VT])[source]

Configure the electron moves

Parameters:move (dict, optional) –

method to move the electrons. default(‘all-elec’,’normal’)

’type’:
’one-elec’: move a single electron per iteration

’all-elec’: move all electrons at the same time

’all-elec-iter’: move all electrons by iterating through single elec moves

’proba’ :
’uniform’: uniform ina cube

’normal’: gussian in a sphere

Raises:ValueError – If moves are not recognized
move(pdf: Callable, id_elec: int) → <sphinx.ext.autodoc.importer._MockObject object at 0x7f59abd47410>[source]

Move electron one at a time in a vectorized way.

Parameters:
  • pdf (callable) – function to sample
  • id_elec (int) – index f the electron to move
Returns:

new positions of the walkers

Return type:

torch.tensor