Keywords

10.1 Introduction

There is now a growing interest in obtaining electric and other response properties from first-principles theory for organic, inorganic, and organometallic compounds containing heavy elements. The inclusion of relativity is crucial for a proper description of photochemistry for systems those containing heavy elements. In particular, it is known that the spin–orbit couplings affect excited-state characters, relaxation dynamics, and radiative and nonradiative decay pathways, as well as lifetimes and reactivity [1] due to the changes induced in the splitting of the orbitals and thus potentially also in the pole structure of a molecule [2, 3].

Time-dependent density functional theory (TDDFT) [4,5,6] has become one of the most widely used methodologies for computing linear response properties since satisfactory accuracy can often be achieved at an acceptable computational cost. The efficient treatment of electron correlation by DFT is particularly important in calculations involving heavy atoms, since electronic correlation effects can be even more important than relativistic effects. There are several ways to calculate the excitation energy from the calculation of the linear response by TDDFT. The first is to calculate the location of the poles and the residues of the frequency-dependent polarizability through eigenvalue-type problems and is widely used in many implementations [7,8,9]. The other is to obtain the excitation energy by directly plotting the dynamic polarizability as a function of the frequency and analyzing the polar structure of the linear response [10, 11]. Since this approach can calculate the absorbing properties in the frequency window of interest, it can potentially be applied to excited states of large molecules with an enormous number of excitations. However, the implementation of this approach is still limited because it is necessary to compute the response of complex numbers.

Until now, in most of the TDDFT linear response calculations for heavy-element systems, only the scalar relativistic effect was taken into account while the spin–orbit effect on the excitation energies is not negligible. Scalar relativistic calculations of the first- and second-order hyperpolarizabilities using the Douglas–Kroll–Hess transformed one-component Hamiltonian [12,13,14], as well as using effective-core potentials [15, 16], have been reported by Norman et al. [17]. At the all-electron level, there exist four-component relativistic implementations of response theory at Hartree–Fock and Kohn–Sham levels of theory for linear [18] and quadratic response functions [19].

However, in most of these implementations, the treatment of noncollinear spin density terms, which is important due to the spin–orbit interaction, is ignored. In recent years, calculations using noncollinear kernels have been performed in excitation energy calculation by pole/residue calculation [20,21,22,23], but most are a Tamm–Dancoff approximation [24], and the full linear response calculations have hardly been performed [25].

In this review, the two-component relativistic linear-response TDDFT for molecular properties is derived and implemented on the NTChem program suite [26]. Our implementation is based on a noncollinear exchange–correlation potential presented by Wang et al. [20, 22]. In addition, since it is difficult to manually implement the latest complicated exchange–correlation functional, the computerized symbolic algebra system is developed and used for those complicated implementation in NTChem. The automatic code generator performs differentiations using the SymPy library [27], which is an open-source symbolic mathematics library for the Python programming language.

10.2 Theory

10.2.1 Polarizability

In the presence of a time-dependent external electric field, the molecular polarization is expressed as a perturbation expansion where the coefficients define the molecular properties known as polarizabilities and hyperpolarizabilities. The electric polarizability provides a measure of the distortion of an atomic or molecular charge distribution by an external field and is therefore an important property. Higher-order dynamic electric polarizabilities are extremely important in nonlinear optical materials research.

The expansion of the following frequency-dependent dipole moment to the third order introduces the linear polarizability \(\alpha \left({ - \omega ;\omega } \right)\), the first-order hyperpolarizability \(\beta \left( { - \omega_{\sigma } ;\omega_{1} ,\omega_{2} } \right)\), and the second-order hyperpolarizability \(\gamma \left( { - \omega_{\sigma } ;\omega_{1} ,\omega_{2} ,\omega_{3} } \right)\):

$$\begin{aligned} \mu_{\alpha } \left( t \right) & = \mu_{\alpha }^{0} + \sum\limits_{\omega } {\sum\limits_{\beta } {\alpha_{\alpha \beta } \left( { - \omega ;\omega } \right)E_{\beta }^{\omega } e^{ - i\omega t} } } \\ & \quad + \frac{1}{2}\sum\limits_{{\omega_{1} ,\omega_{2} }} {\sum\limits_{\beta ,\gamma } {\beta_{\alpha \beta \gamma } \left( { - \omega_{\sigma } ;\omega_{1} ,\omega_{2} } \right)E_{\beta }^{{\omega_{1} }} E_{\gamma }^{{\omega_{2} }} e^{{ - i\left( {\omega_{1} + \omega_{2} } \right)t}} } } \\ & \quad + \frac{1}{3!}\sum\limits_{{\omega_{1} ,\omega_{2} ,\omega_{3} }} {\sum\limits_{\beta ,\gamma ,\delta } {\gamma_{\alpha \beta \gamma \delta } \left( { - \omega_{\sigma } ;\omega_{1} ,\omega_{2} ,\omega_{3} } \right)E_{\beta }^{{\omega_{1} }} E_{\gamma }^{{\omega_{2} }} E_{\delta }^{{\omega_{3} }} e^{{ - i\left( {\omega_{1} + \omega_{2} + \omega_{3} } \right)t}} } } , \\ \end{aligned}$$
(10.1)

where \(\mu_{\alpha }^{0}\) is the permanent electric dipole moment along the molecular axis α, \(E^{\omega }\) are the Fourier components of the perturbing fields, and the sums are performed over both positive and negative frequency (ω) components.

The real part of the linear polarizability \(\alpha^{R}\) is connected to the refractive index, and the imaginary part \(\alpha^{I}\) describes the absorption of light quanta. The linear absorption cross section equals

$$\sigma \left( \omega \right) = \frac{4\pi \omega }{c}\bar{\alpha }^{I} \left( { - \omega ;\omega } \right),$$
(10.2)

where c is the speed of light and the isotropic average of the polarizability has been introduced:

$$\bar{\alpha } = \frac{1}{3}\sum\limits_{i = x,y,z} {\alpha_{ii} } .$$
(10.3)

From the standard time-dependent perturbation theory, we obtain a sum-over-states (SOS) expression for the linear polarizability involving the manifold of excited states of the unperturbed system:

$$\alpha_{\alpha \beta } \left( { - \omega :\omega } \right) = \frac{1}{\hbar }\sum\limits_{n} {\left\{ {\frac{{\left\langle {\left. 0 \right|\mu_{\alpha } \left| n \right.} \right\rangle \left\langle {\left. n \right|\mu_{\beta } \left| 0 \right.} \right\rangle }}{{\omega_{0n} - \omega }} + \frac{{\left\langle {\left. 0 \right|\mu_{\beta } \left| n \right.} \right\rangle \left\langle {\left. n \right|\mu_{\alpha } \left| 0 \right.} \right\rangle }}{{\omega_{0n} + \omega }}} \right\}} ,$$
(10.4)

where \(\mu_{\alpha }\) is the electric dipole moment operator along the molecular axis α, \(\hbar \omega_{0n} = E_{n} - E_{0}\) are the electronic excitation energies, and the sums are performed over the manifold of states of the unperturbed system \(\left( {\left| n \right\rangle } \right)\) excluding the ground state \(\left( {\left| 0 \right\rangle } \right)\).

Such a formula is applicable only in the nonresonant region, since when photon energies are in the proximity of the excitation energies of the system a perturbation analysis is no longer valid. Thus, in the near-resonance case, two alternative strategies have been used: either turning to a few-states model or the inclusion of phenomenological damping terms in the SOS expressions.

The damping terms in the latter approach represent the finite lifetime of the excited states and correspond to line broadening in the absorption spectra. Having introduced damping terms, the SOS expression for the linear polarizability can be written as

