ks-pies: kohn-sham inversion toolkit

13
KS-pies: Kohn-Sham Inversion Toolkit S EUNGSOO NAM,HANSOL PARK, AND EUNJI S IM * Department of Chemistry, Yonsei University, 50 Yonsei-ro Seodaemun-gu, Seoul 03722, Korea RYAN J. MCCARTY Departments of Chemistry, University of California, Irvine, CA 92697, USA February 18, 2021 Abstract A Kohn-Sham (KS) inversion determines a KS potential and orbitals corresponding to a given electron density, a procedure that has applications in developing and evaluating functionals used in density functional theory. Despite the utility of KS inversions, application of these methods among the research community is disproportionately small. We implement the KS inversion methods of Zhao-Morrison-Parr and Wu-Yang in a framework that simplifies analysis and conversion of the resulting potential in real-space. Fully documented Python scripts integrate with PySCF, a popular electronic structure prediction software, and Fortran alternatives are provided for computational hot spots. I. Introduction Future progress in improving Kohn-Sham (KS) density func- tional theory (DFT), one of the most popular computational techniques for materials and molecules, depends upon improved exchange-correlation (XC) functionals.[1] KS DFT assumes that non-interacting electrons and a local, multiplicative po- tential (i.e. KS potential) approximate the electron density of the real system’s interacting electrons. No systematic method for improving XC functionals has been identified within the KS system. Instead, functional development draws upon a broad array of techniques, methods, and data sources for guidance on how to produce more accurate approximations. One re- sourceful method is the KS inversion, which produces a KS potential from a provided electron density. Insight from KS inversions have been used in functional development since 1996 [2] and has seen a recent revival in its use today.[3, 4, 5] It has also become a useful tool for studying DFT methods, such as time-dependent DFT,[6, 7] density-corrected DFT, [8] inter-molecular interactions in partition-DFT [9, 10] and embedded-DFT,[11, 12, 13] and even in symmetry-adapted perturbation theory.[14] A KS inversion can construct an exact potential from an exact electron density as defined by the one-to-one density-to- potential mapping stated in the Hohenberg-Kohn theorem.[15] However, in practice, the finite number of localized basis sets needed to expand KS orbitals destroys the advantageous one-to-one mapping,[16, 17, 18] and the problem becomes ill-posed.[18] Although an exact KS inversion is no longer possible, several approximate methods[19, 20, 21, 22, 23, 24, 25, 13, 26, 27, 28] have been proposed. Despite the developed theory and applications of KS inver- sions, publicly available software for routinely performing these calculations is not common.[29] In this work, we introduce KS-pies, an open source implementation of the most frequently * [email protected] cited KS inversion methods, Zhao-Morrison-Parr[23] (ZMP) and Wu-Yang[24] (WY). Our WY implementation supports user-defined potential basis sets and Hamiltonians. This soft- ware includes a utility module that helps simplify inversion calculations by providing input file conversion function and and real-space evaluation of inversion potentials. The software is distributed under an open source Apache 2.0 licence and developer community is hosted though GitHub. Our Python implementation utilizes NumPy,[30] SciPy libraries,[31] and features from PySCF[32] that are familiar to the DFT community. A section of Python code can alterna- tively call kspies_fort, a compiled Fortran version that decreases computational cost. In this paper we include a theoretical summary, details on implementation, validation, and an appendix with a discussion based user-guide connecting technical features with examples that highlight the simplicity of incorporating KS inversions into modern functional development workflows. Emphasis on the theoretical background seeks to provide a simplified and practical entry point for theorists unfamiliar with the methodology. II. Background i. Kohn-Sham Density Functional Theory and its Inverse The conventional (forward) KS procedure solves a single parti- cle equation {- 1 2 2 + v S [n](r)}ψ i (r)= ε i ψ i (r), (1) where ψ i and ε i are i-th KS orbitals and orbital energies, v S [n](r) is the KS potential, and n is the electron density. Atomic units are used throughout unless specified. Typically v S [n](r) is written as v S [n](r)= v ext (r)+ v H [n](r)+ v XC [n](r), (2) 1 arXiv:2008.08783v2 [physics.comp-ph] 17 Feb 2021

Upload: others

Post on 21-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: KS-pies: Kohn-Sham Inversion Toolkit

KS-pies: Kohn-Sham Inversion Toolkit

SEUNGSOO NAM, HANSOL PARK, AND EUNJI SIM*

Department of Chemistry, Yonsei University, 50 Yonsei-ro Seodaemun-gu, Seoul 03722, KoreaRYAN J. MCCARTY

Departments of Chemistry, University of California, Irvine, CA 92697, USA

February 18, 2021

Abstract

A Kohn-Sham (KS) inversion determines a KS potential and orbitals corresponding to a given electron density, a procedure that hasapplications in developing and evaluating functionals used in density functional theory. Despite the utility of KS inversions, application ofthese methods among the research community is disproportionately small. We implement the KS inversion methods of Zhao-Morrison-Parrand Wu-Yang in a framework that simplifies analysis and conversion of the resulting potential in real-space. Fully documented Pythonscripts integrate with PySCF, a popular electronic structure prediction software, and Fortran alternatives are provided for computationalhot spots.

I. Introduction

Future progress in improving Kohn-Sham (KS) density func-tional theory (DFT), one of the most popular computationaltechniques for materials and molecules, depends upon improvedexchange-correlation (XC) functionals.[1] KS DFT assumesthat non-interacting electrons and a local, multiplicative po-tential (i.e. KS potential) approximate the electron density ofthe real system’s interacting electrons. No systematic methodfor improving XC functionals has been identified within the KSsystem. Instead, functional development draws upon a broadarray of techniques, methods, and data sources for guidanceon how to produce more accurate approximations. One re-sourceful method is the KS inversion, which produces a KSpotential from a provided electron density. Insight from KSinversions have been used in functional development since1996 [2] and has seen a recent revival in its use today.[3, 4, 5]It has also become a useful tool for studying DFT methods,such as time-dependent DFT,[6, 7] density-corrected DFT,[8] inter-molecular interactions in partition-DFT [9, 10] andembedded-DFT,[11, 12, 13] and even in symmetry-adaptedperturbation theory.[14]A KS inversion can construct an exact potential from an

exact electron density as defined by the one-to-one density-to-potential mapping stated in the Hohenberg-Kohn theorem.[15]However, in practice, the finite number of localized basissets needed to expand KS orbitals destroys the advantageousone-to-one mapping,[16, 17, 18] and the problem becomesill-posed.[18] Although an exact KS inversion is no longerpossible, several approximate methods[19, 20, 21, 22, 23, 24,25, 13, 26, 27, 28] have been proposed.

Despite the developed theory and applications of KS inver-sions, publicly available software for routinely performing thesecalculations is not common.[29] In this work, we introduceKS-pies, an open source implementation of the most frequently

*[email protected]

cited KS inversion methods, Zhao-Morrison-Parr[23] (ZMP)and Wu-Yang[24] (WY). Our WY implementation supportsuser-defined potential basis sets and Hamiltonians. This soft-ware includes a utility module that helps simplify inversioncalculations by providing input file conversion function andand real-space evaluation of inversion potentials. The softwareis distributed under an open source Apache 2.0 licence anddeveloper community is hosted though GitHub.Our Python implementation utilizes NumPy,[30] SciPy

libraries,[31] and features from PySCF[32] that are familiar tothe DFT community. A section of Python code can alterna-tively call kspies_fort, a compiled Fortran version thatdecreases computational cost.In this paper we include a theoretical summary, details on

