Analytical nuclear gradients for fully internally contracted complete active space second-order perturbation theory (CASPT2) are reported. This implementation has been realized by an automated code generator that can handle spin-free formulas for the CASPT2 energy and its derivatives with respect to variations of molecular orbitals and reference coefficients. The underlying complete active space self-consistent field and the so-called Z-vector equations are solved using density fitting. The implementation has been applied to the vertical and adiabatic ionization potentials of the porphin molecule to illustrate its capability.

Substantial effort has been devoted to implementing complex formulas in quantum chemistry, resulting in accurate and useful computational tools for chemical applications. However, some equations are too complicated to be handled manually. Among such examples is the analytical nuclear gradient theory of fully internally contracted complete active space second-order perturbation theories (FIC-CASPT2 or simply CASPT2)1–3 and its variants,4–6 whose complexity has hampered their implementation for more than two decades since FIC-CASPT2 was developed.1 In this study, we address this problem by employing an automatic code generation approach to help enable many chemical applications. For instance, such implementations can be used for the geometry optimization7 of strongly correlated molecules as complex as those investigated by respective single-point calculations. They also have the potential to replace mean-field models (e.g., complete active space self-consistent field or CASSCF) often used in photodynamics simulations involving the ground and excited states of molecules.8 

The challenge in implementing the nuclear gradients for the FIC-CASPT2 method can be easily recognized as follows. The state-specific CASPT2 energy functional for the nth state is

(1)

in which f ˆ is the standard state-specific Fock operator, and E 0 ( n ) = Φ 0 | f ˆ | Φ 0 . The reference and correlated wave functions are defined as (using the reference CI coefficients c I ( n ) )

(2)
(3)

where I labels Slater determinants, and E ˆ Ω are external and semi-external excitation operators (such as E ˆ a i , b j and E ˆ r s , a t ).1 In this article, a and b label virtual orbitals, i and j label closed orbitals, r, s, t, and u label active orbitals, and x, y, z, and w label any orbitals. The energy functional E is minimized with respect to the TΩ amplitudes to give the CASPT2 energy. The nuclear energy gradients are the total derivative of the energy with respect to nuclear displacements R,

(4)

in which C is the molecular-orbital coefficient matrix parameterized by an anti-Hermitian matrix κ,

(5)

The first term on the right hand side of Eq. (4) is the Hellmann–Feynman force,9 and the second term is zero in the simplest state-specific CASPT2 case because E is stationary with respect to variation of TΩ. The third term also appears in the standard single-reference algorithms. The complexity of the equations for FIC-CASPT2 nuclear gradients stems from the last term, which is associated with the reference-coefficient derivatives; since the first-order wave functions are expanded in a basis that is dependent on c I ( n ) [Eq. (3)], every single term in E contributes to E / c I ( n ) in a nontrivial way.

The use of partially internally contracted or uncontracted basis functions10 (referred to as WK-CASPT2 in the following) for first-order wave functions greatly simplifies the equations, making it tractable to manually implement nuclear gradients for such variants.11–15 This is because, in these methods, parts (or all) of the first-order wave function are expanded in terms of excited Slater determinants,

(6)

which are not dependent on c I ( n ) (note that in practice only distinct determinants are included in the sum). There is also an implementation of nuclear gradients of uncontracted multireference configuration interaction (MRCI).16 However, the formal scaling of the size of first-order wave functions in these methods is factorial with respect to the number of active orbitals, rendering them sub-optimal for large calculations.4 

Over the last decade, various automatic code generation approaches have been developed to replace tedious, error-prone manual implementation processes in quantum chemistry.17 The automated higher-order coupled-cluster (CC) implementations by Kállay and Surján18 and by Hirata19,20 were the first to demonstrate that the automation strategy can produce programs that are competitive with hand-optimized codes in serial and massively parallel environments, respectively. Hanrath and co-workers have realized an arbitrary-order CC code generator that is almost optimal.21,22 Recently, this strategy has been extended to various methods such as CC-F12,23–26 relativistic CC,27 local CC,28,29 open-shell CC,30,31 and excited-state CC methods.20,32 Note that these automation techniques are complementary to meta-language approaches (such as sial,33itf,34libtensor,35tiledarray,36 to name a few), because code generators can be used to synthesize computer codes in any meta-language as well.