$$\alpha_{\alpha \beta } \left( { - \omega :\omega } \right) = \frac{1}{\hbar }\sum\limits_{n} {\left\{ {\frac{{\left\langle {\left. 0 \right|\mu_{\alpha } \left| n \right.} \right\rangle \left\langle {\left. n \right|\mu_{\beta } \left| 0 \right.} \right\rangle }}{{\omega_{0n} - \omega - i\gamma }} + \frac{{\left\langle {\left. 0 \right|\mu_{\beta } \left| n \right.} \right\rangle \left\langle {\left. n \right|\mu_{\alpha } \left| 0 \right.} \right\rangle }}{{\omega_{0n} + \omega + i\gamma }}} \right\}} ,$$
(10.5)

where damping factor \(\gamma\) is defined using common lifetime \(\tau\) of the excited states as

$$\gamma = \frac{1}{2\tau }.$$
(10.6)

It is immediately seen that in the nonresonant region, the imaginary part of \(\alpha\) depends linearly on \(\gamma\) and that it equals zero in the static limit \(\left( {\omega = 0} \right)\) regardless of \(\gamma\). Furthermore, by using the identity

$$\mathop {\lim }\limits_{\gamma \to 0} \left[ {{\text{Im}}\left\{ {\frac{A}{B - i\gamma }} \right\}} \right] = A\pi \delta \left( B \right),$$
(10.7)

we see by comparing with Eqs. (10.2), (10.3), and (10.7) that

$$\mathop {\lim }\limits_{\gamma \to 0} \sigma \left( \omega \right) = \frac{{4\pi^{2} \omega }}{3\hbar c}\sum\limits_{n} {\left[ {\delta \left( {\omega_{0n} - \omega } \right)\sum\limits_{i = x,y,z} {\left| {\left\langle {\left. 0 \right|\mu_{i} \left| n \right.} \right\rangle } \right|^{2} } } \right]} ,$$
(10.8)

and it is clear that the regular oscillator strengths are related to the infinite lifetime approximation of the absorption as described by the imaginary part of the linear polarizability.

10.2.2 Time-Dependent Kohn–Sham Theory

We assume that a molecule is initially in a stationary state, the electronic structure of which is suitably described by time-independent Kohn–Sham (KS) density functional theory.

In the density matrix formalism, the KS Hamiltonian and density matrices satisfy the time-independent KS equation:

$$\sum\limits_{q} {\left( {F_{pq}^{\left( 0 \right)} D_{qr}^{\left( 0 \right)} - D_{pq}^{\left( 0 \right)} F_{qr}^{\left( 0 \right)} } \right)} = 0,$$
(10.9)

and the idempotency condition (corresponding to the orthonormality condition of orbitals):

$$\sum\limits_{q} {D_{pq}^{\left( 0 \right)} D_{qr}^{\left( 0 \right)} } = D_{pr}^{\left( 0 \right)} ,$$
(10.10)

where F and D are the KS Hamiltonian and density matrices, respectively, represented by Kohn–Sham orbitals for the unperturbed ground state \(\left\{ {\phi_{p} } \right\}\), and p, q, r are spin-orbital indexes.

In two-component generalized KS equations, KS orbitals may be complex and have two spin components:

$$\phi_{p} = \left( \begin{aligned} \phi_{p}^{\alpha } \hfill \\ \phi_{p}^{\beta } \hfill \\ \end{aligned} \right),$$
(10.11)

where \(\phi_{p}^{\alpha }\) and \(\phi_{p}^{\beta }\) are spatial orbitals which are expanded in a linear combination of atomic orbitals \(\left\{ {\chi_{\mu } } \right\}\),

$$\phi_{p}^{\omega } = \sum\limits_{\mu } {\chi_{\mu } C_{\mu p}^{\omega } } \quad \left( {\omega = \alpha ,\beta } \right),$$
(10.12)

where λ, μ, ν, υ, etc. are used for atomic-orbital indexes.

The KS Hamiltonian and density matrices for the ground state are simply

$$F_{pq}^{\left( 0 \right)} = \varepsilon_{p} \delta_{pq} ,$$
(10.13)
$$D_{ij}^{\left( 0 \right)} = \delta_{ij} ,$$
(10.14)
$$D_{ia}^{\left( 0 \right)} = D_{ai}^{\left( 0 \right)} = D_{ab}^{\left( 0 \right)} = 0,$$
(10.15)

where \(\varepsilon_{p}\) is the pth spin-orbital energy, and we use i, j, k, l, m, n, etc., for occupied orbitals, a, b, c, d, e, f, etc., for virtual orbitals, and p, q, r, s, and t for general orbitals throughout this chapter.

We then apply an oscillatory perturbation, which can be described as a single Fourier component:

$$g_{pq}^{\left( 1 \right)} = \frac{1}{2}\left( {h_{pq}^{\left( 1 \right)} e^{ - i\omega t} + h_{qp}^{\left( 1 \right)*} e^{i\omega t} } \right),$$
(10.16)

where the matrix h represents a one-electron operator describing the details of the perturbation.

The response in the density matrix D to this applied perturbation consists of the first-order (linear) and higher-order terms:

$$D_{pq} = D_{pq}^{\left( 0 \right)} + D_{pq}^{\left( 1 \right)} + D_{pq}^{\left( 2 \right)} + D_{pq}^{\left( 3 \right)} + \ldots ,$$
(10.17)

with

$$D_{pq}^{\left( 1 \right)} = \frac{1}{2}\left( {d_{pq}^{\left( 1 \right)} e^{ - i\omega t} + d_{pq}^{\left( 1 \right)*} e^{i\omega t} } \right).$$
(10.18)

The first-order change in the KS Hamiltonian matrix arises from two sources: the direct change in the one-electron part described by Eq. (10.16) and the indirect change induced by the first- and higher-order responses in the density matrix, i.e.,

$$F_{pq} = F_{pq}^{\left( 0 \right)} + g_{pq}^{\left( 1 \right)} + \sum\limits_{r,s} {\frac{{\partial F_{pq} }}{{\partial D_{rs} }}D_{rs}^{\left( 1 \right)} } + \ldots ,$$
(10.19)

with

$$\frac{{\partial F_{pq} }}{{\partial D_{rs} }} = \left( {\left. {pq} \right|sr} \right) - c_{\text{x}} \left( {\left. {pr} \right|sq} \right) - c_{\text{x}}^{\text{lr}} \left( {\left. {pr} \right|sq} \right)^{\text{lr}} + f_{pq,sr}^{\text{xc}} ,$$
(10.20)

where the prefactor \(c_{\text{x}}\) is the mixing ratio of Hartree–Fock (HF) exchange in the hybrid functional and \(c_{\text{x}}^{\text{lr}}\) is the mixing ratio of long-range exchange in the range-separated hybrid functional. The regular two-electron integrals and long-range two-electron integrals are defined in the Mulliken notation as

$$\left( {\left. {pq} \right|sr} \right) = \int {\int {\phi_{p}^{*} \left( {{\mathbf{r}}_{1} } \right)\phi_{q} \left( {{\mathbf{r}}_{1} } \right)\frac{1}{{r_{12} }}} \phi_{s}^{*} \left( {{\mathbf{r}}_{2} } \right)} \phi_{r} \left( {{\mathbf{r}}_{2} } \right)d{\mathbf{r}}_{1} d{\mathbf{r}}_{2} ,$$
(10.21)

and

$$\left( {\left. {pq} \right|sr} \right)^{\text{lr}} = \int {\int {\phi_{p}^{*} \left( {{\mathbf{r}}_{1} } \right)\phi_{q} \left( {{\mathbf{r}}_{1} } \right)\frac{{{\text{erf}}\left( {\mu r_{12} } \right)}}{{r_{12} }}\phi_{s}^{*} \left( {{\mathbf{r}}_{2} } \right)} } \phi_{r} \left( {{\mathbf{r}}_{2} } \right)d{\mathbf{r}}_{1} d{\mathbf{r}}_{2} ,$$
(10.22)