implementation, validation, and an appendix with a discussionbased user-guide connecting technical features with examplesthat highlight the simplicity of incorporating KS inversionsinto modern functional development workflows. Emphasison the theoretical background seeks to provide a simplifiedand practical entry point for theorists unfamiliar with themethodology.

II. Background

i. Kohn-Sham Density Functional Theory and itsInverseThe conventional (forward) KS procedure solves a single parti-cle equation

{−12

∇2 + vS[n](r)}ψi(r) = εiψi(r), (1)

where ψi and εi are i-th KS orbitals and orbital energies,vS[n](r) is the KS potential, and n is the electron density.Atomic units are used throughout unless specified. TypicallyvS[n](r) is written as

vS[n](r) = vext(r)+ vH[n](r)+ vXC[n](r), (2)

1

arX

iv:2

008.

0878

3v2

[ph

ysic

s.co

mp-

ph]

17

Feb

2021

Page 2: KS-pies: Kohn-Sham Inversion Toolkit

where vext(r) is the external potential, vH[n](r) is the Hartreepotential

vH[n](r) =∫ n(r′)‖r− r′‖

dr′, (3)

and vXC[n](r) is an XC potential, which is approximate inpractice. The electron density is determined by the sum of theoccupied orbital densities as

n(r) =Nocc

∑i|ψi(r)|2. (4)

As a funcitonal of the density, vS[n](r) is used in Eq. 1 in a self-consistent field (SCF) procedure, until a converged electrondensity is determined.KS inversions operate in reverse, using a given density (of-

ten refered as target density, ntar(r)) to determine vS. Oncedetermined, vS and Eq. 1 produce the KS orbitals and associ-ated eigenvalues. In principle, one-to-one density-to-potentialmapping stated in the Hohenberg-Kohn theorem[15] guaran-tees that KS inversion can construct an exact KS potential(up to a constant) from an exact electron density. However,in practice, the finite number of localized basis sets neededto expand KS orbitals destroys the advantageous one-to-onemapping,[16, 17, 18] and the problem becomes ill-posed.[18]Although an exact KS inversion is no longer possible, severalapproximate methods[19, 20, 21, 22, 23, 24, 25, 13, 26, 27, 28]have been proposed. KS inversions have been developed foruse with input orbitals [33, 13] or wavefunctions,[34] but wefocus exclusively on density-based methods,[19, 20, 21, 22, 23,24, 25, 26, 27, 28] including ZMP[23] and WY,[24] which willbe explained in the following.

ii. Zhao-Morrison-ParrThe ZMP KS inversion method[23] minimizes an objectiveself-repulsion functional

C[nλ ] =∫∫

[nλ (r)−ntar(r)][nλ (r′)−ntar(r′)]‖r− r′‖

drdr′, (5)

by solving a KS-like equation self-consistently under a givenLagrange multiplier λ

{−12

∇2 + vS[ntar,nλ ](r)}ψλ

i (r) = ελi ψ

λi (r). (6)

A λ -dependent KS-potential

vS[ntar,nλ ](r) =vext(r)+ vH[ntar](r)

+ vg[ntar](r)+ vλC [n

tar,nλ ](r),(7)

includes a guiding potential vg(r) and correction potential

vλC [n

tar,nλ ](r) = λ

∫ nλ (r′)−ntar(r′)‖r− r′‖

dr′. (8)

In principle, as λ → ∞, C[nλ ]→ 0 and nλ → ntar. Only vλC

depends on λ in Eq. 7 and accommodates all necessary

potential modification. If provided, additional potential termsvext(r),vH(r), and vg(r) accelerate the convergence of vS withrespect to λ . In practice, Eq. 6 is solved self-consistently usinga given λ value. The obtained orbitals are used as an initialguess for following calculations at larger λ values, a processrepeated until λ become large enough.The guiding potential vg(r) mimics the XC potential, for

which a variety of potentials can be used. Typically vg(r)is initially formulated to mimic the asymptotic decay of XCpotential, −(1/N)vH(r), where N is the number of electrons.We refer −(1/N)vH(r) as FAXC, the non-Hartree portion ofthe Fermi-Amaldi potential.[35] In principle, any potential canbe used for vg(r) when the asymptotic decay of XC potentialis not important.[8]

For open-shell systems, ZMP is used as a spin-unrestrictedformalism.[36] The correction potential is spin-dependent, andEq. 8 is rewritten for α or β spin as

vλC,σ [n

tarσ ,nλ

σ ](r) = 2λ

∫ nλσ (r′)−ntar

σ (r′)‖r− r′‖

dr′, (9)

where σ denotes the spin index. The factor of 2 is requiredfor consistent results in closed-shell systems for restricted andunrestricted schemes. The guiding potential is spin-dependentfor standard DFT XC potentials, but not for FAXC.

iii. Wu-YangThe WY approach [24] maximizes an objective functional,

WS[{bt}] =N/2

∑i

∫|∇ψ

bi (r)|2dr

+∫

vbS[n

tar](r){nb(r)−ntar(r)}dr,

(10)

where vbS(r) is a KS-potential similar to Eq. 7 in ZMP, except

with vC(r) represented as a linear combination of potentialbasis functions gt(r), given as

vbC(r) = ∑

tbtgt(r), (11)

making vbS(r) exclusively a functional of the target density. KS

orbitals ψbi (r) are determined by solving a KS-like equation,

{−12

∇2 + vb

S[ntar](r)}ψb

i (r) = εbi ψ

bi (r), (12)

that does not require SCF procedure. The objective functionalWS is maximized by adjusting {bt}. The gradient and Hessianof WS with respect to {bt} is given in an analytical form

∂WS

∂bt=∫{nb(r)−ntar(r)}gt(r)dr, (13)

∂ 2WS

∂bt∂bu=

Nocc

∑i

Nvir

∑a

〈ψba|gt |ψb

i 〉〈ψba|gu|ψb

i 〉εb

i − εba

, (14)

2

Page 3: KS-pies: Kohn-Sham Inversion Toolkit

where Nocc (Nvir) denotes the number of occupied (virtual)orbitals, simplifying maximization of Eq. 10.In a spin-unrestricted formalism, Eq. 10 becomes

WS[{bt}] =12 ∑

σ

∑i

∫|∇ψ

bi,σ (r)|2dr

+∫{vext(r)+ vH[ntar](r)}{nb(r)−ntar(r)}dr

+∑σ

∫{vg,σ [ntar,ntar

σ ](r)+ vbC,σ (r)}

×{nbσ (r)−ntar

σ (r)}dr.

(15)

Spin dependence of XC potentials is reflected in the correction(vC) potential due to its spin dependence on {bt} and standardDFT XC guiding (vg) potentials.

Highly oscillatory XC potentials are a well-known drawbackof the WY method that often arise when using a large potentialbasis.[37] One solution to this problem is regularization withthe objective functional

W η

S ({bt}) =WS({bt})+η‖∇vbC(r)‖2, (16)

where η is a regularization strength hyperparamater, and thesmoothness of the correction potential is measured with

‖∇vbC(r)‖2 =

∫vb

C(r)∇2vb

C(r)dr. (17)

An optimal value of η must be selected. If η is too small,the potential may contain severe oscillations, but if η is toolarge, the optimized potential becomes too smooth and missesphysically important features. Heaton-Burgess and Yang[38]describes how this optimal selection can be made.

III. Implementation

