momentGW.thc

Tensor hyper-contraction.

Module Contents

class momentGW.thc.Integrals(with_df, mo_coeff, mo_occ, file_path=None)

Bases: momentGW.ints.Integrals

Container for the tensor-hypercontracted integrals required for GW methods.

Parameters:
  • with_df (pyscf.df.DF) – Density fitting object.

  • mo_coeff (numpy.ndarray) – Molecular orbital coefficients.

  • mo_occ (numpy.ndarray) – Molecular orbital occupations.

  • file_path (str, optional) – Path to the HDF5 file containing the integrals. Default value is None.

property coll

Get the (aux, MO) collocation array.

property cou

Get the (aux, aux) Coulomb array.

property Lp

Get the (aux, MO) array.

property Lx

Get the (aux, MO) array.

property Li

Get the (aux, W occ) array.

property La

Get the (aux, W vir) array.

property Lpq

Get the full uncompressed (aux, MO, MO) integrals.

property Lpx

Get the compressed (aux, MO, G) integrals.

property Lia

Get the compressed (aux, W occ, W vir) integrals.

property mo_coeff_g

Get the MO coefficients for the Green’s function.

property mo_coeff_w

Get the MO coefficients for the screened Coulomb interaction.

property mo_occ_w

Get the MO occupation numbers for the screened Coulomb interaction.

property nao

Get the number of AOs.

property nmo

Get the number of MOs.

property nocc

Get the number of occupied MOs.

property nvir

Get the number of virtual MOs.

property nmo_g

Get the number of MOs for the Green’s function.

property nmo_w

Get the number of MOs for the screened Coulomb interaction.

property nocc_w

Get the number of occupied MOs for the screened Coulomb interaction.

property nvir_w

Get the number of virtual MOs for the screened Coulomb interaction.

property naux

Get the number of auxiliary basis functions, after the compression.

property naux_full

Get the number of auxiliary basis functions, before the compression.

property is_bare

Get a boolean flag indicating whether the integrals have no self-consistencies.

property dtype

Get the dtype of the integrals.

get_compression_metric()

Return the compression metric - not currently used in THC.

import_thc_components()

Import a HDF5 file containing a dictionary. The keys “collocation_matrix” and a “coulomb_matrix” must exist, with shapes (MO, aux) and (aux, aux), respectively.

transform(do_Lpq=True, do_Lpx=True, do_Lia=True)

Transform the integrals in-place.

Parameters:
  • do_Lpq (bool, optional) – Whether the (aux, MO, MO) array is required. In THC, this requires the Lp array. Default value is True.

  • do_Lpx (bool, optional) – Whether the (aux, MO, MO) array is required. In THC, this requires the Lx array. Default value is True.

  • do_Lia (bool, optional) – Whether the (aux, occ, vir) array is required. In THC, this requires the Li and La arrays. Default value is True.

get_j(dm, basis='mo')

Build the J matrix.

Parameters:
  • dm (numpy.ndarray) – Density matrix.

  • basis (str, optional) – Basis in which to build the J matrix. One of (“ao”, “mo”). Default value is “mo”.

Returns:

vj – J matrix.

Return type:

numpy.ndarray

Notes

The basis of dm must be the same as basis.

get_k(dm, basis='mo')

Build the K matrix.

Parameters:
  • dm (numpy.ndarray) – Density matrix.

  • basis (str, optional) – Basis in which to build the K matrix. One of (“ao”, “mo”). Default value is “mo”.

Returns:

vk – K matrix.

Return type:

numpy.ndarray

Notes

The basis of dm must be the same as basis.

update_coeffs(mo_coeff_g=None, mo_coeff_w=None, mo_occ_w=None)

Update the MO coefficients in-place for the Green’s function and the screened Coulomb interaction.

Parameters:
  • mo_coeff_g (numpy.ndarray, optional) – Coefficients corresponding to the Green’s function. Default value is None.

  • mo_coeff_w (numpy.ndarray, optional) – Coefficients corresponding to the screened Coulomb interaction. Default value is None.

  • mo_occ_w (numpy.ndarray, optional) – Occupations corresponding to the screened Coulomb interaction. Default value is None.

Notes

If mo_coeff_g is None, the Green’s function is assumed to remain in the basis in which it was originally defined, and vice-versa for mo_coeff_w and mo_occ_w. At least one of mo_coeff_g and mo_coeff_w must be provided.

get_jk(dm, **kwargs)

Build the J and K matrices.

Returns:

  • vj (numpy.ndarray) – J matrix.

  • vk (numpy.ndarray) – K matrix.

Notes

See get_j and get_k for more information.

get_veff(dm, j=None, k=None, **kwargs)

Build the effective potential.

Returns:

  • veff (numpy.ndarray) – Effective potential.

  • j (numpy.ndarray, optional) – J matrix. If None, compute it. Default value is None.

  • k (numpy.ndarray, optional) – K matrix. If None, compute it. Default value is None.