where \(r_{12} = \left| {{\mathbf{r}}_{1} - {\mathbf{r}}_{2} } \right|\) for coordinate vectors of electrons, \({\mathbf{r}}_{1}\) and \({\mathbf{r}}_{2}\), and μ is an adapted parameter determining the ratio of short- and long-range parts of electron repulsion operator \({1 \mathord{\left/ {\vphantom {1 {r_{12} }}} \right. \kern-0pt} {r_{12} }}\). The response of the exchange–correlation potential term, also called the exchange–correlation kernel, is given as:

$$f_{pq,rs}^{\text{xc}} = \int {\int {\phi_{p}^{*} \left( {{\mathbf{r}}_{1} } \right)\phi_{q} \left( {{\mathbf{r}}_{2} } \right)\frac{{\delta E_{\text{xc}} }}{{\delta \rho \left( {{\mathbf{r}}_{1} } \right)\delta \rho \left( {{\mathbf{r}}_{2} } \right)}}\phi_{r}^{*} \left( {{\mathbf{r}}_{2} } \right)\phi_{s} \left( {{\mathbf{r}}_{2} } \right)} } d{\mathbf{r}}_{1} d{\mathbf{r}}_{2} .$$
(10.23)

We substitute the time-dependent KS and density matrices into the following time-dependent KS equation:

$$\frac{1}{i}\sum\limits_{q} {\left( {F_{pq} D_{qr} - D_{pq} F_{qr} } \right)} = \frac{{\partial D_{pr} }}{\partial t}.$$
(10.24)

Collecting the terms that are linear in the perturbation with the time dependence, we obtain

$$\begin{aligned} & \sum\limits_{q} {F_{pq}^{\left( 0 \right)} d_{qr}^{\left( 1 \right)} } - \sum\limits_{q} {d_{pq}^{\left( 1 \right)} F_{qr}^{\left( 0 \right)} } + \sum\limits_{q} {h_{pq}^{\left( 1 \right)} D_{qr}^{\left( 0 \right)} } + \sum\limits_{q,s,t} {\left( {\frac{{\partial F_{pq} }}{{\partial D_{st} }}} \right)d_{st}^{\left( 1 \right)} D_{qr}^{\left( 0 \right)} } \\ & \quad - \sum\limits_{q} {D_{pq}^{\left( 0 \right)} h_{qr}^{\left( 1 \right)} } - \sum\limits_{q,s,t} {D_{pq}^{\left( 0 \right)} \left( {\frac{{\partial F_{qr} }}{{\partial D_{st} }}} \right)d_{st}^{\left( 1 \right)} } = \omega d_{pr}^{\left( 1 \right)} . \\ \end{aligned}$$
(10.25)

The terms multiplied by the \(e^{i\omega t}\) factor lead to the conjugate complex of the above equation.

Because the KS (or HF) equation and energy are invariant to rotations among just occupied orbitals or among just virtual orbitals, we only need to consider the occupied virtual block of d, i.e., \(\left\{ {d_{ai}^{\left( 1 \right)} } \right\}\) and \(\left\{ {d_{ia}^{\left( 1 \right)} } \right\}\). Substituting Eqs. (10.13)–(10.15) into Eq. (10.25), we arrive at a pair of equations:

$$\left( {\varepsilon_{a} - \varepsilon_{i} } \right)d_{ai}^{\left( 1 \right)} + h_{ai}^{\left( 1 \right)} + \sum\limits_{b,j} {\left( {\frac{{\partial F_{ai} }}{{\partial D_{bj} }}} \right)x_{bj} } + \sum\limits_{b,j} {\left( {\frac{{\partial F_{ai} }}{{\partial D_{jb} }}} \right)y_{bj} } = \omega d_{ai}^{\left( 1 \right)} ,$$
(10.26)
$$\left( {\varepsilon_{i} - \varepsilon_{a} } \right)d_{ia}^{\left( 1 \right)} - h_{ia}^{\left( 1 \right)} - \sum\limits_{b,j} {\left( {\frac{{\partial F_{ia} }}{{\partial D_{bj} }}} \right)x_{bj} } - \sum\limits_{b,j} {\left( {\frac{{\partial F_{ia} }}{{\partial D_{jb} }}} \right)y_{bj} } = \omega d_{ia}^{\left( 1 \right)} ,$$
(10.27)

where \(x_{ai} = d_{ai}^{\left( 1 \right)}\) and \(y_{ai} = d_{ia}^{\left( 1 \right)}\). These may be cast into a compact matrix linear equation:

$$\left( {\begin{array}{*{20}c} {\mathbf{A}} & {\mathbf{B}} \\ {{\mathbf{B}}^{*} } & {{\mathbf{A}}^{*} } \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {\mathbf{x}} \\ {\mathbf{y}} \\ \end{array} } \right) - \omega \left( {\begin{array}{*{20}c} {\mathbf{1}} & {\mathbf{0}} \\ {\mathbf{0}} & { - {\mathbf{1}}} \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {\mathbf{x}} \\ {\mathbf{y}} \\ \end{array} } \right) = - \left( {\begin{array}{*{20}c} {\mathbf{h}} \\ {{\mathbf{h}}^{\dag *} } \\ \end{array} } \right),$$
(10.28)

with

$$\begin{aligned} & A_{ai,bj} = \delta_{ij} \delta_{ab} \left( {\varepsilon_{a} - \varepsilon_{i} } \right) + \left( {\left. {ai} \right|jb} \right) - c_{\text{x}} \left( {\left. {ab} \right|ji} \right) - c_{\text{x}}^{\text{lr}} \left( {\left. {ab} \right|ji} \right)^{\text{lr}} + f_{ai,jb}^{\text{xc}} \\ & B_{ai,bj} = \left( {\left. {ai} \right|bj} \right) - c_{\text{x}} \left( {\left. {aj} \right|bi} \right) - c_{\text{x}}^{\text{lr}} \left( {\left. {aj} \right|bi} \right)^{\text{lr}} + f_{ai,bj}^{\text{xc}} , \\ \end{aligned}$$
(10.29)

where 1 and 0 are unit matrix and zero matrix, respectively. Equation (10.28) can be solved for x and y by standard iterative techniques that use trial vectors and that work with just atomic-orbital-based integrals [28, 29]. Once the equation is solved, the frequency-dependent polarizability is readily evaluated by [30]:

$$\alpha_{\alpha } \left( { - \omega ;\omega } \right) = - {\text{Tr}}\left[ {{\mathbf{h}}^{\left( 1 \right)} {\mathbf{D}}^{\alpha } \left( \omega \right)} \right] = - \sum\limits_{a,i} {\left\{ {h_{ai}^{\left( 1 \right)} x_{ai}^{\alpha } + h_{ia}^{\left( 1 \right)} y_{ia}^{\alpha } } \right\}} ,$$
(10.30)

if \({\mathbf{h}}\) is a dipole moment matrix.

The poles of the frequency-dependent polarizability correspond to electronic excitations, occurring with an infinitesimal perturbation, i.e., \({\mathbf{h}} = 0\). Substituting this into Eq. (10.28) leads to a nonsymmetric matrix eigenvalue problem:

$$\left( {\begin{array}{*{20}c} {\mathbf{A}} & {\mathbf{B}} \\ {{\mathbf{B}}^{*} } & {{\mathbf{A}}^{*} } \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {\mathbf{x}} \\ {\mathbf{y}} \\ \end{array} } \right) = \omega \left( {\begin{array}{*{20}c} {\mathbf{1}} & {\mathbf{0}} \\ {\mathbf{0}} & { - {\mathbf{1}}} \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {\mathbf{x}} \\ {\mathbf{y}} \\ \end{array} } \right),$$
(10.31)