i. Architecture and General workflow of KS-piesKS-pies consists of three sub-modules; zmp and wy, which arethe modules for KS inversion, and util module that supportsadditional utility functions to help prepare inputs to zmp andwy or analyze inversion results. To start inversion calculation(ZMP or WY) with KS-pies, two inputs are required: Moleobject and density matrix of the target density. Mole objectdefines standard details needed for quantum chemical calcula-tions, such as atomic coordinates, number of electrons, andbasis sets. This is exactly the Mole object defined in PySCF,which can be defined with only a few lines of code or loadedfrom a common geometry file such as xyz. The second input,density matrix, can be generated with PySCF calculationsor loaded from external file format such as molden.[39] Toextend accessibility to KS-pies and PySCF, util sub-modulein KS-pies also supports loading wfn file format, which issupported for variety of quantum chemistry programs, suchas Gaussian,[40] ORCA,[41] GAMESS,[42] and Molpro.[43]Target densities generated with quantum chemistry programs

that support molden or wfn formats can be used as inputsfor KS-pies.Performing an inversion calculation with KS-pies is very

similar to running KS-DFT calculation with PySCF. User canspecify algorithm-dependent options for running ZMP andWY calculations. All inversion calculations are defined as aclass object, and KS-pies manages data using Python instancevariables, storing the majority of results in memory. Data fromone instance can be used as an initial guess for subsequentcalculations or analysis within KS-pies or PySCF. util modulesupports additional utility functions to help prepare inputs tozmp and wy and analyze inversion results.

KS-pies makes use of analytical functions within the PySCFintegral library [44] to convert Eq. 6 and 12 to solvable matrixequations. The Hartree and guiding potentials are constructedfrom the target density using a matrix representation by default.KS-pies then uses a method-specific procedure to optimize thecorrection potential. For ZMP, a self-consistent calculationwith Eq. 6 and a user provided λ is performed. For WY, theobtained gradient (Eq. 13) and Hessian (Eq. 14), {bt} areadjusted to maximize Eq. 10 using SciPy optimizer.WY can accommodate non-Gaussian potential basis sets.

Although a Gaussian function is typically used to expand po-tentials due to its integration efficiency, Eq. 11 is not limitedto Gaussian type basis set. KS-pies accommodates this un-common feature and can handle user-defined potential basisset. When arbitrary user-defined potential basis sets are en-countered, a numerical integration of the three-center overlapintegral used in Eq. 10 is calculated with

Si jt =∫

φi(r)φ j(r)gt(r)dr, (18)

where φi(r) is i-th orbital basis function. Numerical integrationof Eq. 18 adds a substantial computational overhead at thebeginning of the calculation.Several features reduce the computational cost of deter-

mining the correction potential. For ZMP, recalculating theHartree potential at each self-consistent iteration can be accel-erated using a density fitting procedure. Density fitting resultsin minor differences in the inversion, while greatly reducing thecomputational cost. For WY, Eq. 13 and Eq. 14 are calculatedusing a Fortran module kspies_fort to provide a substan-tial time savings over a Python implementation. Compiledbinaries and the source code are provided.

ii. Real-Space PotentialsThe KS potential in real-space provides valuable insight beyonda target density calculation. For example, a major motivationfor performing a KS inversion is the visualization of the exactKS potential that can show the non-intuitive step structurespresent in some potentials.[45, 46] However, the use of finiteatom-centered Gaussian basis-sets prevents the XC potentialsproduced by ZMP and WY from being directly converted

3

Page 4: KS-pies: Kohn-Sham Inversion Toolkit

into real-space representation. For a given system, the ba-sis functions {φi(r)}, real-space function v(r) and its matrixrepresentation Vi j have the relation

v(r)→Vi j =∫

φi(r)v(r)φ j(r)dr, (19a)

Vi j→ v(r) = ∑i j

φi(r)Vi jφ j(r). (19b)

However, Eq. 19b is only exact under the basis set limit, and inpractice, would result in large errors in the real-space functionv(r). Therefore, a method other than Eq. 19b is requiredto obtain real-space values of v(r). This is necessary whenthe guiding or correction potential needs to be evaluated inreal-space. The method of Franchini et al.[47] for convertingHartree potentials can be applied to the FAXC guiding potentialand the ZMP correlation potential. A DFT XC potential onreal-space is necessary when ZMP or WY utilizes a DFT XCguiding potential.KS-pies evaluates real-space Hartree potentials following

Franchini et al.[47] In this approach, the density is decomposedinto one-center (i.e. atomic) contributions, and into differentangular contributions as

n(r) =Nnuc

∑i

ni(r) ≈Nnuc

∑i

lmax

∑l

∑m

Zlm(θi,ϕi)silm(ri), (20)

where Z represents real spherical harmonics and s is a cubicspline interpolation of radial density at the i-th atoms radialgrid. The summation inside Eq. 20 can be used to calculatethe Hartree potential for each angular contribution of i-thatom with analytical form

vH,lm(ri) =4π

2l + 1Zlm(θi,ϕi)

×( 1

rl+1i

∫ ri

0r′l+2si

lm(r′)dr′

+ rli

∫∞

ri

silm(r

′)

r′l−1 dr′)

.

(21)

This allows conversion of a density to a real-space Hartreepotential directly, without going through matrix representation,and is implemented in kspies.util.eval_vH.The kspies.util.eval_vxc function evaluates DFT

XC potential on user defined grid points. Our implementationis based on the numerical differentiation. For local densityapproximation functionals (LDA) we use,

vLDAXC (r) =

δEXC

δn=

dεLDAXC

dn(r), (22)

where εLDAXC is the XC density of LDA, and can be directly ob-

tained from pyscf.dft.libxc.eval_xc. For generalizedgradient approximation (GGA) functionals we use,

vGGAXC (r) = vn−2{∇n ·∇vγ + vγ ∇

2n}, (23)

where vn = ∂εGGAXC /∂n, vγ = ∂εGGA

XC /∂γ, and γ =∇n · ∇n. Although vn and vγ are obtainable frompyscf.dft.libxc.eval_xc, ∇vγ should be evalu-ated using a numerical derivative of vγ . For spin-polarizeddensities, Eq. 23 for α spin becomes

vGGAXC,α (r) = vnα

−2(∇nα ·∇vγαα+ vγαα

∇2nα )

−(∇vγαβ·∇nβ + vγαβ

∇2nβ ),

(24)

and the formulation for β spin requires a trivial swappingof respective spins. Eq. 23 and 24 are implemented inkspies.util.eval_vxc. Section vii Utility and associ-ated figures provide an example of obtaining real-space repre-sentation using these approaches.

IV. Validation and performance

Valid implementation is confirmed with accurate KS inversionsof densities obtained from HF or correlated wavefunction meth-ods, in both restricted and unrestricted schemes. Run timebenchmarks are reported as wall time and were performed anIntel(R) Xeon(R) Gold 6142 CPU using 8 processors at 2.6GHz. Calls to PySCF and kspies_fort can take advantageof parallelization with OpenMP. In our KS inversion examplesbelow, benzene used the most memory, approximately 1.2GB. The PySCF CCSD Calculation of molecular O2 used sub-stantially more memory, however, the inversion using KS-piesrequired less than that of benzene. Restricted and unrestrictedinversion benchmarks are included for convenience within thesoftware repository.

i. Restricted Inversion

1

10

100

1000

Tim

e (s

ec)

SCF

Itera

tions

λ

1e-5

1e-4

1e-3

1e-2

1e-1

dN (m

e)

1

10

100

1000

Inte

grat

ed d

ensi

ty d

iffer

ence

ZMP

self-

repu

lsio

n fu

nctio

nal C

[nλ ]

λ = 8 λ = 32

λ = 128 λ = 512

Angstroms0-0.05 0.05

C. Density error (target HF - ZMP)

