:py:mod:`momentGW.pbc.thc` ========================== .. py:module:: momentGW.pbc.thc .. autoapi-nested-parse:: Tensor hyper-contraction with periodic boundary conditions. Module Contents --------------- .. py:class:: KIntegrals(with_df, kpts, mo_coeff, mo_occ, file_path=None, store_full=False) Bases: :py:obj:`momentGW.thc.Integrals`, :py:obj:`momentGW.pbc.ints.KIntegrals` Container for the tensor-hypercontracted integrals required for GW methods with periodic boundary conditions. :param with_df: Density fitting object. :type with_df: pyscf.pbc.df.DF :param mo_coeff: Molecular orbital coefficients at each k-point. :type mo_coeff: numpy.ndarray :param mo_occ: Molecular orbital occupations at each k-point. :type mo_occ: numpy.ndarray :param file_path: Path to the HDF5 file containing the integrals. Default value is `None`. :type file_path: str, optional .. py:property:: nkpts Get the number of k-points .. py:property:: naux Get the number of auxiliary basis functions. .. py:property:: coll Get the ``(aux, MO)`` collocation array. .. py:property:: cou Get the ``(aux, aux)`` Coulomb array. .. py:property:: Lp Get the ``(aux, MO)`` array. .. py:property:: Lx Get the ``(aux, MO)`` array. .. py:property:: Li Get the ``(aux, W occ)`` array. .. py:property:: La Get the ``(aux, W vir)`` array. .. py:property:: Lpq Get the full uncompressed ``(aux, MO, MO)`` integrals. .. py:property:: Lpx Get the compressed ``(aux, MO, G)`` integrals. .. py:property:: Lia Get the compressed ``(aux, W occ, W vir)`` integrals. .. py:property:: mo_coeff_g Get the MO coefficients for the Green's function. .. py:property:: mo_coeff_w Get the MO coefficients for the screened Coulomb interaction. .. py:property:: mo_occ_w Get the MO occupation numbers for the screened Coulomb interaction. .. py:property:: nao Get the number of AOs. .. py:property:: nmo Get the number of MOs. .. py:property:: nocc Get the number of occupied MOs. .. py:property:: nvir Get the number of virtual MOs. .. py:property:: nmo_g Get the number of MOs for the Green's function. .. py:property:: nmo_w Get the number of MOs for the screened Coulomb interaction. .. py:property:: nocc_w Get the number of occupied MOs for the screened Coulomb interaction. .. py:property:: nvir_w Get the number of virtual MOs for the screened Coulomb interaction. .. py:property:: naux_full Get the number of auxiliary basis functions, before the compression. .. py:property:: is_bare Get a boolean flag indicating whether the integrals have no self-consistencies. .. py:property:: dtype Get the dtype of the integrals. .. py:property:: madelung Return the Madelung constant for the lattice. .. py:property:: Lai Get the full uncompressed ``(aux, MO, MO)`` integrals. .. py:method:: 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. .. py:method:: transform(do_Lpq=True, do_Lpx=True, do_Lia=True) Transform the integrals in-place. :param do_Lpq: Whether the ``(aux, MO, MO)`` array is required. In THC, this requires the `Lp` array. Default value is `True`. :type do_Lpq: bool, optional :param do_Lpx: Whether the ``(aux, MO, MO)`` array is required. In THC, this requires the `Lx` array. Default value is `True`. :type do_Lpx: bool, optional :param do_Lia: Whether the ``(aux, occ, vir)`` array is required. In THC, this requires the `Li` and `La` arrays. Default value is `True`. :type do_Lia: bool, optional .. py:method:: get_j(dm, basis='mo') Build the J matrix. :param dm: Density matrix at each k-point. :type dm: numpy.ndarray :param basis: Basis in which to build the J matrix. One of `("ao", "mo")`. Default value is `"mo"`. :type basis: str, optional :returns: **vj** -- J matrix at each k-point. :rtype: numpy.ndarray .. rubric:: Notes The basis of `dm` must be the same as `basis`. .. py:method:: get_k(dm, basis='mo') Build the K matrix. :param dm: Density matrix at each k-point. :type dm: numpy.ndarray :param basis: Basis in which to build the K matrix. One of `("ao", "mo")`. Default value is `"mo"`. :type basis: str, optional :returns: **vk** -- K matrix at each k-point. :rtype: numpy.ndarray .. rubric:: Notes The basis of `dm` must be the same as `basis`. .. py:method:: get_compression_metric() Return the compression metric - not currently used in THC. .. py:method:: 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. :param mo_coeff_g: Coefficients corresponding to the Green's function. Default value is `None`. :type mo_coeff_g: numpy.ndarray, optional :param mo_coeff_w: Coefficients corresponding to the screened Coulomb interaction. Default value is `None`. :type mo_coeff_w: numpy.ndarray, optional :param mo_occ_w: Occupations corresponding to the screened Coulomb interaction. Default value is `None`. :type mo_occ_w: numpy.ndarray, optional .. rubric:: 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. .. py:method:: get_jk(dm, **kwargs) Build the J and K matrices. :returns: * **vj** (*numpy.ndarray*) -- J matrix. * **vk** (*numpy.ndarray*) -- K matrix. .. rubric:: Notes See `get_j` and `get_k` for more information. .. py:method:: 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`. .. rubric:: Notes See `get_jk` for more information. .. py:method:: get_fock(dm, h1e, **kwargs) Build the Fock matrix. :param dm: Density matrix. :type dm: numpy.ndarray :param h1e: Core Hamiltonian matrix. :type h1e: numpy.ndarray :param \*\*kwargs: Additional keyword arguments for `get_jk`. :type \*\*kwargs: dict, optional :returns: **fock** -- Fock matrix. :rtype: numpy.ndarray .. rubric:: Notes See `get_jk` for more information. The basis of `h1e` must be the same as `dm`. .. py:method:: get_cderi_from_thc() Build CDERIs using THC integrals imported from a h5py file. It must contain a 'collocation_matrix' and a 'coulomb_matrix'. .. py:method:: get_ewald(dm, basis='mo') Build the Ewald exchange divergence matrix. :param dm: Density matrix at each k-point. :type dm: numpy.ndarray :param basis: Basis in which to build the K matrix. One of `("ao", "mo")`. Default value is `"mo"`. :type basis: str, optional :returns: **ew** -- Ewald exchange divergence matrix at each k-point. :rtype: numpy.ndarray .. py:class:: dTDA(gw, nmom_max, integrals, mo_energy=None, mo_occ=None) Bases: :py:obj:`momentGW.thc.dTDA`, :py:obj:`momentGW.pbc.tda.dTDA` Compute the self-energy moments using dTDA with tensor hyper-contraction and periodic boundary conditions. :param gw: GW object. :type gw: BaseKGW :param nmom_max: Maximum moment number to calculate. :type nmom_max: int :param integrals: Density-fitted integrals. :type integrals: KIntegrals :param mo_energy: Molecular orbital energies at each k-point. 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`. :type mo_energy: numpy.ndarray or tuple of numpy.ndarray, optional :param mo_occ: Molecular orbital occupancies at each k-point. 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`. :type mo_occ: numpy.ndarray or tuple of numpy.ndarray, optional .. py:property:: Li Get the ``(aux, W occ)`` array. .. py:property:: La Get the ``(aux, W vir)`` array. .. py:property:: cou Get the ``(aux, aux)`` Coulomb array. .. py:property:: nmo Get the number of MOs. .. py:property:: naux Get the number of auxiliaries. .. py:property:: nov Get the number of ov states in the screened Coulomb interaction. .. py:property:: kpts Get the k-points. .. py:property:: nkpts Get the number of k-points. .. py:method:: build_dd_moments() Build the moments of the density-density response. :returns: **moments** -- Moments of the density-density response at each k-point. :rtype: numpy.ndarray .. rubric:: Notes Unlike the standard `momentGW.tda` implementation, this method scales as :math:`O(N^3)` with system size instead of :math:`O(N^4)`. .. py:method:: build_se_moments(zeta) Build the moments of the self-energy via convolution. :param zeta: Moments of the density-density response at each k-point. :type zeta: numpy.ndarray :returns: * **moments_occ** (*numpy.ndarray*) -- Moments of the occupied self-energy at each k-point. * **moments_vir** (*numpy.ndarray*) -- Moments of the virtual self-energy at each k-point. .. py:method:: kernel(exact=False) Run the polarizability calculation to compute moments of the self-energy. :param exact: Has no effect and is only present for compatibility with `dRPA`. Default value is `False`. :type exact: bool, optional :returns: * **moments_occ** (*numpy.ndarray*) -- Moments of the occupied self-energy. * **moments_vir** (*numpy.ndarray*) -- Moments of the virtual self-energy. .. py:method:: 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. :param eta: Moments of the density-density response partly transformed into moments of the screened Coulomb interaction. :type eta: numpy.ndarray :param mo_energy_g: Energies of the Green's function. If `None`, use `self.mo_energy_g`. Default value is `None`. :type mo_energy_g: numpy.ndarray, optional :param eta_orders: List of orders for the rotated density-density moments in `eta`. If `None`, assume it spans all required orders. Default value is `None`. :type eta_orders: list, optional :param mo_occ_g: Occupancies of the Green's function. If `None`, use `self.mo_occ_g`. Default value is `None`. :type mo_occ_g: numpy.ndarray, optional :returns: * **moments_occ** (*numpy.ndarray*) -- Moments of the occupied self-energy. * **moments_vir** (*numpy.ndarray*) -- Moments of the virtual self-energy. .. py:method:: build_dp_moments() Build the moments of the dynamic polarizability for optical spectra calculations. :returns: **moments** -- Moments of the dynamic polarizability. :rtype: numpy.ndarray .. py:method:: 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. :rtype: numpy.ndarray .. rubric:: Notes This is not the full `n=-1` moment, which is .. math:: D^{-1} - D^{-1} V^\dagger (I + V D^{-1} V^\dagger)^{-1} \\ V D^{-1} but rather .. math:: (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. .. py:method:: mpi_slice(n) Return the start and end index for the current process for total size `n`. :param n: Total size. :type n: int :returns: * **p0** (*int*) -- Start index for current process. * **p1** (*int*) -- End index for current process. .. py:method:: mpi_size(n) Return the number of states in the current process for total size `n`. :param n: Total size. :type n: int :returns: **size** -- Number of states in current process. :rtype: int