fcdmft.rpa.pbc.krpa module#

Periodic k-point spin-restricted random phase approximation (direct RPA/dRPA in chemistry) with N^4 scaling

Method:

Main routines are based on GW-AC method described in: T. Zhu and G.K.-L. Chan, J. Chem. Theory. Comput. 17, 727-741 (2021) X. Ren et al., New J. Phys. 14, 053020 (2012)

class fcdmft.rpa.pbc.krpa.KRPA(mf, frozen=None)[source]#

Bases: StreamObject

Attributes:
nmo
nocc

Methods

__call__(*args, **kwargs)

Update the attributes of the current object.

apply(fn, *args, **kwargs)

Apply the fn to rest arguments: return fn(*args, **kwargs). The return value of method set is the object itself. This allows a series of functions/methods to be executed in pipe.

check_sanity()

Check input of class/object attributes, check whether a class method is overwritten.

copy()

Returns a shallow copy

get_frozen_mask()

Boolean mask for orbitals in k-point post-HF method.

get_grids([alg, nw, mo_energy])

Generate grids for integration.

get_nmo([per_kpoint])

Number of orbitals for k-point calculations.

get_nocc([per_kpoint])

Number of occupied orbitals for k-point calculations.

get_q_mesh(mo_energy, mo_coeff)

Get q-mesh for finite size correction.

kernel([mo_energy, mo_coeff, nw, with_e_hf])

RPA correlation and total energy

post_kernel(envs)

A hook to be run after the main body of the kernel function.

pre_kernel(envs)

A hook to be run before the main body of kernel function is executed.

run(*args, **kwargs)

Call the kernel function of current object.

set(*args, **kwargs)

Update the attributes of the current object.

view(cls)

New view of object with the same attributes.

dump_flags

dump_flags(verbose=None)[source]#
get_frozen_mask()#

Boolean mask for orbitals in k-point post-HF method.

Creates a boolean mask to remove frozen orbitals and keep other orbitals for post-HF calculations.

Args:

mp (MP2): An instantiation of an SCF or post-Hartree-Fock object.

Returns:

moidx (list of ndarray of bool): Boolean mask of orbitals to include.

get_grids(alg=None, nw=None, mo_energy=None)[source]#

Generate grids for integration.

Parameters:
algstr, optional

algorithm for generating grids, by default None

nwint, optional

number of grids, by default None

mo_energydouble 2d array, optional

orbital energy, used for minimax grids, by default None

Returns:
freqsdouble 1d array

frequency grid

wtsdouble 1d array

weight of grids

get_nmo(per_kpoint=False)#

Number of orbitals for k-point calculations.

Number of orbitals for use in a calculation with k-points, taking into account frozen orbitals.

Note:

If per_kpoint is False, then the number of orbitals here is equal to max(nocc) + max(nvir), where each max is done over all k-points. Otherwise the number of orbitals is returned as a list of number of orbitals at each k-point.

Args:

mp (MP2): An instantiation of an SCF or post-Hartree-Fock object. per_kpoint (bool, optional): True returns the number of orbitals at each k-point.

For a description of False, see Note.

Returns:
nmo (int, list of int): Number of orbitals. For return type, see description of arg

per_kpoint.

get_nocc(per_kpoint=False)#

Number of occupied orbitals for k-point calculations.

Number of occupied orbitals for use in a calculation with k-points, taking into account frozen orbitals.

Args:

mp (MP2): An instantiation of an SCF or post-Hartree-Fock object. per_kpoint (bool, optional): True returns the number of occupied

orbitals at each k-point. False gives the max of this list.

Returns:
nocc (int, list of int): Number of occupied orbitals. For return type, see description of arg

per_kpoint.

get_q_mesh(mo_energy, mo_coeff)[source]#

Get q-mesh for finite size correction. Equation 39-42 in doi.org/10.1021/acs.jctc.0c00704

Parameters:
mo_energydouble 2d array

orbital energy

mo_coeffdouble 3d array

coefficient from AO to MO

Returns:
qijdouble 1d array

q-mesh grids

q_absdouble 1d array

absolute positions of q-mesh grids

nq_ptsinit

number of q-mesh grids

kernel(mo_energy=None, mo_coeff=None, nw=None, with_e_hf=None)[source]#

