qmctorch.utils package¶
Submodules¶
Module contents¶
Utils module API.
-
qmctorch.utils.
plot_energy
(local_energy, e0=None, show_variance=False)[source]¶ Plot the evolution of the energy
Parameters:
-
qmctorch.utils.
plot_data
(observable, obsname)[source]¶ Plot the evolution a given data
Parameters: - obs_dict (SimpleNamespace) – namespace of observable
- obsname (str) – name (key) of the desired observable
-
qmctorch.utils.
plot_block
(eloc)[source]¶ Plot the blocking thingy
Parameters: eloc (np.array) – values of the local energy
-
qmctorch.utils.
plot_walkers_traj
(eloc, walkers='mean')[source]¶ Plot the trajectory of all the individual walkers
Parameters:
-
qmctorch.utils.
plot_correlation_time
(eloc)[source]¶ Plot the blocking thingy
Parameters: eloc (np.array) – values of the local energy
-
qmctorch.utils.
set_torch_double_precision
()[source]¶ Set the default precision to double for all torch tensors.
-
qmctorch.utils.
set_torch_single_precision
()[source]¶ Set the default precision to single for all torch tensors.
-
class
qmctorch.utils.
DataSet
(data)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Creates a torch data set
Parameters: {torch.tensor} -- data (data) –
-
class
qmctorch.utils.
Loss
(wf, method='energy', clip=False)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Defines the loss to use during the optimization
Parameters: {WaveFunction} -- wave function object used (wf) –
Keyword Arguments: - {str} -- method to use (default (method) – {‘energy’}) (energy, variance, weighted-energy, weighted-variance)
- {bool} -- clip the values that are +/- % sigma away from (clip) – the mean (default: {False})
-
forward
(pos, no_grad=False, deactivate_weight=False)[source]¶ Computes the loss
Parameters: {torch.tensor} -- positions of the walkers in that batch (pos) – Keyword Arguments: {bool} -- computes the gradient of the loss (no_grad) – (default: {False}) Returns: torch.tensor, torch.tensor – value of the loss, local energies
-
static
get_grad_mode
(no_grad)[source]¶ Returns enable_grad or no_grad
Parameters: {bool} -- [description] (no_grad) –
-
class
qmctorch.utils.
OrthoReg
(alpha=0.1)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Add a penalty loss to keep the MO orthogonalized
Keyword Arguments: {float} -- strength of the penaly (default (alpha) – {0.1}) -
forward
(W)[source]¶ Return the loss : |W x W^T - I|.
-
-
qmctorch.utils.
dump_to_hdf5
(obj, fname, root_name=None)[source]¶ Dump the content of an object in a hdf5 file.
Parameters: - {object} -- object to dump (obj) –
- {str} -- name of the hdf5 (fname) –
Keyword Arguments: {str} -- root group in the hdf5 file (default (root_name) – {None})
-
qmctorch.utils.
load_from_hdf5
(obj, fname, obj_name)[source]¶ Load the content of an hdf5 file in an object.
Parameters: - {object} -- object where to load the data (obj) –
- {str} -- name pf the hdf5 file (fname) –
- {str} -- name of the root group in the hdf5 (obj_name) –
-
qmctorch.utils.
register_extra_attributes
(obj, attr_names)[source]¶ Register extra attribute to be able to dump them
Parameters: - {object} -- the object where we want to add attr (obj) –
- {list} -- a list of attr names (attr_names) –
-
qmctorch.utils.
fast_power
(x, k, mask0=None, mask2=None)[source]¶ Computes x**k when k have elements 0, 1, 2
Parameters: - x (torch.tensor) – input
- k (torch.tensor) – exponents
- mask0 (torch.tensor) – precomputed mask of the elements of that are 0 (Defaults to None and computed here)
- mask2 (torch.tensor) – precomputed mask of the elements of that are 2 (Defaults to None and computed here)
Returns: values of x**k
Return type: torch.tensor
-
class
qmctorch.utils.
InterpolateMolecularOrbitals
(wf)[source]¶ Bases:
object
Interpolation of the AO using a log grid centered on each atom.
-
get_mo_max_index
(orb)[source]¶ Get the index of the highest MO to inlcude in the interpoaltion
Parameters: orb (str) – occupied or all Raises: ValueError
– if orb not valid
-
-
class
qmctorch.utils.
InterpolateAtomicOrbitals
(wf)[source]¶ Bases:
object
Interpolation of the AO using a log grid centered on each atom.
-
qmctorch.utils.
btrace
(M)[source]¶ Computes the trace of batched matrices
Parameters: M (torch.tensor) – matrices of size (Na, Nb, … Nx, N, N) Returns: trace of matrices (Na, Nb, … Nx) Return type: torch.tensor Example
>>> m = torch.rand(100,5,5) >>> tr = btrace(m)
-
qmctorch.utils.
bdet2
(M)[source]¶ Computes the determinant of batched 2x2 matrices
Parameters: M (torch.tensor) – input matrices Returns: determinants of the matrices Return type: torch.tensor
-
qmctorch.utils.
bproj
(M, P)[source]¶ Project batched marices using P^T M P
Parameters: - M (torch.tensor) – batched matrices size (…, N, M)
- P (torch.tensor) – Porjectors size (…, N, M)
Returns: Projected matrices
Return type: torch.tensor