which can be solved for electronic excitation energies \(\omega\) and corresponding \({\mathbf{x}}\) and \({\mathbf{y}}\) vectors of TDHF or RPA by standard techniques using Davidson’s trial vector algorithm [31] (as adapted to a nonsymmetric problem [32]) in an atomic-orbital-based scheme [33].

In a phenomenological way, relaxation effects may be introduced into Eq. (10.24) as follows [10, 34]:

$$\frac{1}{i}\sum\limits_{q} {\left( {F_{pq} D_{qr} - D_{pq} F_{qr} } \right)} - \gamma_{pr} \left( {D_{pr} - D_{pr}^{\left( 0 \right)} } \right) = \frac{{\partial D_{pr} }}{\partial t},$$
(10.32)

where the damping terms \(\gamma_{pq}\) correspond to the rate at which density matrix element \(D_{pq}\) relaxes to its equilibrium value of \(D_{pq}^{\left( 0 \right)}\). Applying the common lifetime broadening factor \(\gamma\) for all excited states, Eq. (10.25) becomes

$$\begin{aligned} & \sum\limits_{q} {F_{pq}^{\left( 0 \right)} d_{qr}^{\left( 1 \right)} } - \sum\limits_{q} {d_{pq}^{\left( 1 \right)} F_{qr}^{\left( 0 \right)} } + \sum\limits_{q} {h_{pq}^{\left( 1 \right)} D_{qr}^{\left( 0 \right)} } + \sum\limits_{q,s,t} {\left( {\frac{{\partial F_{pq} }}{{\partial D_{st} }}} \right)d_{st}^{\left( 1 \right)} D_{qr}^{\left( 0 \right)} } \\ & - \sum\limits_{q} {D_{pq}^{\left( 0 \right)} h_{qr}^{\left( 1 \right)} } - \sum\limits_{q,s,t} {D_{pq}^{\left( 0 \right)} \left( {\frac{{\partial F_{qr} }}{{\partial D_{st} }}} \right)d_{st}^{\left( 1 \right)} } = \left( {\omega + i\gamma } \right)d_{pr}^{\left( 1 \right)} . \\ \end{aligned}$$
(10.33)

Since the difference between Eq. (10.25) and Eq. (10.33) is only in those frequency \(\omega\) and \(\omega + i\gamma\), substituting \(\omega\) to \(\omega + i\gamma\) in Eq. (10.28), we obtained the first-order damped-response equation:

$$\left( {\begin{array}{*{20}c} {\mathbf{A}} & {\mathbf{B}} \\ {{\mathbf{B}}^{*} } & {{\mathbf{A}}^{*} } \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {\mathbf{x}} \\ {\mathbf{y}} \\ \end{array} } \right) - \left( {\omega + i\gamma } \right)\left( {\begin{array}{*{20}c} {\mathbf{1}} & {\mathbf{0}} \\ {\mathbf{0}} & { - {\mathbf{1}}} \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {\mathbf{x}} \\ {\mathbf{y}} \\ \end{array} } \right) = - \left( {\begin{array}{*{20}c} {\mathbf{h}} \\ {{\mathbf{h}}^{\dag *} } \\ \end{array} } \right).$$
(10.34)

In the spin–orbit case, Eq. (10.34) can easily be solved since many of the intermediate quantities that are computed are already complex to begin with.

10.2.3 Noncollinear Formulation for Exchange–Correlation Kernel

In relativistic density functional calculations for open-shell systems with spin–orbit couplings, the spin is no longer a good quantum number and a noncollinear formulation for the exchange–correlation potential and exchange–correlation kernels are often used [35,36,37,38,39,40,41,42]. In relativistic TDDFT, this noncollinear formula is important, since the excited state can be an open-shell electronic state by excitation even in the closed–shell system even in the ground state.

In the nonrelativistic calculation, spin electron densities \(\rho_{\alpha }\) and \(\rho_{\beta }\) can be written as \(\rho_{\alpha } = {1 \mathord{\left/ {\vphantom {1 2}} \right. \kern-0pt} 2}\left( {\rho + s} \right)\) and \(\rho_{\beta } = {1 \mathord{\left/ {\vphantom {1 2}} \right. \kern-0pt} 2}\left( {\rho - s} \right)\), using the total electron density \(\rho\), the difference electron density \(s\). Similarly, we can define two new quantities:

$$\begin{aligned} & \rho_{ + } = \frac{1}{2}\left( {\rho + s} \right) \\ & \rho_{ - } = \frac{1}{2}\left( {\rho - s} \right), \\ \end{aligned}$$
(10.35)

where the difference electron density \(s\) is defined as the spin density (magnetization) vector \({\mathbf{m}} = \left( {m_{x} ,m_{y} ,m_{z} } \right)\) by

$$s = \sqrt {m_{x}^{2} + m_{y}^{2} + m_{z}^{2} } .$$
(10.36)

Here, Eq. (10.35) represents the local eigenvalues of spin density. In terms of two-component spinors, \(\phi\), \(\rho\), and \({\mathbf{m}}\) are defined as:

$$\rho \left( {\mathbf{r}} \right) = \sum\limits_{i} {\phi_{i}^{\dag } \left( {\mathbf{r}} \right)\phi \left( {\mathbf{r}} \right)} ,$$
(10.37)
$${\mathbf{m}}\left( {\mathbf{r}} \right) = \sum\limits_{i} {\phi_{i}^{\dag } \left( {\mathbf{r}} \right){\varvec{\upsigma}}\,\phi \left( {\mathbf{r}} \right)} ,$$
(10.38)

where \(\varvec{\sigma}\) are the Pauli spin matrix vector. It should be noted that in the generalized case, the spin density vector can change its modulus and direction at every point in space, but one would like to use only its modulus to evaluate the exchange–correlation energy.

The expression of the exchange–correlation energy is extended in a consistent way as

$$E_{\text{xc}} = \int {d{\mathbf{r}}\hat{E}_{\text{xc}} \left( {\rho_{ + } ,\rho_{ - } ,\gamma_{ + + } ,\gamma_{ - - } ,\gamma_{ + - } } \right)} ,$$
(10.39)

with

$$\gamma_{ij} = \nabla \rho_{i} \cdot \nabla \rho_{j} \;\left( {i,j = + , - } \right),$$
(10.40)

where \(\hat{E}_{xc}\) is general exchange-correlation functional.

The exchange–correlation potential and kernel can be obtained by a proper functional derivative of Eq. (10.39). In LDA case, those are expressed as

$$\begin{aligned} \int {d{\mathbf{r}}\frac{{\delta \hat{E}_{\text{xc}} }}{\delta \rho }\phi_{p}^{*} \phi_{q} } & = \frac{1}{2}\int {d{\mathbf{r}}\phi_{p}^{*} \phi_{q} \left( {\frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } }} + \frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ - } }}} \right)} \\ & \quad + \frac{1}{2}\int {d{\mathbf{r}}} \left( {\frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } }} - \frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ - } }}} \right)\frac{1}{s}\sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)} , \\ \\ \end{aligned}$$
(10.41)

and

