HamiltonCGTO

class dqc.hamilton.HamiltonCGTO(atombases: List[dqc.utils.datastruct.AtomCGTOBasis], spherical: bool = True, df: Optional[dqc.utils.datastruct.DensityFitInfo] = None, efield: Optional[Tuple[torch.Tensor, ]] = None, cache: Optional[dqc.utils.cache.Cache] = None)[source]

Hamiltonian object of contracted Gaussian type-orbital. This class orthogonalizes the basis by taking the weighted eigenvectors of

the overlap matrix, i.e. the eigenvectors divided by square root of the eigenvalues.

The advantage of doing this is making the overlap matrix in Roothan’s equation

identity and it could handle overcomplete basis.

property nao

Returns the number of atomic orbital basis

property kpts

Returns the list of k-points in the Hamiltonian, raise TypeError if the Hamiltonian does not have k-points. Shape: (nkpts, ndim)

property df

Returns the density fitting object (if any) attached to this Hamiltonian object. If None, returns None

build() → dqc.hamilton.base_hamilton.BaseHamilton[source]

Construct the elements needed for the Hamiltonian. Heavy-lifting operations should be put here.

setup_grid(grid: dqc.grid.base_grid.BaseGrid, xc: Optional[dqc.xc.base_xc.BaseXC] = None) → None[source]

Setup the basis (with its grad) in the spatial grid and prepare the gradient of atomic orbital according to the ones required by the xc. If xc is not given, then only setup the grid with ao (without any gradients of ao)

get_nuclattr() → xitorch._core.linop.LinearOperator[source]

Returns the LinearOperator of the nuclear Coulomb attraction.

get_kinnucl() → xitorch._core.linop.LinearOperator[source]

Returns the LinearOperator of the one-electron operator (i.e. kinetic and nuclear attraction).

get_overlap() → xitorch._core.linop.LinearOperator[source]

Returns the LinearOperator representing the overlap of the basis.

get_elrep(dm: torch.Tensor) → xitorch._core.linop.LinearOperator[source]

Obtains the LinearOperator of the Coulomb electron repulsion operator. Known as the J-matrix.

get_exchange(dm: torch.Tensor) → xitorch._core.linop.LinearOperator[source]
get_exchange(dm: dqc.utils.datastruct.SpinParam[torch.Tensor]) → dqc.utils.datastruct.SpinParam[xitorch._core.linop.LinearOperator]

Obtains the LinearOperator of the exchange operator. It is -0.5 * K where K is the K matrix obtained from 2-electron integral.

get_vext(vext: torch.Tensor) → xitorch._core.linop.LinearOperator[source]

Returns a LinearOperator of the external potential in the grid.

\[\mathbf{V}_{ij} = \int b_i(\mathbf{r}) V(\mathbf{r}) b_j(\mathbf{r})\ d\mathbf{r}\]
get_vxc(dm: dqc.utils.datastruct.SpinParam[torch.Tensor]) → dqc.utils.datastruct.SpinParam[xitorch._core.linop.LinearOperator][source]
get_vxc(dm: torch.Tensor) → xitorch._core.linop.LinearOperator

Returns a LinearOperator for the exchange-correlation potential.

ao_orb2dm(orb: torch.Tensor, orb_weight: torch.Tensor) → torch.Tensor[source]

Convert the atomic orbital to the density matrix.

aodm2dens(dm: torch.Tensor, xyz: torch.Tensor) → torch.Tensor[source]

Get the density value in the Cartesian coordinate.

get_e_hcore(dm: torch.Tensor) → torch.Tensor[source]

Get the energy from the one-electron Hamiltonian. The input is total density matrix.

get_e_elrep(dm: torch.Tensor) → torch.Tensor[source]

Get the energy from the electron repulsion. The input is total density matrix.

get_e_exchange(dm: Union[torch.Tensor, dqc.utils.datastruct.SpinParam[torch.Tensor]]) → torch.Tensor[source]

Get the energy from the exact exchange.

get_e_xc(dm: Union[torch.Tensor, dqc.utils.datastruct.SpinParam[torch.Tensor]]) → torch.Tensor[source]

Returns the exchange-correlation energy using the xc object given in .setup_grid()

ao_orb_params2dm(ao_orb_params: torch.Tensor, orb_weight: torch.Tensor, with_penalty: None) → torch.Tensor[source]
ao_orb_params2dm(ao_orb_params: torch.Tensor, orb_weight: torch.Tensor, with_penalty: float) → torch.Tensor

Convert the atomic orbital free parameters (parametrized in such a way so it is not bounded) to the density matrix.

Parameters
  • ao_orb_params (torch.Tensor) – The tensors that parametrized atomic orbital in an unbounded space.

  • orb_weight (torch.Tensor) – The orbital weights.

  • with_penalty (float or None) – If a float, it returns a tuple of tensors where the first element is dm, and the second element is the penalty multiplied by the penalty weights. The penalty is to compensate the overparameterization of ao_orb_params, stabilizing the Hessian for gradient calculation.

Returns

The density matrix from the orbital parameters and (if with_penalty) the penalty of the overparameterization of ao_orb_params.

Return type

torch.Tensor or tuple of torch.Tensor

Notes

  • The penalty should be 0 if ao_orb_params is from dm2ao_orb_params.

  • The density matrix should be recoverable when put through dm2ao_orb_params and ao_orb_params2dm.

dm2ao_orb_params(dm: torch.Tensor, norb: int) → torch.Tensor[source]

Convert from the density matrix to the orbital parameters. The map is not one-to-one, but instead one-to-many where there might be more than one orbital parameters to describe the same density matrix. For restricted systems, only one of the dm (dm.u or dm.d) is sufficient.

Parameters
  • dm (torch.Tensor) – The density matrix.

  • norb (int) – The number of orbitals for the system.

Returns

The atomic orbital parameters.

Return type

torch.Tensor

getparamnames(methodname: str, prefix: str = '') → List[str][source]

Return the paramnames