momentGW.ints

Integral helpers.

Module Contents

momentGW.ints.patch_df_loop(with_df)

Context manager for monkey patching PySCF’s density fitting objects to loop over blocks of the auxiliary functions distributed over MPI.

Parameters:

with_df (pyscf.df.DF) – Density fitting object.

Yields:

with_df (pyscf.df.DF) – Density fitting object with monkey patched loop method.

momentGW.ints.require_compression_metric()

Determine the compression metric before running the function.

class momentGW.ints.BaseIntegrals

Base class for integral containers.

class momentGW.ints.Integrals(with_df, mo_coeff, mo_occ, compression='ia', compression_tol=1e-10, store_full=False)

Bases: BaseIntegrals

Container for the density-fitted 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.

  • compression (str, optional) – Compression scheme to use. Default value is ‘ia’. See momentGW.gw for more details.

  • compression_tol (float, optional) – Compression tolerance. Default value is 1e-10. See momentGW.gw for more details.

  • store_full (bool, optional) – Store the full MO integrals in memory. Default value is False.

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.

Returns:

rot – Rotation matrix into the compressed auxiliary space.

Return type:

numpy.ndarray

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

Transform the integrals in-place.

Parameters:
  • do_Lpq (bool, optional) – Whether to compute the full (aux, MO, MO) array. Default value is True if store_full is True, False otherwise.

  • do_Lpx (bool, optional) – Whether to compute the compressed (aux, MO, MO) array. Default value is True.

  • do_Lia (bool, optional) – Whether to compute the compressed (aux, occ, vir) array. Default value is True.

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_j(dm, basis='mo', other=None)

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”.

  • other (BaseIntegrals, optional) – Integrals object for the ket side. Allows inheritence for mixed-spin evaluations. If None, use self. Default value is None.

Returns:

vj – J matrix.

Return type:

numpy.ndarray

Notes

The contraction is J[p, q] = self[p, q] * other[r, s] * dm[r, s], and the bases must reflect shared indices.

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 contraction is K[p, q] = self[r, q] * self[p, r] * dm[q, s], and the bases must reflect shared indices.

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.