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

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.07091605174018
**** SCF Summaries ****
Total Energy =                          -1.070916051740179
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897310622180397
Two-electron Coulomb Energy =            0.997543903530676
DFT Exchange-Correlation Energy =       -0.548804106417971
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.07106373980849
**** SCF Summaries ****
Total Energy =                          -1.071063739808489
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897672538024412
Two-electron Coulomb Energy =            0.998071975647928
DFT Exchange-Correlation Energy =       -0.549117950759518
Empirical Dispersion Energy =           -0.000328948758201
None
Overwritten attributes  nuc_grad_method  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.07106373972297
**** SCF Summaries ****
Total Energy =                          -1.071063739722973
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.897671244924644
Two-electron Coulomb Energy =            0.998068848631997
DFT Exchange-Correlation Energy =       -0.549116116757840
Empirical Dispersion Energy =           -0.000328948758201
None
Overwritten attributes  nuc_grad_method  of <class 'pyscf.soscf.newton_ah.SecondOrderDFSkalaRKS'>