B. Computational performance

A. Accuracy performance

10 2

milielectrons

DirectIterations Time

Density Fitting

DirectDensity Fitting

dN (me)C[nλ]

1

10

100

1000

10000

8 32 128 512

8 32 128 512

λ

Figure 1: A comparison of ZMP results with and without density fitting.For each λ value, level_shift was set to 0.1× λ . (a) Accuracyperformance evaluated by integrated density difference in milielectron(dN) and minimized self-repulsion functional value (Eq. 5). (b) Com-putational performance in terms of SCF iterations and time needed forconvergence. (c) Density difference between target HF density and ZMPdensities for increasing λ .

4

Page 5: KS-pies: Kohn-Sham Inversion Toolkit

Restricted inversion performance was validated using ZMPand WY on benzene (RCC = 1.3936 Åand RCH = 1.0852 Å).The target density was generated with HF/cc-pVTZ. Result-ing inversion potentials from ZMP and WY can be used toaccurately reproduce the target density. Furthermore, ZMP,qualitatively indicates that C (Eq. 8) is approaching 0 as λ

increases.kspies.zmp.RZMP (restricted ZMP) was used with a

FAXC guiding potential and tested with and without densityfitting. Using the self-repulsion functional value C from Eq. 5and the integrated density difference dN =

∫|nλ (r)−ntar(r)|dr,

we confirmed an expected decrease in C as λ increased. Thisis plotted in Figure 1a. As λ increases, dN also decreases.Our implementation shows negligible difference in accuracywith and without density fitting.

Computationally, the density fitting method decreases thecost of ZMP. Figure 1b plots computational performance interms of SCF iterations and run time per λ ; highlightingnegligible difference in the number of SCF cycles. Per SCFiteration, ZMP takes approximately 0.25 seconds with densityfitting and 3 seconds without, requiring around 700 iterationsto reach convergence on small molecules.

WY performance was evaluated using the same target densityas above and cc-pVTZ for the potential basis set. Optimizationwas complete after 8 iterations, taking less than 1 second ondefault settings. The maximum gradient element was 3×10−8

with dN = 170.8 me. The dN agrees with the values from ZMPat λ=128, indicating an accurately reproduced target density.Implementation verification is also incidentally discussed insection v where WY reproduces a target density from a user-defined harmonic potential Hamiltonian.

ii. Unrestricted Inversion

To validate the unrestricted calculations of ZMP and WY,we use a coupled-cluster singles-and-doubles (CCSD) targetdensity of molecular oxygen (ROO = 1.208 Å) obtained withUHF-UCCSD/cc-pVQZ. We used FAXC guiding potential forboth cases.

Benchmark values for ZMP with λ=2048 are C=1.10×10−6

and dN=5.75 me. A small and decreasing dN as λ is increasedconfirms the unrestricted ZMP implementation. As a secondaryvalidation benchmark, identical results are produced from spin-restricted and unrestricted ZMP calculation on closed-shellbenzene.

Benchmark values for WY with a cc-pVQZ potential basis setconverges after 5 optimization steps, taking 0.07 seconds, witha maximum gradient element of 3×10−8, and dN=36.3 me,which agrees with ZMP dN at λ=128, verifying the WYimplementation.

Position (atomic units)

Val

ues

(at

om

icu

nit

s)

Figure 2: Finite-difference HF target density (black) generated fromharmonic external potential (blue) and inverted density (red dashed) andKS potential (orange) generated with WY. For visibility, densities areincreased vertically 10× and density differences are increased 106×.

iii. Inversion of User-Defined SystemsWY inversions can be calculated on user-defined systems usingkspies.wy and a properly defined, user supplied, Hamil-tonian component. Figure 2 shows a calculated potentialfrom a user-defined Hamiltonian of a harmonic potential(vext(x) = 1/8x2,blue solid curve in Figure 2) with four elec-trons. Finite-difference HF with soft electron-electron repul-sion w(x1,x2) = 1/

√(x2− x1)2 + 0.52 was used to generate

the target density within the domain x ∈ [−10,10] and a gridspacing of 0.02. The WY calculation was then performed usingthe finite-difference method by providing a finite-differenceHamiltonian and using a grid to expand the potential.Section v and the online KS-pies documentation expand

upon the present example with information on how to obtainnecessary inputs for user-defined Hamiltonians.

The resulting WY KS potential for the user-defined harmonicpotential is displayed in orange in Figure 2. The KS potentialincludes small oscillations near x =±7 due to a known issue ofWY[18] arising from the small electron density in these regions.The oscillations are not a fault of our implementation. Theresulting potential, and its oscillations are not unique.[48] Inthe general use of WY, these oscillations can be influencedby conditions, such as the optimization scheme, convergencecriteria, or selection of a basis set. Nevertheless, the agreementof the density as represented by the red and black curves inFigure 2 highlights the accuracy of WY theoretically, as wellas our successful implementation.

V. Usage

To encourage the use of KS inversions in functional develop-ment, kspies requires only a few inputs. In appendix A we

5

Page 6: KS-pies: Kohn-Sham Inversion Toolkit

provide several examples that highlight the relative simplicity ofroutine KS inversions with and without real space conversions.The ZMP section details basic ZMP use, and the WY sectiondetails basic use as well as an example using regularizationand another using a user defined harmonic potential. Utilitymodule examples demonstrate importing target densities fromother software and analysis tools for evaluating and visualizingresulting KS potentials.The package can be easily installed from PyPI using pip

install kspies, and full documentation, examples fromthe appendix, and test scripts are available online. Frequentusers can compile a provide Fortran subroutine that improvesthe speed of WY calculations.

VI. Conclusion

KS-pies presents an open source, publicly available code forperforming KS inversions of electron densities into KS po-tentials. Since every KS inversion method is approximate,we implemented the two most cited inversion methods, ZMPand WY. Our software integrates with PySCF, an environ-ment familiar to the theoretical development community. Ourframework provides a starting point for the implementation offuture KS inversion methods. This publication presents thetheoretical context and examples that highlight the simplicityof running KS inversions. Incorporating KS inversion methodsto determine real-space potentials should be beneficial for XCfunctional development and testing.With two implemented methods, users are able to choose

and compare results, leveraging advantages of each method.ZMP requires many SCF iterations and is computationallyintensive relative to WY, but the result of inversion can besystematically improved by increasing λ . Alternatively, WYcan perform inversions on user-defined Hamiltonians and iscomputationally efficient. Potentials produced by both meth-ods can be converted into real space representations using oursoftware.

VII. Data availability