$$\begin{aligned} \int {d\tau \phi_{p}^{*} \phi_{q} \frac{{\delta^{2} \hat{E}_{\text{xc}} }}{{\delta \rho \delta \rho^{{\prime }} }}\phi_{r}^{*} \phi_{s} } & = \frac{1}{4}\int {d{\mathbf{r}}\left( {\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + }^{2} }} + \frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ - }^{2} }} + 2\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } \partial \rho_{ - } }}} \right)} \left( {\phi_{p}^{*} \phi_{q} } \right)\left( {\phi_{r}^{*} \phi_{s} } \right) \\ & \quad + \frac{1}{2}\int {d{\mathbf{r}}} \left( {\frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } }} - \frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ - } }}} \right)\frac{1}{s}\sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}\left( {\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + }^{2} }} - \frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ - }^{2} }}} \right)\frac{1}{s}} \\ & \quad \times \left[ {\left( {\phi_{p}^{*} \phi_{q} } \right)\sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{r}^{*} \sigma_{i} \phi_{s} } \right) + \sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)} \left( {\phi_{r}^{*} \phi_{s} } \right)} } \right] \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}\left( {\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + }^{2} }} + \frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ - }^{2} }} - 2\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } \partial \rho_{ - } }}} \right)\frac{1}{s}} \\ & \quad \times \sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)} \frac{1}{s}\sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{r}^{*} \sigma_{i} \phi_{s} } \right)} \\ & \quad - \frac{1}{2}\int {d{\mathbf{r}}\left( {\frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } }} - \frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ - } }}} \right)\frac{1}{{s^{3} }}\sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)} \sum\limits_{i = x,y,z} {m_{i} \left( {\phi_{r}^{*} \sigma_{i} \phi_{s} } \right)} } \\ & \quad + \frac{1}{2}\int {d{\mathbf{r}}\left( {\frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } }} - \frac{{\partial \hat{E}_{\text{xc}} }}{{\partial \rho_{ - } }}} \right)\frac{1}{s}\sum\limits_{i = x,y,z} {\left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)\left( {\phi_{r}^{*} \sigma_{i} \phi_{s} } \right)} } . \\ \\ \end{aligned}$$
(10.42)

Note that all the derivatives are taken at the ground-state density and spin densities. Equation (10.42) can be further simplified in some special cases. For closed-shell systems, we will have the following additional conditions with \(s \to 0\) [20]:

$$\frac{{\delta \hat{E}_{\text{xc}} }}{\delta s} \to 0,$$
(10.43)
$$\frac{{\delta^{2} \hat{E}_{\text{xc}} }}{\delta \rho \delta s} \to 0,$$
(10.44)
$$\frac{1}{s}\frac{{\delta \hat{E}_{\text{xc}} }}{\delta s} \to \frac{{\delta^{2} \hat{E}_{\text{xc}} }}{{\delta s^{2} }}.$$
(10.45)

Equation (10.42) is then simplified to

$$\begin{aligned} \int {d\tau \phi_{p}^{*} \phi_{q} \frac{{\delta^{2} \hat{E}_{\text{xc}} }}{{\delta \rho \delta \rho^{{\prime }} }}\phi_{r}^{*} \phi_{s} } & = \frac{1}{4}\int {d{\mathbf{r}}\left( {\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + }^{2} }} + \frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ - }^{2} }} + 2\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } \partial \rho_{ - } }}} \right)\left( {\phi_{p}^{*} \phi_{q} } \right)\left( {\phi_{r}^{*} \phi_{s} } \right)} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}\left( {\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + }^{2} }} + \frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ - }^{2} }} - 2\frac{{\partial^{2} \hat{E}_{\text{xc}} }}{{\partial \rho_{ + } \partial \rho_{ - } }}} \right)\sum\limits_{i = x,y,z} {\left( {\phi_{p}^{*} \sigma_{i} \phi_{q} } \right)\left( {\phi_{r}^{*} \sigma_{i} \phi_{s} } \right)} .} \\ \\ \end{aligned}$$
(10.46)

From Eq. (10.46), it is shown that in the nonrelativistic limit with the molecular spinors of either spin α or spin β, if p and q have the same spin and s and t have the same spin, the first term of Eq. (10.46) is exactly the same as the corresponding term in nonrelativistic TDDFT calculations.

When p and q have different spins and s and t have different spins, these transitions correspond to spin-flip excitations, and it has already been shown that for closed-shell systems, spin-flip transitions will result in singlet–triplet excitations and the excitation energies calculated from the second term of Eq. (10.46) are the same as those from ordinary TDDFT for singlet–triplet transitions. From this argument, we can see that the TDDFT formulation based on a noncollinear exchange–correlation potential has the correct nonrelativistic limit and can recover the threefold degeneracy of triplet excitations correctly.

10.3 Implementation

10.3.1 Trial Vector Algorithm

In the present implementation of TDHF and TDDFT, the explicit formation of an enormous number of the two-electron integrals in Eq. (29) is avoided by invoking a trial vector algorithm, which is based on the idea of projecting the full matrices onto ones of greatly reduced dimensions. The generalization of this algorithm to a non-Hermitian eigenvalue equation has been considered by Hirao and Nakatsuji [32] and for the particular form of Eq. (10.31) by Olsen, Jensen, and Jørgensen [33], who also propose efficient algorithm for linear equation of Eq. (10.28) using trial vectors in the same paper. It should be remembered that A and B matrices are complex matrices and hence we cannot reduce Eq. (10.31) to a Hermitian eigenvalue equation of half the dimension as has usually been done in the implementations in the nonrelativistic program [7,8,9, 43]. In NTChem, the KAIN algorithm [44] for linear equation and Olsen’s algorithm [33, 45] for non-Hermitian eigenvalue equation are implemented.

The key steps in these trial vector algorithms are to calculate matrix–trial vector products. By projecting the A and B matrices in Eq. (10.28) onto a subspace spanned by a set of trial vectors

$$\left\{ {\left( \begin{aligned} {\mathbf{x}}\left( 1 \right) \hfill \\ {\mathbf{y}}\left( 1 \right) \hfill \\ \end{aligned} \right),\left( \begin{aligned} {\mathbf{x}}\left( 2 \right) \hfill \\ {\mathbf{y}}\left( 2 \right) \hfill \\ \end{aligned} \right), \ldots ,\left( \begin{aligned} {\mathbf{x}}\left( p \right) \hfill \\ {\mathbf{y}}\left( p \right) \hfill \\ \end{aligned} \right)} \right\},$$
(10.47)

the matrix–trial vector products are written as:

$$\begin{aligned} & \bar{x}_{ai}^{\left( p \right)} = \sum\limits_{b,j} {\left( {A_{ai,bj} x_{bj}^{\left( p \right)} + B_{ai,bj} y_{bj}^{\left( p \right)} } \right)} , \\ & \bar{y}_{ai}^{\left( p \right)} = \sum\limits_{b,j} {\left( {B_{ai,bj}^{*} x_{bj}^{\left( p \right)} + A_{ai,bj}^{*} y_{bj}^{\left( p \right)} } \right)} . \\ \end{aligned}$$
(10.48)

Using the AO representation of the A and B matrices, Eq. (10.48) is written as:

$$\begin{aligned} & \bar{x}_{ai}^{\left( p \right)} = \sum\limits_{{\omega ,\omega^{{\prime }} }} {\sum\limits_{\mu ,\nu } {C_{\mu a}^{\omega *} C_{\nu i}^{{\omega^{\prime}}} G\left[ {{\mathbf{D}}^{\left( p \right)} } \right]_{\mu \nu }^{{\omega \omega^{{\prime }} }} } } \\ & \bar{y}_{ai}^{\left( p \right)} = \left( {\sum\limits_{{\omega ,\omega^{\prime}}} {\sum\limits_{\mu ,\nu } {C_{\mu a}^{\omega *} C_{\nu i}^{{\omega^{{\prime }} }} G\left[ {{\mathbf{D}}^{\left( p \right)} } \right]_{\mu \nu }^{{\omega \omega^{{^{{{\prime }*}} }} }} } } } \right)^{*} , \\ \end{aligned}$$
(10.49)

where the trial density matrices \({\mathbf{D}}^{\left( p \right)}\) and trial Fock matrices \({\mathbf{G}}\) are defined as:

