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 skala.pyscf import SkalaKS

from pyscf import gto

The Kohn-Sham calculator for the Skala functional is created from a regular PySCF molecule object. By specifying the xc parameter as "skala-1.1", 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-1.1")
ks.kernel()

print(ks.dump_scf_summary())
converged SCF energy = -1.07427604049692
**** SCF Summaries ****
Total Energy =                          -1.074276040496920
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.893183564158031
Two-electron Energy =                    0.441252750333597
Two-electron Coulomb Energy =            0.989038385234885
DFT Exchange-Correlation Energy =       -0.547785634901288
HOMO-LUMO gap [eV] =                     5.028283231128416
Empirical Dispersion Energy =           -0.000328948758201
None
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.

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-1.1", with_density_fit=True, auxbasis="def2-universal-jkfit"
)
ks.kernel()

print(ks.dump_scf_summary())
converged SCF energy = -1.07439124048871
**** SCF Summaries ****
Total Energy =                          -1.074391240488712
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.893533469600977
Two-electron Energy =                    0.441487455784752
Two-electron Coulomb Energy =            0.989527615838750
DFT Exchange-Correlation Energy =       -0.548040160053999
HOMO-LUMO gap [eV] =                     5.035532250323084
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-1.1",
    with_density_fit=True,
    auxbasis="def2-universal-jkfit",
    with_newton=True,
)
ks.kernel()

print(ks.dump_scf_summary())
converged SCF energy = -1.07439124120362
**** SCF Summaries ****
Total Energy =                          -1.074391241203625
Nuclear Repulsion Energy =               0.377654773327513
One-electron Energy =                   -1.893532232737226
Two-electron Energy =                    0.441486218206088
Two-electron Coulomb Energy =            0.989524877464686
DFT Exchange-Correlation Energy =       -0.548038659258598
HOMO-LUMO gap [eV] =                     5.604711681946530
Empirical Dispersion Energy =           -0.000328948758201
None
Overwritten attributes  nuc_grad_method Gradients  of <class 'pyscf.soscf.newton_ah.SecondOrderDFSkalaRKS'>