pyscf.dft package#

Subpackages#

Submodules#

pyscf.dft.LebedevGrid module#

pyscf.dft.LebedevGrid.MakeAngularGrid(points)[source]#

Angular grids for specified Lebedev points

pyscf.dft.LebedevGrid.MakeAngularGrid_110()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_1202()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_14()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_1454()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_146()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_170()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_1730()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_194()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_2030()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_230()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_2354()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_26()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_266()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_2702()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_302()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_3074()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_3470()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_350()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_38()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_3890()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_4334()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_434()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_4802()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_50()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_5294()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_5810()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_590()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_6()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_74()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_770()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_86()[source]#
pyscf.dft.LebedevGrid.MakeAngularGrid_974()[source]#
pyscf.dft.LebedevGrid.SphGenOh(code, a, b, v)[source]#

pyscf.dft.dft_parser module#

unified dft parser for coordinating dft protocols with 1. xc functionals 2. dispersion corrections / nonlocal correction 3. GTO basis (TODO) 4. geometrical counterpoise (gCP) correction (TODO)

pyscf.dft.dks module#

4-component Dirac-Kohn-Sham

class pyscf.dft.dks.DKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, DHF

Kramers unrestricted Dirac-Kohn-Sham

CasidaTDDFT = None#
TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT(*args, **kwargs)#
TDHF = None#
dump_flags(verbose=None)[source]#
to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

x2c()#
x2c1e()[source]#
class pyscf.dft.dks.KohnShamDFT(xc='LDA,VWN')[source]#

Bases: KohnShamDFT

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-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

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

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
Returns:

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

property spin_samples#
to_dhf()[source]#

Convert the input mean-field object to a DHF 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_dks(xc=None)[source]#
to_ghf()[source]#

Convert the input mean-field object to a GHF 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_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()#

Convert the input mean-field object to a DHF 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_ks(xc=None)#
to_rhf()[source]#

Convert the input mean-field object to a RHF/ROHF 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_uhf()[source]#

Convert the input mean-field object to a UHF 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.dft.dks.RDKS(mol, xc='LDA,VWN')[source]#

Bases: DKS, RDHF

Kramers restricted Dirac-Kohn-Sham

CasidaTDDFT = None#
TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT(*args, **kwargs)#
TDHF = None#
to_dhf()[source]#

Convert the input mean-field object to a DHF 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.

x2c()#
x2c1e()[source]#
pyscf.dft.dks.RKS#

alias of RDKS

pyscf.dft.dks.UDKS#

alias of DKS

pyscf.dft.dks.UKS#

alias of DKS

pyscf.dft.dks.energy_elec(ks, dm=None, h1e=None, vhf=None)[source]#

Electronic part of DKS energy.

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

Args:

ks : an instance of DFT class

dm2D ndarray

one-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

DKS electronic energy and the 2-electron contribution

pyscf.dft.dks.get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)[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

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
Returns:

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

pyscf.dft.gen_grid module#

Generate DFT grids and weights, based on the code provided by Gerald Knizia <>

Reference for Lebedev-Laikov grid:

V. I. Lebedev, and D. N. Laikov “A quadrature formula for the sphere of the 131st algebraic order of accuracy”, Doklady Mathematics, 59, 477-481 (1999)

class pyscf.dft.gen_grid.Grids(mol)[source]#

Bases: StreamObject

DFT mesh grids

Attributes for Grids:
levelint

To control the number of radial and angular grids. Large number leads to large mesh grids. The default level 3 corresponds to (50,302) for H, He; (75,302) for second row; (80~105,434) for rest.

Grids settings at other levels can be found in pyscf.dft.gen_grid.RAD_GRIDS and pyscf.dft.gen_grid.ANG_ORDER

atomic_radii1D array
radi.BRAGG_RADII (default)
radi.COVALENT_RADII
None : to switch off atomic radii adjustment
radii_adjustfunction(mol, atomic_radii) => (function(atom_id, atom_id, g) => array_like_g)

Function to adjust atomic radii, can be one of | radi.treutler_atomic_radii_adjust | radi.becke_atomic_radii_adjust | None : to switch off atomic radii adjustment

radi_methodfunction(n) => (rad_grids, rad_weights)

scheme for radial grids, can be one of | radi.treutler (default) | radi.delley | radi.mura_knowles | radi.gauss_chebyshev

becke_schemefunction(v) => array_like_v

weight partition function, can be one of | gen_grid.original_becke (default) | gen_grid.stratmann

prunefunction(nuc, rad_grids, n_ang) => list_n_ang_for_each_rad_grid

scheme to reduce number of grids, can be one of | gen_grid.nwchem_prune (default) | gen_grid.sg1_prune | gen_grid.treutler_prune | None : to switch off grid pruning

symmetrybool

whether to symmetrize mesh grids (TODO)

atom_griddict

Set (radial, angular) grids for particular atoms. Eg, grids.atom_grid = {‘H’: (20,110)} will generate 20 radial grids and 110 angular grids for H atom.

Examples:

>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.level = 4
>>> grids.build()
alignment = 8#
atomic_radii = array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243,        1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306,        2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874,        1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747,        3.40150702, 3.0235618 , 2.64561657, 2.55113027, 2.64561657,        2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027,        2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504,        2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702,        2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396,        2.55113027, 2.64561657, 3.0235618 , 2.92907549, 2.92907549,        2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486,        4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333,        3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027,        2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027,        2.83458919, 3.59047964, 3.40150702, 3.0235618 , 3.59047964,        2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594,        3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072,        3.30702072])#
static becke_scheme(g)#

Becke, JCP 88, 2547 (1988); DOI:10.1063/1.454033

build(mol=None, with_non0tab=False, sort_grids=True, **kwargs)[source]#
cutoff = 1e-15#
dump_flags(verbose=None)[source]#
gen_atomic_grids(mol=None, atom_grid=None, radi_method=None, level=None, prune=None, **kwargs)#

Generate number of radial grids and angular grids for the given molecule.

Returns:

A dict, with the atom symbol for the dict key. For each atom type, the dict value has two items: one is the meshgrid coordinates wrt the atom center; the second is the volume of that grid.

gen_partition(mol, atom_grids_tab=None, radii_adjust=None, atomic_radii=array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243, 1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306, 2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874, 1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747, 3.40150702, 3.0235618, 2.64561657, 2.55113027, 2.64561657, 2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027, 2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504, 2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702, 2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396, 2.55113027, 2.64561657, 3.0235618, 2.92907549, 2.92907549, 2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486, 4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027, 2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027, 2.83458919, 3.59047964, 3.40150702, 3.0235618, 3.59047964, 2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594, 3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072]), becke_scheme=<function original_becke>, concat=True)#

Generate the mesh grid coordinates and weights for DFT numerical integration. We can change radii_adjust, becke_scheme functions to generate different meshgrid.

Kwargs:
concat: bool

Whether to concatenate grids and weights in return

Returns:

grid_coord and grid_weight arrays. grid_coord array has shape (N,3); weight 1D array has N elements.

get_partition(mol, atom_grids_tab=None, radii_adjust=None, atomic_radii=array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243, 1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306, 2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874, 1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747, 3.40150702, 3.0235618, 2.64561657, 2.55113027, 2.64561657, 2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027, 2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504, 2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702, 2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396, 2.55113027, 2.64561657, 3.0235618, 2.92907549, 2.92907549, 2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486, 4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027, 2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027, 2.83458919, 3.59047964, 3.40150702, 3.0235618, 3.59047964, 2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594, 3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072]), becke_scheme=<function original_becke>, concat=True)[source]#

Generate the mesh grid coordinates and weights for DFT numerical integration. We can change radii_adjust, becke_scheme functions to generate different meshgrid.

Kwargs:
concat: bool

Whether to concatenate grids and weights in return

Returns:

grid_coord and grid_weight arrays. grid_coord array has shape (N,3); weight 1D array has N elements.

kernel(mol=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.).

level = 3#
make_mask(mol=None, coords=None, relativity=0, shls_slice=None, cutoff=None, verbose=None)#

Mask to indicate whether a shell is ignorable on grids. See also the function gto.eval_gto.make_screen_index

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of grids.

Kwargs:
relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

verboseint or object of Logger

No effects.

Returns:

2D mask array of shape (N,nbas), where N is the number of grids, nbas is the number of shells.

static prune(nuc, rads, n_ang, radii=array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243, 1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306, 2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874, 1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747, 3.40150702, 3.0235618, 2.64561657, 2.55113027, 2.64561657, 2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027, 2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504, 2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702, 2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396, 2.55113027, 2.64561657, 3.0235618, 2.92907549, 2.92907549, 2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486, 4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027, 2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027, 2.83458919, 3.59047964, 3.40150702, 3.0235618, 3.59047964, 2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594, 3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072]))#

NWChem

Args:
nucint

Nuclear charge.

rads1D array

Grid coordinates on radical axis.

n_angint

Max number of grids over angular part.

Kwargs:
radii1D array

radii (in Bohr) for atoms in periodic table

Returns:

A list has the same length as rads. The list element is the number of grids over angular part for each radial grid.

prune_by_density_(rho, threshold=0)[source]#

Prune grids if the electron density on the grid is small

static radi_method(n, chg, *args, **kwargs)#

Treutler-Ahlrichs [JCP 102, 346 (1995); DOI:10.1063/1.469408] (M4) radial grids

static radii_adjust(mol, atomic_radii)#

Treutler atomic radii adjust function: [JCP 102, 346 (1995); DOI:10.1063/1.469408]

reset(mol=None)[source]#

Reset mol and clean up relevant attributes for scanner mode

property size#
to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

pyscf.dft.gen_grid.arg_group_grids(mol, coords, box_size=1.2)[source]#

Partition the entire space into small boxes according to the input box_size. Group the grids against these boxes.

pyscf.dft.gen_grid.gen_atomic_grids(mol, atom_grid={}, radi_method=<function gauss_chebyshev>, level=3, prune=<function nwchem_prune>, **kwargs)[source]#

Generate number of radial grids and angular grids for the given molecule.

Returns:

A dict, with the atom symbol for the dict key. For each atom type, the dict value has two items: one is the meshgrid coordinates wrt the atom center; the second is the volume of that grid.

pyscf.dft.gen_grid.gen_partition(mol, atom_grids_tab, radii_adjust=None, atomic_radii=array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243, 1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306, 2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874, 1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747, 3.40150702, 3.0235618, 2.64561657, 2.55113027, 2.64561657, 2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027, 2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504, 2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702, 2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396, 2.55113027, 2.64561657, 3.0235618, 2.92907549, 2.92907549, 2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486, 4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027, 2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027, 2.83458919, 3.59047964, 3.40150702, 3.0235618, 3.59047964, 2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594, 3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072]), becke_scheme=<function original_becke>, concat=True)#

Generate the mesh grid coordinates and weights for DFT numerical integration. We can change radii_adjust, becke_scheme functions to generate different meshgrid.

Kwargs:
concat: bool

Whether to concatenate grids and weights in return

Returns:

grid_coord and grid_weight arrays. grid_coord array has shape (N,3); weight 1D array has N elements.

pyscf.dft.gen_grid.get_partition(mol, atom_grids_tab, radii_adjust=None, atomic_radii=array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243, 1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306, 2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874, 1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747, 3.40150702, 3.0235618, 2.64561657, 2.55113027, 2.64561657, 2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027, 2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504, 2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702, 2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396, 2.55113027, 2.64561657, 3.0235618, 2.92907549, 2.92907549, 2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486, 4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027, 2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027, 2.83458919, 3.59047964, 3.40150702, 3.0235618, 3.59047964, 2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594, 3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072]), becke_scheme=<function original_becke>, concat=True)[source]#

Generate the mesh grid coordinates and weights for DFT numerical integration. We can change radii_adjust, becke_scheme functions to generate different meshgrid.

Kwargs:
concat: bool

Whether to concatenate grids and weights in return

Returns:

grid_coord and grid_weight arrays. grid_coord array has shape (N,3); weight 1D array has N elements.

pyscf.dft.gen_grid.make_mask(mol, coords, relativity=0, shls_slice=None, cutoff=1e-15, verbose=None)[source]#

Mask to indicate whether a shell is ignorable on grids. See also the function gto.eval_gto.make_screen_index

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of grids.

Kwargs:
relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

verboseint or object of Logger

No effects.

Returns:

2D mask array of shape (N,nbas), where N is the number of grids, nbas is the number of shells.