The KS-pies code is openly available on GitHub(https://github.com/ssnam92/KSPies) and can be ref-erenced via https://doi.org/10.25351/V3.KS-PIES.2020

Acknowledgement

We thank Kieron Burke for thoughtful manuscript feedback.S.N., H.P., and E.S. are thankful for support from the NationalResearch Foundation of Korea (NRF-2020R1A2C2007468 andNRF-2020R1A4A1017737). R.J.M is thankful for support fromthe University of California President’s Postdoctoral Fellowshipand the National Science Foundation (CHE 1856165).

A. Basic KS-pies Usage and Examples

i. Zhao-Morrison-Parr method

from pyscf import gto, scfimport kspies

mol_1 = gto.M(atom=’Ne’,basis=’aug-cc-pVTZ’)mf = scf.RHF(mol_1).run()P_tar_1 = mf.make_rdm1()

zmp_a = kspies.zmp.RZMP(mol_1, P_tar_1)zmp_a.zscf(8)

converged SCF energy = -128.5332728252 lambda=

8.00 niter: 11 gap= 0.6484575 dN= 155.54 C=

3.99e-03

Figure 3: Example inputs for calculating a ZMP KS inversion (top) andthe terminal outputs (bottom). PySCF is used to generate a Ne density,which is used in a ZMP KS inversion with λ = 8

ZMP calculations proceed by instantiating akspies.zmp.RZMP object and then calling zscf(l),which generates a KS potential with the user specified l, (λ ),value. The instance requires a Mole() object that defines thebasis set, and an atomic orbital representation of the targetdensity. Calculation results are printed to the terminal, anda matrix representation form of the potential is stored asinstance attributes. This can be converted into real-spacerepresentation with the later discussed kspies.utilmodule.Figure 3 demonstrates generating a Ne HF density using

PySCF, generating a KS potential with kspies.zmp, andthe run outputs printed to the terminal. Creating a RZMPinstance requires a Mole() object (mol_1) and density matrixof the target density (P_tar_1). In the output, niter is thenumber of SCF iterations needed to reach convergence, gapis the HOMO-LUMO gap in atomic unit, dN is the integrateddensity difference in millielectrons, and C is the minimizedvalue from Eq. 5. In unrestricted ZMP, resulting C valuesaccount for contributions from both spins, 2(Cα +Cβ ).Additional options in ZMP include:

(i) diis_space (int): DIIS space size. Default is 40.

(ii) max_cycle (int): Maximum SCF iterations. Default is400.

(iii) guide (character): Guiding potential. None setsvg(r) = −vH(r) (i.e. only the external and correctionpotential cover vs, see Eq. 7), ’faxc’ sets vg(r) =−vH(r)/N, or any DFT XC functional defined in PySCF

6

Page 7: KS-pies: Kohn-Sham Inversion Toolkit

zmp_b = kspies.zmp.RZMP(mol_1, P_tar_1)zmp_b.diis_space = 30zmp_b.max_cycle = 200zmp_b.guide = ’pbe’zmp_b.conv_tol_dm = 1e-10zmp_b.conv_tol_diis = 1e-7for l in [ 8, 32, 128, 512]:

zmp_b.level_shift = l*0.1zmp_b.zscf(l)

zmp_b.level_shift = 0.zmp_b.zscf(512)P = zmp_b.make_rdm1()print(’Expectation value:’,mf.energy_tot(P))print(zmp_b.mo_energy[2:6])print(’Converged?’, zmp_b.converged, zmp_b.l)

lambda= 8.00 niter: 12 gap= 0.6435071 dN=

83.32 C= 4.89e-04

lambda= 32.00 niter: 18 gap= 0.6719725 dN=

32.53 C= 7.77e-05

lambda= 128.00 niter: 26 gap= 0.6896898 dN=

9.89 C= 7.56e-06

lambda= 512.00 niter: 33 gap= 0.7009582 dN=

3.72 C= 7.25e-07

lambda= 512.00 niter: 9 gap= 0.7009582 dN=

3.72 C= 7.25e-07

Expectation value: -128.5330990412423

[-0.63510454 -0.63510454 -0.63510454 0.0658537

]

Converged? True 512

Figure 4: Example inputs for ZMP with DIIS settings at multiple λ

values using the mol_1 and P_tar_1 from Figure 3 (top). Terminaloutputs reporting ZMP potential results at the specified λ values anddetermined quantities form the final run (bottom).

can be specified at any additive value. For example,setting ’b3lyp-0.2*hf+0.2*faxc’ will remove theexact exchange portion from b3lyp potential and addreplace it with the faxc guiding potential.

(iv) level_shift (float): Amount of level shift used duringSCF cycles. Default is 0.2.

(v) with_df (boolean): Use of density fitting. Default isFalse.

(vi) conv_tol_dm (float): Density matrix convergence cri-teria. Default is 1e-7.

(vii) conv_tol_diis (float): Convergence criteria of DIISerror. Default is 1e-4.

Results from zscf(l) are stored as the following classattributes:

(i) converged (boolean): If convergence criteria was metduring SCF iterations

(ii) dm (array): Density matrix

(iii) mo_coeff (array): Molecular orbital coefficient

(iv) mo_energy (array): Molecular orbital energy

(v) mo_occ (array): Orbital occupation numbers

For kspies.zmp.UZMP, alpha and beta values for dm,mo_coeff, mo_energy, and mo_occ are stored as an or-dered pair tuple. The instance only stores one set of results;previous values will be overwritten and only the most recentcalculations results are accessible.

On the first zscf() SCF cycle the target density is used asthe initial density matrix guess, as demonstrated Figure 4 withP_tar_1. The guiding potential is constructed from userspecifications during the first call to the function. Subsequentchanges to the user specifications for the guiding potentialafter the first call are ignored.

The direct inversion of the iterative subspace (DIIS) proce-dure [49] for convergence stabilization implemented in ks-piesis independent of the PySCF DIIS options. We recommendsetting diis_space ≤ 40 to avoid a matrix singularity dur-ing DIIS extrapolation. DIIS convergence stabilization is notused when diis_space ≤ 1. ZMP often fails to convergewithout DIIS, and we recommend using this feature, even forsmall λ .When specified, virtual orbital energies are increased by

level_shift, which can aid convergence. In general, set-ting level_shift = 0.1×λ is likely to be sufficient formost systems. level_shift is inactive when set to 0. Whenλ is larger than 10 ∼ 20, level_shift values of 1 ∼ 2or larger are needed for convergence. The larger values forlevel_shift reduce the mixing between the occupied andvirtual orbits, which slows the orbital rotation with the intentof assisting convergence. In some systems, the initial ZMP iter-ations will significantly perturb the potential from a trajectorytowards convergence. Increasing level_shift to slow theorbital rotation as shown in Figure 4 can minimize or removethis effect. As level_shift is an artificial value added toaid in convergence, its contribution is ignored when calculatingproperties such as the HOMO-LUMO gap and orbital energies.

ii. Wu-Yang methodPerforming a KS inversion with kspies.wy requires an inputMole() object and target density, as demonstrated in Figure 5.The potential basis (pbas) defaults to the atomic orbitalbasis, and Sijt is integrated analytically. At the conclusionof Figure 5, the KS potential produced by maximizing WS isnow accessible as an instance attribute.

7

Page 8: KS-pies: Kohn-Sham Inversion Toolkit

wy_a = kspies.wy.RWY(mol_1, P_tar_1)wy_a.run()

Figure 5: Minimum inputs for a WY calculation using the predefinedMole() object (mol_1) and target density (P_tar_1) from Figure 3.

wy_b = wy.RWY(mol_1, P_tar_1,pbas=’aug-cc-pV5Z’)

wy_b.method = ’BFGS’wy_b.guide = ’blyp’wy_b.tol = 1e-7for eta in [ 1e-3, 1e-4, 1e-5, 1e-6 ]:

wy_b.reg = etawy_b.run()gap = wy_b.mo_energy[5] - wy_b.mo_energy[4]v = wy_b.Dvb()print(f’eta= {eta:.1e} gap: {gap:.5f}

v_grad: {v:.3f}’)

eta= 1.0e-03 gap: 0.67420 v_grad: 1.501eta= 1.0e-04 gap: 0.69885 v_grad: 2.741eta= 1.0e-05 gap: 0.71409 v_grad: 7.141eta= 1.0e-06 gap: 0.71568 v_grad: 12.703

Figure 6: Use of kspies.wy (top) and terminal outputs (bottom)using mol_1 and P_tar_1 as created in Figure 3.

wy_b.info()print(len(wy_b.b))print(wy_b.converged)

****Optimization Completed****after 325 iterations

func_value : -128.48469083max_grad : 0.00000004127True

Figure 7: Informational calls (top) and outputs (bottom) to the WYinstance from Figure 6. Outputs confirms a converged KS potential.

A second WY example in Figure 6 demonstrates additionaloptions and uses non-equivalent basis functions. The userspecifies the potential basis set with pbas, demonstrated inthe example with aug-cc-pV5Z. The terminal output (Figure 6,bottom) shows the HOMO-LUMO gap and the smoothness ofthe correction potential (Eq. 17) for each eta.

Figure 7 calls the instance from Figure 6 for information on

the run, the number of basis functions used in the potential,and confirmation on convergence. The instance overwritesitself after each calculation and the reported values are foreta = 1e-6.Options available in kspies.wy include:

(i) method (string): Optimization algorithm used inscipy.optimize.minimize. Default is ’trust-exact’.

(ii) guide (string): Guiding potential. Default is ’faxc’.Usage is same as guide in ZMP.

(iii) tol (float): Tolerance of the maximum gradient val-ues used to determine optimization completion (Eq. 13).Default is 1e-6.

(iv) reg (float): Potential regularization weight. (η in Eq. 16)Default is 0.

The molecular orbital coefficients, energies, occupation num-bers, density matrices, and convergence are all stored as in-stance attributes. Optimized {bt} values are stored as ’b’, andcan be useful as an initial guess for subsequent calculationsusing different regularization strength η , as demonstrated inthe for loop of Figure 6. Other notable methods include:make_rdm1() for generating a density matrix in the sameformat and method as the PySCF function of the same name,info() for printing optimization results, and Dvb() for cal-culating the smoothness of the correction potential (Eq. 17).A WY inversion may fail if the Scipy optimizer failed to

find a maximum WS. Common reasons for this failure withstraightforward solutions include: 1. The given electron densityis not vS-representable. As the target density cannot be re-constructed with a density from single-determinant. Schipperet al. 50 provide further discussion about vS-representability.2. A bad initial guess was used. By default, {bt} is initial-ized as zero. Users can specify an initial {bt} guess withthe b attribute, i.e., wy_a.b = b_init. For stretchedmolecules, an initial guess {bt} from less stretched calcula-tions may solve this failure. 3. A nearly singular Hessian wasencountered. This can occur when the potential basis is verylarge. We recommend a gradient-based optimization algo-rithm for these problems, such as conjugate gradient (CG) orBroyden–Fletcher–Goldfarb–Shanno (BFGS). 4. An unsuitableguiding potential was used. For example, using a semi-localDFT XC guiding potential for stretched ionic bond systemwould lead to failure in a similar nature to how a forwardKS calculation using the same functional may have troubleidentifying a converged density.[8]

iii. Regularized WYRegularized WY can compensate for issues resulting fromunbalanced potential basis sets. [37] Figure 8 provides exampleinputs on a N2 molecule, and Figure 9 displays example plots

8

Page 9: KS-pies: Kohn-Sham Inversion Toolkit

used to select the regularization parameter. kspies.wy.RWYrequires a Mole() object, a target density, and a large even-tempered Gaussian basis set for the potential calculation, allof which can be produced using PySCF.

mol_2 = gto.M(atom=’N 0 0 0 ; N 1.1 0 0’,basis=’cc-pVDZ’)

mf = scf.RHF(mol_2).run()P_tar_2 = mf.make_rdm1()

PBS = gto.expand_etbs([(0, 13, 2**-4 , 2),(1, 3 , 2**-2 , 2)])

wy_c = kspies.wy.RWY(mol_2, P_tar_2, pbas=PBS)wy_c.tol=1e-7

import numpy as npetas = [ 1/2**a for a in np.arange(5,27,1)]v = np.zeros(len(etas))W = np.zeros(len(etas))for i, eta in enumerate(etas):

wy_c.reg = etawy_c.run()v[i] = wy_c.Dvb()W[i] = wy_c.Ws

wy_c.reg = 0.wy_c.run()Ws_fin = wy_c.Ws

import matplotlib.pyplot as pltfig, ax = plt.subplots(2)ax[0].scatter(np.log10(Ws_fin-W), np.log10(v))ax[1].scatter(np.log10(etas),

v*etas/(Ws_fin-W))

Figure 8: Regularized WY calculations require an additional potentialbasis set and eta parameter. Selection of eta using a trial and errorprocess as plotted in Figure 9 is recommended.

The optimal regularization parameter, η can be identifiedusing the L-curve method of,[51] where the maximum value ofthe reciprocal derivative should be selected. As η decreases,W η

S approaches WS and the curvature of the KS potentialincreases (i.e. increasing ‖∇vb

C‖2). The need for regularizationarises because an unbalanced potential basis set may cause‖∇vb

C‖2 to increases sharply, but is not guaranteed to corre-spond with a significant decreases in WS−W η

S (see Figure 9a).This implies that the increase in potential curvature resultsfrom unphysical oscillation. According to,[37] an optimal η

gives a maximum reciprocal slope of the L-curve, which hasthe analytical form

(∂ log(‖∇vb

C‖2)

∂ log(WS−W η

S ))−1 = η

‖∇vbC‖2

WS−W η

S

, (25)

as identified by Bulat et al.[51] Using an N2 molecule with the

log10 ||v c ||2b( )

log10η||v c ||b( )Ws−W s

η

a)

