qmctorch.sampler package¶
Submodules¶
Module contents¶
-
class
qmctorch.sampler.
SamplerBase
(nwalkers, nstep, step_size, ntherm, ndecor, nelec, ndim, init, cuda)[source]¶ Bases:
object
Base class for the sampler
Parameters: - nwalkers (int) – number of walkers
- nstep (int) – number of MC steps
- step_size (float) – size of the steps in bohr
- ntherm (int) – number of MC steps to thermalize
- ndecor (int) – unmber of MC steps to decorellate
- nelec (int) – number of electrons in the system
- ndim (int) – number of cartesian dimension
- init (dict) – method to initialize the walkers
- cuda ([type]) – [description]
-
class
qmctorch.sampler.
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)
-
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
-
class
qmctorch.sampler.
Hamiltonian
(nwalkers: int = 100, nstep: int = 100, step_size: float = 0.2, L: int = 10, ntherm: int = -1, ndecor: int = 1, nelec: int = 1, ndim: int = 3, init: Dict[KT, VT] = {'max': 5, 'min': -5}, cuda: bool = False)[source]¶ Bases:
qmctorch.sampler.sampler_base.SamplerBase
Hamiltonian Monte Carlo Sampler.
Parameters: - nwalkers (int, optional) – Number of walkers. Defaults to 100.
- nstep (int, optional) – Number of steps. Defaults to 100.
- step_size (int, optional) – length of the step. Defaults to 0.2.
- L (int, optional) – length of the trajectory . Defaults to 10.
- 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 last position
- ndecor (int, optional) – number of mc step for decorrelation. Defaults 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()
- cuda (bool, optional) – turn CUDA ON/OFF. Defaults to False.
-
class
qmctorch.sampler.
GeneralizedMetropolis
(nwalkers=100, nstep=1000, step_size=3, ntherm=-1, ndecor=1, nelec=1, ndim=1, init={'max': 5, 'min': -5, 'type': 'uniform'}, cuda=False)[source]¶ Bases:
qmctorch.sampler.sampler_base.SamplerBase
Generalized Metropolis Hasting sampler
Parameters: - nwalkers (int, optional) – number of walkers. Defaults to 100.
- nstep (int, optional) – number of steps. Defaults to 1000.
- step_size (int, optional) – size of the steps. Defaults to 3.
- ntherm (int, optional) – number of steps for thermalization. Defaults to -1.
- ndecor (int, optional) – number of steps for decorelation. Defaults to 1.
- nelec (int, optional) – number of electron. Defaults to 1.
- ndim (int, optional) – number of dimensions. Defaults to 1.
- init (dict, optional) – method to initialize the walkers. Defaults to {‘type’: ‘uniform’, ‘min’: -5, ‘max’: 5}.
- cuda (bool, optional) – use cuda. Defaults to False.
-
move
(drift)[source]¶ Move electron one at a time in a vectorized way.
Parameters: drift (torch.tensor) – drift velocity of the walkers Returns: new positions of the walkers Return type: torch.tensor