$$D_{\lambda \kappa }^{{\left( p \right)\omega \omega^{{\prime }} }} = \sum\limits_{b,j} {C_{\lambda b}^{\omega } x_{bj}^{\left( p \right)} C_{\kappa j}^{\omega *} } + \sum\limits_{b,j} {C_{\lambda j}^{\omega } y_{bj}^{\left( p \right)} C_{\kappa b}^{{\omega^{{{\prime }\, * }} }} } ,$$
(10.50)
$$\begin{aligned} G\left[ {{\mathbf{D}}^{\left( p \right)} } \right]_{\mu \nu }^{{\omega \omega^{{\prime }} }} & = \left( {\left. {\mu \nu } \right|\lambda \kappa } \right)D_{\lambda \kappa }^{{\left( p \right)\omega \omega^{{\prime }} }} + f_{\mu \nu ,\lambda \kappa }^{\text{xc}} D_{\lambda \kappa }^{{\left( p \right)\omega \omega^{{\prime }} }} \\ & \quad - \delta_{{\omega \omega^{\prime}}} \left[ {c_{\text{x}} \left( {\left. {\mu \kappa } \right|\lambda \nu } \right) - c_{\text{x}}^{\text{lr}} \left( {\left. {\mu \kappa } \right|\lambda \nu } \right)^{\text{lr}} } \right]D_{\lambda \kappa }^{{\left( p \right)\omega \omega^{{\prime }} }} , \\ \\ \end{aligned}$$
(10.51)

and

$$\begin{aligned} G\left[ {{\mathbf{D}}^{\left( p \right)} } \right]_{\mu \nu }^{{\omega \omega^{{\prime }} }} f_{\mu \nu ,\lambda \kappa }^{\text{xc}} = \int {\int {\chi_{\mu } \left( {{\mathbf{r}}_{1} } \right)\chi_{\nu } \left( {{\mathbf{r}}_{2} } \right)\frac{{\delta^{2} E_{\text{xc}} }}{{\delta \rho \left( {{\mathbf{r}}_{1} } \right)\delta \rho \left( {{\mathbf{r}}_{2} } \right)}}\chi_{\lambda } \left( {{\mathbf{r}}_{2} } \right)\chi_{\kappa } \left( {{\mathbf{r}}_{2} } \right)} } d{\mathbf{r}}_{1} d{\mathbf{r}}_{2} . \hfill \\ \hfill \\ \end{aligned}$$
(10.52)

In two-component TDDFT equations, the one-electron trial density matrix will present a nonvanishing αβ block coupling the two spin components:

$${\mathbf{D}}^{\left( p \right)} = \left( {\begin{array}{*{20}c} {{\mathbf{D}}^{\left( p \right)\alpha \alpha } } & {{\mathbf{D}}^{\left( p \right)\alpha \beta } } \\ {{\mathbf{D}}^{\left( p \right)\beta \alpha } } & {{\mathbf{D}}^{\left( p \right)\beta \beta } } \\ \end{array} } \right).$$
(10.53)

Therefore, the evaluation of these matrix–trial vector products can be carried out in the direct AO-based algorithm. Since the time-consuming calculation of \({\mathbf{G}}\) for two trial vectors is only one time, the cost is not so different from the CIS or Tamm–Dancoff approximation using one trial vector.

The contribution to the matrix–trial vector product from the noncollinear exchange–correlation kernel (10.46) can be calculated as:

$$\sum\limits_{{\omega \omega^{\prime}}} {f_{\mu \nu ,\lambda \kappa }^{\text{xc}} D_{\lambda \kappa }^{{\left( p \right)\omega \omega^{{\prime }} }} } = \int {d{\mathbf{r}}} \frac{{\delta^{2} E_{\text{xc}} }}{{\delta \rho^{2} }}\rho^{\left( p \right)} \left( {\chi_{\mu } \chi_{\nu } } \right) + \sum\limits_{i = x,y,z} {\int {d{\mathbf{r}}} \frac{{\delta^{2} E_{\text{xc}} }}{{\delta m^{2} }}m_{i}^{\left( p \right)} \left( {\chi_{\mu } \sigma_{i} \chi_{\nu } } \right)} ,$$
(10.54)

where trial total electron density and trial spin density vector are defined by analogy of total electron density and spin density vector as:

$$\rho_{0}^{\left( p \right)} = \sum\limits_{\mu \nu } {D_{\mu \nu }^{\left( p \right)0} \phi_{\mu } \phi_{\nu } } ,$$
(10.55)
$$m_{i}^{\left( p \right)} = \sum\limits_{\mu \nu } {D_{\mu \nu }^{\left( p \right)i} \phi_{\mu } \phi_{\nu } } \quad \left( {i = x,y,z} \right),$$
(10.56)

and corresponding density matrices are obtained by:

$$D_{\mu \nu }^{\left( p \right)0} = D_{\mu \nu }^{\left( p \right)\alpha \alpha } + D_{\mu \nu }^{\left( p \right)\beta \beta } ,$$
(10.57)
$$D_{\mu \nu }^{\left( p \right)x} = D_{\mu \nu }^{\left( p \right)\beta \alpha } + D_{\mu \nu }^{\left( p \right)\alpha \beta } ,$$
(10.58)
$$D_{\mu \nu }^{\left( p \right)y} = - i\left\{ {D_{\mu \nu }^{\left( p \right)\beta \alpha } - D_{\mu \nu }^{\left( p \right)\alpha \beta } } \right\},$$
(10.59)
$$D_{\mu \nu }^{\left( p \right)z} = D_{\mu \nu }^{\left( p \right)\alpha \alpha } - D_{\mu \nu }^{\left( p \right)\beta \beta } .$$
(10.60)

Here, the first term on the right-hand side of Eq. (10.54) is a term derived from singlet excitation and derived in GGA as

$$\begin{aligned} \int {d{\mathbf{r}}} \frac{{\delta^{2} E_{\text{xc}} }}{{\delta \rho^{2} }}\left( {\chi_{\mu } \chi_{\nu } } \right) & = \frac{1}{4}\int {d{\mathbf{r}}} \left( {\chi_{\mu } \chi_{\nu } } \right)\rho_{0}^{\left( p \right)} \left\{ {\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \rho_{\alpha } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \rho_{\alpha } \partial \rho_{\beta } }} + \frac{{\partial^{2} E_{\text{xc}} }}{{\partial \rho_{\beta } \partial \rho_{\beta } }}} \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\chi_{\mu } \chi_{\nu } } \right)\left( {\nabla \rho_{\alpha } \cdot\nabla \rho_{0}^{\left( p \right)} } \right) \\ & \quad \times \left\{ {\begin{array}{*{20}l} {2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\beta } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\beta } }}} \hfill \\ { + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } \partial \rho_{\beta } }}} \hfill \\ \end{array} } \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\nabla \left( {\chi_{\mu } \chi_{\nu } } \right) \cdot \nabla \rho_{\alpha } } \right)\rho_{0}^{\left( p \right)} \\ & \quad \times \left\{ {\begin{array}{*{20}l} {2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\beta } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\beta } }}} \hfill \\ { + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } \partial \rho_{\beta } }}} \hfill \\ \end{array} } \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\nabla \left( {\chi_{\mu } \chi_{\nu } } \right) \cdot \nabla \rho_{\alpha } } \right)\left( {\nabla \rho_{\alpha } \cdot\nabla \rho_{0}^{\left( p \right)} } \right) \\ & \quad \times \left\{ {\begin{array}{*{20}l} {4\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \gamma_{\alpha \alpha } }} + 8\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \gamma_{\beta \beta } }} + 8\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \gamma_{\alpha \beta } }} + 4\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \gamma_{\beta \beta } }}} \hfill \\ { + 8\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \gamma_{\alpha \beta } }} + 4\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } \partial \gamma_{\alpha \beta } }}} \hfill \\ \end{array} } \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\nabla \left( {\chi_{\mu } \chi_{\nu } } \right) \cdot \nabla \rho_{0}^{\left( p \right)} } \right)\left\{ {2\frac{{\partial E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } }} + 2\frac{{\partial E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } }} + 2\frac{{\partial E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } }}} \right\} \\ \\ \end{aligned}$$
(10.61)

