Mol¶
-
class
dqc.
Mol
(moldesc: Union[str, Tuple[Union[List[str], List[Union[int, float, torch.Tensor]], torch.Tensor], Union[List[List[float]], numpy.ndarray, torch.Tensor]]], basis: Union[str, List[dqc.utils.datastruct.CGTOBasis], List[str], List[List[dqc.utils.datastruct.CGTOBasis]], Dict[Union[str, int], Union[List[dqc.utils.datastruct.CGTOBasis], str]]], *, orthogonalize_basis: bool = True, ao_parameterizer: str = 'qr', grid: Union[int, str] = 'sg3', spin: Optional[Union[int, float, torch.Tensor]] = None, charge: Union[int, float, torch.Tensor] = 0, orb_weights: Optional[dqc.utils.datastruct.SpinParam[torch.Tensor]] = None, efield: Optional[Union[torch.Tensor, Tuple[torch.Tensor, …]]] = None, vext: Optional[torch.Tensor] = None, dtype: torch.dtype = torch.float64, device: torch.device = device(type='cpu'))[source]¶ Describe the system of an isolated molecule.
- Parameters
moldesc (*) – Description of the molecule system. If string, it can be described like
"H 1 0 0; H -1 0 0"
. If tuple, the first element of the tuple is the Z number of the atoms while the second element is the position of the atoms:(atomzs, atomposs)
.basis (*) – The string describing the gto basis. If it is a list, then it must have the same length as the number of atoms.
grid (*) – Describe the grid. If it is an integer, then it uses the default grid with specified level of accuracy.
spin (*) – The difference between spin-up and spin-down electrons. It must be an integer or
None
. IfNone
, then it isnum_electrons % 2
. For floating point atomzs and/or charge, thespin
must be specified.charge (*) – The charge of the molecule.
orb_weights (*) – Specifiying the orbital occupancy (or weights) directly. If specified,
spin
andcharge
arguments are ignored.vext (*) – The tensor describing the external potential given in the grid. The grid position can be obtained by
Mol().get_grid().get_rgrid()
.efield (*) – Uniform electric field of the system. If a tensor, then it is assumed to be a constant electric field with the energy is calculated based on potential at
(0, 0, 0)
is0
. If a tuple of tensor, then the first element will have a shape of(ndim,)
representing the constant electric field, second element is the gradient of electric field with the last dimension is the direction of the electric field, third element is the gradgrad of electric field, etc. IfNone
, then the electric field is assumed to be0
.dtype (*) – The data type of tensors in this class.
device (*) – The device on which the tensors in this class are stored.
orthogonalize_basis (*) – (computational option) If True, orthogonalize the basis in the hamiltonian calculation. If False, then use the raw basis, this might not work with over-complete basis.
ao_parameterizer (*) – (computational option) Specifying the atomic orbital parameterizer.
-
densityfit
(method: Optional[str] = None, auxbasis: Optional[Union[str, List[dqc.utils.datastruct.CGTOBasis], List[str], List[List[dqc.utils.datastruct.CGTOBasis]], Dict[Union[str, int], Union[List[dqc.utils.datastruct.CGTOBasis], str]]]] = None) → dqc.system.base_system.BaseSystem[source]¶ Indicate that the system’s Hamiltonian uses density fit for its integral.
- Parameters
method (Optional[str]) –
Density fitting method. Available methods in this class are:
"coulomb"
: Minimizing the Coulomb inner product, i.e.min <p-p_fit|r_12|p-p_fit>
Ref: Eichkorn, et al. Chem. Phys. Lett. 240 (1995) 283-290. (default)"overlap"
: Minimizing the overlap inner product, i.e. min <p-p_fit|p-p_fit>
auxbasis (Optional[BasisInpType]) – Auxiliary basis for the density fit. If not specified, then it uses
"cc-pvtz-jkfit"
.
-
get_hamiltonian
() → dqc.hamilton.base_hamilton.BaseHamilton[source]¶ Returns the Hamiltonian that corresponds to the system, i.e.
HamiltonCGTO
-
set_cache
(fname: str, paramnames: Optional[List[str]] = None) → dqc.system.base_system.BaseSystem[source]¶ Setup the cache of some parameters specified by paramnames to be read/written on a file. If the file exists, then the parameters will not be recomputed, but just loaded from the cache instead. Cache is usually used for repeated calculations where the cached parameters are not changed (e.g. running multiple systems with slightly different environment.)
- Parameters
fname (str) – The file to store the cache.
paramnames (list of str or None) – List of parameter names to be read/write from the cache.
-
get_orbweight
(polarized: bool = False) → Union[torch.Tensor, dqc.utils.datastruct.SpinParam[torch.Tensor]][source]¶ Returns the atomic orbital weights. If polarized == False, then it returns the total orbital weights. Otherwise, it returns a tuple of orbital weights for spin-up and spin-down.
-
requires_grid
() → bool[source]¶ True if the system needs the grid to be constructed. Otherwise, returns False
-
getparamnames
(methodname: str, prefix: str = '') → List[str][source]¶ This method should list tensor names that affect the output of the method with name indicated in
methodname
. If themethodname
is not on the list in this function, it should raiseKeyError
.- Parameters
methodname (str) – The name of the method of the class.
prefix (str) – The prefix to be appended in front of the parameters name. This usually contains the dots.
- Returns
Sequence of name of parameters affecting the output of the method.
- Return type
Sequence of string
- Raises
KeyError – If the list in this function does not contain
methodname
.
Example
>>> class A(xitorch.EditableModule): ... def __init__(self, a): ... self.b = a*a ... ... def mult(self, x): ... return self.b * x ... ... def getparamnames(self, methodname, prefix=""): ... if methodname == "mult": ... return [prefix+"b"] ... else: ... raise KeyError()
-
make_copy
(**kwargs) → dqc.system.mol.Mol[source]¶ Returns a copy of the system identical to the orginal except for new parameters set in the kwargs.
- Parameters
**kwargs – Must be the same kwargs as Mol.
-
property
atompos
¶ Returns the atom positions as a tensor with shape
(natoms, ndim)
-
property
atomzs
¶ Returns the tensor containing the atomic number with shape
(natoms,)
-
property
atommasses
¶ Returns the tensor containing atomic mass with shape
(natoms)
in atomic unit
-
property
spin
¶ Returns the total spin of the system.
-
property
charge
¶ Returns the charge of the system.
-
property
numel
¶ Returns the total number of the electrons in the system.
-
property
efield
¶ Returns the external electric field of the system, or None if there is no electric field.