Configuring SCF parameters

Configuring SCF parameters#

When running a SCF calculation with PySCF, there are a number of parameters that are set to control, for example, the convergence criteria or other aspects of the computation (e.g diis, level_shift etc).

from pyscf import gto

from skala.pyscf import SkalaKS

We create a molecule to use in the SCF calculation:

mol = gto.M(
    atom="""H 0 0 0; H 0 0 1.4""",
    basis="def2-tzvp",
)

As seen in the Using the Skala functional in PySCF example notebook, this is how we run a calculation using Skala functional.

ks = SkalaKS(mol, xc="skala")
ks.kernel()

ks.dump_scf_summary()
converged SCF energy = -1.07091605180786
**** SCF Summaries ****
Total Energy =                          -1.070916051807861
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897310622615235
Two-electron Coulomb Energy =            0.997543904319598
DFT Exchange-Correlation Energy =       -0.548804106839736
Empirical Dispersion Energy =           -0.000328948758201

We can check the convergence tolerance as follows:

print(ks.conv_tol)
print(ks.conv_tol_grad)
1e-09
None

This is how you can modify such settings (and a few more) in order to use the same ones as in our paper.

ks_config = {
    "conv_tol": 5e-6,
    "conv_tol_grad": 0.001,
    "max_cycle": 60,
    "damp": 0.0,
    "diis_start_cycle": 1,
    "level_shift": 0.0,
}
ks = SkalaKS(mol, ks_config=ks_config, xc="skala")

We print again the convergence tolerance to check that it was updated:

print(ks.conv_tol)
print(ks.conv_tol_grad)
5e-06
0.001

In our paper, we also use a retry-logic to modify the SCF settings and run it again in case the computation does not converge. See section D.3 in the paper for more details.