b)

Figure 9: The L-curve (a) and its reciprocal derivative (b) used forselecting eta. The plots are outputs from Figure 8 and displayed herenext to the formulas used in the plot. The horizontal axis of (a) islog(WS−W η

S ) and of (b) is log(η). The optimal η value is the maximumof the reciprocal derivative, Eq. 25, approximately 10−4.2 as visible in(b).

cc-pVDZ basis and a HF target density, the reciprocal derivativeof the L-curve plotted for each η in Figure 9b), highlightsthe usefulness of this approach in selecting an optimal value;η ≈ 10−4.2 in the given example.

iv. WY for user-defined potential basis

def make_sto(zeta):def sto(coords):

dist = np.sum(coords**2,axis=1)**.5return np.exp(-zeta*dist)

return sto

pbas = []for zeta in [ 0.25, 0.5, 1., 2., 4., 8. ]:

pbas.append(make_sto(zeta))

mywy = kspies.wy.RWY(mol_1, P_tar_1, pbas=pbas)mywy.run()mywy.info()

Three-center overlap integral by numericalintegration

n1 : 46n2 : 6time: 0.0 min****Optimization Completed****

after 9 iterationsfunc_value : -128.48460973max_grad : 0.00000015

Figure 10: Informational calls (top) and outputs (bottom) to the WYinstance from Figure 6. Outputs confirms a converged KS potential.

9

Page 10: KS-pies: Kohn-Sham Inversion Toolkit

Although Gaussian functions are typically used to expandcorrection potential in WY due to their integration efficiency,this basis choice is not mandatory. KS-pies can perform WYcalculation on any user-defined potential basis. Figure 10shows example of using Slater-type basis functions to expandthe WY correction potential. A user can designate pbas as alist of functions that take Bohr-unit xyz coordinates as inputsand return a value for each coordinates. Using this pbas,kspies.wy will then numerically calculate the three-centeroverlap integral and perform a WY calculation with it. Notethat numerical integration of the three-center overlap integraladds an initial computing cost which can be substantial forlarge systems.