Furthermore, the automation strategy has been applied to development of multireference electron correlation theories. Neuscamman et al. used an automated scheme for the canonical transformation theory;37 Parkhill et al. developed local active-space methods (e.g., an active-space perfect quadruples model38) using a sparse framework;39 Hanauer and Köhn extended their string-based code to implement an internally contracted MRCC method.40 Saitow et al. reported a fully internally contracted MRCI method based on density-matrix-renormalization-group reference functions.41 

In this work, we extend the automatic code generation approach to realize FIC-CASPT2 nuclear gradients that have been sought for a long time. Following the standard approach,9,13 we use the CASPT2 Lagrangian and the so-called Z-vector equation,42 instead of directly evaluating Eq. (4), to avoid computation of geometry derivatives of wave function parameters (such as d c I ( m ) / d R ). The state-specific CASPT2 Lagrangian is13 

(7)

Each term on the right hand side (other than E ) corresponds to a constraint arising from the CASSCF reference calculation. A is the orbital gradient of CASSCF, and Z is its Lagrange multiplier. S is the overlap matrix, and X is the Lagrange multiplier for orbital orthogonality. The next two terms are related to the stationary condition in the full configuration interaction in the active space performed in CASSCF. Here, m labels states averaged in CASSCF and Wm is the weight in the state averaging. The final term originates from the use of the frozen core approximation in CASPT2. See details in Ref. 13. When the stationary conditions on L with respect to all the parameters and multipliers are met, the nuclear gradients can be computed as

(8)

since only molecular integrals have explicit dependence on the nuclear displacement R. We will consider level shifts43 in future work, which requires the additional implementation of the so-called λ equation (as do multistate variants14).

We have developed a new automated code generator, named smith3, that derives equations on the basis of the spin-free version of Wick’s theorem in which the normal ordering is defined with respect to the closed-Fock vacuum. In addition, smith3 expresses the terms that involve active-orbital indices as a sum of canonical terms so that they can be computed from canonical density matrices and its derivatives, e.g.,

(9a)
(9b)

with σ and ρ labeling spins. Note that ( Γ 0 ) Λ = Φ 0 | E ˆ Λ | Φ 0 and ( Γ 0 ) Λ I = I | E ˆ Λ | Φ 0 , where E ˆ Λ is a general operator. Here, smith3 is used to implement the following expressions:

(10a)
(10b)
(10c)

in which | Ψ = I t I | I is any multi-configuration reference function, and G ˆ = Λ G Λ E ˆ Λ and R ˆ = Ω R Ω E ˆ Ω are general and excitation operators, respectively. Note that the determinant index I is treated analogously to the orbital indices in the generated code; for instance, ( Γ 0 ) t u I is viewed as a three-index tensor whose size is n det n act 2 (ndet and nact are the numbers of the determinants and the active orbitals, respectively).

Using this machinery, we automate the nuclear-gradient implementation as follows. First, to optimize TΩ, the program for computing the CASPT2 residual vectors is generated using Eq. (10a), i.e.,

(11)

Second, the Z-CASSCF equation is solved, which is a set of coupled equations defined as

(12a)
(12b)

For Eq. (12a), the reference-coefficient derivatives of the CASPT2 energy,

(13)

are implemented by smith3 using Eq. (10c). Next, for Eq. (12b) the MO-coefficient derivatives of the CASPT2 energy,

(14)

are calculated from the one- and two-body density matrices (see Refs. 13 and 15 for explicit formulas). The density matrices are defined as

(15a)
(15b)
(15c)