Notes

See get_jk for more information.

get_fock(dm, h1e, **kwargs)

Build the Fock matrix.

Parameters:
  • dm (numpy.ndarray) – Density matrix.

  • h1e (numpy.ndarray) – Core Hamiltonian matrix.

  • **kwargs (dict, optional) – Additional keyword arguments for get_jk.

Returns:

fock – Fock matrix.

Return type:

numpy.ndarray

Notes

See get_jk for more information. The basis of h1e must be the same as dm.

class momentGW.thc.dTDA(gw, nmom_max, integrals, mo_energy=None, mo_occ=None)

Bases: momentGW.tda.dTDA

Compute the self-energy moments using dTDA and numerical integration with tensor-hypercontraction.

Parameters:
  • gw (BaseGW) – GW object.

  • nmom_max (int) – Maximum moment number to calculate.

  • integrals (BaseIntegrals) – Integrals object.

  • mo_energy (numpy.ndarray or tuple of numpy.ndarray, optional) – Molecular orbital energies. If a tuple is passed, the first element corresponds to the Green’s function basis and the second to the screened Coulomb interaction. Default value is that of gw.mo_energy.

  • mo_occ (numpy.ndarray or tuple of numpy.ndarray, optional) – Molecular orbital occupancies. If a tuple is passed, the first element corresponds to the Green’s function basis and the second to the screened Coulomb interaction. Default value is that of gw.mo_occ.

property Li

Get the (aux, W occ) array.

property La

Get the (aux, W vir) array.

property cou

Get the (aux, aux) Coulomb array.

property nmo

Get the number of MOs.

property naux

Get the number of auxiliaries.

property nov

Get the number of ov states in the screened Coulomb interaction.

build_dd_moments()

Build the moments of the density-density response using tensor-hypercontraction.

Returns:

moments – Moments of the density-density response.

Return type:

numpy.ndarray

Notes

Unlike the standard momentGW.tda implementation, this method scales as \(O(N^3)\) with system size instead of \(O(N^4)\).

build_se_moments(zeta)

Build the moments of the self-energy via convolution with tensor-hypercontraction.

Parameters:

moments_dd (numpy.ndarray) – Moments of the density-density response.

Returns:

  • moments_occ (numpy.ndarray) – Moments of the occupied self-energy.

  • moments_vir (numpy.ndarray) – Moments of the virtual self-energy.

kernel(exact=False)

Run the polarizability calculation to compute moments of the self-energy.

Parameters:

exact (bool, optional) – Has no effect and is only present for compatibility with dRPA. Default value is False.

Returns:

  • moments_occ (numpy.ndarray) – Moments of the occupied self-energy.

  • moments_vir (numpy.ndarray) – Moments of the virtual self-energy.

convolve(eta, eta_orders=None, mo_energy_g=None, mo_occ_g=None)

Handle the convolution of the moments of the Green’s function and screened Coulomb interaction.

Parameters:
  • eta (numpy.ndarray) – Moments of the density-density response partly transformed into moments of the screened Coulomb interaction.

  • mo_energy_g (numpy.ndarray, optional) – Energies of the Green’s function. If None, use self.mo_energy_g. Default value is None.

  • eta_orders (list, optional) – List of orders for the rotated density-density moments in eta. If None, assume it spans all required orders. Default value is None.

  • mo_occ_g (numpy.ndarray, optional) – Occupancies of the Green’s function. If None, use self.mo_occ_g. Default value is None.

Returns:

  • moments_occ (numpy.ndarray) – Moments of the occupied self-energy.

  • moments_vir (numpy.ndarray) – Moments of the virtual self-energy.

build_dp_moments()

Build the moments of the dynamic polarizability for optical spectra calculations.

Returns:

moments – Moments of the dynamic polarizability.

Return type:

numpy.ndarray

build_dd_moment_inv()

Build the first inverse (n=-1) moment of the density-density response.

Returns:

moment – First inverse (n=-1) moment of the density-density response.

Return type:

numpy.ndarray

Notes

This is not the full n=-1 moment, which is

\[\begin{split}D^{-1} - D^{-1} V^\dagger (I + V D^{-1} V^\dagger)^{-1} \\ V D^{-1}\end{split}\]

but rather

\[(I + V D^{-1} V^\dagger)^{-1} V D^{-1}\]

which ensures that the function scales properly. The final contractions are done when constructing the matrix-vector product.

mpi_slice(n)

Return the start and end index for the current process for total size n.

Parameters:

n (int) – Total size.

Returns:

  • p0 (int) – Start index for current process.

  • p1 (int) – End index for current process.

mpi_size(n)

Return the number of states in the current process for total size n.

Parameters:

n (int) – Total size.

Returns:

size – Number of states in current process.

Return type:

int