v. WY for user-defined systemsKS-pies can calculate a WY KS potential for user-definedHamiltonians in the restricted and unrestricted formalism, asdemonstrated in Figure 11. A user must provide a Mole()object (mol), target density density matrix (P_tar), and aSijt array to instantiate a user defined system, as well asthe following instance attributes: Kinetic energy T, externalpotential V, overlap matrix S, kinetic energy matrix of thepotential basis Tp, and a None override to prevent defaultuse of a guiding potential.

wy_d = kspies.wy.RWY(mol, P_tar, Sijt=Sijt)wy_d.T = Kinetic_matrixwy_d.Tp = Kinetic_matrix_potential_basiswy_d.V = Potential_matrixwy_d.S = Overlap_matrixwy_d.guide = Nonewy_d.run()

Figure 11: An example input for running WY with a user-defined Hamil-tonian, where the user has calculated all the necessary variables. Seethe online documentation for additional examples.

vi. Utility for cross-platform inputsThe kspies.util.wfnreader function loads wfn file for-mats as generated by many quantum chemistry packages, suchas Gaussian,[40] ORCA,[41] GAMESS,[42] and Molpro,[43]and converts it into the PySCF format used in kspies. Figure 12shows an example usage of kspies.util.wfnreader toread wavefunction information from a ccsd.wfn file. Notethat system information such as nuclear coordinates, numberof electrons, and basis sets stored in wfn format should be thesame as in mol. The dm_tar output in the second line ofFigure 12 is ready to serve as a target density for ZMP or WY.Of course, users also can use PySCF default conversion

tools to load densities that are generated with other platforms,which can extend the usability of KS-pies.

mo_coeff, mo_occ, mo_energy =kspies.util.wfnreader(’ccsd.wfn’, mol)

dm_tar = scf.hf.make_rdm1(mo_coeff, mo_occ)

Figure 12: Example for loading wfn file to PySCF.

vii. Evaluation utility

coords = []for x in np.linspace(0, 3, 1001):

coords.append((x, 0., 0.))coords = np.array(coords)

zmp_c = kspies.zmp.RZMP(mol_1, P_tar_1)zmp_c.guide = ’faxc’for l in [ 16, 128, 1024 ]:

zmp_c.level_shift = 0.1*lzmp_c.zscf(l)dmxc = l*zmp_c.dm - (l +

1./mol_1.nelectron)*P_tar_1vxc = kspies.util.eval_vh(mol_1, coords,

dmxc )plt.plot(coords[:, 0], vxc, label =

r’$\lambda$=’+str(l))

Figure 13: An example script using kspies.util.eval_vh forvisualizing XC potential obtained with ZMP. Plotting and formattingcommands, such as plt.show(), are omitted, but included in addi-tional examples available in the online documentation. An exampleplot is shown in Figure 15a. mol_1 and P_tar_1 are as defined inFigure 3.

The usage of kspies.util.eval_vh function for eval-uating XC potentials (Figure 15a) is presented in Figure 13.Referring to the example, kspies.util.eval_vh requiresa Mole() object (mol), density matrix to calculate Hartree po-tential (dmxc), and specified xyz-coordinates (coords) thatdescribe the positions of grid points that are to be calculated.At a given λ , the ZMP XC potential can be written as

vXC(r) = −1N

vH[ntar](r)+λ (vH[nλ ](r)− vH[ntar](r))

= vH[λnλ − (1N+λ )ntar](r),

(26)

indicating that the XC potential obtained from ZMP at the spe-cific λ , is the Hartree potential of the density λnλ − ((1/N)+λ )ntar.An example of kspies.util.eval_vxc is used in Fig-

ure 14 to create the visualization of the WY XC potentialin Figure 15b. The finite difference required for numericaldifferentiation of vγ in Eq. 23 and Eq. 24 is set with delta(atomic units) in eval_vxc, and defaults to 1e−7.

10

Page 11: KS-pies: Kohn-Sham Inversion Toolkit

wy_e = kspies.wy.RWY(mol_1, P_tar_1,pbas=’cc-pVQZ’)

wy_e.method = ’BFGS’wy_e.guide = ’pbe’wy_e.tol = 1e-7

from pyscf import dftao2 = dft.numint.eval_ao(wy_e.pmol, coords)vg = util.eval_vxc(mol_1, P_tar_1, ’pbe’,

coords, delta=1e-8)

for eta in [1e-2, 1e-3, 1e-4, 1e-5, 1e-6]:wy_e.reg = etawy_e.run()vC = np.einsum(’t,rt->r’, wy_e.b, ao2)plt.plot(coords[:,0], vg+vC, label=str(eta))

Figure 14: An example script using eval_vxc for visualizing XCpotential obtained with WY. The resulting plot is shown in Figure 15b.mol_1 and P_tar_1 are as defined in Figure 3.

(a) (b)

Figure 15: The exchange potential of atomic Ne produced using Fig-ure 13 (a) and Figure 14 (b). The horizontal axis denotes the distancefrom the Ne nucleus in Bohr, and the vertical axis denotes the exchangepotential obtained from the inversion of the HF density in atomic units.These examples are included in the online documentation, and users canconfigure the code to display regions of interest.

Either ZMP or WY methods can beused with kspies.utils.eval_vh andkspies.utils.eval_vxc. Some useful possibili-ties beyond our current examples include using ZMP withPBE XC guiding potential, to draw PBE XC potentialwith kspies.utils.eval_vxc and ZMP correctionpotential with kspies.utils.eval_vh. Visualizationwith kspies.utils is not limited to XC potential obtainedfrom KS inversion, but can be used independently with KSinversion.

References

[1] K. Burke, J. Chem. Phys. 136, 150901 (2012),https://doi.org/10.1063/1.4704546 .

[2] D. J. Tozer, V. E. Ingamells, and N. C. Handy, J. Chem.Phys. 105, 9200 (1996).

[3] R. Nagai, R. Akashi, S. Sasaki, and S. Tsuneyuki, J. Chem.Phys. 148, 241737 (2018).

[4] T. Naito, D. Ohashi, and H. Liang, J. Phys. B: At. Mol.Opt. Phys. 52, 245003 (2019).

[5] Y. Zhou, J. Wu, S. Chen, and G. Chen, J. Phys. Chem.Lett. 10, 7264 (2019).

[6] P. Bleiziffer, A. Heßelmann, C. Umrigar, and A. Görling,Phys. Rev. A. 88, 042513 (2013).

[7] J. Kaur, E. Ospadov, and V. N. Staroverov, J. Chem.Theory Comput. 15, 4956 (2019).

[8] S. Nam, S. Song, E. Sim, and K. Burke, J. Chem. TheoryComput. 16, 5014 (2020).

[9] P. Elliott, K. Burke, M. H. Cohen, and A. Wasserman,Phys. Rev. A. 82, 024501 (2010).

[10] J. Nafziger and A. Wasserman, J. Phys. Chem. A 118,7623 (2014).

[11] J. D. Goodpaster, N. Ananth, F. R. Manby, and T. F.Miller, J. Chem. Phys. 133, 084103 (2010).

[12] M. Banafsheh and T. Adam Wesolowski, Int. J. QuantumChem. 118, e25410 (2018).

[13] X. Zhang and E. A. Carter, J. Chem. Phys. 148, 034105(2018).

[14] A. D. Boese and G. Jansen, J. Chem. Phys. 150, 154101(2019).

[15] P. Hohenberg and W. Kohn, Phys. Rev. 136, B864(1964).

[16] S. Hirata, S. Ivanov, I. Grabowski, R. J. Bartlett, K. Burke,and J. D. Talman, J. Chem. Phys. 115, 1635 (2001).

[17] V. Staroverov, G. Scuseria, and E. Davidson, J. Chem.Phys. 124, 141103 (2006).

