pyscf.pbc.dft package

Submodules

pyscf.pbc.dft.cdft module

pyscf.pbc.dft.cdft.cdft(mf, cell, offset, orbital, basis=None)[source]
Input:

mf – a mean field object for DFT or (in principle) HF (doesn’t really matter) shift – float – a semi aribitrary energy which displaces the selected orbitals by the diagonal orbital – int – indicating which orbital are shifted in the selected basis basis – 2D numpy array – the working basis in the basis of AOs from ‘cell’ (Defaults to AO basis)

Returns:

mf – converged mean field object (with AO basis)

pyscf.pbc.dft.cdft.fast_iao_mullikan_pop(mf, cell, a=None)[source]

Input: mf – a preconverged mean fild object Returns: mullikan populaion analysis in the basisIAO a

pyscf.pbc.dft.gen_grid module

pyscf.pbc.dft.gen_grid.AtomicGrids

alias of BeckeGrids

class pyscf.pbc.dft.gen_grid.BeckeGrids(cell)[source]

Bases: Grids

Atomic grids for all-electron calculation.

build(cell=None, with_non0tab=False)[source]
make_mask(cell=None, coords=None, relativity=0, shls_slice=None, verbose=None)[source]

Mask to indicate whether a shell is zero on grid. The resultant mask array is an extension to the mask array used in molecular code (see also pyscf.dft.numint.make_mask function). For given shell ID and block ID, the value of the extended mask array means the number of images in Ls that does not vanish.

class pyscf.pbc.dft.gen_grid.UniformGrids(cell)[source]

Bases: StreamObject

Uniform Grid class.

build(cell=None, with_non0tab=False)[source]
property coords
cutoff = 1e-15
dump_flags(verbose=None)[source]
kernel(cell=None, with_non0tab=False)[source]

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

make_mask(cell=None, coords=None, relativity=0, shls_slice=None, verbose=None)[source]

Mask to indicate whether a shell is zero on grid. The resultant mask array is an extension to the mask array used in molecular code (see also pyscf.dft.numint.make_mask function). For given shell ID and block ID, the value of the extended mask array means the number of images in Ls that does not vanish.

reset(cell=None)[source]
property weights
pyscf.pbc.dft.gen_grid.gen_becke_grids(cell, atom_grid={}, radi_method=<function gauss_chebyshev>, level=3, prune=<function nwchem_prune>)

real-space grids using Becke scheme

Args:

cell : instance of Cell

Returns:
coords(N, 3) ndarray

The real-space grid point coordinates.

weights : (N) ndarray

pyscf.pbc.dft.gen_grid.get_becke_grids(cell, atom_grid={}, radi_method=<function gauss_chebyshev>, level=3, prune=<function nwchem_prune>)[source]

real-space grids using Becke scheme

Args:

cell : instance of Cell

Returns:
coords(N, 3) ndarray

The real-space grid point coordinates.

weights : (N) ndarray

pyscf.pbc.dft.gen_grid.make_mask(cell, coords, relativity=0, shls_slice=None, cutoff=None, verbose=None)[source]

Mask to indicate whether a shell is zero on grid. The resultant mask array is an extension to the mask array used in molecular code (see also pyscf.dft.numint.make_mask function). For given shell ID and block ID, the value of the extended mask array means the number of images in Ls that does not vanish.

pyscf.pbc.dft.gks module

Generalized collinear Kohn-Sham in the spin-orbital basis for periodic systems at a single k-point

See Also:
pyscf.pbc.dft.kgks.pyGeneral spin-orbital Kohn-Sham for periodic

systems with k-point sampling

class pyscf.pbc.dft.gks.GKS(cell, kpt=array([0., 0., 0.]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, GHF

GKS class adapted for PBCs at a single k-point.

This is a literal duplication of the molecular GKS class with some mol variables replaced by cell.

property collinear
dump_flags(verbose=None)[source]
energy_elec(dm=None, h1e=None, vhf=None)

Electronic part of RKS energy.

Note this function has side effects which cause mf.scf_summary updated.

Args:

ks : an instance of DFT class

dm2D ndarray

one-partical density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)

Coulomb + XC functional for GKS.

nuc_grad_method()[source]

Hook to create object for analytical nuclear gradients.

property spin_samples
stability()[source]
to_hf()[source]

Convert to GHF object.

x2c()

Adds spin-orbit coupling effects to H0 through the x2c1e approximation

x2c1e()[source]

Adds spin-orbit coupling effects to H0 through the x2c1e approximation

pyscf.pbc.dft.gks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)[source]

Coulomb + XC functional for GKS.

pyscf.pbc.dft.kgks module

Generalized collinear Kohn-Sham in the spin-orbital basis for periodic systems with k-point sampling

See Also:
pyscf.pbc.dft.rks.pyGeneral spin-orbital Kohn-Sham for periodic

systems at a single k-point