pyscf.dft.gen_grid.nwchem_prune(nuc, rads, n_ang, radii=array([3.77945036, 0.66140414, 2.64561657, 2.74010288, 1.98421243, 1.60626721, 1.32280829, 1.22832198, 1.13383567, 0.94486306, 2.83458919, 3.40150702, 2.83458919, 2.36215766, 2.07869874, 1.88972612, 1.88972612, 1.88972612, 3.40150702, 4.15739747, 3.40150702, 3.0235618, 2.64561657, 2.55113027, 2.64561657, 2.64561657, 2.64561657, 2.55113027, 2.55113027, 2.55113027, 2.55113027, 2.45664396, 2.36215766, 2.17318504, 2.17318504, 2.17318504, 3.59047964, 4.44085639, 3.77945225, 3.40150702, 2.92907549, 2.74010288, 2.74010288, 2.55113027, 2.45664396, 2.55113027, 2.64561657, 3.0235618, 2.92907549, 2.92907549, 2.74010288, 2.74010288, 2.64561657, 2.64561657, 3.96842486, 4.91328792, 4.06291117, 3.68496594, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.49599333, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 2.92907549, 2.74010288, 2.55113027, 2.55113027, 2.45664396, 2.55113027, 2.55113027, 2.55113027, 2.83458919, 3.59047964, 3.40150702, 3.0235618, 3.59047964, 2.74010288, 3.96842486, 3.40150702, 4.06291117, 3.68496594, 3.40150702, 3.40150702, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072, 3.30702072]))[source]#

NWChem

Args:
nucint

Nuclear charge.

rads1D array

Grid coordinates on radical axis.

n_angint

Max number of grids over angular part.

Kwargs:
radii1D array

radii (in Bohr) for atoms in periodic table

Returns:

A list has the same length as rads. The list element is the number of grids over angular part for each radial grid.

pyscf.dft.gen_grid.original_becke(g)[source]#

Becke, JCP 88, 2547 (1988); DOI:10.1063/1.454033

pyscf.dft.gen_grid.sg1_prune(nuc, rads, n_ang, radii=array([0., 1., 0.5882, 3.0769, 2.0513, 1.5385, 1.2308, 1.0256, 0.8791, 0.7692, 0.6838, 4.0909, 3.1579, 2.5714, 2.1687, 1.875, 1.6514, 1.4754, 1.3333]))[source]#

SG1, CPL, 209, 506

Args:
nucint

Nuclear charge.

rads1D array

Grid coordinates on radical axis.

n_angint

Max number of grids over angular part.

Kwargs:
radii1D array

radii (in Bohr) for atoms in periodic table

Returns:

A list has the same length as rads. The list element is the number of grids over angular part for each radial grid.

pyscf.dft.gen_grid.stratmann(g)[source]#

Stratmann, Scuseria, Frisch. CPL, 257, 213 (1996); DOI:10.1016/0009-2614(96)00600-8

pyscf.dft.gen_grid.treutler_prune(nuc, rads, n_ang, radii=None)[source]#

Treutler-Ahlrichs

Args:
nucint

Nuclear charge.

rads1D array

Grid coordinates on radical axis.

n_angint

Max number of grids over angular part.

Returns:

A list has the same length as rads. The list element is the number of grids over angular part for each radial grid.

pyscf.dft.gks module#

Generalized Kohn-Sham

class pyscf.dft.gks.GKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, GHF

Generalized Kohn-Sham