[18] D. S. Jensen and A. Wasserman, Int. J. Quantum Chem.118, e25425 (2018).

[19] C.-O. Almbladh and A. C. Pedroza, Phys. Rev. A. 29,2322 (1984).

[20] A. Görling, Phys. Rev. A. 46, 3753 (1992).

[21] Y. Wang and R. G. Parr, Phys. Rev. A. 47, R1591 (1993).

11

Page 12: KS-pies: Kohn-Sham Inversion Toolkit

[22] R. Van Leeuwen and E. Baerends, Phys. Rev. A. 49, 2421(1994).

[23] Q. Zhao, R. C. Morrison, and R. G. Parr, Phys. Rev. A.50, 2138 (1994).

[24] Q. Wu and W. Yang, J. Chem. Phys. 118, 2498 (2003).

[25] I. G. Ryabinkin and V. N. Staroverov, J. Chem. Phys.137, 164113 (2012).

[26] K. Finzel, P. W. Ayers, and P. Bultinck, Theor. Chem.Acc. 137, 30 (2018).

[27] B. Kanungo, P. M. Zimmerman, and V. Gavini, Nat.Commun. 10, 1 (2019).

[28] T. J. Callow, N. N. Lathiotakis, and N. I. Gidopoulos, J.Chem. Phys. 152, 164114 (2020).

[29] J. P. Unsleber, T. Dresselhaus, K. Klahr, D. Schnieders,M. Böckers, D. Barton, and J. Neugebauer, J. Comput.Chem. 39, 788 (2018).

[30] S. v. d. Walt, S. C. Colbert, and G. Varoquaux, Comput.Sci. Eng. 13, 22 (2011).

[31] P. Virtanen, R. Gommers, T. E. Oliphant, M. Haberland,T. Reddy, D. Cournapeau, E. Burovski, P. Peterson,W. Weckesser, J. Bright, S. J. van der Walt, M. Brett,J. Wilson, K. Jarrod Millman, N. Mayorov, A. R. J. Nelson,E. Jones, R. Kern, E. Larson, C. Carey, İ. Polat, Y. Feng,E. W. Moore, J. Vand erPlas, D. Laxalde, J. Perktold,R. Cimrman, I. Henriksen, E. A. Quintero, C. R. Harris,A. M. Archibald, A. H. Ribeiro, F. Pedregosa, P. vanMulbregt, and S. . . Contributors, Nat. Methods 17, 261(2020).

[32] Q. Sun, T. C. Berkelbach, N. S. Blunt, G. H. Booth,S. Guo, Z. Li, J. Liu, J. D. McClain, E. R. Sayfutyarova,S. Sharma, S. Wouters, and G. K.-L. Chan, Wiley Inter-discip. Rev.: Comput. Mol. Sci. 8, e1340 (2018).

[33] A. P. Gaiduk, I. G. Ryabinkin, and V. N. Staroverov, J.Chem. Theory Comput. 9, 3959 (2013).

[34] I. G. Ryabinkin, S. V. Kohut, and V. N. Staroverov, Phys.Rev. Lett. 115, 083001 (2015).

[35] E. Fermi and E. Amaldi, Accad. Ital. Rome. 6, 117 (1934).

[36] D. J. Tozer, N. C. Handy, and W. H. Green, Chem. Phys.Lett. 273, 183 (1997).

[37] T. Heaton-Burgess, F. A. Bulat, and W. Yang, Phys. Rev.Lett. 98, 256401 (2007).

[38] T. Heaton-Burgess and W. Yang, J. Chem. Phys. 129,194102 (2008).

[39] G. Schaftenaar and J. H. Noordik, J. Comput. Aid. Mol.Des. 14, 123 (2000).

[40] M. J. Frisch, G. W. Trucks, H. B. Schlegel, G. E. Scuseria,M. A. Robb, J. R. Cheeseman, G. Scalmani, V. Barone,G. A. Petersson, H. Nakatsuji, X. Li, M. Caricato, A. V.Marenich, J. Bloino, B. G. Janesko, R. Gomperts, B. Men-nucci, H. P. Hratchian, J. V. Ortiz, A. F. Izmaylov, J. L.Sonnenberg, D. Williams-Young, F. Ding, F. Lipparini,F. Egidi, J. Goings, B. Peng, A. Petrone, T. Hender-son, D. Ranasinghe, V. G. Zakrzewski, J. Gao, N. Rega,G. Zheng, W. Liang, M. Hada, M. Ehara, K. Toy-ota, R. Fukuda, J. Hasegawa, M. Ishida, T. Nakajima,Y. Honda, O. Kitao, H. Nakai, T. Vreven, K. Throssell,J. A. Montgomery, Jr., J. E. Peralta, F. Ogliaro, M. J.Bearpark, J. J. Heyd, E. N. Brothers, K. N. Kudin,V. N. Staroverov, T. A. Keith, R. Kobayashi, J. Nor-mand, K. Raghavachari, A. P. Rendell, J. C. Burant, S. S.Iyengar, J. Tomasi, M. Cossi, J. M. Millam, M. Klene,C. Adamo, R. Cammi, J. W. Ochterski, R. L. Martin,K. Morokuma, O. Farkas, J. B. Foresman, and D. J.Fox, Gaussian~16 Revision C.01 (2016), gaussian Inc.Wallingford CT.

[41] F. Neese, Wiley Interdiscip. Rev.: Comput. Mol. Sci. 8,e1327 (2018).

[42] G. M. J. Barca, C. Bertoni, L. Carrington, D. Datta,N. De Silva, J. E. Deustua, D. G. Fedorov, J. R. Gour,A. O. Gunina, E. Guidez, T. Harville, S. Irle, J. Ivanic,K. Kowalski, S. S. Leang, H. Li, W. Li, J. J. Lutz,I. Magoulas, J. Mato, V. Mironov, H. Nakata, B. Q.Pham, P. Piecuch, D. Poole, S. R. Pruitt, A. P. Rendell,L. B. Roskop, K. Ruedenberg, T. Sattasathuchana, M. W.Schmidt, J. Shen, L. Slipchenko, M. Sosonkina, V. Sun-driyal, A. Tiwari, J. L. Galvez Vallejo, B. Westheimer,M. Wloch, P. Xu, F. Zahariev, and M. S. Gordon, J.Chem. Phys. 152, 154102 (2020).

[43] H.-J. Werner, P. J. Knowles, G. Knizia, F. R. Manby, andM. Schütz, Wiley Interdiscip. Rev.: Comput. Mol. Sci. 2,242 (2012).

[44] Q. Sun, J. Comput. Chem. 36, 1664 (2015).

[45] R. Van Leeuwen, O. Gritsenko, and E. J. Baerends, Z.Phys. D. 33, 229 (1995).

[46] S. V. Kohut, A. M. Polgar, and V. N. Staroverov, Phys.Chem. Chem. Phys. 18, 20938 (2016).

[47] M. Franchini, P. H. T. Philipsen, E. van Lenthe, andL. Visscher, J. Chem. Theory Comput. 10, 1994 (2014).

[48] C. R. Jacob, J. Chem. Phys. 135, 244102 (2011).

[49] P. Pulay, Chem. Phys. Lett. 73, 393 (1980).

12

Page 13: KS-pies: Kohn-Sham Inversion Toolkit

[50] P. Schipper, O. Gritsenko, and E. Baerends, Theor. Chem.Acc. 99, 329 (1998).

[51] F. A. Bulat, T. Heaton-Burgess, A. J. Cohen, andW. Yang, J. Chem. Phys. 127, 174101 (2007).

13