Using the Skala functional in PySCF

Using the Skala functional in PySCF#

The Skala functional can be used in PySCF by creating a new Kohn-Sham calculator based on the SkalaKS constructor. This allows to perform self-consistent field calculations with most of the features available in PySCF, such as density fitting and Newton’s method.

from pyscf import gto

from skala.pyscf import SkalaKS
/home/runner/micromamba/envs/skala/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

The Kohn-Sham calculator for the Skala functional is created from a regular PySCF molecule object. By specifying the xc parameter as "skala", the Skala functional is automatically loaded and used for the calculations.

mol = gto.M(
    atom="""H 0 0 0; H 0 0 1.4""",
    basis="def2-tzvp",
)
ks = SkalaKS(mol, xc="skala")
ks.kernel()

print(ks.dump_scf_summary())
converged SCF energy = -1.07091605169473
**** SCF Summaries ****
Total Energy =                          -1.070916051694730
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897310626188731
Two-electron Coulomb Energy =            0.997543911291975
DFT Exchange-Correlation Energy =       -0.548804110125487
Empirical Dispersion Energy =           -0.000328948758201
None

Note that using the Skala functional will automatically enable the D3 dispersion correction, which is a part of the Skala functional. To disable the D3 correction, you can pass the with_dftd3 parameter as False when creating the Kohn-Sham calculator.

The Skala functional can be used with density fitting by calling the density_fit() method on the Kohn-Sham calculator or by setting the with_density_fit parameter to True when creating the calculator. This will set up the necessary integrals and approximations for efficient calculations.

mol = gto.M(
    atom="""H 0 0 0; H 0 0 1.4""",
    basis="def2-tzvp",
)
ks = SkalaKS(mol, xc="skala", with_density_fit=True)
ks.kernel()

print(ks.dump_scf_summary())
converged SCF energy = -1.07106374023819
**** SCF Summaries ****
Total Energy =                          -1.071063740238186
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897672542456614
Two-electron Coulomb Energy =            0.998071986721748
DFT Exchange-Correlation Energy =       -0.549117957830833
Empirical Dispersion Energy =           -0.000328948758201
None
Overwritten attributes  nuc_grad_method Gradients  of <class 'pyscf.df.df_jk.DFSkalaRKS'>

For challenging to converge systems, the Newton’s method can be used by calling the newton() method on the Kohn-Sham calculator. Note, that you need to call density_fit() before using Newton’s method, to apply the density fitting to the Kohn-Sham calculator. The calculator will automatically use the density fitting integrals for the Newton’s method if the with_density_fit and with_newton parameters are set to True.

mol = gto.M(
    atom="""H 0 0 0; H 0 0 1.4""",
    basis="def2-tzvp",
)
ks = SkalaKS(mol, xc="skala", with_density_fit=True, with_newton=True)
ks.kernel()

print(ks.dump_scf_summary())
converged SCF energy = -1.0710637391043
**** SCF Summaries ****
Total Energy =                          -1.071063739104303
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897671244658146
Two-electron Coulomb Energy =            0.998068849779088
DFT Exchange-Correlation Energy =       -0.549116117552759
Empirical Dispersion Energy =           -0.000328948758201
None
Overwritten attributes  nuc_grad_method Gradients  of <class 'pyscf.soscf.newton_ah.SecondOrderDFSkalaRKS'>