class pyscf.pbc.dft.kgks.KGKS(cell, kpts=array([[0., 0., 0.]]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, KGHF

GKS class adapted for PBCs with k-point sampling.

dump_flags(verbose=None)[source]
energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Following pyscf.scf.hf.energy_elec()

get_rho(dm=None, grids=None, kpts=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional for KGKS

Args:
ksan instance of GKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, 2*nao, 2*nao) or (*, nkpts, 2*nao, 2*nao) ndarray Veff = J + Vxc.

nuc_grad_method()[source]

Hook to create object for analytical nuclear gradients.

stability()[source]
to_hf()[source]

Convert to KGHF object.

x2c()

Adds spin-orbit coupling effects to H0 through the x2c1e approximation

x2c1e()[source]

Adds spin-orbit coupling effects to H0 through the x2c1e approximation

pyscf.pbc.dft.kgks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional for KGKS

Args:
ksan instance of GKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, 2*nao, 2*nao) or (*, nkpts, 2*nao, 2*nao) ndarray Veff = J + Vxc.

pyscf.pbc.dft.krks module

Non-relativistic Restricted Kohn-Sham for periodic systems with k-point sampling

See Also:
pyscf.pbc.dft.rks.pyNon-relativistic Restricted Kohn-Sham for periodic

systems at a single k-point

class pyscf.pbc.dft.krks.KRKS(cell, kpts=array([[0., 0., 0.]]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, KRHF

RKS class adapted for PBCs with k-point sampling.

dump_flags(verbose=None)[source]
energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Following pyscf.scf.hf.energy_elec()

get_rho(dm=None, grids=None, kpts=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc.

nuc_grad_method()[source]

Hook to create object for analytical nuclear gradients.

to_hf()[source]

Convert to KRHF object.

pyscf.pbc.dft.krks.energy_elec(mf, dm_kpts=None, h1e_kpts=None, vhf=None)[source]
pyscf.pbc.dft.krks.get_rho(mf, dm=None, grids=None, kpts=None)[source]

Compute density in real space

pyscf.pbc.dft.krks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc.

pyscf.pbc.dft.krks_ksymm module

pyscf.pbc.dft.krks_ksymm.KRKS

alias of KsymAdaptedKRKS

class pyscf.pbc.dft.krks_ksymm.KsymAdaptedKRKS(cell, kpts=<pyscf.pbc.lib.kpts.KPoints object>, xc='LDA, VWN', exxdiv='ewald')[source]

Bases: KRKS, KsymAdaptedKRHF

dump_chk(envs)
dump_flags(verbose=None)[source]
eig(h_kpts, s_kpts)

Solver for generalized eigenvalue problem

\[HC = SCE\]
energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)[source]

Following pyscf.scf.hf.energy_elec()

get_hcore(cell=None, kpts=None)

Get the core Hamiltonian AO matrices at sampled k-points.

Args:

kpts : (nkpts, 3) ndarray

Returns:

hcore : (nkpts, nao, nao) ndarray

get_init_guess(cell=None, key='minao')
get_jk(cell=None, dm_kpts=None, hermi=1, kpts=None, kpts_band=None, with_j=True, with_k=True, omega=None, **kwargs)

Get the Coulomb (J) and exchange (K) AO matrices at sampled k-points.

Args:
dm_kpts(nkpts, nao, nao) ndarray

Density matrix at each k-point. It needs to be Hermitian.

Kwargs:
kpts_band(3,) ndarray

A list of arbitrary “band” k-point at which to evalute the matrix.

Returns:

vj : (nkpts, nao, nao) ndarray vk : (nkpts, nao, nao) ndarray or list of vj and vk if the input dm_kpts is a list of DMs

get_occ(mo_energy_kpts=None, mo_coeff_kpts=None)

Label the occupancies for each orbital for sampled k-points.

This is a k-point version of scf.hf.SCF.get_occ

get_orbsym(mo_coeff=None, s=None)
get_ovlp(cell=None, kpts=None)

Get the overlap AO matrices at sampled k-points.

Args:

kpts : (nkpts, 3) ndarray

Returns:

ovlp_kpts : (nkpts, nao, nao) ndarray

get_rho(dm=None, grids=None, kpts=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc.

init_guess_by_chkfile(chk=None, project=None, kpts=None)

Read the HF results from checkpoint file, then project it to the basis defined by mol

Returns:

Density matrix, 2D ndarray

property kpts
property orbsym
to_hf()[source]

Convert to KRHF object.

pyscf.pbc.dft.krks_ksymm.get_rho(mf, dm=None, grids=None, kpts=None)[source]
pyscf.pbc.dft.krks_ksymm.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc.

pyscf.pbc.dft.krkspu module

Restricted DFT+U with kpoint sampling. Based on KRHF routine.

Refs: PRB, 1998, 57, 1505.

class pyscf.pbc.dft.krkspu.KRKSpU(cell, kpts=array([[0., 0., 0.]]), xc='LDA,VWN', exxdiv='ewald', U_idx=[], U_val=[], C_ao_lo='minao', minao_ref='MINAO')[source]

Bases: KRKS

RKSpU class adapted for PBCs with k-point sampling.

energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Electronic energy for KRKSpU.

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional + Hubbard U terms.

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc + V_U.

nuc_grad_method()[source]

Hook to create object for analytical nuclear gradients.

to_hf(*args, **kwargs)

Convert to KRHF object.

pyscf.pbc.dft.krkspu.energy_elec(ks, dm_kpts=None, h1e_kpts=None, vhf=None)[source]

Electronic energy for KRKSpU.

pyscf.pbc.dft.krkspu.format_idx(idx_list)[source]
pyscf.pbc.dft.krkspu.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional + Hubbard U terms.

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc + V_U.

pyscf.pbc.dft.krkspu.make_minao_lo(ks, minao_ref)[source]

Construct minao local orbitals.

pyscf.pbc.dft.krkspu.mdot(*args)[source]

Compute the dot product of a list of arrays in a single function call.

pyscf.pbc.dft.krkspu.proj_ref_ao(mol, minao='minao', kpts=None, return_labels=False)[source]

Get a set of reference AO spanned by the calculation basis. Not orthogonalized.

Args:

return_labels: if True, return the labels as well.

pyscf.pbc.dft.krkspu.set_U(ks, U_idx, U_val)[source]

Regularize the U_idx and U_val to each atom, and set ks.U_idx, ks.U_val, ks.U_lab.

pyscf.pbc.dft.krkspu_ksymm module

pyscf.pbc.dft.krkspu_ksymm.KRKSpU

alias of KsymAdaptedKRKSpU

class pyscf.pbc.dft.krkspu_ksymm.KsymAdaptedKRKSpU(cell, kpts=<pyscf.pbc.lib.kpts.KPoints object>, xc='LDA, VWN', exxdiv='ewald', U_idx=[], U_val=[], C_ao_lo='minao', minao_ref='MINAO')[source]

Bases: KsymAdaptedKRKS

RKSpU class adapted for PBCs with k-point sampling.

energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Electronic energy for KRKSpU.

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional + Hubbard U terms.

Note

This is a replica of pyscf.dft.rks.get_veff with kpts added. This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

Veff : (nkpts, nao, nao) or (*, nkpts, nao, nao) ndarray Veff = J + Vxc + V_U.

to_hf(*args, **kwargs)

Convert to KRHF object.

pyscf.pbc.dft.kroks module

Restricted open-shell Kohn-Sham for periodic systems with k-point sampling

class pyscf.pbc.dft.kroks.KROKS(cell, kpts=array([[0., 0., 0.]]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, KROHF

RKS class adapted for PBCs with k-point sampling.

dump_flags(verbose=None)[source]
energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Following pyscf.scf.hf.energy_elec()

get_rho(dm=None, grids=None, kpts=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

to_hf()[source]

Convert to KROHF object.

pyscf.pbc.dft.kroks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

pyscf.pbc.dft.kuks module

Non-relativistic Restricted Kohn-Sham for periodic systems with k-point sampling

See Also:
pyscf.pbc.dft.rks.pyNon-relativistic Restricted Kohn-Sham for periodic

systems at a single k-point

class pyscf.pbc.dft.kuks.KUKS(cell, kpts=array([[0., 0., 0.]]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, KUHF

UKS class adapted for PBCs with k-point sampling.

dump_flags(verbose=None)[source]
energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Following pyscf.scf.hf.energy_elec()

get_rho(dm=None, grids=None, kpts=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

nuc_grad_method()[source]

Hook to create object for analytical nuclear gradients.

to_hf()[source]

Convert to KUHF object.

pyscf.pbc.dft.kuks.energy_elec(mf, dm_kpts=None, h1e_kpts=None, vhf=None)[source]
pyscf.pbc.dft.kuks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

pyscf.pbc.dft.kuks_ksymm module

pyscf.pbc.dft.kuks_ksymm.KUKS

alias of KsymAdaptedKUKS

class pyscf.pbc.dft.kuks_ksymm.KsymAdaptedKUKS(cell, kpts=<pyscf.pbc.lib.kpts.KPoints object>, xc='LDA, VWN', exxdiv='ewald')[source]

Bases: KUKS, KsymAdaptedKUHF

dump_chk(envs)
dump_flags(verbose=None)[source]
eig(h_kpts, s_kpts)

Solver for generalized eigenvalue problem

\[HC = SCE\]
energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)[source]

Following pyscf.scf.hf.energy_elec()

get_hcore(cell=None, kpts=None)

Get the core Hamiltonian AO matrices at sampled k-points.

Args:

kpts : (nkpts, 3) ndarray

Returns:

hcore : (nkpts, nao, nao) ndarray

get_init_guess(cell=None, key='minao')
get_jk(cell=None, dm_kpts=None, hermi=1, kpts=None, kpts_band=None, with_j=True, with_k=True, omega=None, **kwargs)

Get the Coulomb (J) and exchange (K) AO matrices at sampled k-points.

Args:
dm_kpts(nkpts, nao, nao) ndarray

Density matrix at each k-point. It needs to be Hermitian.

Kwargs:
kpts_band(3,) ndarray

A list of arbitrary “band” k-point at which to evalute the matrix.

Returns:

vj : (nkpts, nao, nao) ndarray vk : (nkpts, nao, nao) ndarray or list of vj and vk if the input dm_kpts is a list of DMs

get_occ(mo_energy_kpts=None, mo_coeff_kpts=None)

Label the occupancies for each orbital for sampled k-points.

This is a k-point version of scf.hf.SCF.get_occ

get_orbsym(mo_coeff=None, s=None)
get_ovlp(cell=None, kpts=None)

Get the overlap AO matrices at sampled k-points.

Args:

kpts : (nkpts, 3) ndarray

Returns:

ovlp_kpts : (nkpts, nao, nao) ndarray

get_rho(dm=None, grids=None, kpts=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

init_guess_by_chkfile(chk=None, project=None, kpts=None)

Read the HF results from checkpoint file, then project it to the basis defined by mol

Returns:

Density matrix, 2D ndarray

property kpts
property nelec
property orbsym
to_hf()[source]

Convert to KRHF object.

pyscf.pbc.dft.kuks_ksymm.get_rho(mf, dm=None, grids=None, kpts=None)[source]
pyscf.pbc.dft.kuks_ksymm.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

pyscf.pbc.dft.kukspu module

Unrestricted DFT+U with kpoint sampling. Based on KUHF routine.

Refs: PRB, 1998, 57, 1505.

class pyscf.pbc.dft.kukspu.KUKSpU(cell, kpts=array([[0., 0., 0.]]), xc='LDA,VWN', exxdiv='ewald', U_idx=[], U_val=[], C_ao_lo='minao', minao_ref='MINAO')[source]

Bases: KUKS

UKSpU class adapted for PBCs with k-point sampling.

energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Electronic energy for KUKSpU.

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional + (Hubbard - double counting) for KUKSpU.

nuc_grad_method()[source]

Hook to create object for analytical nuclear gradients.

to_hf(*args, **kwargs)

Convert to KUHF object.

pyscf.pbc.dft.kukspu.energy_elec(mf, dm_kpts=None, h1e_kpts=None, vhf=None)[source]

Electronic energy for KUKSpU.

pyscf.pbc.dft.kukspu.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)[source]

Coulomb + XC functional + (Hubbard - double counting) for KUKSpU.

pyscf.pbc.dft.kukspu_ksymm module

pyscf.pbc.dft.kukspu_ksymm.KUKSpU

alias of KsymAdaptedKUKSpU

class pyscf.pbc.dft.kukspu_ksymm.KsymAdaptedKUKSpU(cell, kpts=<pyscf.pbc.lib.kpts.KPoints object>, xc='LDA, VWN', exxdiv='ewald', U_idx=[], U_val=[], C_ao_lo='minao', minao_ref='MINAO')[source]

Bases: KsymAdaptedKUKS

UKSpU class adapted for PBCs with k-point sampling.

energy_elec(dm_kpts=None, h1e_kpts=None, vhf=None)

Electronic energy for KUKSpU.

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpts=None, kpts_band=None)

Coulomb + XC functional + (Hubbard - double counting) for KUKSpU.

to_hf(*args, **kwargs)

Convert to KRHF object.

pyscf.pbc.dft.multigrid module

Multigrid to compute DFT integrals

class pyscf.pbc.dft.multigrid.MultiGridFFTDF(cell, kpts=array([[0., 0., 0.]]))[source]

Bases: FFTDF

build()[source]
get_jk(dm, hermi=1, kpts=None, kpts_band=None, with_j=True, with_k=True, exxdiv='ewald', **kwargs)[source]
get_nuc(kpts=None)
get_pp(kpts=None)

Get the periodic pseudotential nuc-el AO matrix, with G=0 removed.

get_rho(dm, kpts=array([[0., 0., 0.]]))

Density in real space

reset(cell=None)[source]
pyscf.pbc.dft.multigrid.cache_xc_kernel(mydf, xc_code, mo_coeff, mo_occ, spin=0, kpts=None)[source]
pyscf.pbc.dft.multigrid.cache_xc_kernel1(mydf, xc_code, dm, spin=0, kpts=None)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

pyscf.pbc.dft.multigrid.eval_mat(cell, weights, shls_slice=None, comp=1, hermi=0, xctype='LDA', kpts=None, mesh=None, offset=None, submesh=None)[source]
pyscf.pbc.dft.multigrid.eval_rho(cell, dm, shls_slice=None, hermi=0, xctype='LDA', kpts=None, mesh=None, offset=None, submesh=None, ignore_imag=False, out=None)[source]

Collocate the real density (opt. gradients) on the real-space grid.

Kwargs:
ignore_image :

The output density is assumed to be real if ignore_imag=True.

pyscf.pbc.dft.multigrid.get_j_kpts(mydf, dm_kpts, hermi=1, kpts=array([[0., 0., 0.]]), kpts_band=None)[source]

Get the Coulomb (J) AO matrix at sampled k-points.

Args:
dm_kpts(nkpts, nao, nao) ndarray or a list of (nkpts,nao,nao) ndarray

Density matrix at each k-point. If a list of k-point DMs, eg, UHF alpha and beta DM, the alpha and beta DMs are contracted separately.

kpts : (nkpts, 3) ndarray

Kwargs:
kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evalute the matrix.

Returns:

vj : (nkpts, nao, nao) ndarray or list of vj if the input dm_kpts is a list of DMs

pyscf.pbc.dft.multigrid.get_nuc(mydf, kpts=None)[source]
pyscf.pbc.dft.multigrid.get_pp(mydf, kpts=None)[source]

Get the periodic pseudotential nuc-el AO matrix, with G=0 removed.

pyscf.pbc.dft.multigrid.get_rho(mydf, dm, kpts=array([[0., 0., 0.]]))[source]

Density in real space

pyscf.pbc.dft.multigrid.multi_grids_tasks(cell, fft_mesh=None, verbose=None)[source]
pyscf.pbc.dft.multigrid.multi_grids_tasks_for_ke_cut(cell, fft_mesh=None, verbose=None)[source]
pyscf.pbc.dft.multigrid.multi_grids_tasks_for_rcut(cell, fft_mesh=None, verbose=None)[source]
pyscf.pbc.dft.multigrid.multigrid(mf)[source]

Use MultiGridFFTDF to replace the default FFTDF integration method in the DFT object.

pyscf.pbc.dft.multigrid.nr_rks(mydf, xc_code, dm_kpts, hermi=1, kpts=None, kpts_band=None, with_j=False, return_j=False, verbose=None)[source]

Compute the XC energy and RKS XC matrix at sampled k-points. multigrid version of function pbc.dft.numint.nr_rks.

Args:
dm_kpts(nkpts, nao, nao) ndarray or a list of (nkpts,nao,nao) ndarray

Density matrix at each k-point.

kpts : (nkpts, 3) ndarray

Kwargs:
kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evalute the matrix.

Returns:

exc : XC energy nelec : number of electrons obtained from the numerical integration veff : (nkpts, nao, nao) ndarray

or list of veff if the input dm_kpts is a list of DMs

vj(nkpts, nao, nao) ndarray

or list of vj if the input dm_kpts is a list of DMs

pyscf.pbc.dft.multigrid.nr_rks_fxc(mydf, xc_code, dm0, dms, hermi=0, with_j=False, rho0=None, vxc=None, fxc=None, kpts=None, verbose=None)[source]

multigrid version of function pbc.dft.numint.nr_rks_fxc

pyscf.pbc.dft.multigrid.nr_rks_fxc_st(mydf, xc_code, dm0, dms_alpha, singlet=True, rho0=None, vxc=None, fxc=None, kpts=None, verbose=None)[source]

multigrid version of function pbc.dft.numint.nr_rks_fxc_st

pyscf.pbc.dft.multigrid.nr_uks(mydf, xc_code, dm_kpts, hermi=1, kpts=None, kpts_band=None, with_j=False, return_j=False, verbose=None)[source]

Compute the XC energy and UKS XC matrix at sampled k-points. multigrid version of function pbc.dft.numint.nr_uks

Args:
dm_kpts(nkpts, nao, nao) ndarray or a list of (nkpts,nao,nao) ndarray

Density matrix at each k-point.

kpts : (nkpts, 3) ndarray

Kwargs:
kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evalute the matrix.

Returns:

exc : XC energy nelec : number of electrons obtained from the numerical integration veff : (2, nkpts, nao, nao) ndarray

or list of veff if the input dm_kpts is a list of DMs

vj(nkpts, nao, nao) ndarray

or list of vj if the input dm_kpts is a list of DMs

pyscf.pbc.dft.multigrid.nr_uks_fxc(mydf, xc_code, dm0, dms, hermi=0, with_j=False, rho0=None, vxc=None, fxc=None, kpts=None, verbose=None)[source]

multigrid version of function pbc.dft.numint.nr_uks_fxc

pyscf.pbc.dft.numint module

class pyscf.pbc.dft.numint.KNumInt(kpts=array([[0., 0., 0.]]))[source]

Bases: StreamObject, LibXCMixin

Generalization of pyscf’s NumInt class for k-point sampling and periodic images.

block_loop(cell, grids, nao=None, deriv=0, kpts=None, kpts_band=None, max_memory=2000, non0tab=None, blksize=None)[source]

Define this macro to loop over grids by blocks.

cache_xc_kernel(cell, grids, xc_code, mo_coeff, mo_occ, spin=0, kpts=None, max_memory=2000)

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

cache_xc_kernel1(cell, grids, xc_code, dm, spin=0, kpts=None, max_memory=2000)

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

static eval_ao(cell, coords, kpts=None, deriv=0, relativity=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None, **kwargs)
Returns:
ao_kpts: (nkpts, [comp], ngrids, nao) ndarray

AO values at each k-point

eval_rho(cell, ao_kpts, dm_kpts, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)[source]

Collocate the density (opt. gradients) on the real-space grid.

Args:

cell : Mole or Cell object ao_kpts : (nkpts, ngrids, nao) ndarray

AO values at each k-point

dm_kpts: (nkpts, nao, nao) ndarray

Density matrix at each k-point

Returns:

rhoR : (ngrids,) ndarray

eval_rho1(cell, ao_kpts, dm_kpts, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, cutoff=1e-15, grids=None, verbose=None)[source]
eval_rho2(cell, ao_kpts, mo_coeff_kpts, mo_occ_kpts, non0tab=None, xctype='LDA', with_lapl=True, verbose=None)[source]
get_rho(cell, dm, grids, kpts=array([[0., 0., 0.]]), max_memory=2000)

Density in real space

get_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

make_mask(cell, coords, relativity=0, shls_slice=None, verbose=None)[source]

Mask to indicate whether a shell is zero on grid. The resultant mask array is an extension to the mask array used in molecular code (see also pyscf.dft.numint.make_mask function). For given shell ID and block ID, the value of the extended mask array means the number of images in Ls that does not vanish.

nr_rks(cell, grids, xc_code, dms, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None, **kwargs)[source]

Calculate RKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point.

kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

nr_rks_fxc(cell, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_rks_fxc_st(cell, grids, xc_code, dm0, dms_alpha, relativity=0, singlet=True, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)

Associated to singlet or triplet Hessian Note the difference to nr_rks_fxc, dms_alpha is the response density matrices of alpha spin, alpha+/-beta DM is applied due to singlet/triplet coupling

Ref. CPL, 256, 454

nr_uks(cell, grids, xc_code, dms, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None, **kwargs)[source]

Calculate UKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms :

Density matrices

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point. kpts_band : (3,) ndarray or (*,3) ndarray A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

nr_uks_fxc(cell, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)

Contract UKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D array a list of 2D arrays

Density matrix or multiple density matrices

Kwargs:
hermiint

Input density matrices symmetric or not

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

Examples:

nr_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

class pyscf.pbc.dft.numint.NumInt[source]

Bases: StreamObject, LibXCMixin

Generalization of pyscf’s NumInt class for a single k-point shift and periodic images.

block_loop(cell, grids, nao=None, deriv=0, kpt=None, kpts_band=None, max_memory=2000, non0tab=None, blksize=None)[source]

Define this macro to loop over grids by blocks.

cache_xc_kernel(cell, grids, xc_code, mo_coeff, mo_occ, spin=0, kpt=None, max_memory=2000)[source]
cache_xc_kernel1(cell, grids, xc_code, dm, spin=0, kpt=None, max_memory=2000)[source]
cutoff = 1e-13
static eval_ao(cell, coords, kpt=array([0., 0., 0.]), deriv=0, relativity=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)

Collocate AO crystal orbitals (opt. gradients) on the real-space grid.

Args:

cell : instance of Cell

coords(nx*ny*nz, 3) ndarray

The real-space grid point coordinates.

Kwargs:
kpt(3,) ndarray

The k-point corresponding to the crystal AO.

derivint

AO derivative order. It affects the shape of the return array. If deriv=0, the returned AO values are stored in a (N,nao) array. Otherwise the AO values are stored in an array of shape (M,N,nao). Here N is the number of grids, nao is the number of AO functions, M is the size associated to the derivative deriv.

Returns:
aoR([4,] nx*ny*nz, nao=cell.nao_nr()) ndarray

The value of the AO crystal orbitals on the real-space grid by default. If deriv=1, also contains the value of the orbitals gradient in the x, y, and z directions. It can be either complex or float array, depending on the kpt argument. If kpt is not given (gamma point), aoR is a float array.

See Also:

pyscf.dft.numint.eval_ao

static eval_rho(cell, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)

Collocate the density (opt. gradients) on the real-space grid.

Args:

cell : instance of Mole or Cell

ao([4,] nx*ny*nz, nao=cell.nao_nr()) ndarray

The value of the AO crystal orbitals on the real-space grid by default. If xctype=’GGA’, also contains the value of the gradient in the x, y, and z directions.

Returns:
rho([4,] nx*ny*nz) ndarray

The value of the density on the real-space grid. If xctype=’GGA’, also contains the value of the gradient in the x, y, and z directions.

See Also:

pyscf.dft.numint.eval_rho

eval_rho1(cell, ao, dm, screen_index=None, xctype='LDA', hermi=0, with_lapl=True, cutoff=None, ao_cutoff=None, verbose=None)[source]
static eval_rho2(cell, ao, mo_coeff, mo_occ, non0tab=None, xctype='LDA', with_lapl=True, verbose=None)

Refer to pyscf.dft.numint.eval_rho2 for full documentation.

get_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

get_rho(cell, dm, grids, kpts=array([[0., 0., 0.]]), max_memory=2000)

Density in real space

get_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpt=None, kpts_band=None, max_memory=2000, verbose=None)

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

static make_mask(cell, coords, relativity=0, shls_slice=None, cutoff=None, verbose=None)

Mask to indicate whether a shell is zero on grid. The resultant mask array is an extension to the mask array used in molecular code (see also pyscf.dft.numint.make_mask function). For given shell ID and block ID, the value of the extended mask array means the number of images in Ls that does not vanish.

nr_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)[source]

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_rks(cell, grids, xc_code, dms, relativity=0, hermi=1, kpt=array([0., 0., 0.]), kpts_band=None, max_memory=2000, verbose=None)[source]

Calculate RKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point.

kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

nr_rks_fxc(cell, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_rks_fxc_st(cell, grids, xc_code, dm0, dms_alpha, relativity=0, singlet=True, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)

Associated to singlet or triplet Hessian Note the difference to nr_rks_fxc, dms_alpha is the response density matrices of alpha spin, alpha+/-beta DM is applied due to singlet/triplet coupling

Ref. CPL, 256, 454

nr_uks(cell, grids, xc_code, dms, relativity=0, hermi=1, kpt=array([0., 0., 0.]), kpts_band=None, max_memory=2000, verbose=None)[source]

Calculate UKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms :

Density matrices

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point. kpts_band : (3,) ndarray or (*,3) ndarray A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

nr_uks_fxc(cell, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)

Contract UKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D array a list of 2D arrays

Density matrix or multiple density matrices

Kwargs:
hermiint

Input density matrices symmetric or not

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

Examples:

nr_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpt=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

pyscf.pbc.dft.numint.cache_xc_kernel(ni, cell, grids, xc_code, mo_coeff, mo_occ, spin=0, kpts=None, max_memory=2000)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

pyscf.pbc.dft.numint.cache_xc_kernel1(ni, cell, grids, xc_code, dm, spin=0, kpts=None, max_memory=2000)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

pyscf.pbc.dft.numint.eval_ao(cell, coords, kpt=array([0., 0., 0.]), deriv=0, relativity=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)[source]

Collocate AO crystal orbitals (opt. gradients) on the real-space grid.

Args:

cell : instance of Cell

coords(nx*ny*nz, 3) ndarray

The real-space grid point coordinates.

Kwargs:
kpt(3,) ndarray

The k-point corresponding to the crystal AO.

derivint

AO derivative order. It affects the shape of the return array. If deriv=0, the returned AO values are stored in a (N,nao) array. Otherwise the AO values are stored in an array of shape (M,N,nao). Here N is the number of grids, nao is the number of AO functions, M is the size associated to the derivative deriv.

Returns:
aoR([4,] nx*ny*nz, nao=cell.nao_nr()) ndarray

The value of the AO crystal orbitals on the real-space grid by default. If deriv=1, also contains the value of the orbitals gradient in the x, y, and z directions. It can be either complex or float array, depending on the kpt argument. If kpt is not given (gamma point), aoR is a float array.

See Also:

pyscf.dft.numint.eval_ao

pyscf.pbc.dft.numint.eval_ao_kpts(cell, coords, kpts=None, deriv=0, relativity=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None, **kwargs)[source]
Returns:
ao_kpts: (nkpts, [comp], ngrids, nao) ndarray

AO values at each k-point

pyscf.pbc.dft.numint.eval_rho(cell, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)[source]

Collocate the density (opt. gradients) on the real-space grid.

Args:

cell : instance of Mole or Cell

ao([4,] nx*ny*nz, nao=cell.nao_nr()) ndarray

The value of the AO crystal orbitals on the real-space grid by default. If xctype=’GGA’, also contains the value of the gradient in the x, y, and z directions.

Returns:
rho([4,] nx*ny*nz) ndarray

The value of the density on the real-space grid. If xctype=’GGA’, also contains the value of the gradient in the x, y, and z directions.

See Also:

pyscf.dft.numint.eval_rho

pyscf.pbc.dft.numint.eval_rho2(cell, ao, mo_coeff, mo_occ, non0tab=None, xctype='LDA', with_lapl=True, verbose=None)[source]

Refer to pyscf.dft.numint.eval_rho2 for full documentation.

pyscf.pbc.dft.numint.get_rho(ni, cell, dm, grids, kpts=array([[0., 0., 0.]]), max_memory=2000)[source]

Density in real space

pyscf.pbc.dft.numint.nr_nlc_vxc(ni, cell, grids, xc_code, dms, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Calculate NLC functional and potential matrix on given grids

Args:

ni : an instance of NumInt

cell : an instance of Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dm2D array

Density matrix or multiple density matrices

Kwargs:
hermiint

Input density matrices symmetric or not. It also indicates whether the potential matrices in return are symmetric or not.

max_memoryint or float

The maximum size of cache to use (in MB).

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

pyscf.pbc.dft.numint.nr_rks(ni, cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Calculate RKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point.

kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

pyscf.pbc.dft.numint.nr_rks_fxc(ni, cell, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)[source]

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

pyscf.pbc.dft.numint.nr_rks_fxc_st(ni, cell, grids, xc_code, dm0, dms_alpha, relativity=0, singlet=True, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)[source]

Associated to singlet or triplet Hessian Note the difference to nr_rks_fxc, dms_alpha is the response density matrices of alpha spin, alpha+/-beta DM is applied due to singlet/triplet coupling

Ref. CPL, 256, 454

pyscf.pbc.dft.numint.nr_rks_vxc(ni, cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)

Calculate RKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point.

kpts_band(3,) ndarray or (*,3) ndarray

A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

pyscf.pbc.dft.numint.nr_uks(ni, cell, grids, xc_code, dms, spin=1, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Calculate UKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms :

Density matrices

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point. kpts_band : (3,) ndarray or (*,3) ndarray A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

pyscf.pbc.dft.numint.nr_uks_fxc(ni, cell, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpts=None, max_memory=2000, verbose=None)[source]

Contract UKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D array a list of 2D arrays

Density matrix or multiple density matrices

Kwargs:
hermiint

Input density matrices symmetric or not

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

Examples:

pyscf.pbc.dft.numint.nr_uks_vxc(ni, cell, grids, xc_code, dms, spin=1, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)

Calculate UKS XC functional and potential matrix for given meshgrids and density matrix

Note: This is a replica of pyscf.dft.numint.nr_rks_vxc with kpts added. This implemented uses slow function in numint, which only calls eval_rho, eval_mat.

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms :

Density matrices

Kwargs:
spinint

spin polarized if spin = 1

relativityint

No effects.

hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

verboseint or object of Logger

No effects.

kpts(3,) ndarray or (nkpts,3) ndarray

Single or multiple k-points sampled for the DM. Default is gamma point. kpts_band : (3,) ndarray or (*,3) ndarray A list of arbitrary “band” k-points at which to evaluate the XC matrix.

Returns:

nelec, excsum, vmat. nelec is the number of electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

pyscf.pbc.dft.numint2c module

Numerical integration functions for (2-component) GKS and KGKS

Ref:

Phys. Rev. Research 5, 013036

class pyscf.pbc.dft.numint2c.KNumInt2C(kpts=array([[0., 0., 0.]]))[source]

Bases: StreamObject, LibXCMixin

block_loop(cell, grids, nao=None, deriv=0, kpts=None, kpts_band=None, max_memory=2000, non0tab=None, blksize=None)

Define this macro to loop over grids by blocks.

cache_xc_kernel(cell, grids, xc_code, mo_coeff_kpts, mo_occ_kpts, spin=0, kpts=None, max_memory=2000)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

cache_xc_kernel1(cell, grids, xc_code, dm_kpts, spin=0, kpts=None, max_memory=2000)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

collinear = 'col'
collinear_samples = 200
collinear_thrd = 0.99
eval_rho(cell, ao_kpts, dm_kpts, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)[source]

Collocate the density (opt. gradients) on the real-space grid.

Args:

cell : Mole or Cell object ao_kpts : (nkpts, ngrids, nao) ndarray

AO values at each k-point

dm_kpts: (nkpts, nao, nao) ndarray

Density matrix at each k-point

Returns:

rhoR : (ngrids,) ndarray

eval_rho1(cell, ao_kpts, dm_kpts, screen_index=None, xctype='LDA', hermi=0, with_lapl=True, cutoff=None, ao_cutoff=None, pair_mask=None, verbose=None)[source]
eval_rho2(cell, ao_kpts, mo_coeff_kpts, mo_occ_kpts, non0tab=None, xctype='LDA', with_lapl=True, verbose=None)[source]
eval_xc_eff(xc_code, rho, deriv=1, omega=None, xctype=None, verbose=None)

Returns the derivative tensor against the density parameters

[[density_a, (nabla_x)_a, (nabla_y)_a, (nabla_z)_a, tau_a],

[density_b, (nabla_x)_b, (nabla_y)_b, (nabla_z)_b, tau_b]].

It differs from the eval_xc method in the derivatives of non-local part. The eval_xc method returns the XC functional derivatives to sigma (|nabla rho|^2)

Args:
rho: 2-dimensional or 3-dimensional array

Total density and spin density (and their derivatives if GGA or MGGA functionals) on grids

Kwargs:
deriv: int

derivative orders

omega: float

define the exponent in the attenuated Coulomb for RSH functional

get_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

get_rho(cell, dm, grids, kpts=array([[0., 0., 0.]]), max_memory=2000)[source]

Density in real space

get_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

make_mask(*args, **kwargs)
mcfun_eval_xc_adapter(xc_code)

Wrapper to generate the eval_xc function required by mcfun

nr_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_gks_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_gks_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

nr_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpts=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

spin_samples = 770
class pyscf.pbc.dft.numint2c.NumInt2C[source]

Bases: StreamObject, LibXCMixin

Numerical integration methods for 2-component basis (used by GKS)

block_loop(cell, grids, nao=None, deriv=0, kpt=None, kpts_band=None, max_memory=2000, non0tab=None, blksize=None)

Define this macro to loop over grids by blocks.

cache_xc_kernel(cell, grids, xc_code, mo_coeff, mo_occ, spin=0, kpt=None, max_memory=2000)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

cache_xc_kernel1(cell, grids, xc_code, dm, spin=0, kpt=None, max_memory=2000)[source]

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc.

collinear = 'col'
collinear_samples = 200
collinear_thrd = 0.99
static eval_ao(cell, coords, kpt=array([0., 0., 0.]), deriv=0, relativity=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)

Collocate AO crystal orbitals (opt. gradients) on the real-space grid.

Args:

cell : instance of Cell

coords(nx*ny*nz, 3) ndarray

The real-space grid point coordinates.

Kwargs:
kpt(3,) ndarray

The k-point corresponding to the crystal AO.

derivint

AO derivative order. It affects the shape of the return array. If deriv=0, the returned AO values are stored in a (N,nao) array. Otherwise the AO values are stored in an array of shape (M,N,nao). Here N is the number of grids, nao is the number of AO functions, M is the size associated to the derivative deriv.

Returns:
aoR([4,] nx*ny*nz, nao=cell.nao_nr()) ndarray

The value of the AO crystal orbitals on the real-space grid by default. If deriv=1, also contains the value of the orbitals gradient in the x, y, and z directions. It can be either complex or float array, depending on the kpt argument. If kpt is not given (gamma point), aoR is a float array.

See Also:

pyscf.dft.numint.eval_ao

static eval_rho(mol, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)

Calculate the electron density and magnetization spin density in the framework of 2-component real basis. Calculate the electron density for LDA functional, and the density derivatives for GGA and MGGA functionals.

Args:

mol : an instance of Mole

ao2D array of shape (N,nao) for LDA, 3D array of shape (4,N,nao) for GGA

or meta-GGA. N is the number of grids, nao is the number of AO functions. If xctype is GGA (MGGA), ao[0] is AO value and ao[1:3] are the AO gradients. ao[4:10] are second derivatives of ao values if applicable.

dm2D array

Density matrix

Kwargs:
non0tab2D bool array

mask array to indicate whether the AO values are zero. The mask array can be obtained by calling make_mask()

xctypestr

LDA/GGA/mGGA. It affects the shape of the return density.

hermibool

dm is hermitian or not

verboseint or object of Logger

No effects.

Returns:

1D array of size N to store electron density if xctype = LDA; 2D array of (4,N) to store density and “density derivatives” for x,y,z components if xctype = GGA; For meta-GGA, returns can be a (6,N) (with_lapl=True) array where last two rows are nabla^2 rho and tau = 1/2(nabla f)^2 or (5,N) (with_lapl=False) where the last row is tau = 1/2(nabla f)^2

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz')
>>> coords = numpy.random.random((100,3))  # 100 random points
>>> ao_value = eval_ao(mol, coords, deriv=0)
>>> dm = numpy.random.random((mol.nao_nr(),mol.nao_nr()))
>>> dm = dm + dm.T
>>> rho, dx_rho, dy_rho, dz_rho = eval_rho(mol, ao, dm, xctype='LDA')
eval_rho1(cell, ao, dm, screen_index=None, xctype='LDA', hermi=0, with_lapl=True, cutoff=None, ao_cutoff=None, pair_mask=None, verbose=None)[source]
eval_rho2(mol, ao, mo_coeff, mo_occ, non0tab=None, xctype='LDA', with_lapl=True, verbose=None)[source]

Calculate the electron density for LDA functional and the density derivatives for GGA functional in the framework of 2-component basis.

eval_xc_eff(xc_code, rho, deriv=1, omega=None, xctype=None, verbose=None)

Returns the derivative tensor against the density parameters

[[density_a, (nabla_x)_a, (nabla_y)_a, (nabla_z)_a, tau_a],

[density_b, (nabla_x)_b, (nabla_y)_b, (nabla_z)_b, tau_b]].

It differs from the eval_xc method in the derivatives of non-local part. The eval_xc method returns the XC functional derivatives to sigma (|nabla rho|^2)

Args:
rho: 2-dimensional or 3-dimensional array

Total density and spin density (and their derivatives if GGA or MGGA functionals) on grids

Kwargs:
deriv: int

derivative orders

omega: float

define the exponent in the attenuated Coulomb for RSH functional

get_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

get_rho(cell, dm, grids, kpt=array([[0., 0., 0.]]), max_memory=2000)[source]

Density in real space

get_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpt=None, kpts_band=None, max_memory=2000, verbose=None)

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

make_mask(*args, **kwargs)
mcfun_eval_xc_adapter(xc_code)

Wrapper to generate the eval_xc function required by mcfun

nr_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)[source]

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_gks_fxc(cell, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, kpt=None, max_memory=2000, verbose=None)

Contract RKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt or KNumInt

cell : instance of Mole or Cell

gridsan instance of Grids

grids.coords and grids.weights are needed for coordinates and weights of meshgrids.

xc_codestr

XC functional description. See parse_xc() of pyscf/dft/libxc.py for more details.

dms2D/3D array or a list of 2D/3D arrays

Density matrices (2D) / density matrices for k-points (3D)

Kwargs:
hermiint

Whether the input density matrix is hermitian

max_memoryint or float

The maximum size of cache to use (in MB).

rho0float array

Zero-order density (and density derivative for GGA). Giving kwargs rho0, vxc and fxc to improve better performance.

vxcfloat array

First order XC derivatives

fxcfloat array

Second order XC derivatives

Examples:

nr_gks_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpt=None, kpts_band=None, max_memory=2000, verbose=None)

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

nr_vxc(cell, grids, xc_code, dms, spin=0, relativity=0, hermi=1, kpt=None, kpts_band=None, max_memory=2000, verbose=None)[source]

Evaluate RKS/UKS XC functional and potential matrix. See nr_rks() and nr_uks() for more details.

spin_samples = 770

pyscf.pbc.dft.rks module

Non-relativistic Restricted Kohn-Sham for periodic systems at a single k-point

See Also:
pyscf.pbc.dft.krks.pyNon-relativistic Restricted Kohn-Sham for periodic

systems with k-point sampling

class pyscf.pbc.dft.rks.KohnShamDFT(xc='LDA,VWN')[source]

Bases: KohnShamDFT

PBC-KS

build(cell=None)[source]
density_fit(auxbasis=None, with_df=None, *args, **kwargs)
dump_flags(verbose=None)[source]
get_rho(dm=None, grids=None, kpt=None)

Compute density in real space

initialize_grids(cell, dm, kpts, ground_state=True)[source]

Initialize self.grids the first time call get_veff

jk_method(J='FFTDF', K=None)[source]

Set up the schemes to evaluate Coulomb and exchange matrix

FFTDF: planewave density fitting using Fast Fourier Transform AFTDF: planewave density fitting using analytic Fourier Transform GDF: Gaussian density fitting MDF: Gaussian and planewave mix density fitting RS: range-separation JK builder RSDF: range-separation density fitting

mix_density_fit(auxbasis=None, with_df=None, *args, **kwargs)
reset(cell=None)[source]
rs_density_fit(auxbasis=None, with_df=None, *args, **kwargs)
to_gks(xc=None)[source]

Convert the input mean-field object to a GKS object.

Note this conversion only changes the class of the mean-field object. The total energy and wave-function are the same as them in the input mean-field object.

to_hf()[source]

Convert the input KS object to the associated HF object.

Note this conversion only changes the class of the mean-field object. The total energy and wave-function are the same as them in the input mean-field object.

to_rks(xc=None)[source]

Convert the input mean-field object to a RKS/ROKS object.

Note this conversion only changes the class of the mean-field object. The total energy and wave-function are the same as them in the input mean-field object.

to_uks(xc=None)[source]

Convert the input mean-field object to a UKS object.

Note this conversion only changes the class of the mean-field object. The total energy and wave-function are the same as them in the input mean-field object.

class pyscf.pbc.dft.rks.RKS(cell, kpt=array([0., 0., 0.]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, RHF

RKS class adapted for PBCs.

This is a literal duplication of the molecular RKS class with some mol variables replaced by cell.

dump_flags(verbose=None)[source]
energy_elec(dm=None, h1e=None, vhf=None)

Electronic part of RKS energy.

Note this function has side effects which cause mf.scf_summary updated.

Args:

ks : an instance of DFT class

dm2D ndarray

one-partical density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)

Coulomb + XC functional

Note

This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

matrix Veff = J + Vxc. Veff can be a list matrices, if the input dm is a list of density matrices.

get_vsap(mol=None)

Superposition of atomic potentials

S. Lehtola, Assessment of initial guesses for self-consistent field calculations. Superposition of Atomic Potentials: simple yet efficient, J. Chem. Theory Comput. 15, 1593 (2019). DOI: 10.1021/acs.jctc.8b01089. arXiv:1810.11659.

This function evaluates the effective charge of a neutral atom, given by exchange-only LDA on top of spherically symmetric unrestricted Hartree-Fock calculations as described in

S. Lehtola, L. Visscher, E. Engel, Efficient implementation of the superposition of atomic potentials initial guess for electronic structure calculations in Gaussian basis sets, J. Chem. Phys., in press (2020).

The potentials have been calculated for the ground-states of spherically symmetric atoms at the non-relativistic level of theory as described in

S. Lehtola, “Fully numerical calculations on atoms with fractional occupations and range-separated exchange functionals”, Phys. Rev. A 101, 012516 (2020). DOI: 10.1103/PhysRevA.101.012516

using accurate finite-element calculations as described in

S. Lehtola, “Fully numerical Hartree-Fock and density functional calculations. I. Atoms”, Int. J. Quantum Chem. e25945 (2019). DOI: 10.1002/qua.25945

Note

This function will modify the input ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

Returns:

matrix Vsap = Vnuc + J + Vxc.

init_guess_by_vsap(mol=None)

Form SAP guess

to_hf()[source]

Convert to RHF object.

pyscf.pbc.dft.rks.get_rho(mf, dm=None, grids=None, kpt=None)[source]

Compute density in real space

pyscf.pbc.dft.rks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)[source]

Coulomb + XC functional

Note

This function will change the ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Returns:

matrix Veff = J + Vxc. Veff can be a list matrices, if the input dm is a list of density matrices.

pyscf.pbc.dft.rks.prune_small_rho_grids_(ks, cell, dm, grids, kpts)[source]

pyscf.pbc.dft.roks module

Restricted open-shell Kohn-Sham for periodic systems at a single k-point

class pyscf.pbc.dft.roks.ROKS(cell, kpt=array([0., 0., 0.]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, ROHF

UKS class adapted for PBCs.

This is a literal duplication of the molecular UKS class with some mol variables replaced by cell.

dump_flags(verbose=None)[source]
energy_elec(dm=None, h1e=None, vhf=None)

Electronic part of Hartree-Fock energy, for given core hamiltonian and HF potential

… math:

E = \sum_{ij}h_{ij} \gamma_{ji}
  + \frac{1}{2}\sum_{ijkl} \gamma_{ji}\gamma_{lk} \langle ik||jl\rangle

Note this function has side effects which cause mf.scf_summary updated.

Args:

mf : an instance of SCF class

Kwargs:
dm2D ndarray

one-partical density matrix

h1e2D ndarray

Core hamiltonian

vhf2D ndarray

HF potential

Returns:

Hartree-Fock electronic energy and the Coulomb energy

Examples:

>>> from pyscf import gto, scf
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> mf = scf.RHF(mol)
>>> mf.scf()
>>> dm = mf.make_rdm1()
>>> scf.hf.energy_elec(mf, dm)
(-1.5176090667746334, 0.60917167853723675)
>>> mf.energy_elec(dm)
(-1.5176090667746334, 0.60917167853723675)
get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

get_vsap(mol=None)

Superposition of atomic potentials

S. Lehtola, Assessment of initial guesses for self-consistent field calculations. Superposition of Atomic Potentials: simple yet efficient, J. Chem. Theory Comput. 15, 1593 (2019). DOI: 10.1021/acs.jctc.8b01089. arXiv:1810.11659.

This function evaluates the effective charge of a neutral atom, given by exchange-only LDA on top of spherically symmetric unrestricted Hartree-Fock calculations as described in

S. Lehtola, L. Visscher, E. Engel, Efficient implementation of the superposition of atomic potentials initial guess for electronic structure calculations in Gaussian basis sets, J. Chem. Phys., in press (2020).

The potentials have been calculated for the ground-states of spherically symmetric atoms at the non-relativistic level of theory as described in

S. Lehtola, “Fully numerical calculations on atoms with fractional occupations and range-separated exchange functionals”, Phys. Rev. A 101, 012516 (2020). DOI: 10.1103/PhysRevA.101.012516

using accurate finite-element calculations as described in

S. Lehtola, “Fully numerical Hartree-Fock and density functional calculations. I. Atoms”, Int. J. Quantum Chem. e25945 (2019). DOI: 10.1002/qua.25945

Note

This function will modify the input ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

Returns:

matrix Vsap = Vnuc + J + Vxc.

init_guess_by_vsap(mol=None)

Form SAP guess

to_hf()[source]

Convert to RHF object.

pyscf.pbc.dft.roks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)[source]

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

pyscf.pbc.dft.uks module

Non-relativistic unrestricted Kohn-Sham for periodic systems at a single k-point

See Also:
pyscf.pbc.dft.krks.pyNon-relativistic Restricted Kohn-Sham for periodic

systems with k-point sampling

class pyscf.pbc.dft.uks.UKS(cell, kpt=array([0., 0., 0.]), xc='LDA,VWN', exxdiv='ewald')[source]

Bases: KohnShamDFT, UHF

UKS class adapted for PBCs.

This is a literal duplication of the molecular UKS class with some mol variables replaced by cell.

dump_flags(verbose=None)[source]
energy_elec(dm=None, h1e=None, vhf=None)

Electronic energy of Unrestricted Hartree-Fock

Note this function has side effects which cause mf.scf_summary updated.

Returns:

Hartree-Fock electronic energy and the 2-electron part contribution

get_rho(dm=None, grids=None, kpt=None)

Compute density in real space

get_veff(cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

get_vsap(mol=None)

Superposition of atomic potentials

S. Lehtola, Assessment of initial guesses for self-consistent field calculations. Superposition of Atomic Potentials: simple yet efficient, J. Chem. Theory Comput. 15, 1593 (2019). DOI: 10.1021/acs.jctc.8b01089. arXiv:1810.11659.

This function evaluates the effective charge of a neutral atom, given by exchange-only LDA on top of spherically symmetric unrestricted Hartree-Fock calculations as described in

S. Lehtola, L. Visscher, E. Engel, Efficient implementation of the superposition of atomic potentials initial guess for electronic structure calculations in Gaussian basis sets, J. Chem. Phys., in press (2020).

The potentials have been calculated for the ground-states of spherically symmetric atoms at the non-relativistic level of theory as described in

S. Lehtola, “Fully numerical calculations on atoms with fractional occupations and range-separated exchange functionals”, Phys. Rev. A 101, 012516 (2020). DOI: 10.1103/PhysRevA.101.012516

using accurate finite-element calculations as described in

S. Lehtola, “Fully numerical Hartree-Fock and density functional calculations. I. Atoms”, Int. J. Quantum Chem. e25945 (2019). DOI: 10.1002/qua.25945

Note

This function will modify the input ks object.

Args:
ksan instance of RKS

XC functional are controlled by ks.xc attribute. Attribute ks.grids might be initialized.

Returns:

matrix Vsap = Vnuc + J + Vxc.

init_guess_by_vsap(mol=None)

Form SAP guess

to_hf()[source]

Convert to UHF object.

pyscf.pbc.dft.uks.get_veff(ks, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None)[source]

Coulomb + XC functional for UKS. See pyscf/pbc/dft/uks.py get_veff() fore more details.

Module contents

Kohn-Sham DFT for periodic systems

pyscf.pbc.dft.KKS(cell, *args, **kwargs)[source]

A wrap function to create DFT object with k-point sampling (KRKS or KUKS).

RKS class adapted for PBCs with k-point sampling.

pyscf.pbc.dft.KRKS(cell, *args, **kwargs)[source]
pyscf.pbc.dft.KRKSpU(cell, *args, **kwargs)[source]
pyscf.pbc.dft.KS(cell, *args, **kwargs)[source]

A wrap function to create DFT object (RKS or UKS) for PBC systems.

RKS class adapted for PBCs.

This is a literal duplication of the molecular RKS class with some mol variables replaced by cell.

pyscf.pbc.dft.KUKS(cell, *args, **kwargs)[source]
pyscf.pbc.dft.KUKSpU(cell, *args, **kwargs)[source]
pyscf.pbc.dft.RKS(cell, *args, **kwargs)[source]

RKS class adapted for PBCs.

This is a literal duplication of the molecular RKS class with some mol variables replaced by cell.