and are implemented using Eq. (10b). Given y I ( n ) and Yrs, solutions of Z-CASSCF [Z, X, z I ( m ) , and zij in Eq. (7)] can be obtained as detailed in Ref. 13. Using these wave function parameters and the Lagrange multipliers, effective density matrices are formed, which are then contracted to two-index and three-index gradient integrals.13,15

The generated code uses a tile-based data layout that is similar to that used in tce19 and in the earlier version of smith.23,24 All the codes implemented in the bagel package44 and the code generator smith345 are openly available under the GNU General Public License. The technical details on the implementation, working equations, and source code of the smith3 program are also found in supplementary material.46 CASSCF and Z-CASSCF were manually implemented in bagel using density fitting (DF) for efficiency as reported in Ref. 15. In CASPT2, four-index two-external integrals were explicitly constructed from DF integrals. The smith3 program generated ca. 1150 tasks, the majority of which are tensor contractions. Each task is expressed as a node of a tree-like directed acyclic graph, which we traverse at runtime. This infrastructure should assist in interfacing smith3 code to parallel-runtime libraries in the future.

First, to show the numerical impact of full internal contraction on geometrical parameters, we optimized the ground-state geometry of the N,N ′-diiminato-copper-dioxygen complex [(H5C3N2)CuO2] in its side-on coordination configuration. The ground state is singlet. We used the (14e, 9o) active space consisting of an in-plane d orbital of copper and eight valence orbitals of dioxygen as suggested in earlier work.15,34 The aug-cc-pVDZ47,48 and def2-QZVPP/JKFIT49 basis sets were used for orbital and auxiliary functions, respectively. Table I compiles optimized Cu–O and O–O bond lengths. It is evident that neither the degrees of internal contraction (i.e., CASPT2 and WK-CASPT2) nor the DF approximation has impact on the bond lengths. Our program did not take advantage of spatial symmetry. One optimization step took about 13 min using 2 Xeon E5-2650 CPUs (2.0 GHz). More than half the time is spent for evaluation of Eq. (13). Note, however, that the code generated by smith3 has not been threaded efficiently, and there is room for further improvement.

TABLE I.

Optimized Cu–O and O–O bond lengths (in Å) for the ground state of (H5C3N2)CuO2 using CASSCF and CASPT2 with aug-cc-pVDZ and the (14e, 9o) active space. DF was used unless otherwise stated.

Method Cu–O O–O
CASSCF  1.886  1.386 
CASPT2  1.820  1.399 
WK-CASPT2a  1.820  1.400 
WK-CASPT2 (w/o DF)a  1.820  1.400 
Method Cu–O O–O
CASSCF  1.886  1.386 
CASPT2  1.820  1.399 
WK-CASPT2a  1.820  1.400 
WK-CASPT2 (w/o DF)a  1.820  1.400 
a

Partially contracted CASPT2 computed using molpro.50 

Next, we calculated the vertical and adiabatic ionization potentials (IPs) of the porphin molecule (C20H14N4) using the optimized geometries computed by CASPT2. The cc-pVDZ basis set47 was used together with the corresponding JKFIT basis set51 for DF. The (4e, 4o) and (3e, 4o) active spaces were used,46 which consist of the four frontier orbitals of Gouterman’s model.52 The numbers of (correlated) inactive and virtual orbitals were 55 and 323, respectively. One optimization step took about 30 min on the same hardware. For comparison, we also computed the IPs from the PBE functional53 and MP2 (with an unrestricted variant for the radical cation) using turbomole.54 The PBE calculations were performed using the def2-SVP basis set.55 Geometry optimization using all methods including CASPT2 was performed without imposing spatial symmetry; the geometry of the neutral porphin was found to belong to the D2h symmetry group, whereas that of the radical cation was found to be C2h (even when an initial geometry was set to a D2h structure, optimization converged to this minimum). Similar symmetry breaking of metalloporphyrin cation radicals due to the pseudo-Jahn–Teller effect has been reported in the literature.56 The optimized geometry of the radical cation from unrestricted PBE was found to be D2h. We were not able to optimize the geometry of the radical cation using unrestricted MP2 due to wave function instability. The geometrical parameters are compiled in supplementary material.46 The IPs are shown in Table II. The vertical IP computed by CASPT2 (6.84 eV) is in good agreement with the experimental value (6.9 eV).57 The difference between the vertical and adiabatic IPs computed at 0.18 eV is an order of magnitude larger than that computed using PBE. Furthermore, we computed the IPs with CASPT2 using the PBE-optimized geometries. As expected, the vertical IP is almost identical to that computed at the CASPT2 geometry; however, the adiabatic IP is larger than the vertical IP, which attests to the importance of geometry optimization at the CASPT2 level.