CasidaTDDFT(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT()#

Driver to create TDDFT or CasidaTDDFT object

TDDFTNoHybrid(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDHF = None#
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-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

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

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
Returns:

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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

property spin_samples#
to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

to_hf()[source]#

Convert to GHF object.

pyscf.dft.gks.get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)[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

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
Returns:

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

pyscf.dft.gks_symm module#

Generalized Kohn-Sham

class pyscf.dft.gks_symm.GKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, SymAdaptedGHF

Restricted Kohn-Sham

CasidaTDDFT(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT()#

Driver to create TDDFT or CasidaTDDFT object

TDDFTNoHybrid(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDHF = None#
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-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

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

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
Returns:

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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

pyscf.dft.libxc module#

XC functional, the interface to libxc (http://www.tddft.org/programs/octopus/wiki/index.php/Libxc)

pyscf.dft.libxc.available_libxc_functionals()[source]#
pyscf.dft.libxc.define_xc(ni, description, xctype='LDA', hyb=0, rsh=(0, 0, 0))[source]#

Define XC functional. See also eval_xc() for the rules of input description.

Args:

ni : an instance of NumInt

descriptionstr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” was appeared in the string, it stands for the exact exchange.

Kwargs:
xctypestr

‘LDA’ or ‘GGA’ or ‘MGGA’

hybfloat

hybrid functional coefficient

rsha list of three floats

coefficients (omega, alpha, beta) for range-separated hybrid functional. omega is the exponent factor in attenuated Coulomb operator e^{-omega r_{12}}/r_{12} alpha is the coefficient for long-range part, hybrid coefficient can be obtained by alpha + beta

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz')
>>> mf = dft.RKS(mol)
>>> define_xc_(mf._numint, '.2*HF + .08*LDA + .72*B88, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> define_xc_(mf._numint, 'LDA*.08 + .72*B88 + .2*HF, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> def eval_xc(xc_code, rho, *args, **kwargs):
...     exc = 0.01 * rho**2
...     vrho = 0.01 * 3 * rho**2
...     vxc = (vrho, None, None, None)
...     fxc = None  # 2nd order functional derivative
...     kxc = None  # 3rd order functional derivative
...     return exc, vxc, fxc, kxc
>>> define_xc_(mf._numint, eval_xc, xctype='LDA')
>>> mf.kernel()
48.8525211046668
pyscf.dft.libxc.define_xc_(ni, description, xctype='LDA', hyb=0, rsh=(0, 0, 0))[source]#

Define XC functional. See also eval_xc() for the rules of input description.

Args:

ni : an instance of NumInt

descriptionstr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” was appeared in the string, it stands for the exact exchange.

Kwargs:
xctypestr

‘LDA’ or ‘GGA’ or ‘MGGA’

hybfloat

hybrid functional coefficient

rsha list of three floats

coefficients (omega, alpha, beta) for range-separated hybrid functional. omega is the exponent factor in attenuated Coulomb operator e^{-omega r_{12}}/r_{12} alpha is the coefficient for long-range part, hybrid coefficient can be obtained by alpha + beta

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz')
>>> mf = dft.RKS(mol)
>>> define_xc_(mf._numint, '.2*HF + .08*LDA + .72*B88, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> define_xc_(mf._numint, 'LDA*.08 + .72*B88 + .2*HF, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> def eval_xc(xc_code, rho, *args, **kwargs):
...     exc = 0.01 * rho**2
...     vrho = 0.01 * 3 * rho**2
...     vxc = (vrho, None, None, None)
...     fxc = None  # 2nd order functional derivative
...     kxc = None  # 3rd order functional derivative
...     return exc, vxc, fxc, kxc
>>> define_xc_(mf._numint, eval_xc, xctype='LDA')
>>> mf.kernel()
48.8525211046668
pyscf.dft.libxc.eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=None)[source]#

Interface to call libxc library to evaluate XC functional, potential and functional derivatives.

  • The given functional xc_code must be a one-line string.

  • The functional xc_code is case-insensitive.

  • The functional xc_code string has two parts, separated by “,”. The first part describes the exchange functional, the second part sets the correlation functional.

    • If “,” not appeared in string, the entire string is treated as the name of a compound functional (containing both the exchange and the correlation functional) which was declared in the functional aliases list. The full list of functional aliases can be obtained by calling the function pyscf.dft.xcfun.XC_ALIAS.keys() .

      If the string was not found in the aliased functional list, it is treated as X functional.

    • To input only X functional (without C functional), leave the second part blank. E.g. description=’slater,’ means a functional with LDA contribution only.

    • To neglect the contribution of X functional (just apply C functional), leave blank in the first part, e.g. description=’,vwn’ means a functional with VWN only.

    • If compound XC functional is specified, no matter whether it is in the X part (the string in front of comma) or the C part (the string behind comma), both X and C functionals of the compound XC functional will be used.

  • The functional name can be placed in arbitrary order. Two names need to be separated by operators “+” or “-”. Blank spaces are ignored. NOTE the parser only reads operators “+” “-” “*”. / is not supported.

  • A functional name can have at most one factor. If the factor is not given, it is set to 1. Compound functional can be scaled as a unit. For example ‘0.5*b3lyp’ is equivalent to ‘HF*0.1 + .04*LDA + .36*B88, .405*LYP + .095*VWN’

  • String “HF” stands for exact exchange (HF K matrix). “HF” can be put in the correlation functional part (after comma). Putting “HF” in the correlation part is the same to putting “HF” in the exchange part.

  • String “RSH” means range-separated operator. Its format is RSH(omega, alpha, beta). Another way to input RSH is to use keywords SR_HF and LR_HF: “SR_HF(0.1) * alpha_plus_beta” and “LR_HF(0.1) * alpha” where the number in parenthesis is the value of omega.

  • Be careful with the libxc convention of GGA functional, in which the LDA contribution is included.

Args:
xc_codestr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” (exact exchange) is appeared in the string, the HF part will be skipped. If an empty string “” is given, the returns exc, vxc,… will be vectors of zeros.

rhondarray

Shape of ((,N)) for electron density (and derivatives) if spin = 0; Shape of ((,N),(,N)) for alpha/beta electron density (and derivatives) if spin > 0; where N is number of grids. rho (,N) are ordered as (den,grad_x,grad_y,grad_z,laplacian,tau) where grad_x = d/dx den, laplacian = nabla^2 den, tau = 1/2(nabla f)^2 In spin unrestricted case, rho is ((den_u,grad_xu,grad_yu,grad_zu,laplacian_u,tau_u)

(den_d,grad_xd,grad_yd,grad_zd,laplacian_d,tau_d))

Kwargs:
spinint

spin polarized if spin > 0

relativityint

No effects.

verboseint or object of Logger

No effects.

Returns:

ex, vxc, fxc, kxc

where

  • vxc = (vrho, vsigma, vlapl, vtau) for restricted case

  • vxc for unrestricted case | vrho[:,2] = (u, d) | vsigma[:,3] = (uu, ud, dd) | vlapl[:,2] = (u, d) | vtau[:,2] = (u, d)

  • fxc for restricted case: (v2rho2, v2rhosigma, v2sigma2, v2lapl2, vtau2, v2rholapl, v2rhotau, v2lapltau, v2sigmalapl, v2sigmatau)

  • fxc for unrestricted case: | v2rho2[:,3] = (u_u, u_d, d_d) | v2rhosigma[:,6] = (u_uu, u_ud, u_dd, d_uu, d_ud, d_dd) | v2sigma2[:,6] = (uu_uu, uu_ud, uu_dd, ud_ud, ud_dd, dd_dd) | v2lapl2[:,3] | v2tau2[:,3] = (u_u, u_d, d_d) | v2rholapl[:,4] | v2rhotau[:,4] = (u_u, u_d, d_u, d_d) | v2lapltau[:,4] | v2sigmalapl[:,6] | v2sigmatau[:,6] = (uu_u, uu_d, ud_u, ud_d, dd_u, dd_d)

  • kxc for restricted case: (v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3,

    v3rho2lapl, v3rho2tau, v3rhosigmalapl, v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma2lapl, v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, v3lapltau2, v3tau3)

  • kxc for unrestricted case: | v3rho3[:,4] = (u_u_u, u_u_d, u_d_d, d_d_d) | v3rho2sigma[:,9] = (u_u_uu, u_u_ud, u_u_dd, u_d_uu, u_d_ud, u_d_dd, d_d_uu, d_d_ud, d_d_dd) | v3rhosigma2[:,12] = (u_uu_uu, u_uu_ud, u_uu_dd, u_ud_ud, u_ud_dd, u_dd_dd, d_uu_uu, d_uu_ud, d_uu_dd, d_ud_ud, d_ud_dd, d_dd_dd) | v3sigma3[:,10] = (uu_uu_uu, uu_uu_ud, uu_uu_dd, uu_ud_ud, uu_ud_dd, uu_dd_dd, ud_ud_ud, ud_ud_dd, ud_dd_dd, dd_dd_dd) | v3rho2lapl[:,6] | v3rho2tau[:,6] = (u_u_u, u_u_d, u_d_u, u_d_d, d_d_u, d_d_d) | v3rhosigmalapl[:,12] | v3rhosigmatau[:,12] = (u_uu_u, u_uu_d, u_ud_u, u_ud_d, u_dd_u, u_dd_d,

    d_uu_u, d_uu_d, d_ud_u, d_ud_d, d_dd_u, d_dd_d)

    v3rholapl2[:,6]
    v3rholapltau[:,8]
    v3rhotau2[:,6] = (u_u_u, u_u_d, u_d_d, d_u_u, d_u_d, d_d_d)
    v3sigma2lapl[:,12]
    v3sigma2tau[:,12] = (uu_uu_u, uu_uu_d, uu_ud_u, uu_ud_d, uu_dd_u, uu_dd_d, ud_ud_u, ud_ud_d, ud_dd_u, ud_dd_d, dd_dd_u, dd_dd_d)
    v3sigmalapl2[:,9]
    v3sigmalapltau[:,12]
    v3sigmatau2[:,9] = (uu_u_u, uu_u_d, uu_d_d, ud_u_u, ud_u_d, ud_d_d, dd_u_u, dd_u_d, dd_d_d)
    v3lapl3[:,4]
    v3lapl2tau[:,6]
    v3lapltau2[:,6]
    v3tau3[:,4] = (u_u_u, u_u_d, u_d_d, d_d_d)

see also libxc_itrf.c

pyscf.dft.libxc.eval_xc1(xc_code, rho, spin=0, deriv=1, omega=None)[source]#

Similar to eval_xc. Returns an array with the order of derivatives following xcfun convention.

pyscf.dft.libxc.eval_xc_eff(xc_code, rho, deriv=1, omega=None)[source]#

Returns the derivative tensor against the density parameters

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

or spin-polarized 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 or (spin-up, spin-down) densities (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

pyscf.dft.libxc.hybrid_coeff(xc_code, spin=0)[source]#

Support recursively defining hybrid functional

pyscf.dft.libxc.is_gga(xc_code)[source]#
pyscf.dft.libxc.is_hybrid_xc(xc_code)[source]#
pyscf.dft.libxc.is_lda(xc_code)[source]#
pyscf.dft.libxc.is_meta_gga(xc_code)[source]#
pyscf.dft.libxc.is_nlc(xc_code)[source]#
pyscf.dft.libxc.libxc_reference()[source]#

Returns the reference to libxc

pyscf.dft.libxc.libxc_reference_doi()[source]#

Returns the reference to libxc

pyscf.dft.libxc.libxc_version()[source]#

Returns the version of libxc

pyscf.dft.libxc.max_deriv_order(xc_code)[source]#
pyscf.dft.libxc.needs_laplacian(xc_code)[source]#
pyscf.dft.libxc.nlc_coeff(xc_code)[source]#

Get NLC coefficients

pyscf.dft.libxc.parse_xc(description)[source]#

Rules to input functional description:

  • The given functional description must be a one-line string.

  • The functional description is case-insensitive.

  • The functional description string has two parts, separated by “,”. The first part describes the exchange functional, the second is the correlation functional.

    • If “,” was not in string, the entire string is considered as a compound XC functional (including both X and C functionals, such as b3lyp).

    • To input only X functional (without C functional), leave the second part blank. E.g. description=’slater,’ means pure LDA functional.

    • To neglect X functional (just apply C functional), leave the first part blank. E.g. description=’,vwn’ means pure VWN functional.

    • If compound XC functional is specified, no matter whether it is in the X part (the string in front of comma) or the C part (the string behind comma), both X and C functionals of the compound XC functional will be used.

  • The functional name can be placed in arbitrary order. Two name needs to be separated by operators “+” or “-”. Blank spaces are ignored. NOTE the parser only reads operators “+” “-” “*”. / is not in support.

  • A functional name can have at most one factor. If the factor is not given, it is set to 1. Compound functional can be scaled as a unit. For example ‘0.5*b3lyp’ is equivalent to ‘HF*0.1 + .04*LDA + .36*B88, .405*LYP + .095*VWN’

  • String “HF” stands for exact exchange (HF K matrix). Putting “HF” in correlation functional part is the same to putting “HF” in exchange part.

  • String “RSH” means range-separated operator. Its format is RSH(omega, alpha, beta). Another way to input RSH is to use keywords SR_HF and LR_HF: “SR_HF(0.1) * alpha_plus_beta” and “LR_HF(0.1) * alpha” where the number in parenthesis is the value of omega.

  • Be careful with the libxc convention on GGA functional, in which the LDA contribution has been included.

Args:
descriptionstr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” was appeared in the string, it stands for the exact exchange.

Returns:

decoded XC description, with the data structure (hybrid, alpha, omega), ((libxc-Id, fac), (libxc-Id, fac), …)

pyscf.dft.libxc.parse_xc_name(xc_name='LDA,VWN')[source]#

Convert the XC functional name to libxc library internal ID.

pyscf.dft.libxc.print_XC_CODES()[source]#

Dump the built-in libxc XC_CODES along with their references in a readable format.

pyscf.dft.libxc.rsh_coeff(xc_code)[source]#

Range-separated parameter and HF exchange components: omega, alpha, beta

Exc_RSH = c_LR * LR_HFX + c_SR * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec

= alpha * HFX + beta * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec = alpha * LR_HFX + hyb * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec

SR_HFX = < pi | (1-erf(-omega r_{12}))/r_{12} | iq > LR_HFX = < pi | erf(-omega r_{12})/r_{12} | iq > alpha = c_LR beta = c_SR - c_LR = hyb - alpha

pyscf.dft.libxc.test_deriv_order(xc_code, deriv, raise_error=False)[source]#
pyscf.dft.libxc.xc_reference(xc_code)[source]#

Returns the reference to the individual XC functional

pyscf.dft.libxc.xc_type(xc_code)[source]#

pyscf.dft.numint module#

Numerical integration functions for RKS and UKS with real AO basis

class pyscf.dft.numint.LibXCMixin[source]#

Bases: object

eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=None)[source]#

Interface to call libxc library to evaluate XC functional, potential and functional derivatives.

  • The given functional xc_code must be a one-line string.

  • The functional xc_code is case-insensitive.

  • The functional xc_code string has two parts, separated by “,”. The first part describes the exchange functional, the second part sets the correlation functional.

    • If “,” not appeared in string, the entire string is treated as the name of a compound functional (containing both the exchange and the correlation functional) which was declared in the functional aliases list. The full list of functional aliases can be obtained by calling the function pyscf.dft.xcfun.XC_ALIAS.keys() .

      If the string was not found in the aliased functional list, it is treated as X functional.

    • To input only X functional (without C functional), leave the second part blank. E.g. description=’slater,’ means a functional with LDA contribution only.

    • To neglect the contribution of X functional (just apply C functional), leave blank in the first part, e.g. description=’,vwn’ means a functional with VWN only.

    • If compound XC functional is specified, no matter whether it is in the X part (the string in front of comma) or the C part (the string behind comma), both X and C functionals of the compound XC functional will be used.

  • The functional name can be placed in arbitrary order. Two names need to be separated by operators “+” or “-”. Blank spaces are ignored. NOTE the parser only reads operators “+” “-” “*”. / is not supported.

  • A functional name can have at most one factor. If the factor is not given, it is set to 1. Compound functional can be scaled as a unit. For example ‘0.5*b3lyp’ is equivalent to ‘HF*0.1 + .04*LDA + .36*B88, .405*LYP + .095*VWN’

  • String “HF” stands for exact exchange (HF K matrix). “HF” can be put in the correlation functional part (after comma). Putting “HF” in the correlation part is the same to putting “HF” in the exchange part.

  • String “RSH” means range-separated operator. Its format is RSH(omega, alpha, beta). Another way to input RSH is to use keywords SR_HF and LR_HF: “SR_HF(0.1) * alpha_plus_beta” and “LR_HF(0.1) * alpha” where the number in parenthesis is the value of omega.

  • Be careful with the libxc convention of GGA functional, in which the LDA contribution is included.

Args:
xc_codestr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” (exact exchange) is appeared in the string, the HF part will be skipped. If an empty string “” is given, the returns exc, vxc,… will be vectors of zeros.

rhondarray

Shape of ((,N)) for electron density (and derivatives) if spin = 0; Shape of ((,N),(,N)) for alpha/beta electron density (and derivatives) if spin > 0; where N is number of grids. rho (,N) are ordered as (den,grad_x,grad_y,grad_z,laplacian,tau) where grad_x = d/dx den, laplacian = nabla^2 den, tau = 1/2(nabla f)^2 In spin unrestricted case, rho is ((den_u,grad_xu,grad_yu,grad_zu,laplacian_u,tau_u)

(den_d,grad_xd,grad_yd,grad_zd,laplacian_d,tau_d))

Kwargs:
spinint

spin polarized if spin > 0

relativityint

No effects.

verboseint or object of Logger

No effects.

Returns:

ex, vxc, fxc, kxc

where

  • vxc = (vrho, vsigma, vlapl, vtau) for restricted case

  • vxc for unrestricted case | vrho[:,2] = (u, d) | vsigma[:,3] = (uu, ud, dd) | vlapl[:,2] = (u, d) | vtau[:,2] = (u, d)

  • fxc for restricted case: (v2rho2, v2rhosigma, v2sigma2, v2lapl2, vtau2, v2rholapl, v2rhotau, v2lapltau, v2sigmalapl, v2sigmatau)

  • fxc for unrestricted case: | v2rho2[:,3] = (u_u, u_d, d_d) | v2rhosigma[:,6] = (u_uu, u_ud, u_dd, d_uu, d_ud, d_dd) | v2sigma2[:,6] = (uu_uu, uu_ud, uu_dd, ud_ud, ud_dd, dd_dd) | v2lapl2[:,3] | v2tau2[:,3] = (u_u, u_d, d_d) | v2rholapl[:,4] | v2rhotau[:,4] = (u_u, u_d, d_u, d_d) | v2lapltau[:,4] | v2sigmalapl[:,6] | v2sigmatau[:,6] = (uu_u, uu_d, ud_u, ud_d, dd_u, dd_d)

  • kxc for restricted case: (v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3,

    v3rho2lapl, v3rho2tau, v3rhosigmalapl, v3rhosigmatau, v3rholapl2, v3rholapltau, v3rhotau2, v3sigma2lapl, v3sigma2tau, v3sigmalapl2, v3sigmalapltau, v3sigmatau2, v3lapl3, v3lapl2tau, v3lapltau2, v3tau3)

  • kxc for unrestricted case: | v3rho3[:,4] = (u_u_u, u_u_d, u_d_d, d_d_d) | v3rho2sigma[:,9] = (u_u_uu, u_u_ud, u_u_dd, u_d_uu, u_d_ud, u_d_dd, d_d_uu, d_d_ud, d_d_dd) | v3rhosigma2[:,12] = (u_uu_uu, u_uu_ud, u_uu_dd, u_ud_ud, u_ud_dd, u_dd_dd, d_uu_uu, d_uu_ud, d_uu_dd, d_ud_ud, d_ud_dd, d_dd_dd) | v3sigma3[:,10] = (uu_uu_uu, uu_uu_ud, uu_uu_dd, uu_ud_ud, uu_ud_dd, uu_dd_dd, ud_ud_ud, ud_ud_dd, ud_dd_dd, dd_dd_dd) | v3rho2lapl[:,6] | v3rho2tau[:,6] = (u_u_u, u_u_d, u_d_u, u_d_d, d_d_u, d_d_d) | v3rhosigmalapl[:,12] | v3rhosigmatau[:,12] = (u_uu_u, u_uu_d, u_ud_u, u_ud_d, u_dd_u, u_dd_d,

    d_uu_u, d_uu_d, d_ud_u, d_ud_d, d_dd_u, d_dd_d)

    v3rholapl2[:,6]
    v3rholapltau[:,8]
    v3rhotau2[:,6] = (u_u_u, u_u_d, u_d_d, d_u_u, d_u_d, d_d_d)
    v3sigma2lapl[:,12]
    v3sigma2tau[:,12] = (uu_uu_u, uu_uu_d, uu_ud_u, uu_ud_d, uu_dd_u, uu_dd_d, ud_ud_u, ud_ud_d, ud_dd_u, ud_dd_d, dd_dd_u, dd_dd_d)
    v3sigmalapl2[:,9]
    v3sigmalapltau[:,12]
    v3sigmatau2[:,9] = (uu_u_u, uu_u_d, uu_d_d, ud_u_u, ud_u_d, ud_d_d, dd_u_u, dd_u_d, dd_d_d)
    v3lapl3[:,4]
    v3lapl2tau[:,6]
    v3lapltau2[:,6]
    v3tau3[:,4] = (u_u_u, u_u_d, u_d_d, d_d_d)

see also libxc_itrf.c

eval_xc1(xc_code, rho, spin=0, deriv=1, omega=None)[source]#
eval_xc_eff(xc_code, rho, deriv=1, omega=None, xctype=None, verbose=None)[source]#

Returns the derivative tensor against the density parameters

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

or spin-polarized 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 or (spin-up, spin-down) densities (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

hybrid_coeff(xc_code, spin=0)[source]#
libxc = <module 'pyscf.dft.libxc' from '/home/runner/.local/lib/python3.10/site-packages/pyscf/dft/libxc.py'>#
nlc_coeff(xc_code)[source]#
omega = None#
rsh_and_hybrid_coeff(xc_code, spin=0)[source]#

Range-separated parameter and HF exchange components: omega, alpha, beta

Exc_RSH = c_SR * SR_HFX + c_LR * LR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec

= alpha * HFX + beta * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec = alpha * LR_HFX + hyb * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec

SR_HFX = < pi | (1-erf(-omega r_{12}))/r_{12} | iq > LR_HFX = < pi | erf(-omega r_{12})/r_{12} | iq > alpha = c_LR beta = c_SR - c_LR

rsh_coeff(xc_code)[source]#
class pyscf.dft.numint.NumInt[source]#

Bases: StreamObject, LibXCMixin

Numerical integration methods for non-relativistic RKS and UKS

block_loop(mol, grids, nao=None, deriv=0, max_memory=2000, non0tab=None, blksize=None, buf=None)[source]#

Define this macro to loop over grids by blocks.

cache_xc_kernel(mol, grids, xc_code, mo_coeff, mo_occ, spin=0, max_memory=2000)#

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

cache_xc_kernel1(mol, grids, xc_code, dm, spin=0, max_memory=2000)#

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc. Note dm the zeroth order density matrix must be a hermitian matrix.

cutoff = 1e-13#
static eval_ao(mol, coords, deriv=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)#

Evaluate AO function value on the given grids.

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of the grids.

Kwargs:
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.

relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

non0tab2D bool array

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

cutofffloat

AO values smaller than cutoff will be set to zero. The default cutoff threshold is ~1e-22 (defined in gto/grid_ao_drv.h)

outndarray

If provided, results are written into this array.

verboseint or object of Logger

No effects.

Returns:

2D array of shape (N,nao) for AO values if deriv = 0. Or 3D array of shape (:,N,nao) for AO values and AO derivatives if deriv > 0. In the 3D array, the first (N,nao) elements are the AO values, followed by (3,N,nao) for x,y,z components; Then 2nd derivatives (6,N,nao) for xx, xy, xz, yy, yz, zz; Then 3rd derivatives (10,N,nao) for xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz; …

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)
>>> print(ao_value.shape)
(100, 24)
>>> ao_value = eval_ao(mol, coords, deriv=1, shls_slice=(1,4))
>>> print(ao_value.shape)
(4, 100, 7)
>>> ao_value = eval_ao(mol, coords, deriv=2, shls_slice=(1,4))
>>> print(ao_value.shape)
(10, 100, 7)
static eval_rho(mol, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)#

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(mol=None, ao=None, dm=None, screen_index=None, xctype='LDA', hermi=0, with_lapl=True, cutoff=None, ao_cutoff=1e-15, pair_mask=None, verbose=None)#

Calculate the electron density for LDA and the density derivatives for GGA and MGGA with sparsity information.

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:
screen_index2D uint8 array

How likely the AO values on grids are negligible. This array can be obtained by calling gen_grid.make_screen_index()

xctypestr

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

hermibool

dm is hermitian or not

cutofffloat

cutoff for density value

ao_cutofffloat

cutoff for AO value. Needs to be the same to the cutoff when generating screen_index

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

static eval_rho2(mol, ao, mo_coeff, mo_occ, non0tab=None, xctype='LDA', with_lapl=True, verbose=None)#

Calculate the electron density for LDA functional, and the density derivatives for GGA functional. This function has the same functionality as eval_rho() except that the density are evaluated based on orbital coefficients and orbital occupancy. It is more efficient than eval_rho() in most scenario.

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.

with_lapl: bool

Whether to compute laplacian. It affects the shape of returns.

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

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

Contract XC kernel matrix with given density matrices

… math:

a_{pq} = f_{pq,rs} * x_{rs}
get_rho(mol, dm, grids, max_memory=2000)#

Density in real space

get_vxc(mol, grids, xc_code, dms, spin=0, relativity=0, hermi=0, max_memory=2000, verbose=None)#

Evaluate RKS/UKS XC functional and potential matrix on given meshgrids for a set of density matrices. See nr_rks() and nr_uks() for more details.

Args:

mol : an instance of Mole

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 or 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).

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:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((2,nao,nao))
>>> nelec, exc, vxc = dft.numint.nr_vxc(mol, grids, 'lda,vwn', dm, spin=1)
static make_mask(mol, coords, relativity=0, shls_slice=None, cutoff=1e-15, verbose=None)#

Mask to indicate whether a shell is ignorable on grids. See also the function gto.eval_gto.make_screen_index

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of grids.

Kwargs:
relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

verboseint or object of Logger

No effects.

Returns:

2D mask array of shape (N,nbas), where N is the number of grids, nbas is the number of shells.

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

Contract XC kernel matrix with given density matrices

… math:

a_{pq} = f_{pq,rs} * x_{rs}
nr_nlc_vxc(mol, grids, xc_code, dm, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate NLC functional and potential matrix on given grids

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

nr_rks(mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate RKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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 or a list of 2D arrays

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.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_rks(mol, grids, 'lda,vwn', dm)
nr_rks_fxc(mol, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)#

Contract RKS XC (singlet hessian) kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm02D array

Zeroth order density matrix

dms2D array a list of 2D arrays

First order density matrix or density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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_rks_fxc_st(mol, grids, xc_code, dm0, dms_alpha, relativity=0, singlet=True, rho0=None, vxc=None, fxc=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_sap(mol, grids, max_memory=2000, verbose=None)#

Calculate superposition of atomic potentials matrix on given meshgrids.

Args:

ni : an instance of NumInt

mol : an instance of Mole

gridsan instance of Grids

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

Kwargs:
max_memoryint or float

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

Returns:

vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

Examples: >>> import numpy >>> from pyscf import gto, dft >>> mol = gto.M(atom=’H 0 0 0; H 0 0 1.1’) >>> grids = dft.gen_grid.Grids(mol) >>> ni = dft.numint.NumInt() >>> vsap = ni.nr_sap(mol, grids)

nr_sap_vxc(mol, grids, max_memory=2000, verbose=None)#

Calculate superposition of atomic potentials matrix on given meshgrids.

Args:

ni : an instance of NumInt

mol : an instance of Mole

gridsan instance of Grids

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

Kwargs:
max_memoryint or float

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

Returns:

vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

Examples: >>> import numpy >>> from pyscf import gto, dft >>> mol = gto.M(atom=’H 0 0 0; H 0 0 1.1’) >>> grids = dft.gen_grid.Grids(mol) >>> ni = dft.numint.NumInt() >>> vsap = ni.nr_sap(mol, grids)

nr_uks(mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate UKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

mol : an instance of Mole

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.

dmsa list of 2D arrays

A list of density matrices, stored as (alpha,alpha,…,beta,beta,…)

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 (alpha,beta) electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix for (alpha,beta) spin.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((2,nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_uks(mol, grids, 'lda,vwn', dm)
nr_uks_fxc(mol, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)#

Contract UKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm0(2, N, N) array

Zeroth order density matrices

dms2D array a list of 2D arrays

First order density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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(mol, grids, xc_code, dms, spin=0, relativity=0, hermi=0, max_memory=2000, verbose=None)[source]#

Evaluate RKS/UKS XC functional and potential matrix on given meshgrids for a set of density matrices. See nr_rks() and nr_uks() for more details.

Args:

mol : an instance of Mole

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 or 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).

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:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((2,nao,nao))
>>> nelec, exc, vxc = dft.numint.nr_vxc(mol, grids, 'lda,vwn', dm, spin=1)
to_gpu()[source]#
pyscf.dft.numint.cache_xc_kernel(ni, mol, grids, xc_code, mo_coeff, mo_occ, spin=0, max_memory=2000)[source]#

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

pyscf.dft.numint.cache_xc_kernel1(ni, mol, grids, xc_code, dm, spin=0, max_memory=2000)[source]#

Compute the 0th order density, Vxc and fxc. They can be used in TDDFT, DFT hessian module etc. Note dm the zeroth order density matrix must be a hermitian matrix.

pyscf.dft.numint.eval_ao(mol, coords, deriv=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)[source]#

Evaluate AO function value on the given grids.

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of the grids.

Kwargs:
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.

relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

non0tab2D bool array

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

cutofffloat

AO values smaller than cutoff will be set to zero. The default cutoff threshold is ~1e-22 (defined in gto/grid_ao_drv.h)

outndarray

If provided, results are written into this array.

verboseint or object of Logger

No effects.

Returns:

2D array of shape (N,nao) for AO values if deriv = 0. Or 3D array of shape (:,N,nao) for AO values and AO derivatives if deriv > 0. In the 3D array, the first (N,nao) elements are the AO values, followed by (3,N,nao) for x,y,z components; Then 2nd derivatives (6,N,nao) for xx, xy, xz, yy, yz, zz; Then 3rd derivatives (10,N,nao) for xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz; …

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)
>>> print(ao_value.shape)
(100, 24)
>>> ao_value = eval_ao(mol, coords, deriv=1, shls_slice=(1,4))
>>> print(ao_value.shape)
(4, 100, 7)
>>> ao_value = eval_ao(mol, coords, deriv=2, shls_slice=(1,4))
>>> print(ao_value.shape)
(10, 100, 7)
pyscf.dft.numint.eval_mat(mol, ao, weight, rho, vxc, non0tab=None, xctype='LDA', spin=0, verbose=None)[source]#

Calculate XC potential matrix.

Args:

mol : an instance of Mole

ao([4/10,] ngrids, nao) ndarray

2D array of shape (N,nao) for LDA, 3D array of shape (4,N,nao) for GGA or (10,N,nao) for 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 real space gradients. ao[4:10] are second derivatives of ao values if applicable.

weight1D array

Integral weights on grids.

rho([4/6,] ngrids) ndarray

Shape of ((,N)) for electron density (and derivatives) if spin = 0; Shape of ((,N),(,N)) for alpha/beta electron density (and derivatives) if spin > 0; where N is number of grids. rho (,N) are ordered as (den,grad_x,grad_y,grad_z,laplacian,tau) where grad_x = d/dx den, laplacian = nabla^2 den, tau = 1/2(nabla f)^2 In spin unrestricted case, rho is ((den_u,grad_xu,grad_yu,grad_zu,laplacian_u,tau_u)

(den_d,grad_xd,grad_yd,grad_zd,laplacian_d,tau_d))

vxc([4,] ngrids) ndarray

XC potential value on each grid = (vrho, vsigma, vlapl, vtau) vsigma is GGA potential value on each grid. If the kwarg spin != 0, a list [vsigma_uu,vsigma_ud] is required.

Kwargs:
xctypestr

LDA/GGA/mGGA. It affects the shape of ao and rho

non0tab2D bool array

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

spinint

If not 0, the returned matrix is the Vxc matrix of alpha-spin. It is computed with the spin non-degenerated UKS formula.

Returns:

XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

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

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')
pyscf.dft.numint.eval_rho1(mol, ao, dm, screen_index=None, xctype='LDA', hermi=0, with_lapl=True, cutoff=None, ao_cutoff=1e-15, pair_mask=None, verbose=None)[source]#

Calculate the electron density for LDA and the density derivatives for GGA and MGGA with sparsity information.

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:
screen_index2D uint8 array

How likely the AO values on grids are negligible. This array can be obtained by calling gen_grid.make_screen_index()

xctypestr

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

hermibool

dm is hermitian or not

cutofffloat

cutoff for density value

ao_cutofffloat

cutoff for AO value. Needs to be the same to the cutoff when generating screen_index

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

pyscf.dft.numint.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. This function has the same functionality as eval_rho() except that the density are evaluated based on orbital coefficients and orbital occupancy. It is more efficient than eval_rho() in most scenario.

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.

with_lapl: bool

Whether to compute laplacian. It affects the shape of returns.

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

pyscf.dft.numint.get_rho(ni, mol, dm, grids, max_memory=2000)[source]#

Density in real space

pyscf.dft.numint.nr_fxc(mol, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)[source]#

Contract XC kernel matrix with given density matrices

… math:

a_{pq} = f_{pq,rs} * x_{rs}
pyscf.dft.numint.nr_nlc_vxc(ni, mol, grids, xc_code, dm, relativity=0, hermi=1, max_memory=2000, verbose=None)[source]#

Calculate NLC functional and potential matrix on given grids

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.dft.numint.nr_rks(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)[source]#

Calculate RKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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 or a list of 2D arrays

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.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_rks(mol, grids, 'lda,vwn', dm)
pyscf.dft.numint.nr_rks_fxc(ni, mol, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)[source]#

Contract RKS XC (singlet hessian) kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm02D array

Zeroth order density matrix

dms2D array a list of 2D arrays

First order density matrix or density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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.dft.numint.nr_rks_fxc_st(ni, mol, grids, xc_code, dm0, dms_alpha, relativity=0, singlet=True, rho0=None, vxc=None, fxc=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.dft.numint.nr_rks_vxc(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate RKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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 or a list of 2D arrays

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.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_rks(mol, grids, 'lda,vwn', dm)
pyscf.dft.numint.nr_sap_vxc(ni, mol, grids, max_memory=2000, verbose=None)[source]#

Calculate superposition of atomic potentials matrix on given meshgrids.

Args:

ni : an instance of NumInt

mol : an instance of Mole

gridsan instance of Grids

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

Kwargs:
max_memoryint or float

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

Returns:

vmat is the XC potential matrix in 2D array of shape (nao,nao) where nao is the number of AO functions.

Examples: >>> import numpy >>> from pyscf import gto, dft >>> mol = gto.M(atom=’H 0 0 0; H 0 0 1.1’) >>> grids = dft.gen_grid.Grids(mol) >>> ni = dft.numint.NumInt() >>> vsap = ni.nr_sap(mol, grids)

pyscf.dft.numint.nr_uks(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)[source]#

Calculate UKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

mol : an instance of Mole

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.

dmsa list of 2D arrays

A list of density matrices, stored as (alpha,alpha,…,beta,beta,…)

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 (alpha,beta) electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix for (alpha,beta) spin.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((2,nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_uks(mol, grids, 'lda,vwn', dm)
pyscf.dft.numint.nr_uks_fxc(ni, mol, grids, xc_code, dm0, dms, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)[source]#

Contract UKS XC kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm0(2, N, N) array

Zeroth order density matrices

dms2D array a list of 2D arrays

First order density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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.dft.numint.nr_uks_vxc(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate UKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

mol : an instance of Mole

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.

dmsa list of 2D arrays

A list of density matrices, stored as (alpha,alpha,…,beta,beta,…)

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 (alpha,beta) electrons generated by numerical integration. excsum is the XC functional value. vmat is the XC potential matrix for (alpha,beta) spin.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((2,nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_uks(mol, grids, 'lda,vwn', dm)
pyscf.dft.numint.nr_vxc(mol, grids, xc_code, dms, spin=0, relativity=0, hermi=0, max_memory=2000, verbose=None)[source]#

Evaluate RKS/UKS XC functional and potential matrix on given meshgrids for a set of density matrices. See nr_rks() and nr_uks() for more details.

Args:

mol : an instance of Mole

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 or 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).

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:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((2,nao,nao))
>>> nelec, exc, vxc = dft.numint.nr_vxc(mol, grids, 'lda,vwn', dm, spin=1)

pyscf.dft.numint2c module#

Numerical integration functions for (2-component) GKS with real AO basis

class pyscf.dft.numint2c.NumInt2C[source]#

Bases: StreamObject, LibXCMixin

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

block_loop(mol, grids, nao=None, deriv=0, max_memory=2000, non0tab=None, blksize=None, buf=None)#

Define this macro to loop over grids by blocks.

cache_xc_kernel(mol, grids, xc_code, mo_coeff, mo_occ, spin=0, 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(mol, grids, xc_code, dm, spin=0, 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(mol, coords, deriv=0, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)#

Evaluate AO function value on the given grids.

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of the grids.

Kwargs:
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.

relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

non0tab2D bool array

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

cutofffloat

AO values smaller than cutoff will be set to zero. The default cutoff threshold is ~1e-22 (defined in gto/grid_ao_drv.h)

outndarray

If provided, results are written into this array.

verboseint or object of Logger

No effects.

Returns:

2D array of shape (N,nao) for AO values if deriv = 0. Or 3D array of shape (:,N,nao) for AO values and AO derivatives if deriv > 0. In the 3D array, the first (N,nao) elements are the AO values, followed by (3,N,nao) for x,y,z components; Then 2nd derivatives (6,N,nao) for xx, xy, xz, yy, yz, zz; Then 3rd derivatives (10,N,nao) for xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz; …

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)
>>> print(ao_value.shape)
(100, 24)
>>> ao_value = eval_ao(mol, coords, deriv=1, shls_slice=(1,4))
>>> print(ao_value.shape)
(4, 100, 7)
>>> ao_value = eval_ao(mol, coords, deriv=2, shls_slice=(1,4))
>>> print(ao_value.shape)
(10, 100, 7)
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(mol, 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(mol, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)#

Contract RKS XC (singlet hessian) kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm02D array

Zeroth order density matrix

dms2D array a list of 2D arrays

First order density matrix or density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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:

get_rho(mol, dm, grids, max_memory=2000)[source]#

Density in real space

get_vxc(mol, grids, xc_code, dms, spin=0, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate RKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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 or a list of 2D arrays

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.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_rks(mol, grids, 'lda,vwn', dm)
static make_mask(mol, coords, relativity=0, shls_slice=None, cutoff=1e-15, verbose=None)#

Mask to indicate whether a shell is ignorable on grids. See also the function gto.eval_gto.make_screen_index

Args:

mol : an instance of Mole

coords2D array, shape (N,3)

The coordinates of grids.

Kwargs:
relativitybool

No effects.

shls_slice2-element list

(shl_start, shl_end). If given, only part of AOs (shl_start <= shell_id < shl_end) are evaluated. By default, all shells defined in mol will be evaluated.

verboseint or object of Logger

No effects.

Returns:

2D mask array of shape (N,nbas), where N is the number of grids, nbas is the number of shells.

mcfun_eval_xc_adapter(xc_code)#

Wrapper to generate the eval_xc function required by mcfun

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

Contract RKS XC (singlet hessian) kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm02D array

Zeroth order density matrix

dms2D array a list of 2D arrays

First order density matrix or density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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_gks_fxc(mol, grids, xc_code, dm0, dms, spin=0, relativity=0, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)#

Contract RKS XC (singlet hessian) kernel matrix with given density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

dm02D array

Zeroth order density matrix

dms2D array a list of 2D arrays

First order density matrix or density matrices

Kwargs:
hermiint

First order density matrix symmetric or not. It also indicates whether the matrices in return are 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_gks_vxc(mol, grids, xc_code, dms, spin=0, relativity=0, hermi=1, max_memory=2000, verbose=None)#

Calculate RKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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 or a list of 2D arrays

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.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_rks(mol, grids, 'lda,vwn', dm)
nr_nlc_vxc(mol, grids, xc_code, dm, spin=0, relativity=0, hermi=1, max_memory=2000, verbose=None)[source]#

Calculate NLC functional and potential matrix on given grids

Args:

ni : an instance of NumInt

mol : an instance of Mole

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.

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

Calculate RKS XC functional and potential matrix on given meshgrids for a set of density matrices

Args:

ni : an instance of NumInt

mol : an instance of Mole

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 or a list of 2D arrays

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.

Examples:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1')
>>> grids = dft.gen_grid.Grids(mol)
>>> grids.coords = numpy.random.random((100,3))  # 100 random points
>>> grids.weights = numpy.random.random(100)
>>> nao = mol.nao_nr()
>>> dm = numpy.random.random((nao,nao))
>>> ni = dft.numint.NumInt()
>>> nelec, exc, vxc = ni.nr_rks(mol, grids, 'lda,vwn', dm)
spin_samples = 770#
pyscf.dft.numint2c.eval_rho(mol, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=True, verbose=None)[source]#

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')
pyscf.dft.numint2c.mcfun_eval_xc_adapter(ni, xc_code)[source]#

Wrapper to generate the eval_xc function required by mcfun

pyscf.dft.r_numint module#

Numerical integration functions for 4-component or 2-component relativistic methods with j-adapted AO basis

class pyscf.dft.r_numint.RNumInt[source]#

Bases: StreamObject, LibXCMixin

NumInt for j-adapted (spinor) basis

block_loop(mol, grids, nao, deriv=0, max_memory=2000, non0tab=None, blksize=None, buf=None, with_s=False)[source]#

Define this macro to loop over grids by blocks.

cache_xc_kernel(mol, grids, xc_code, mo_coeff, mo_occ, spin=1, max_memory=2000)#

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

cache_xc_kernel1(mol, grids, xc_code, dm, spin=1, max_memory=2000)#
collinear = 'col'#
collinear_samples = 200#
collinear_thrd = 0.99#
static eval_ao(mol, coords, deriv=0, with_s=True, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)#

Evaluates the value of 2-component or 4-component j-adapted basis on grids.

static eval_rho(mol, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=False, verbose=None)#
eval_rho1(mol, 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]#
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(mol, grids, xc_code, dm0, dms, spin=0, relativity=1, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)#
get_rho(mol, dm, grids, max_memory=2000)#
get_vxc(mol, grids, xc_code, dms, spin=0, relativity=1, hermi=1, max_memory=2000, verbose=None)#
mcfun_eval_xc_adapter(xc_code)#

Wrapper to generate the eval_xc function required by mcfun

r_fxc(mol, grids, xc_code, dm0, dms, spin=0, relativity=1, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)#
r_vxc(mol, grids, xc_code, dms, spin=0, relativity=1, hermi=1, max_memory=2000, verbose=None)#
spin_samples = 770#
pyscf.dft.r_numint.cache_xc_kernel(ni, mol, grids, xc_code, mo_coeff, mo_occ, spin=1, max_memory=2000)[source]#

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

pyscf.dft.r_numint.cache_xc_kernel1(ni, mol, grids, xc_code, dm, spin=1, max_memory=2000)[source]#
pyscf.dft.r_numint.eval_ao(mol, coords, deriv=0, with_s=True, shls_slice=None, non0tab=None, cutoff=None, out=None, verbose=None)[source]#

Evaluates the value of 2-component or 4-component j-adapted basis on grids.

pyscf.dft.r_numint.eval_rho(mol, ao, dm, non0tab=None, xctype='LDA', hermi=0, with_lapl=False, verbose=None)[source]#
pyscf.dft.r_numint.get_rho(ni, mol, dm, grids, max_memory=2000)[source]#
pyscf.dft.r_numint.r_fxc(ni, mol, grids, xc_code, dm0, dms, spin=0, relativity=1, hermi=0, rho0=None, vxc=None, fxc=None, max_memory=2000, verbose=None)[source]#
pyscf.dft.r_numint.r_vxc(ni, mol, grids, xc_code, dms, spin=0, relativity=1, hermi=1, max_memory=2000, verbose=None)[source]#

pyscf.dft.radi module#

radii grids

pyscf.dft.radi.becke(n, charge, *args, **kwargs)[source]#

Becke, JCP 88, 2547 (1988); DOI:10.1063/1.454033

pyscf.dft.radi.becke_atomic_radii_adjust(mol, atomic_radii)[source]#

Becke atomic radii adjust function

pyscf.dft.radi.delley(n, *args, **kwargs)[source]#
  1. Delley radial grids. Ref. JCP 104, 9848 (1996); DOI:10.1063/1.471749. log2 algorithm

pyscf.dft.radi.gauss_chebyshev(n, *args, **kwargs)[source]#

Gauss-Chebyshev [JCP 108, 3226 (1998); DOI:10.1063/1.475719) radial grids

pyscf.dft.radi.gauss_legendre(n, *args, **kwargs)#
  1. Delley radial grids. Ref. JCP 104, 9848 (1996); DOI:10.1063/1.471749. log2 algorithm

pyscf.dft.radi.mura_knowles(n, charge=None, *args, **kwargs)[source]#

Mura-Knowles [JCP 104, 9848 (1996); DOI:10.1063/1.471749] log3 quadrature radial grids

pyscf.dft.radi.murray(n, *args, **kwargs)[source]#
pyscf.dft.radi.treutler(n, chg, *args, **kwargs)#

Treutler-Ahlrichs [JCP 102, 346 (1995); DOI:10.1063/1.469408] (M4) radial grids

pyscf.dft.radi.treutler_ahlrichs(n, chg, *args, **kwargs)[source]#

Treutler-Ahlrichs [JCP 102, 346 (1995); DOI:10.1063/1.469408] (M4) radial grids

pyscf.dft.radi.treutler_atomic_radii_adjust(mol, atomic_radii)[source]#

Treutler atomic radii adjust function: [JCP 102, 346 (1995); DOI:10.1063/1.469408]

pyscf.dft.rks module#

Non-relativistic restricted Kohn-Sham

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

Bases: object

Attributes for Kohn-Sham DFT:
xcstr

‘X_name,C_name’ for the XC functional. Default is ‘lda,vwn’

nlcstr

‘NLC_name’ for the NLC functional. Default is ‘’ (i.e., None)

omegafloat

Omega of the range-separated Coulomb operator e^{-omega r_{12}^2} / r_{12}

gridsGrids object

grids.level (0 - 9) big number for large mesh grids. Default is 3

radii_adjust
radi.treutler_atomic_radii_adjust (default)
radi.becke_atomic_radii_adjust
None : to switch off atomic radii adjustment
grids.atomic_radii
radi.BRAGG_RADII (default)
radi.COVALENT_RADII
None : to switch off atomic radii adjustment
grids.radi_method scheme for radial grids
radi.treutler (default)
radi.delley
radi.mura_knowles
radi.gauss_chebyshev
grids.becke_scheme weight partition function
gen_grid.original_becke (default)
gen_grid.stratmann
grids.prune scheme to reduce number of grids
gen_grid.nwchem_prune (default)
gen_grid.sg1_prune
gen_grid.treutler_prune
None : to switch off grids pruning

grids.symmetry True/False to symmetrize mesh grids (TODO)

grids.atom_grid Set (radial, angular) grids for particular atoms. Eg, grids.atom_grid = {‘H’: (20,110)} will generate 20 radial grids and 110 angular grids for H atom.

small_rho_cutofffloat

Drop grids if their contribution to total electrons smaller than this cutoff value. Default is 1e-7.

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz', verbose=0)
>>> mf = dft.RKS(mol)
>>> mf.xc = 'b3lyp'
>>> mf.kernel()
-76.415443079840458
check_sanity()[source]#
define_xc_(description, xctype='LDA', hyb=0, rsh=(0, 0, 0))#
do_nlc()[source]#

Check if the object needs to do nlc calculations

if self.nlc == False (or 0), nlc is disabled regardless the value of self.xc if self.nlc == ‘vv10’, do nlc (vv10) regardless the value of self.xc if self.nlc == ‘’, determined by self.xc, certain xc allows the nlc part

dump_flags(verbose=None)[source]#
initialize_grids(mol=None, dm=None)[source]#

Initialize self.grids the first time call get_veff

property omega#
reset(mol=None)[source]#
to_ghf()[source]#

Convert the input mean-field object to a GHF 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_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_gpu()[source]#
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_rhf()[source]#

Convert the input mean-field object to a RHF/ROHF 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_uhf()[source]#

Convert the input mean-field object to a UHF 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.dft.rks.RKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, RHF

Restricted Kohn-Sham SCF base class. non-relativistic RHF.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose

max_memoryfloat or int

Allowed memory in MB. Default equals to Mole.max_memory

chkfilestr

checkpoint file to save MOs, orbital energies etc. Writing to chkfile can be disabled if this attribute is set to None or False.

conv_tolfloat

converge threshold. Default is 1e-9

conv_tol_gradfloat

gradients converge threshold. Default is sqrt(conv_tol)

max_cycleint

max number of iterations. If max_cycle <= 0, SCF iteration will be skipped and the kernel function will compute only the total energy based on the initial guess. Default value is 50.

init_guessstr

initial guess method. It can be one of ‘minao’, ‘atom’, ‘huckel’, ‘hcore’, ‘1e’, ‘sap’, ‘chkfile’. Default is ‘minao’

sap_basisstr or dict

basis for SAP initial guess, either filename or path as str or internal format dictionary.

DIISDIIS class

The class to generate diis object. It can be one of diis.SCF_DIIS, diis.ADIIS, diis.EDIIS.

diisboolean or object of DIIS class defined in scf.diis.

Default is the object associated to the attribute self.DIIS. Set it to None/False to turn off DIIS. Note if this attribute is initialized as a DIIS object, the SCF driver will use this object in the iteration. The DIIS information (vector basis and error vector) will be held inside this object. When kernel function is called again, the old states (vector basis and error vector) will be reused.

diis_spaceint

DIIS space size. By default, 8 Fock matrices and errors vector are stored.

diis_dampfloat

DIIS damping factor. Default is 0.

diis_start_cycleint

The step to start DIIS. Default is 1.

diis_file: ‘str’

File to store DIIS vectors and error vectors.

level_shiftfloat or int

Level shift (in AU) for virtual space. Default is 0.

direct_scfbool

Direct SCF is used by default.

direct_scf_tolfloat

Direct SCF cutoff threshold. Default is 1e-13.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current environment.

conv_checkbool

An extra cycle to check convergence after SCF iterations.

check_convergencefunction(envs) => bool

A hook for overloading convergence criteria in SCF iterations.

Saved results:

convergedbool

Whether the SCF iteration converged

e_totfloat

Total HF energy (electronic energy plus nuclear repulsion)

mo_energy :

Orbital energies

mo_occ

Orbital occupancy

mo_coeff

Orbital coefficients

cyclesint

The number of iteration cycles performed

Examples:

>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1', basis='cc-pvdz')
>>> mf = scf.hf.SCF(mol)
>>> mf.verbose = 0
>>> mf.level_shift = .4
>>> mf.scf()
-1.0811707843775884
Attributes for Kohn-Sham DFT:
xcstr

‘X_name,C_name’ for the XC functional. Default is ‘lda,vwn’

nlcstr

‘NLC_name’ for the NLC functional. Default is ‘’ (i.e., None)

omegafloat

Omega of the range-separated Coulomb operator e^{-omega r_{12}^2} / r_{12}

gridsGrids object

grids.level (0 - 9) big number for large mesh grids. Default is 3

radii_adjust
radi.treutler_atomic_radii_adjust (default)
radi.becke_atomic_radii_adjust
None : to switch off atomic radii adjustment
grids.atomic_radii
radi.BRAGG_RADII (default)
radi.COVALENT_RADII
None : to switch off atomic radii adjustment
grids.radi_method scheme for radial grids
radi.treutler (default)
radi.delley
radi.mura_knowles
radi.gauss_chebyshev
grids.becke_scheme weight partition function
gen_grid.original_becke (default)
gen_grid.stratmann
grids.prune scheme to reduce number of grids
gen_grid.nwchem_prune (default)
gen_grid.sg1_prune
gen_grid.treutler_prune
None : to switch off grids pruning

grids.symmetry True/False to symmetrize mesh grids (TODO)

grids.atom_grid Set (radial, angular) grids for particular atoms. Eg, grids.atom_grid = {‘H’: (20,110)} will generate 20 radial grids and 110 angular grids for H atom.

small_rho_cutofffloat

Drop grids if their contribution to total electrons smaller than this cutoff value. Default is 1e-7.

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz', verbose=0)
>>> mf = dft.RKS(mol)
>>> mf.xc = 'b3lyp'
>>> mf.kernel()
-76.415443079840458
CasidaTDDFT(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

Gradients(*args, **kwargs)#

Non-relativistic restricted Hartree-Fock gradients

Hessian(*args, **kwargs)#

Non-relativistic RKS hessian

TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT()#

Driver to create TDDFT or CasidaTDDFT object

TDDFTNoHybrid(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDHF = None#
dRPA(*args, **kwargs)#
dTDA(*args, **kwargs)#
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-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

Coulomb + XC functional

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.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

to_hf()[source]#

Convert to RHF object.

pyscf.dft.rks.define_xc_(ks, description, xctype='LDA', hyb=0, rsh=(0, 0, 0))[source]#
pyscf.dft.rks.energy_elec(ks, dm=None, h1e=None, vhf=None)[source]#

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-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

pyscf.dft.rks.get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)[source]#

Coulomb + XC functional

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.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
Returns:

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

pyscf.dft.rks.get_vsap(ks, mol=None)[source]#

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.

pyscf.dft.rks.init_guess_by_vsap(mf, mol=None)[source]#

Form SAP guess

pyscf.dft.rks.prune_small_rho_grids_(ks, mol, dm, grids)[source]#

pyscf.dft.rks_symm module#

Non-relativistic Restricted Kohn-Sham

pyscf.dft.rks_symm.RKS#

alias of SymAdaptedRKS

pyscf.dft.rks_symm.ROKS#

alias of SymAdaptedROKS

class pyscf.dft.rks_symm.SymAdaptedRKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, SymAdaptedRHF

Restricted Kohn-Sham

CasidaTDDFT(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

Gradients(*args, **kwargs)#

Non-relativistic restricted Hartree-Fock gradients

Hessian(*args, **kwargs)#

Non-relativistic RKS hessian

TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT()#

Driver to create TDDFT or CasidaTDDFT object

TDDFTNoHybrid(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDHF = None#
dRPA(*args, **kwargs)#
dTDA(*args, **kwargs)#
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-particle density matrix

h1e2D ndarray

Core hamiltonian

Returns:

RKS electronic energy and the 2-electron contribution

get_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

Coulomb + XC functional

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.

dmndarray or list of ndarrays

A density matrix or a list of density matrices

Kwargs:
dm_lastndarray or a list of ndarrays or 0

The density matrix baseline. If not 0, this function computes the increment of HF potential w.r.t. the reference HF potential matrix.

vhf_lastndarray or a list of ndarrays or 0

The reference Vxc potential matrix.

hermiint

Whether J, K matrix is hermitian

0 : no hermitian or symmetric
1 : hermitian
2 : anti-hermitian
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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

class pyscf.dft.rks_symm.SymAdaptedROKS(mol=None, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, SymAdaptedROHF

Restricted Kohn-Sham

Gradients(*args, **kwargs)#

Non-relativistic ROHF gradients

Hessian(*args, **kwargs)#
TDA = None#
TDDFT = None#
TDDFTNoHybrid = None#
TDHF = None#
dRPA = None#
dTDA = None#
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-particle 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(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

Coulomb + XC functional for UKS. See pyscf/dft/rks.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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

pyscf.dft.roks module#

Non-relativistic restricted open-shell Kohn-Sham

class pyscf.dft.roks.ROKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, ROHF

Restricted open-shell Kohn-Sham See pyscf/dft/rks.py RKS class for the usage of the attributes

Gradients(*args, **kwargs)#

Non-relativistic ROHF gradients

Hessian(*args, **kwargs)#
TDA = None#
TDDFT = None#
TDDFTNoHybrid = None#
TDHF = None#
dRPA = None#
dTDA = None#
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-particle 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(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

Coulomb + XC functional for UKS. See pyscf/dft/rks.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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

to_hf()[source]#

Convert to ROHF object.

pyscf.dft.roks.get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)[source]#

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

pyscf.dft.sap module#

pyscf.dft.sap.sap_effective_charge(Z, r)[source]#

Calculates the effective charge for the 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

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

Input:

Z: atomic charge r: distance from nucleus

Output:

Z(r): screened charge

pyscf.dft.sap_data module#

pyscf.dft.uks module#

Non-relativistic Unrestricted Kohn-Sham

class pyscf.dft.uks.UKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, UHF

Unrestricted Kohn-Sham See pyscf/dft/rks.py RKS class for document of the attributes

CasidaTDDFT(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

Gradients(*args, **kwargs)#

Non-relativistic unrestricted Hartree-Fock gradients

Hessian(*args, **kwargs)#

Non-relativistic UKS hessian

TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT()#

Driver to create TDDFT or CasidaTDDFT object

TDDFTNoHybrid(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDHF = None#
dRPA(*args, **kwargs)#
dTDA(*args, **kwargs)#
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_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

Coulomb + XC functional for UKS. See pyscf/dft/rks.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

initialize_grids(mol=None, dm=None)[source]#

Initialize self.grids the first time call get_veff

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

to_hf()[source]#

Convert to UHF object.

pyscf.dft.uks.energy_elec(ks, dm=None, h1e=None, vhf=None)[source]#
pyscf.dft.uks.get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)[source]#

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

pyscf.dft.uks.get_vsap(ks, mol=None)[source]#

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.

pyscf.dft.uks_symm module#

Non-relativistic Unrestricted Kohn-Sham

class pyscf.dft.uks_symm.SymAdaptedUKS(mol, xc='LDA,VWN')[source]#

Bases: KohnShamDFT, SymAdaptedUHF

Restricted Kohn-Sham

CasidaTDDFT(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

Gradients(*args, **kwargs)#

Non-relativistic unrestricted Hartree-Fock gradients

Hessian(*args, **kwargs)#

Non-relativistic UKS hessian

TDA(*args, **kwargs)#

Tamm-Dancoff approximation

Attributes:
conv_tolfloat

Diagonalization convergence tolerance. Default is 1e-9.

nstatesint

Number of TD states to be computed. Default is 3.

Saved results:

convergedbool

Diagonalization converged or not

e1D array

excitation energy for each excited state.

xyA list of two 2D arrays

The two 2D arrays are Excitation coefficients X (shape [nocc,nvir]) and de-excitation coefficients Y (shape [nocc,nvir]) for each excited state. (X,Y) are normalized to 1/2 in RHF/RKS methods and normalized to 1 for UHF/UKS methods. In the TDA calculation, Y = 0.

TDDFT()#

Driver to create TDDFT or CasidaTDDFT object

TDDFTNoHybrid(*args, **kwargs)#

Solve the Casida TDDFT formula (A-B)(A+B)(X+Y) = (X+Y)w^2

TDHF = None#
dRPA(*args, **kwargs)#
dTDA(*args, **kwargs)#
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_veff(mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1)#

Coulomb + XC functional for UKS. See pyscf/dft/rks.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

nuc_grad_method()[source]#

Hook to create object for analytical nuclear gradients.

to_gpu(out=None)#

Convert a method to its corresponding GPU variant, and recursively converts all attributes of a method to cupy objects or gpu4pyscf objects.

pyscf.dft.uks_symm.UKS#

alias of SymAdaptedUKS

pyscf.dft.xc_deriv module#

Transform XC functional derivatives between different representations

pyscf.dft.xc_deriv.count_combinations(nvar, order)[source]#

sum(len(combinations_with_replacement(range(nvar), o) for o in range(order))

pyscf.dft.xc_deriv.transform_fxc(rho, vxc, fxc, xctype, spin=0)[source]#

Transform libxc functional derivatives to the derivative tensor of parameters in rho:

[[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]].

The output tensor has the shape:
  • spin polarized

    LDA : [2,1,2,1,N] GGA : [2,4,2,4,N] MGGA: [2,5,2,5,N]

  • spin unpolarized

    LDA : [1,1,N] GGA : [4,4,N] MGGA: [5,5,N]

pyscf.dft.xc_deriv.transform_kxc(rho, fxc, kxc, xctype, spin=0)[source]#

Transform libxc functional derivatives to the derivative tensor of parameters in rho:

[[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]].

The output tensor has the shape:
  • spin polarized

    LDA : [2,1,2,1,2,1,N] GGA : [2,4,2,4,2,4,N] MGGA: [2,5,2,5,2,5,N]

  • spin unpolarized

    LDA : [1,1,1,N] GGA : [4,4,4,N] MGGA: [5,5,5,N]

pyscf.dft.xc_deriv.transform_lxc(rho, fxc, kxc, lxc, xctype, spin=0)[source]#

Transform libxc vxc functional output to the derivative tensor of parameters in rho: [density, nabla_x, nabla_y, nabla_z, tau]. The output tensor has the shape:

  • spin polarized

    LDA : [2,1,2,1,2,1,2,1,N] GGA : [2,4,2,4,2,4,2,4,N] MGGA: [2,5,2,5,2,5,2,5,N]

  • spin unpolarized

    LDA : [1,1,1,1,N] GGA : [4,4,4,4,N] MGGA: [5,5,5,5,N]

pyscf.dft.xc_deriv.transform_vxc(rho, vxc, xctype, spin=0)[source]#

Transform libxc functional derivatives to the derivative tensor of parameters in rho:

[[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]].

The output tensor has the shape:
  • spin polarized

    LDA : [2,1,N] GGA : [2,4,N] MGGA: [2,5,N]

  • spin unpolarized

    LDA : [1,N] GGA : [4,N] MGGA: [5,N]

pyscf.dft.xc_deriv.transform_xc(rho, xc_val, xctype, spin, order)[source]#

General transformation to construct XC derivative tensor

pyscf.dft.xc_deriv.ts2ud(v_ts)[source]#

XC derivatives total-density/spin-density representations to spin-up/spin-down representations

pyscf.dft.xc_deriv.ud2ts(v_ud)[source]#

XC derivatives spin-up/spin-down representations to total-density/spin-density representations

pyscf.dft.xcfun module#

XC functional, the interface to xcfun (dftlibs/xcfun) U. Ekstrom et al, J. Chem. Theory Comput., 6, 1971

pyscf.dft.xcfun.define_xc(ni, description, xctype='LDA', hyb=0, rsh=(0, 0, 0))[source]#

Define XC functional. See also eval_xc() for the rules of input description.

Args:

ni : an instance of NumInt

descriptionstr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” was appeared in the string, it stands for the exact exchange.

Kwargs:
xctypestr

‘LDA’ or ‘GGA’ or ‘MGGA’

hybfloat

hybrid functional coefficient

rsha list of three floats

coefficients (omega, alpha, beta) for range-separated hybrid functional. omega is the exponent factor in attenuated Coulomb operator e^{-omega r_{12}}/r_{12} alpha is the coefficient for long-range part, hybrid coefficient can be obtained by alpha + beta

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz')
>>> mf = dft.RKS(mol)
>>> define_xc_(mf._numint, '.2*HF + .08*LDA + .72*B88, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> define_xc_(mf._numint, 'LDA*.08 + .72*B88 + .2*HF, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> def eval_xc(xc_code, rho, *args, **kwargs):
...     exc = 0.01 * rho**2
...     vrho = 0.01 * 2 * rho
...     vxc = (vrho, None, None, None)
...     fxc = None  # 2nd order functional derivative
...     kxc = None  # 3rd order functional derivative
...     return exc, vxc, fxc, kxc
>>> define_xc_(mf._numint, eval_xc, xctype='LDA')
>>> mf.kernel()
48.8525211046668
pyscf.dft.xcfun.define_xc_(ni, description, xctype='LDA', hyb=0, rsh=(0, 0, 0))[source]#

Define XC functional. See also eval_xc() for the rules of input description.

Args:

ni : an instance of NumInt

descriptionstr

A string to describe the linear combination of different XC functionals. The X and C functional are separated by comma like ‘.8*LDA+.2*B86,VWN’. If “HF” was appeared in the string, it stands for the exact exchange.

Kwargs:
xctypestr

‘LDA’ or ‘GGA’ or ‘MGGA’

hybfloat

hybrid functional coefficient

rsha list of three floats

coefficients (omega, alpha, beta) for range-separated hybrid functional. omega is the exponent factor in attenuated Coulomb operator e^{-omega r_{12}}/r_{12} alpha is the coefficient for long-range part, hybrid coefficient can be obtained by alpha + beta

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz')
>>> mf = dft.RKS(mol)
>>> define_xc_(mf._numint, '.2*HF + .08*LDA + .72*B88, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> define_xc_(mf._numint, 'LDA*.08 + .72*B88 + .2*HF, .81*LYP + .19*VWN')
>>> mf.kernel()
-76.3783361189611
>>> def eval_xc(xc_code, rho, *args, **kwargs):
...     exc = 0.01 * rho**2
...     vrho = 0.01 * 2 * rho
...     vxc = (vrho, None, None, None)
...     fxc = None  # 2nd order functional derivative
...     kxc = None  # 3rd order functional derivative
...     return exc, vxc, fxc, kxc
>>> define_xc_(mf._numint, eval_xc, xctype='LDA')
>>> mf.kernel()
48.8525211046668
pyscf.dft.xcfun.eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=None)[source]#

Interface to call xcfun library to evaluate XC functional, potential and functional derivatives. Return derivatives following libxc convention.

See also pyscf.dft.libxc.eval_xc()

pyscf.dft.xcfun.eval_xc1(xc_code, rho, spin=0, deriv=1, omega=None)[source]#

Similar to eval_xc. Returns an array with the order of derivatives following xcfun convention.

pyscf.dft.xcfun.eval_xc_eff(xc_code, rho, deriv=1, omega=None)[source]#

Returns the derivative tensor against the density parameters

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

or spin-polarized 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 or (spin-up, spin-down) densities (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

pyscf.dft.xcfun.hybrid_coeff(xc_code, spin=0)[source]#
pyscf.dft.xcfun.is_gga(xc_code)[source]#
pyscf.dft.xcfun.is_hybrid_xc(xc_code)[source]#
pyscf.dft.xcfun.is_lda(xc_code)[source]#
pyscf.dft.xcfun.is_meta_gga(xc_code)[source]#
pyscf.dft.xcfun.is_nlc(xc_code)[source]#
pyscf.dft.xcfun.max_deriv_order(xc_code)[source]#
pyscf.dft.xcfun.nlc_coeff(xc_code)[source]#

Get NLC coefficients

pyscf.dft.xcfun.parse_xc(description)[source]#

Rules to input functional description:

  • The given functional description must be a one-line string.

  • The functional description is case-insensitive.

  • The functional description string has two parts, separated by “,”. The first part describes the exchange functional, the second is the correlation functional.

    • If “,” not appeared in string, the entire string is treated as the name of a compound functional (containing both the exchange and the correlation functional) which was declared in the functional aliases list. The full list of functional aliases can be obtained by calling the function pyscf.dft.xcfun.XC_ALIAS.keys() .

    • To input only X functional (without C functional), leave the second part blank. E.g. description=’slater,’ means a functional with LDA contribution only.

    • To neglect the contribution of X functional (just apply C functional), leave blank in the first part, e.g. description=’,vwn’ means a functional with VWN only.

    • If compound XC functional is specified, no matter whether it is in the X part (the string in front of comma) or the C part (the string behind comma), both X and C functionals of the compound XC functional will be used.

  • The functional name can be placed in arbitrary order. Two names need to be separated by operators “+” or “-”. Blank spaces are ignored. NOTE the parser only reads operators “+” “-” “*”. / is not supported.

  • A functional name can have at most one factor. If the factor is not given, it is set to 1. Compound functional can be scaled as a unit. For example ‘0.5*b3lyp’ is equivalent to ‘HF*0.1 + .04*LDA + .36*B88, .405*LYP + .095*VWN’

  • String “HF” stands for exact exchange (HF K matrix). “HF” can be put in the correlation functional part (after comma). Putting “HF” in the correlation part is the same to putting “HF” in the exchange part.

  • String “RSH” means range-separated operator. Its format is RSH(omega, alpha, beta). Another way to input RSH is to use keywords SR_HF and LR_HF: “SR_HF(0.1) * alpha_plus_beta” and “LR_HF(0.1) * alpha” where the number in parenthesis is the value of omega.

  • Be careful with the convention of GGA functional, in which the LDA contribution has been included.

pyscf.dft.xcfun.parse_xc_name(xc_name)[source]#
pyscf.dft.xcfun.print_XC_CODES()[source]#

Dump the built-in xcfun XC_CODES in a readable format.

pyscf.dft.xcfun.rsh_coeff(xc_code)[source]#

Get Range-separated-hybrid coefficients

pyscf.dft.xcfun.test_deriv_order(xc_code, deriv, raise_error=False)[source]#
pyscf.dft.xcfun.xc_type(xc_code)[source]#

Module contents#

Density functional theory#

Simple usage:

>>> from pyscf import gto, dft
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='def2-tzvp')
>>> mf = dft.RKS(mol)
>>> mf.xc = 'pbe,pbe'
>>> mf.run()
pyscf.dft.DFT(mol, xc='LDA,VWN')#

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

Restricted Kohn-Sham SCF base class. non-relativistic RHF.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose

max_memoryfloat or int

Allowed memory in MB. Default equals to Mole.max_memory

chkfilestr

checkpoint file to save MOs, orbital energies etc. Writing to chkfile can be disabled if this attribute is set to None or False.

conv_tolfloat

converge threshold. Default is 1e-9

conv_tol_gradfloat

gradients converge threshold. Default is sqrt(conv_tol)

max_cycleint

max number of iterations. If max_cycle <= 0, SCF iteration will be skipped and the kernel function will compute only the total energy based on the initial guess. Default value is 50.

init_guessstr

initial guess method. It can be one of ‘minao’, ‘atom’, ‘huckel’, ‘hcore’, ‘1e’, ‘sap’, ‘chkfile’. Default is ‘minao’

sap_basisstr or dict

basis for SAP initial guess, either filename or path as str or internal format dictionary.

DIISDIIS class

The class to generate diis object. It can be one of diis.SCF_DIIS, diis.ADIIS, diis.EDIIS.

diisboolean or object of DIIS class defined in scf.diis.

Default is the object associated to the attribute self.DIIS. Set it to None/False to turn off DIIS. Note if this attribute is initialized as a DIIS object, the SCF driver will use this object in the iteration. The DIIS information (vector basis and error vector) will be held inside this object. When kernel function is called again, the old states (vector basis and error vector) will be reused.

diis_spaceint

DIIS space size. By default, 8 Fock matrices and errors vector are stored.

diis_dampfloat

DIIS damping factor. Default is 0.

diis_start_cycleint

The step to start DIIS. Default is 1.

diis_file: ‘str’

File to store DIIS vectors and error vectors.

level_shiftfloat or int

Level shift (in AU) for virtual space. Default is 0.

direct_scfbool

Direct SCF is used by default.

direct_scf_tolfloat

Direct SCF cutoff threshold. Default is 1e-13.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current environment.

conv_checkbool

An extra cycle to check convergence after SCF iterations.

check_convergencefunction(envs) => bool

A hook for overloading convergence criteria in SCF iterations.

Saved results:

convergedbool

Whether the SCF iteration converged

e_totfloat

Total HF energy (electronic energy plus nuclear repulsion)

mo_energy :

Orbital energies

mo_occ

Orbital occupancy

mo_coeff

Orbital coefficients

cyclesint

The number of iteration cycles performed

Examples:

>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1', basis='cc-pvdz')
>>> mf = scf.hf.SCF(mol)
>>> mf.verbose = 0
>>> mf.level_shift = .4
>>> mf.scf()
-1.0811707843775884
Attributes for Kohn-Sham DFT:
xcstr

‘X_name,C_name’ for the XC functional. Default is ‘lda,vwn’

nlcstr

‘NLC_name’ for the NLC functional. Default is ‘’ (i.e., None)

omegafloat

Omega of the range-separated Coulomb operator e^{-omega r_{12}^2} / r_{12}

gridsGrids object

grids.level (0 - 9) big number for large mesh grids. Default is 3

radii_adjust
radi.treutler_atomic_radii_adjust (default)
radi.becke_atomic_radii_adjust
None : to switch off atomic radii adjustment
grids.atomic_radii
radi.BRAGG_RADII (default)
radi.COVALENT_RADII
None : to switch off atomic radii adjustment
grids.radi_method scheme for radial grids
radi.treutler (default)
radi.delley
radi.mura_knowles
radi.gauss_chebyshev
grids.becke_scheme weight partition function
gen_grid.original_becke (default)
gen_grid.stratmann
grids.prune scheme to reduce number of grids
gen_grid.nwchem_prune (default)
gen_grid.sg1_prune
gen_grid.treutler_prune
None : to switch off grids pruning

grids.symmetry True/False to symmetrize mesh grids (TODO)

grids.atom_grid Set (radial, angular) grids for particular atoms. Eg, grids.atom_grid = {‘H’: (20,110)} will generate 20 radial grids and 110 angular grids for H atom.

small_rho_cutofffloat

Drop grids if their contribution to total electrons smaller than this cutoff value. Default is 1e-7.

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz', verbose=0)
>>> mf = dft.RKS(mol)
>>> mf.xc = 'b3lyp'
>>> mf.kernel()
-76.415443079840458
pyscf.dft.DKS(mol, xc='LDA,VWN')[source]#
pyscf.dft.GKS(mol, xc='LDA,VWN')[source]#

Generalized Kohn-Sham

pyscf.dft.KS(mol, xc='LDA,VWN')[source]#

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

Restricted Kohn-Sham SCF base class. non-relativistic RHF.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose

max_memoryfloat or int

Allowed memory in MB. Default equals to Mole.max_memory

chkfilestr

checkpoint file to save MOs, orbital energies etc. Writing to chkfile can be disabled if this attribute is set to None or False.

conv_tolfloat

converge threshold. Default is 1e-9

conv_tol_gradfloat

gradients converge threshold. Default is sqrt(conv_tol)

max_cycleint

max number of iterations. If max_cycle <= 0, SCF iteration will be skipped and the kernel function will compute only the total energy based on the initial guess. Default value is 50.

init_guessstr

initial guess method. It can be one of ‘minao’, ‘atom’, ‘huckel’, ‘hcore’, ‘1e’, ‘sap’, ‘chkfile’. Default is ‘minao’

sap_basisstr or dict

basis for SAP initial guess, either filename or path as str or internal format dictionary.

DIISDIIS class

The class to generate diis object. It can be one of diis.SCF_DIIS, diis.ADIIS, diis.EDIIS.

diisboolean or object of DIIS class defined in scf.diis.

Default is the object associated to the attribute self.DIIS. Set it to None/False to turn off DIIS. Note if this attribute is initialized as a DIIS object, the SCF driver will use this object in the iteration. The DIIS information (vector basis and error vector) will be held inside this object. When kernel function is called again, the old states (vector basis and error vector) will be reused.

diis_spaceint

DIIS space size. By default, 8 Fock matrices and errors vector are stored.

diis_dampfloat

DIIS damping factor. Default is 0.

diis_start_cycleint

The step to start DIIS. Default is 1.

diis_file: ‘str’

File to store DIIS vectors and error vectors.

level_shiftfloat or int

Level shift (in AU) for virtual space. Default is 0.

direct_scfbool

Direct SCF is used by default.

direct_scf_tolfloat

Direct SCF cutoff threshold. Default is 1e-13.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current environment.

conv_checkbool

An extra cycle to check convergence after SCF iterations.

check_convergencefunction(envs) => bool

A hook for overloading convergence criteria in SCF iterations.

Saved results:

convergedbool

Whether the SCF iteration converged

e_totfloat

Total HF energy (electronic energy plus nuclear repulsion)

mo_energy :

Orbital energies

mo_occ

Orbital occupancy

mo_coeff

Orbital coefficients

cyclesint

The number of iteration cycles performed

Examples:

>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1', basis='cc-pvdz')
>>> mf = scf.hf.SCF(mol)
>>> mf.verbose = 0
>>> mf.level_shift = .4
>>> mf.scf()
-1.0811707843775884
Attributes for Kohn-Sham DFT:
xcstr

‘X_name,C_name’ for the XC functional. Default is ‘lda,vwn’

nlcstr

‘NLC_name’ for the NLC functional. Default is ‘’ (i.e., None)

omegafloat

Omega of the range-separated Coulomb operator e^{-omega r_{12}^2} / r_{12}

gridsGrids object

grids.level (0 - 9) big number for large mesh grids. Default is 3

radii_adjust
radi.treutler_atomic_radii_adjust (default)
radi.becke_atomic_radii_adjust
None : to switch off atomic radii adjustment
grids.atomic_radii
radi.BRAGG_RADII (default)
radi.COVALENT_RADII
None : to switch off atomic radii adjustment
grids.radi_method scheme for radial grids
radi.treutler (default)
radi.delley
radi.mura_knowles
radi.gauss_chebyshev
grids.becke_scheme weight partition function
gen_grid.original_becke (default)
gen_grid.stratmann
grids.prune scheme to reduce number of grids
gen_grid.nwchem_prune (default)
gen_grid.sg1_prune
gen_grid.treutler_prune
None : to switch off grids pruning

grids.symmetry True/False to symmetrize mesh grids (TODO)

grids.atom_grid Set (radial, angular) grids for particular atoms. Eg, grids.atom_grid = {‘H’: (20,110)} will generate 20 radial grids and 110 angular grids for H atom.

small_rho_cutofffloat

Drop grids if their contribution to total electrons smaller than this cutoff value. Default is 1e-7.

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz', verbose=0)
>>> mf = dft.RKS(mol)
>>> mf.xc = 'b3lyp'
>>> mf.kernel()
-76.415443079840458
pyscf.dft.RKS(mol, xc='LDA,VWN')[source]#

Restricted Kohn-Sham SCF base class. non-relativistic RHF.

Attributes:
verboseint

Print level. Default value equals to Mole.verbose

max_memoryfloat or int

Allowed memory in MB. Default equals to Mole.max_memory

chkfilestr

checkpoint file to save MOs, orbital energies etc. Writing to chkfile can be disabled if this attribute is set to None or False.

conv_tolfloat

converge threshold. Default is 1e-9

conv_tol_gradfloat

gradients converge threshold. Default is sqrt(conv_tol)

max_cycleint

max number of iterations. If max_cycle <= 0, SCF iteration will be skipped and the kernel function will compute only the total energy based on the initial guess. Default value is 50.

init_guessstr

initial guess method. It can be one of ‘minao’, ‘atom’, ‘huckel’, ‘hcore’, ‘1e’, ‘sap’, ‘chkfile’. Default is ‘minao’

sap_basisstr or dict

basis for SAP initial guess, either filename or path as str or internal format dictionary.

DIISDIIS class

The class to generate diis object. It can be one of diis.SCF_DIIS, diis.ADIIS, diis.EDIIS.

diisboolean or object of DIIS class defined in scf.diis.

Default is the object associated to the attribute self.DIIS. Set it to None/False to turn off DIIS. Note if this attribute is initialized as a DIIS object, the SCF driver will use this object in the iteration. The DIIS information (vector basis and error vector) will be held inside this object. When kernel function is called again, the old states (vector basis and error vector) will be reused.

diis_spaceint

DIIS space size. By default, 8 Fock matrices and errors vector are stored.

diis_dampfloat

DIIS damping factor. Default is 0.

diis_start_cycleint

The step to start DIIS. Default is 1.

diis_file: ‘str’

File to store DIIS vectors and error vectors.

level_shiftfloat or int

Level shift (in AU) for virtual space. Default is 0.

direct_scfbool

Direct SCF is used by default.

direct_scf_tolfloat

Direct SCF cutoff threshold. Default is 1e-13.

callbackfunction(envs_dict) => None

callback function takes one dict as the argument which is generated by the builtin function locals(), so that the callback function can access all local variables in the current environment.

conv_checkbool

An extra cycle to check convergence after SCF iterations.

check_convergencefunction(envs) => bool

A hook for overloading convergence criteria in SCF iterations.

Saved results:

convergedbool

Whether the SCF iteration converged

e_totfloat

Total HF energy (electronic energy plus nuclear repulsion)

mo_energy :

Orbital energies

mo_occ

Orbital occupancy

mo_coeff

Orbital coefficients

cyclesint

The number of iteration cycles performed

Examples:

>>> mol = gto.M(atom='H 0 0 0; H 0 0 1.1', basis='cc-pvdz')
>>> mf = scf.hf.SCF(mol)
>>> mf.verbose = 0
>>> mf.level_shift = .4
>>> mf.scf()
-1.0811707843775884
Attributes for Kohn-Sham DFT:
xcstr

‘X_name,C_name’ for the XC functional. Default is ‘lda,vwn’

nlcstr

‘NLC_name’ for the NLC functional. Default is ‘’ (i.e., None)

omegafloat

Omega of the range-separated Coulomb operator e^{-omega r_{12}^2} / r_{12}

gridsGrids object

grids.level (0 - 9) big number for large mesh grids. Default is 3

radii_adjust
radi.treutler_atomic_radii_adjust (default)
radi.becke_atomic_radii_adjust
None : to switch off atomic radii adjustment
grids.atomic_radii
radi.BRAGG_RADII (default)
radi.COVALENT_RADII
None : to switch off atomic radii adjustment
grids.radi_method scheme for radial grids
radi.treutler (default)
radi.delley
radi.mura_knowles
radi.gauss_chebyshev
grids.becke_scheme weight partition function
gen_grid.original_becke (default)
gen_grid.stratmann
grids.prune scheme to reduce number of grids
gen_grid.nwchem_prune (default)
gen_grid.sg1_prune
gen_grid.treutler_prune
None : to switch off grids pruning

grids.symmetry True/False to symmetrize mesh grids (TODO)

grids.atom_grid Set (radial, angular) grids for particular atoms. Eg, grids.atom_grid = {‘H’: (20,110)} will generate 20 radial grids and 110 angular grids for H atom.

small_rho_cutofffloat

Drop grids if their contribution to total electrons smaller than this cutoff value. Default is 1e-7.

Examples:

>>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz', verbose=0)
>>> mf = dft.RKS(mol)
>>> mf.xc = 'b3lyp'
>>> mf.kernel()
-76.415443079840458
pyscf.dft.ROKS(mol, xc='LDA,VWN')[source]#

Restricted open-shell Kohn-Sham See pyscf/dft/rks.py RKS class for the usage of the attributes

pyscf.dft.UKS(mol, xc='LDA,VWN')[source]#

Unrestricted Kohn-Sham See pyscf/dft/rks.py RKS class for document of the attributes

pyscf.dft.X2C(mol, *args)[source]#

X2C Kohn-Sham

pyscf.dft.X2C_KS(mol, *args)#

X2C Kohn-Sham