Similarly, the second term of Eq. (10.54) is the triplet-excitation term and written as:

$$\begin{aligned} \int {d{\mathbf{r}}} \frac{{\delta^{2} E_{\text{xc}} }}{{\delta m^{2} }}m_{i}^{\left( p \right)} \left( {\chi_{\mu } \sigma_{i} \chi_{\nu } } \right) & = \frac{1}{4}\int {d{\mathbf{r}}} \left( {\chi_{\mu } \chi_{\nu } } \right)m_{i}^{\left( p \right)} \left\{ {\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \rho_{\alpha } \partial \rho_{\alpha } }} + \frac{{\partial^{2} E_{\text{xc}} }}{{\partial \rho_{\beta } \partial \rho_{\beta } }} - 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \rho_{\alpha } \partial \rho_{\beta } }}} \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\chi_{\mu } \chi_{\nu } } \right)\left( {\nabla \rho_{\alpha } \cdot\nabla m_{i}^{\left( p \right)} } \right) \\ & \quad \times \left\{ {2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\alpha } }}2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\beta } }} - 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\beta } }} - 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\alpha } }}} \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\nabla \left( {\chi_{\mu } \chi_{\nu } } \right) \cdot \nabla \rho_{\alpha } } \right)m_{i}^{\left( p \right)} \\ & \quad \times \left\{ {2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\alpha } }} + 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\beta } }} - 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \rho_{\alpha } }} - 2\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \rho_{\beta } }}} \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\nabla \left( {\chi_{\mu } \chi_{\nu } } \right) \cdot \nabla \rho_{\alpha } } \right)\left( {\nabla \rho_{\alpha } \cdot\nabla m_{i}^{\left( p \right)} } \right) \\ & \quad \times \left\{ {4\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \gamma_{\alpha \alpha } }} + 4\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } \partial \gamma_{\beta \beta } }} - 8\frac{{\partial^{2} E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } \partial \gamma_{\beta \beta } }}} \right\} \\ & \quad + \frac{1}{4}\int {d{\mathbf{r}}} \left( {\nabla \left( {\chi_{\mu } \chi_{\nu } } \right) \cdot \nabla m_{i}^{\left( p \right)} } \right)\left\{ {2\frac{{\partial E_{\text{xc}} }}{{\partial \gamma_{\alpha \alpha } }} + 2\frac{{\partial E_{\text{xc}} }}{{\partial \gamma_{\beta \beta } }} - 2\frac{{\partial E_{\text{xc}} }}{{\partial \gamma_{\alpha \beta } }}} \right\} \\ \end{aligned}$$
(10.62)

In NTChem, these matrix elements of the noncollinear exchange–correlation kernel and functional derivatives of exchange–correlation functional for the LDA, GGA, and meta-GGA functionals have been derived and implemented into efficient computer codes with the aid of a newly developed computerized symbolic algebra system.

10.3.2 Automatic Implementation

Increasing complexity of quantum chemistry methods, most of the modern exchange–correlation functionals have rather complicated forms and manual implementation of these algebraic formulas into a computer program is often impractical. In particular, the problem is more serious in implementing the nth order properties, which require the same order derivatives of the exchange–correlation functionals because of the nonlinear dependencies on density matrices.

Alternatively, several automatic implementations have been attempted using symbolic differentiation techniques [46, 47] or automatic differentiation techniques [48]. In NTChem, such implementation was achieved with the aid of a newly developed computerized symbolic algebra system. The automatic code generator performs differentiations using the SymPy library, which is an open-source symbolic mathematics library for the Python programming language.

The procedure for implementation of the exchange–correlation functional using our automatic implementation program is shown below.

The first thing to do is to write out the definition formula in the original paper in the input file. In this input file, the functional is described in multiple lines using the predefined input/output variable and the intermediate variable defined by the author, whereas in many programs those are defined with only one line. Figure 10.1 shows the input file of spin-polarized form of PBE exchange functional [49], which is defined as:

Fig. 10.1
figure 1

Input equations of PBE exchange functional

$$s_{\sigma } = \frac{{\left| {\nabla \gamma_{\sigma \sigma } } \right|}}{{\rho_{\sigma }^{{{4 \mathord{\left/ {\vphantom {4 3}} \right. \kern-0pt} 3}}} }}c_{s} ,$$
(10.63)
$$E_{\text{x}} = \sum\limits_{\sigma = \alpha ,\beta } {C_{x} \rho_{\sigma }^{{\frac{4}{3}}} \left( {1 + \kappa - \frac{\kappa }{{1 + \frac{{\mu s_{\sigma }^{2} }}{\kappa }}}} \right)} ,$$
(10.64)

where \(\kappa\), \(\mu\), and \(c_{s}\) are constants independent of electron density. Here, the right-hand side of each line is written in the SymPy format, which is similar to Fortran’s grammar, and variables are defined in order from above in the same way as in ordinary programs. As predefined input and output variables, “Exc” indicates the exchange-correlation energy of output and “rhoa” and “gma” are the input the alpha-spin density \(\rho_{\alpha }\) and its gradient \(\gamma_{\alpha \alpha } = \nabla \rho_{\alpha } \cdot \nabla \rho_{\alpha }\), respectively (accordingly “rhob” and “gmb” denote the beta-spin quantities). In this way, those definitions can be described in the input file just like implementing into code. Importantly, at this stage, the SymPy library itself merely interprets the variables and does not optimize or deform the expressions at all, so it is possible to use the traditional programming techniques in some extent, such as avoiding zero-division and omitting digits.

After reading the input file, the autogeneration program checks the dependency on the input variables for each line. Based on the input variable dependency, the autogeneration program performs differentiation for each expression up to the desired rank. If there is a derivative of the intermediate variable that becomes zero, those terms are searched and erased in all expressions. In case of closed-shell system, duplicate calculations are erased by replacing the electron density of beta spin with alpha spin. Figure 10.2 shows the result of differentiation of the input of Fig. 10.1 for conversion to a closed-shell system. Here, “d1Exd1” indicates the first derivative of the input variables of “Ex”. At this point, we have not yet done the optimization that SymPy provides yet, so we still can find many common terms generated by chain rules.

Fig. 10.2
figure 2

Output equations of first derivative of PBE exchange functional derived by autogeneration program

Next is the optimization of the whole expression. This is particularly important for rather long functional expressions to reduce the number of floating-point operations by extracting common subexpressions and if nonoptimized compilers are evoked afterward. In order not to destroy the formula of the input at the input stage much here, we developed a new optimization program that considers only “break down” and “common term” instead of using SymPy’s advanced optimization. Figure 10.3 shows the result of optimizing the equations in Fig. 10.2. Despite only being optimized by extremely simple rules, the mathematical expressions generated are sufficiently optimal expressions.

Fig. 10.3
figure 3

Working equations of the first derivative of PBE exchange functional derived and optimized by autogeneration program

The expressions are finally translated into Fortran routines with the addition of the proper skeleton common to all functionals. A conditional branch statement can also be added to this skeleton program. This capability enables us to treat classes of functionals that have stability issues, including meta-GGA and range-separated hybrid functionals, in NTChem.

10.4 Applications

10.4.1 Dynamic Polarizabilities of SnH4 and PbH4

As a first application, dynamic polarizabilities of SnH4 and PbH4 molecules were calculated by two-component TDDFT for linear response, in which noncollinear magnetism was considered for all response calculations. These calculations were performed with various exchange–correlation functional functions, where SVWN [50, 51] as LDA functional, BLYP [52, 53] as pure GGA functional, B3LYP [54] as hybrid type functional, LC-BLYP [55] as range-separated functional, and CAM-B3LYP [56] as range-separated hybrid function were used.