TABLE II.

Ionization potentials (eV) of the porphin molecule. The cc-pVDZ basis set was used unless otherwise stated. The (4e, 4o) and (3e, 4o) active spaces were used in the CASPT2 calculations.

Method Vertical IP Adiabatic IP ΔIP S2a
PBEb  6.70  6.68  0.02  0.77 
MP2  8.51  c  …  1.47 
CASPT2  6.84  6.65  0.18  0.75 
CASPT2/PBE  6.83  6.85  −0.02  0.75 
Experimentd  6.9  …  …  … 
Method Vertical IP Adiabatic IP ΔIP S2a
PBEb  6.70  6.68  0.02  0.77 
MP2  8.51  c  …  1.47 
CASPT2  6.84  6.65  0.18  0.75 
CASPT2/PBE  6.83  6.85  −0.02  0.75 
Experimentd  6.9  …  …  … 
a

S2〉 of the radical cation at the equilibrium geometry of the neutral.

b

Computed using the def2-SVP basis set.

c

Due to instability, we could not optimize the geometry of the radical cation.

d

Taken from Ref. 57.

In summary, we have used automatic code generation to realize analytical CASPT2 nuclear gradients with full internal contraction. Our implementation has been applied to the N,N ′-diiminato-copper-dioxygen complex to show that errors due to full internal contraction are marginal. We have also computed the vertical and adiabatic IPs of the porphin molecule to illustrate the capability of our implementation. There is, however, room for improvement in our program in terms of efficiency and storage requirement; currently, application of our program is limited by the storage of

(16)

and the TΩ amplitudes of n occ 2 n bas 2 size (nocc and nbas are the numbers of occupied orbitals and basis functions, respectively). Further optimization and distributed-memory parallelization of our program are warranted and will be performed in the future. We will also consider the level shift,43 other zeroth-order Hamiltonians,6,58 and multistate extensions.14,59,60

The debugging of parts of the code in bagel, including Z-CASSCF, was facilitated by existing implementations in molpro.50 This work has been supported by Department of Energy, Basic Energy Sciences (Grant No. DE-FG02-13ER16398), and the Air Force Office of Scientific Research Young Investigator Program (Grant No. FA9550-15-1-0031).

