qmctorch.wavefunction.pooling package
Submodules
qmctorch.wavefunction.pooling.orbital_configurations module
- class qmctorch.wavefunction.pooling.orbital_configurations.OrbitalConfigurations(mol: Molecule)[source]
Bases:
object
- qmctorch.wavefunction.pooling.orbital_configurations.get_excitation(configs: Tuple[torch.LongTensor, torch.LongTensor]) Tuple[List[List[List[int]]], List[List[List[int]]]][source]
Get the excitation data
- Parameters:
configs – tuple of two tensors of shape (nconfig, norb) configuratin of the electrons
- Returns:
- two lists of lists of lists of integers
excitation i -> l, j -> l exc_up[i][0] : occupied orbital, exc_up[i][1] : virtual orbital exc_down[i][0] : occupied orbital, exc_down[i][1] : virtual orbital
- Return type:
exc_up, exc_down
- qmctorch.wavefunction.pooling.orbital_configurations.get_unique_excitation(configs: Tuple[torch.LongTensor, torch.LongTensor]) Tuple[Tuple[List[List[int]], List[List[int]]], Tuple[List[int], List[int]]][source]
get the unique excitation data
- Parameters:
configs (tuple) – configuratin of the electrons
- Returns:
- unique excitation data
uniq_exc[0] (list): unique excitation of spin up uniq_exc[1] (list): unique excitation of spin down
- index_uniq_exc (tuple): index map for the unique exc
index_uniq_exc[0] (list): index of the unique excitation of spin up index_uniq_exc[1] (list): index of the unique excitation of spin down
- Return type:
uniq_exc (tuple)
qmctorch.wavefunction.pooling.orbital_projector module
- class qmctorch.wavefunction.pooling.orbital_projector.OrbitalProjector(configs: List[torch.tensor], mol: Molecule, cuda: bool = False)[source]
Bases:
objectProject the MO matrix in Slater Matrices
- Parameters:
- get_unique_configs() Tuple[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor, torch.Tensor]][source]
Get the unique configurations
- Returns:
configs_up (torch.Tensor): unique configurations of the spin up electrons configs_down (torch.Tensor): unique configurations of the spin down electrons index_unique_confs_up (torch.Tensor): index of the unique configurations of the spin up electrons index_unique_confs_down (torch.Tensor): index of the unique configurations of the spin down electrons
- Return type:
Tuple[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor, torch.Tensor]]
- split_orbitals(mat: torch.Tensor, unique_configs: bool = False) Tuple[torch.Tensor, torch.Tensor][source]
- Split the orbital matrix in multiple Slater matrices
This version does not store the projectors
- Parameters:
mat – matrix to split
unique_confgs – compute only the Slater matrices of the unique conf if True (Default=False)
- Returns:
all Slater matrices
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- class qmctorch.wavefunction.pooling.orbital_projector.ExcitationMask(unique_excitations: List[Tuple[torch.Tensor, torch.Tensor]], mol: Molecule, max_orb: List[int], cuda: bool = False)[source]
Bases:
objectSelect the occupied MOs of Slater determinant using masks
- Parameters:
qmctorch.wavefunction.pooling.slater_pooling module
- class qmctorch.wavefunction.pooling.slater_pooling.SlaterPooling(*args: Any, **kwargs: Any)[source]
Bases:
ModuleComputes the Slater determinants
- Parameters:
- forward(input: torch.Tensor) torch.Tensor[source]
Computes the values of the determinats
- Parameters:
input (torch.Tensor) – MO matrices nbatch x nelec x nmo
- Returns:
slater determinants
- Return type:
- get_slater_matrices(input: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]
Computes the slater matrices
- Parameters:
input (torch.Tensor) – MO matrices nbatch x nelec x nmo
- Returns:
slater matrices of spin up/down
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- det_explicit(input: torch.Tensor) torch.Tensor[source]
Computes the values of the determinants from the slater matrices
- Parameters:
input (torch.tensor) – MO matrices nbatch x nelec x nmo
- Returns:
slater determinants
- Return type:
torch.tensor
- det_single_double(input: torch.Tensor) torch.Tensor[source]
Computes the determinant of ground state + single + double excitations.
- Parameters:
input (torch.Tensor) – MO matrices nbatch x nelec x nmo
- Returns:
Slater determinants for the configurations
- Return type:
- det_ground_state(input: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]
Computes the Slater determinants of the ground state.
- Parameters:
input (torch.Tensor) – Molecular orbital matrices of shape (nbatch, nelec, nmo).
- Returns:
Slater determinants for spin up and spin down configurations.
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- det_unique_single_double(input: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]
Computes the SD of single/double excitations
The determinants of the single excitations are calculated from the ground state determinant and the ground state Slater matrices whith one column modified. See : Monte Carlo Methods in ab initio quantum chemistry B.L. Hammond, appendix B1
Note : if the state on configs are specified in order we end up with excitations that comes from a deep orbital, the resulting slater matrix has one column changed (with the new orbital) and several permutation. We therefore need to multiply the slater determinant by (-1)^nperm.
\[MO = [ A | B ] det(Exc_{ij}) = (det(A) * A^{-1} * B)_{i,j}\]- Parameters:
input (torch.tensor) – MO matrices nbatch x nelec x nmo
- operator(mo: torch.Tensor, bop: torch.Tensor, op: ~typing.Callable[[torch.Tensor, torch.Tensor], torch.Tensor] = <built-in function add>, op_squared: bool = False, inv_mo: ~typing.Tuple[torch.Tensor, torch.Tensor] | None = None) torch.Tensor[source]
Computes the values of an opearator applied to the procuts of determinant
- Parameters:
mo (torch.Tensor) – matrix of MO vals(Nbatch, Nelec, Nmo)
bkin (torch.Tensor) – kinetic operator (Nbatch, Nelec, Nmo)
op (operator) – how to combine the up/down contribution
op_squared (bool, optional) – return the trace of the square of the product if True
inv_mo (tupe, optional) – precomputed inverse of the mo up & down matrices
- Returns:
kinetic energy
- Return type:
- operator_ground_state(mo: torch.Tensor, bop: torch.Tensor, op_squared: bool = False, inv_mo: Tuple[torch.Tensor, torch.Tensor] | None = None) Tuple[torch.Tensor, torch.Tensor][source]
Computes the values of any operator on gs only
- operator_explicit(mo: torch.Tensor, bkin: torch.Tensor, op_squared: bool = False) Tuple[torch.Tensor, torch.Tensor][source]
- Computes the value of any operator using the trace trick for a product
of spin up/down determinant.
\[\begin{split}-\\frac{1}{2} \Delta \Psi = -\\frac{1}{2} D_{up} D_{down} ( \Delta_{up} D_{up} / D_{up} + \Delta_{down} D_{down} / D_{down} )\end{split}\]- Parameters:
mo – matrix of MO vals(Nbatch, Nelec, Nmo)
bkin – kinetic operator (Nbatch, Nelec, Nmo)
op_squared – return the trace of the square of the product if True
- Returns:
kinetic energy
- Return type:
- operator_single_double(mo: torch.Tensor, bop: torch.Tensor, op_squared: bool = False, inv_mo: Tuple[torch.Tensor, torch.Tensor] | None = None) Tuple[torch.Tensor, torch.Tensor][source]
Computes the value of any operator on gs + single + double
- Parameters:
mo – matrix of molecular orbitals (torch.tensor)
bop – matrix of kinetic operator (torch.tensor)
op_squared – return the trace of the square of the product if True (bool)
inv_mo – precomputed inverse of the up/down MO matrices (tuple, optional)
- Returns:
kinetic energy values (torch.tensor)
- Return type:
- operator_unique_single_double(mo: torch.Tensor, bop: torch.Tensor, op_squared: bool, inv_mo: Tuple[torch.Tensor, torch.Tensor] | None = None) Tuple[torch.Tensor, torch.Tensor][source]
Compute the operator value of the unique single/double conformation
- Parameters:
mo (torch.Tensor) – matrix of molecular orbitals
bop (torch.Tensor) – matrix of kinetic operator
op_squared (bool) – return the trace of the square of the product if True
inv_mo (tuple, optional) – precomputed inverse of the up/down MO matrices
- Returns:
operator values
- Return type:
- static op_single(baseterm: torch.Tensor, mat_exc: torch.Tensor, M: torch.Tensor, index: List[int], nbatch: int) torch.Tensor[source]
Computes the operator values for single excitation
\[Tr( \bar{A}^{-1} \bar{B}) = Tr(A^{-1} B) + Tr( T M ) T = P ( A^{-1} \bar{A})^{-1} P M = A^{-1}\bar{B} - A^{-1}BA^{-1}\bar{A}\]- Parameters:
baseterm (torch.Tensor) – trace(A B)
mat_exc (torch.Tensor) – invA @ Abar
M (torch.Tensor) – invA Bbar - inv A B inv A Abar
index (List[int]) – list of index of the excitations
nbatch (int) – batch size
- Returns:
trace(T M) + trace(A B)
- Return type:
- static op_multiexcitation(baseterm: torch.Tensor, mat_exc: torch.Tensor, M: torch.Tensor, index: List[int], size: int, nbatch: int) torch.Tensor[source]
Computes the operator values for single excitation
\[Tr( \bar{A}^{-1} \bar{B}) = Tr(A^{-1} B) + Tr( T M ) T = P ( A^{-1} \bar{A})^{-1} P M = A^{-1}\bar{B} - A^{-1}BA^{-1}\bar{A}\]- Parameters:
baseterm (torch.Tensor) – trace(A B)
mat_exc (torch.Tensor) – invA @ Abar
M (torch.Tensor) – invA Bbar - inv A B inv A Abar
index (List[int]) – list of index of the excitations
size (int) – number of excitation
nbatch (int) – batch size
- Returns:
trace(A B) + trace(T M)
- Return type:
- static op_squared_single(baseterm: torch.Tensor, mat_exc: torch.Tensor, M: torch.Tensor, Y: torch.Tensor, index: List[int], nbatch: int) torch.Tensor[source]
Computes the operator squared for single excitation
\[Tr( (\bar{A}^{-1} \bar{B})^2) = Tr((A^{-1} B)^2) + Tr( (T M)^2 ) + 2 Tr(T Y) T = P ( A^{-1} \bar{A})^{-1} P -> mat_exc in the code M = A^{-1}\bar{B} - A^{-1}BA^{-1}\bar{A} Y = A^{-1} B M\]- Parameters:
baseterm (torch.Tensor) – trace(A B A B)
mat_exc (torch.Tensor) – invA @ Abar
M (torch.Tensor) – invA Bbar - inv A B inv A Abar
Y (torch.Tensor) – invA B M
index (List[int]) – list of index of the excitations
nbatch (int) – batch size
- Returns:
trace((A^{-1} B)^2) + trace((T M)^2) + 2 trace(T Y)
- Return type:
- static op_squared_multiexcitation(baseterm: torch.tensor, mat_exc: torch.tensor, M: torch.tensor, Y: torch.tensor, index: List[int], size: int, nbatch: int) torch.tensor[source]
Computes the operator squared for multiple excitation
\[Tr( (\bar{A}^{-1} \bar{B})^2) = Tr((A^{-1} B)^2) + Tr( (T M)^2 ) + 2 Tr(T Y) T = P ( A^{-1} \bar{A})^{-1} P -> mat_exc in the code M = A^{-1}\bar{B} - A^{-1}BA^{-1}\bar{A} Y = A^{-1} B M\]- Parameters:
- Returns:
trace((A^{-1} B)^2) + trace((T M)^2) + 2 trace(T Y)
- Return type:
torch.tensor
- compute_inverse_occupied_mo_matrix(mo: torch.Tensor) Tuple[torch.Tensor, torch.Tensor] | None[source]
precompute the inverse of the occupied mo matrix
- Parameters:
mo (torch.tensor) – matrix of the molecular orbitals
- Returns:
inverse of the spin up/down mo matrices
- Return type: