# 10.27. sgx — Pseudo-spectral methods (COSX, PS, SN-K)¶

The sgx module implements pseudo-spectral methods for Hartree-Fock exchange.

Here is a simple example of how to use pseudo spectral integrals in SCF calculation:

from pyscf import gto
from pyscf import scf
from pyscf import sgx
mol = gto.M(
atom='''O    0.   0.       0.
H    0.   -0.757   0.587
H    0.   0.757    0.587
''',
basis = 'ccpvdz',
)
mf = sgx.sgx_fit(scf.RHF(mol))
mf.kernel()
# Using RI for Coulomb matrix while K-matrix is constructed with COS-X method
mf.with_df.dfj = True
mf.kernel()


## 10.27.1. Examples¶

Relevant examples examples/sgx/00-simple_sgx.py

## 10.27.2. Program reference¶

### 10.27.2.1. Main class¶

Pseudo-spectral methods (COSX, PS, SN-K)

class pyscf.sgx.sgx.SGX(mol, auxbasis=None)[source]
kernel(*args, **kwargs)[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.).

reset(mol=None)[source]

Reset mol and clean up relevant attributes for scanner mode

pyscf.sgx.sgx.sgx_fit(mf, auxbasis=None, with_df=None)[source]

For the given SCF object, update the J, K matrix constructor with corresponding SGX or density fitting integrals.

Args:

mf : an SCF object

Kwargs:
auxbasisstr or basis dict

Same format to the input attribute mol.basis. If auxbasis is None, optimal auxiliary basis based on AO basis (if possible) or even-tempered Gaussian basis will be used.

Returns:

An SCF object with a modified J, K matrix constructor which uses density fitting integrals to compute J and K

Examples:

>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = sgx_fit(scf.RHF(mol))
>>> mf.scf()
-100.00978770917165

>>> mol.symmetry = 1
>>> mol.build(0, 0)
>>> mf = sgx_fit(scf.UHF(mol))
>>> mf.scf()
-100.00978770951018


### 10.27.2.2. Get JK¶

semi-grid Coulomb and eXchange without differencial density matrix

To lower the scaling of coulomb and exchange matrix construction for large system, one coordinate is analitical and the other is grid. The traditional two electron integrals turn to analytical one electron integrals and numerical integration based on grid.(see Friesner, R. A. Chem. Phys. Lett. 1985, 116, 39)

Minimizing numerical errors using overlap fitting correction.(see Lzsak, R. et. al. J. Chem. Phys. 2011, 135, 144105) Grid screening for weighted AO value and DktXkg. Two SCF steps: coarse grid then fine grid. There are 5 parameters can be changed: # threshold for Xg and Fg screening gthrd = 1e-10 # initial and final grids level grdlvl_i = 0 grdlvl_f = 1 # norm_ddm threshold for grids change thrd_nddm = 0.03 # set block size to adapt memory sblk = 200

Set mf.direct_scf = False because no traditional 2e integrals