1.
K.
Andersson
,
P.-Å.
Malmqvist
, and
B. O.
Roos
,
J. Chem. Phys.
96
,
1218
(
1992
).
2.
K.
Wolinski
,
H. L.
Sellers
, and
P.
Pulay
,
Chem. Phys. Lett.
140
,
225
(
1987
).
3.
P.
Pulay
,
Int. J. Quantum Chem.
111
,
3273
(
2011
).
4.
P.
Celani
and
H.-J.
Werner
,
J. Chem. Phys.
112
,
5546
(
2000
).
5.
C.
Angeli
,
R.
Cimiraglia
,
S.
Evangelisti
,
T.
Leininger
, and
J.-P.
Malrieu
,
J. Chem. Phys.
114
,
10252
(
2001
).
6.
C.
Angeli
,
R.
Cimiraglia
, and
J.-P.
Malrieu
,
J. Chem. Phys.
117
,
9138
(
2002
).
7.
H. B.
Schlegel
,
WIREs Comput. Mol. Sci.
1
,
790
(
2011
).
8.
B. G.
Levine
and
T. J.
Martínez
,
Annu. Rev. Phys. Chem.
58
,
613
(
2007
).
9.
T.
Helgaker
,
P.
Jørgensen
, and
J.
Olsen
,
Molecular Electronic-Structure Theory
(
John Wiley & Sons
,
Chichester
,
2000
).
10.
H.-J.
Werner
and
P. J.
Knowles
,
J. Chem. Phys.
89
,
5803
(
1988
).
11.
H.
Nakano
,
K.
Hirao
, and
M. S.
Gordon
,
J. Chem. Phys.
108
,
5660
(
1998
).
12.
T. J.
Dudley
,
Y. G.
Khait
, and
M. R.
Hoffmann
,
J. Chem. Phys.
119
,
651
(
2003
).
13.
P.
Celani
and
H.-J.
Werner
,
J. Chem. Phys.
119
,
5044
(
2003
).
14.
T.
Shiozaki
,
W.
Győrffy
,
P.
Celani
, and
H.-J.
Werner
,
J. Chem. Phys.
135
,
081106
(
2011
).
15.
W.
Győrffy
,
T.
Shiozaki
,
G.
Knizia
, and
H.-J.
Werner
,
J. Chem. Phys.
138
,
104104
(
2013
).
16.
R.
Shepard
,
Int. J. Quantum Chem.
31
,
33
(
1987
).
17.
S.
Hirata
,
Theor. Chem. Acc.
116
,
2
(
2006
).
18.
M.
Kállay
and
P. R.
Surján
,
J. Chem. Phys.
115
,
2945
(
2001
).
19.
S.
Hirata
,
J. Phys. Chem. A
107
,
9887
(
2003
).
20.
S.
Hirata
,
J. Chem. Phys.
121
,
51
(
2004
).
21.
M.
Hanrath
and
A.
Engels-Putzka
,
J. Chem. Phys.
133
,
064108
(
2010
).
22.
A.
Engels-Putzka
and
M.
Hanrath
,
J. Chem. Phys.
134
,
124106
(
2011
).
23.
T.
Shiozaki
,
M.
Kamiya
,
S.
Hirata
, and
E. F.
Valeev
,
Phys. Chem. Chem. Phys.
10
,
3358
(
2008
).
24.
T.
Shiozaki
,
M.
Kamiya
,
S.
Hirata
, and
E. F.
Valeev
,
J. Chem. Phys.
129
,
071101
(
2008
).
25.
A.
Köhn
,
G. W.
Richings
, and
D. P.
Tew
,
J. Chem. Phys.
129
,
201103
(
2008
).
26.
T.
Shiozaki
,
M.
Kamiya
,
S.
Hirata
, and
E. F.
Valeev
,
J. Chem. Phys.
130
,
054101
(
2009
).
27.
H. S.
Nataraj
,
M.
Kállay
, and
L.
Visscher
,
J. Chem. Phys.
133
,
234109
(
2010
).
28.
Z.
Rolik
and
M.
Kállay
,
J. Chem. Phys.
135
,
104111
(
2011
).
29.
D.
Kats
and
F. R.
Manby
,
J. Chem. Phys.
138
,
144101
(
2013
).
30.
D.
Datta
and
J.
Gauss
,
J. Chem. Theory Comput.
9
,
2639
(
2013
).
31.
D.
Datta
and
J.
Gauss
,
J. Chem. Phys.
141
,
104102
(
2014
).
32.
M.
Wladyslawski
and
M.
Nooijen
,
Adv. Quantum Chem.
49
,
1
(
2005
).
33.
E.
Deumens
,
V. F.
Lotrich
,
A.
Perera
,
M. J.
Ponton
,
B. A.
Sanders
, and
R. J.
Bartlett
,
WIREs Comput. Mol. Sci.
1
,
895
(
2011
).
34.
K. R.
Shamasundar
,
G.
Knizia
, and
H.-J.
Werner
,
J. Chem. Phys.
135
,
054101
(
2011
).
35.