To compare relativistic effects, we used nonrelativistic Hamiltonian, spin-free Hamiltonian, and full relativistic Hamiltonian including spin–orbit interaction. Those Hamiltonians are obtained from spin-free and spin-dependent parts of the third- and first-order Douglas–Kroll Hamiltonians, respectively. The screened nucleus spin–orbit approximation was adopted for the spin-dependent part. Pol-DK basis set [57] was used for relativistic calculation, and Pol basis set [58] was used for nonrelativistic calculation. The molecular structures were Td symmetry, and the bond lengths r(Sn–H) and r(Pb–H) were 1.7108 Å and 1.742 Å, respectively [59].

Figures 10.4 and 10.5 show the dynamic polarizabilities of SnH4 and PbH4, respectively, by TDDFT, CCSD-LR, and TDHF with spin-free DK3 Hamiltonian. In both systems, LDA and BLYP overestimate the dynamical polarizability, the extent of which increases as the frequency increases. By adding long-range Hartree–Fock exchange, the overestimation is greatly improved in the results of the hybrid functional and the range-separated functional, which are in good agreement with the CCSD-LR results. However, in PbH4, the correction in the hybrid functional B3LYP is not sufficient, and at a large frequency, the polarizability is overestimated. The importance of long-range exchange interaction with such frequency-dependent dynamical polarizability and its dispersion has been discussed.

Fig. 10.4
figure 4

Dynamical polarizabilities of SnH4 by TDDFT, CCSD-LR, and TDHF with spin-free DK3 Hamiltonian

Fig. 10.5
figure 5

Dynamical polarizabilities of PbH4 by TDDFT, CCSD-LR, and TDHF with spin-free DK3 Hamiltonian

In Figs. 10.6 and 10.7, dynamical polarizabilities of SnH4 and PbH4 with the Hamiltonian of various relativistic approximation levels obtained by RHF and LC-BLYP methods are shown. The scalar relativistic effect by DK3 increases the polarizability, and its magnitude is greater for Pb, a heavier element. The effect of electronic correlation is larger than the relativistic effect in the polarizability calculation in the comparison between RHF and LC-BLYP. From the comparison between LC-BLYP and RHF, it is shown that the contribution of the electron correlation to the polarizability is equal to or greater than those of the relativistic effect. Furthermore, by comparing the results with or without the spin–orbit interaction, it is found that the spin–orbit effect also increases the polarizability at low frequencies far from the poles, but its magnitude is small and less than 1%. However, as seen in 0.22 a.u. in Fig. 10.7, in the vicinity of the poles, the orbitals of Pb are split by spin–orbit interaction, so that a large influence of spin–orbit interaction on polarizability is observed.

Fig. 10.6
figure 6

Dynamical polarizabilities of SnH4 with the Hamiltonian of various relativistic approximation levels

Fig. 10.7
figure 7

Dynamical polarizabilities of PbH4 with the Hamiltonian of various relativistic approximation levels

10.4.2 Excitation Spectra of HI

For the next test, complex dynamic polarizabilities, that is, excitation energies of HI molecule, were calculated by the damped-response calculation. Those obtained peaks were compared with excitation energy obtained from pole/residue calculation. In the pole/residue calculation, we obtained 50 roots from the bottom. The damping factor in Eq. (10.6) is set to 0.004 a.u. in the all damped-response calculations. LC-ωPBE [60,61,62], which is a range-separated functional, was used as the exchange–correlation functional. The Ext-Pol basis set and Ext-Pol-DK basis [63] set were used in nonrelativistic and relativistic calculation, respectively. The relativistic Hamiltonians are obtained from spin-free and spin-dependent parts of the third- [64] and first-order [14] Douglas–Kroll Hamiltonians, respectively. The screened nucleus spin–orbit approximation [65] was adopted for the spin-dependent part.

The calculated dynamical polarizabilities with or without damping and transition dipoles obtained by pole/residue calculation are shown in Figs. 10.8, 10.9, and 10.10. From Figs. 10.8 and 10.9, the divergence of the dynamic polarizabilities at the poles shown in Fig. 10.9 is suppressed in Fig. 10.8 by introducing the effect of the relaxation of the excitation, but instead the imaginary polarizabilities appear. The position and the relative size of the imaginary polarizability are in good agreement with the square of the magnitude of the transition dipole by the pole/residue calculation. Here, Fig. 10.10 shows the peak of the pole/residue calculation is only up to 0.35 a.u. because the 50 roots obtained by the pole/residue calculation failed to cover the whole frequency range of 0.0 a.u. to 0.4 a.u. On the other hand, the imaginary polarizability obtained by the damped-response theory can be calculated with sufficient precision for all the regions of interest within similar calculation time. In the peak consisting of many excitations like the second big peak around 0.33 a.u., since the respective states are averaged by the damping factor at the calculated imaginary polarizabilities, it is difficult to analyze the characteristics of those excited states.

Fig. 10.8
figure 8

Dynamical polarizabilities of HI with damping

Fig. 10.9
figure 9

Dynamical polarizabilities of HI without damping

Fig. 10.10
figure 10

Transition dipoles obtained by pole/residue calculation

Figures 10.11 and 10.12 show the results of nonrelativistic and the result including scalar and so relativistic effect. As shown in Figs. 10.8 and 10.11, the real and imaginary polarizabilities are slightly shifted by the scalar relativistic effect, but the peak shape itself does not change much. Also, because the distribution of electron density changes due to the relativistic effect, absorption around 0.21 a.u. can be seen. However, from Figs. 10.8 and 10.12, the spin–orbit interaction greatly changes the shape of the spectrum, which can be understood from the splitting of atomic orbitals of I atom because of the large spin–orbit interaction of the I atom. From these results, we can say that the spin–orbit interaction is extremely important near the pole of the dynamical polarizabilities and excitation energies compared with other relativistic terms.

Fig. 10.11
figure 11

Dynamical polarizabilities of HI with nonrelativistic calculations

Fig. 10.12
figure 12

Dynamical polarizabilities of HI calculated with both scalar and spin–orbit relativistic effects

10.5 Conclusion

In this review article, the two-component relativistic linear-response TDDFT for molecular properties is derived and implemented into NTChem program suite. Applying an empirical damping for the electronic excited states has shown that response suitable for simulating dispersion curves can be calculated. The damping avoids singularities in the calculated real part of the polarizability around the resonance frequencies. Further, the damping technique yields both the real and imaginary parts of dipole polarizability with the latter being directly related to the radiation absorption of the system. Such an approach makes it possible to calculate absorption properties within a selected frequency window. This feature could potentially make this direct response route an alternative to common TDDFT pole-/residue-based excitation spectra calculations in the case of large molecules having a large number of excitations within and below a frequency window of interest.

Our implementation is based on a noncollinear exchange–correlation potential presented by Wang et al. In addition, since it is difficult to manually implement the latest complicated functional, the computerized symbolic algebra system is developed and used for those complicated implementation in NTChem. The automatic code generator performs differentiations using the SymPy library, which is an open-source symbolic mathematics library for the Python programming language.

By using the present approach, calculations of the frequency-dependent polarizabilities of SnH4 and PbH4 molecules containing heavy atoms were carried out. In the calculation of the dispersion of the polarizability, it is found that the relativistic effect and the electronic correlation effect are about the same, while the spin–orbit interaction is not so large. The two-component TDDFT was also applied to the excitation spectra of HI molecule. The calculated spectra from the imaginary part of damped dynamical polarizabilities are in excellent agreement with those obtained using poles/residues TDDFT. It is found that the spin–orbit interaction is extremely important in the dynamical polarizabilities near the pole and excitation energies.