RPA correlation and total energy

Calculated total energy, HF energy and RPA correlation energy are stored in self.e_tot, self.e_hf, self.e_corr

Parameters:
mo_energydouble array

molecular orbital energies

mo_coeffdouble ndarray

molecular orbital coefficients

nwint, optional

number of frequency point on imaginary axis, by default None

with_e_hffloat, optional

If given, overrides the HF energy computation.

Returns:
e_totfloat

RPA total energy

e_hffloat

HF energy (exact exchange for given mo_coeff)

e_corrfloat

RPA correlation energy

property nmo#
property nocc#
fcdmft.rpa.pbc.krpa.get_rho_response_metal(omega, mo_energy, mo_occ, Lpq, kidx)[source]#

Get Pi=PV for metallic systems. P is density-density response function. V is two-electron integral. See equation 24 in doi.org/10.1021/acs.jctc.0c00704.

NOTE: this function is different from the one in krgw_ac.py. They should be merged in the future. The metal version here is more efficient both in memory and computational time.

Parameters:
omegadouble

real position of imaginary frequency

mo_energydouble ndarray

orbital energy

mo_occdouble ndarray

occupation number

Lpqlist of complex ndarray

three-center density-fitting matrix in MO. Lpq[ki] contains the naux x (nocc_i + nfrac_i) x (nfrac_i + nvir_i) sub-block.

kidxlist

momentum-conserved k-point list kj=kidx[ki]

Returns:
Picomplex ndarray

Pi in auxiliary basis at freq iw

fcdmft.rpa.pbc.krpa.get_rpa_ecorr(rpa, freqs, wts)[source]#

Compute RPA correlation energy.

Parameters:
rpaKRPA

rpa object

freqsdouble 1d array

frequency grid

wtsdouble 1d array

weight of grids

Returns:
e_corrdouble

correlation energy

fcdmft.rpa.pbc.krpa.get_rpa_ecorr_outcore(rpa, freqs, wts)[source]#

Low-memory routine to compute RPA correlation energy.

Parameters:
rpaKRPA

rpa object

freqsdouble 1d array

frequency grid

wtsdouble 1d array

weight of grids

Returns:
e_corrdouble

correlation energy

fcdmft.rpa.pbc.krpa.get_rpa_ecorr_outcore_metal(rpa, freqs, wts)[source]#

Low-memory routine to compute RPA correlation energy for metals.

Parameters:
rpaKRPA

rpa object

freqsdouble 1d array

frequency grid

wtsdouble 1d array

weight of grids

Returns:
e_corrdouble

correlation energy

fcdmft.rpa.pbc.krpa.get_rpa_ecorr_w(Pi_w, wts_w)[source]#

Get contribution to RPA correlation energy from a single frequency.

Parameters:
Pi_wcomplex 2d array

density-density response function at a single frequency

wts_wdouble

weights of the frequency

Returns:
e_corrdouble

correlation energy

fcdmft.rpa.pbc.krpa.kernel(rpa, mo_energy, mo_coeff, nw=None, with_e_hf=None)[source]#

RPA correlation and total energy

Parameters:
rpaKRPA

rpa object

mo_energydouble array

molecular orbital energies

mo_coeffdouble ndarray

molecular orbital coefficients

Lpqdouble array, optional

density fitting 3-center integral in MO basis, by default None

nwint, optional

number of frequency point on imaginary axis, by default None

with_e_hffloat, optional

extra input HF energy, by default None

Returns:
e_totfloat

RPA total energy

e_hffloat

HF energy (exact exchange for given mo_coeff)

e_corrfloat

RPA correlation energy

fcdmft.rpa.pbc.krpa.rho_accum_inner(Pi, eia, omega, Lov, alpha=0.0, fia=None)[source]#

Get contribution to response function from current occupied-virtual block.

Parameters:
Picomplex 2d array

density-density response function, will be overwritten

eiadouble 2d array

occupied-virtual orbital energy difference

omegadouble

real position of imaginary frequency

Lovcomplex 3d array

occupied-virtual block of three-center density-fitting matrix in MO

alphafloat, optional

prefactor, by default 0.0

fiadouble 2d array, optional

occupied-virtual occupation number difference, by default None