libtensor Tensor algebra library for computational chemistry, E. Epifanovsky, M. Wormit, A. Dreuw, and A. I. Krylov with portions by I. Kaliman, D. Zuev, and K. Khistyaev.

36.

See http://group.valeyev.net/tiledarray for tiledarray, a massively parallel, block-sparse tensor library written in C++ developed by the Valeev group.

37.
E.
Neuscamman
,
T.
Yanai
, and
G. K.-L.
Chan
,
J. Chem. Phys.
130
,
124102
(
2009
).
38.
J. A.
Parkhill
,
K.
Lawler
, and
M.
Head-Gordon
,
J. Chem. Phys.
130
,
084101
(
2009
).
39.
J. A.
Parkhill
and
M.
Head-Gordon
,
Mol. Phys.
108
,
513
(
2010
).
40.
M.
Hanauer
and
A.
Köhn
,
J. Chem. Phys.
134
,
204111
(
2011
).
41.
M.
Saitow
,
Y.
Kurashige
, and
T.
Yanai
,
J. Chem. Phys.
139
,
044118
(
2013
).
42.
N. C.
Handy
and
H. F.
Schaefer
,
J. Chem. Phys.
81
,
5031
(
1984
).
43.
B. O.
Roos
and
K.
Andersson
,
Chem. Phys. Lett.
245
,
215
(
1995
).
44.

bagel, Brilliantly Advanced General Electronic-structure Library. http://www.nubakery.org under the GNU General Public License.

45.

smith3, Symbolic Manipulation Interpreter for Theoretical cHemistry, version 3.0. http://www.nubakery.org under the GNU General Public License.

46.
See supplementary material at http://dx.doi.org/10.1063/1.4907717 for the details on the implementation, the active space, and the optimized geometries. The working equations and the source code of smith3 are also found.
47.
T. H.
Dunning
,
J. Chem. Phys.
90
,
1007
(
1989
).
48.
R. A.
Kendall
,
T. H.
Dunning
, and
R. J.
Harrison
,
J. Chem. Phys.
96
,
6796
(
1992
).
49.
F.
Weigend
,
J. Comput. Chem.
29
,
167
(
2008
).
50.
H.-J.
Werner
,
P. J.
Knowles
,
G.
Knizia
,
F. R.
Manby
, and
M.
Schütz
,
WIREs Comput. Mol. Sci.
2
,
242
(
2011
).
51.
F.
Weigend
,
Phys. Chem. Chem. Phys.
4
,
4285
(
2002
).
52.
M.
Gouterman
,
J. Chem. Phys.
30
,
1139
(
1959
).
53.
J. P.
Perdew
,
K.
Burke
, and
M.
Ernzerhof
,
Phys. Rev. Lett.
77
,
3865
(
1992
).
54.
F.
Furche
,
R.
Ahlrichs
,
C.
Hättig
,
W.
Klopper
,
M.
Sierka
, and
F.
Weigend
,
WIREs Comput. Mol. Sci.
4
,
91
(
2014
).
55.
F.
Weigend
and
R.
Ahlrichs
,
Phys. Chem. Chem. Phys.
7
,
3297
(
2005
).
56.
T.
Vangberg
,
R.
Lie
, and
A.
Ghosh
,
J. Am. Chem. Soc.
124
,
8122
(
2002
).
57.
P.
Dupuis
,
R.
Roberge
, and
C.
Sandorfy
,
Chem. Phys. Lett.
75
,
434
(
1980
).
58.
G.
Ghigo
,
B. O.
Roos
, and
P.-Å.
Malmqvist
,
Chem. Phys. Lett.
396
,
142
(
2004
).
59.
J.
Finley
,
P.-Å.
Malmqvist
,
B. O.
Roos
, and
L.
Serrano-Andrés
,
Chem. Phys. Lett.
288
,
299
(
1998
).
60.
A. A.
Granovsky
,
J. Chem. Phys.
134
,
214113
(
2011
).

Supplementary Material