Introduction

Vibrational spectroscopies are one of the most powerful, fast and reliable methods for materials’ structure identification and characterization. Among the different techniques probing atomic motions, infrared (IR) absorption and Raman experiments are widespread in most experimental setups, thanks to their low cost and precision in identifying microscopic features. Despite these advantages, data interpretation for many cases calls for theoretical and computational support. Density-functional theory (DFT) is most often employed as a reliable framework for accurate predictions of such spectra, providing in principle exact estimates of the second- and third-order derivatives of the energy functional that are needed to predict these vibrational spectra. Over the past decade, many techniques have been developed to efficiently obtain non-resonant spectra of insulating crystals, such as linear-response theory1,2,3,4,5 for infrared absorption, second-order response of the density matrix6 and the 2n + 1 theorem7 for Raman couplings. While being elegant and attractive, these methods come at the cost of rather complex code implementations, limiting in practice applications to selected semi-local functionals and often only to norm-conserving pseudopotentials. This is especially the case for the third-order derivatives of the total energy, required for the Raman calculations. One common expedient for the latter is to resort to finite differences of the dielectric tensor upon atomic displacements, computed using density-functional perturbation theory (DFPT)8,9. However, this approach scales in general as 6Nat with the number of atoms Nat, a burden in low-symmetry systems, and becomes out of reach for the non-linear optical susceptibility tensor, which has been shown to be fundamental to achieve good agreement for Raman intensities both in single crystals10 and powder spectra11. An alternative framework for carrying out such derivatives is the finite numerical differentiation of forces and polarization upon the application of a homogeneous electric field7,12,13,14,15. With this technique, along with finite displacements16, one can compute straightforwardly all the quantities needed for IR and Raman spectra, as well as allowing to use any functional (Hubbard corrected, hybrids, ...), and pseudopotential formalism (norm-conserving, ultrasoft, PAW)17 with little effort. Furthermore, the use of finite fields overcomes the expensive computation and poor scaling of the finite dielectric tensor approach, allowing for the study of complex materials such as amorphous and defective structures18,19,20. In fact, with the present approach, one would need to perform typically only 12 ground-state calculations in the presence of a homogeneous electric field (see Eq. (19) and related discussion). While appealing, this avenue has seen scarce applicability, possibly due to the many steps and pitfalls related to the underlying algorithm, which can be highly non-trivial even for expert users.

A key step forward is to streamline all of these operations through a modern workflow manager, adhering in passing to the FAIR21 principles for data sharing, while being able of automatically submitting, parsing, and processing the outputs generated by multiple calculations. In this study, we present a comprehensive formulation for a unified finite-displacement and finite-field approach, along with efficient Brillouin zone sampling, and encode this formalism in a self-contained Python package that operates within the AiiDA framework22,23, offering a scalable computational infrastructure for automated and reproducible workflows and data provenance. To showcase these capabilities, we demonstrate its effectiveness in predicting the infrared and Raman spectra of LiNbO3 using seven different functionals: LDA, PBE, PBEsol, PBEsol+U, PBEsol+U+V, PBE0, and HSE06.

Results

The finite-displacement and finite-field method

Infrared and Raman spectroscopy are investigation methods probing the atomic vibrations of materials. In both techniques, a source of light shines on the sample, and the incident photons are either absorbed or scattered by the material. In IR experiments, peaks of the absorption spectra correspond to collective atomic motions in resonance with that frequency, corresponding to long-wavelength polar optical phonons. Raman spectroscopy records instead a scattered frequency ωS; in this case, the excited lattice vibration corresponds to the shift ± ων = ωL − ωS from the incoming laser frequency ωL, where the plust (minus) sign refers to (anti-)Stokes process for which a phonon is created (annihilated). Far from resonance the two phenomena can be captured by the change in polarization P and the change in susceptibility χ, for IR and Raman respectively, leading to different selection rules24 for the activated phonon modes which ultimately provide a comprehensive fingerprint of the material. The former mechanism is coupled to the Born effective charge \({{{{\bf{Z}}}}}_{I}^{* }\)5,25 of an atom I in the unit cell, and the latter instead to the Raman tensor defined as dχ/dτI in the Placzek approximation26,27,28, where χ is the electronic susceptibility tensor and τI the atomic displacement. In terms of these quantities, the absorption intensities in the infrared regime of a normal mode ν with angular frequency ων are:

$${I}_{{{{\rm{IR}}}}}^{\nu }=\frac{| {\bar{{{{\bf{Z}}}}}}^{\nu }{| }^{2}}{{\omega }_{\nu }},$$
(1)

associated to the imaginary part of the complex dielectric function5,18,29

$${\epsilon }_{ij}(\omega )={\epsilon }_{ij}^{\infty }+\frac{4\pi }{\Omega }\mathop{\sum}\limits_{\nu }\frac{{\bar{Z}}_{i}^{\nu }{\bar{Z}}_{j}^{\nu }}{{\omega }_{\nu }^{2}-{\omega }^{2}},$$
(2)

which is connected to other measurable quantities, such as the energy loss function and reflectivity spectrum5,18,29 (\({\epsilon }_{ij}^{\infty }\) is the high-frequency dielectric tensor). The amplitudes are defined via the polarization vector

$${\bar{Z}}_{i}^{\nu }=\mathop{\sum}\limits_{I,k}{Z}_{I,ik}^{* }\frac{{e}_{I,k}^{\nu }}{\sqrt{{m}_{I}}},$$
(3)

where \({e}_{I,k}^{\nu }\) is the phonon eigenvector of the mode ν, describing the collective dynamics of atoms (index I) in space (index k). In particular, the relationship to the reflectivity \({{{\mathcal{R}}}}(\omega )\) of optical waves oriented perpendicularly to the surface and having their electric field along a crystal optical axis q is

$${{{\mathcal{R}}}}(\omega )=\left| \frac{\sqrt{{\epsilon }_{\hat{{{{\bf{q}}}}}}(\omega )}-1}{\sqrt{{\epsilon }_{\hat{{{{\bf{q}}}}}}(\omega )}+1}\right| ,$$
(4)

where \({\epsilon }_{\hat{{{{\bf{q}}}}}}(\omega )=\hat{{{{\bf{q}}}}}\cdot {{{\boldsymbol{\epsilon }}}}(\omega )\cdot \hat{{{{\bf{q}}}}}\) and \(\hat{{{{\bf{q}}}}}\) is the versor of q. The Raman scattering intensities are instead, in the Placzek approximation26,27

$${I}_{{{{\rm{Raman}}}}}^{\nu }\propto \frac{{\omega }_{S}^{4}}{{\omega }_{\nu }}({n}_{\nu }(T)+1)| {{{{\bf{e}}}}}_{S}\cdot {{{{\boldsymbol{\alpha }}}}}^{\nu }\cdot {{{{\bf{e}}}}}_{L}{| }^{2}$$
(5)

for Stokes processes for which ωS = ωL − ων, and where eL,S represent the photon polarization vectors, orthogonal to their propagation vectors kL,S, and nν(T) is the Bose-Einstein occupation function; αν is the Raman susceptibility tensor

$${\alpha }_{ij}^{\nu }=\sqrt{\Omega }\mathop{\sum}\limits_{I,k}\frac{\partial {\chi }_{ij}}{\partial {\tau }_{I,k}}\frac{{e}_{I,k}^{\nu }}{\sqrt{{m}_{I}}},$$
(6)

where mI is the mass of the atom I and Ω the volume of the unit cell. In anti-Stokes processes, the prefactor (nν(T) + 1) must be replaced with nν(T), and ωS = ωL + ων. The ratio of Stokes and anti-Stokes peak intensities is therefore temperature dependent, and, interestingly, can be used as a microscopic thermometer30. In the harmonic approximation, the phonon normal modes are obtained from the interatomic force constants (IFCs)

$${\Phi }_{IJ,ij}(a,b)=\frac{{\partial }^{2}E}{\partial {\tau }_{I,i}^{a}\partial {\tau }_{J,j}^{b}},$$
(7)

where E is the potential-energy surface, and a and b indicate the periodic images with respect to the origin (i.e., the unit cell). The IFCs can be written in terms of first-order derivative of atomic forces FI with respect to atomic displacements, and thus can also be obtained using a set of small displacement configurations in supercells, as discussed in the literature5,16, rather than the more efficient density-functional perturbation theory approach. One can exploit periodic-boundary conditions to conveniently Fourier transform the IFCs, and rewrite the latter as a function of the wavevector q; the mass-scaled of this Fourier transform is the dynamical matrix describing the harmonic ion dynamics

$${D}_{IJ,ij}({{{\bf{q}}}})=\frac{1}{\sqrt{{m}_{I}{m}_{J}}}\mathop{\sum}\limits_{b}{\Phi }_{IJ,ij}(0,b){e}^{i{{{\bf{q}}}}\cdot ({\bf R}_{J}^{b}-{\bf R}_{I}^{0})},$$
(8)

where \({\mathbf{R}}_J^b\) is the equilibrium position of atom J in the l-th unit cell image. The diagonalization of the dynamical matrix leads to the phonon frequencies and eigenvectors

$$\mathop{\sum}\limits_{J,j}{D}_{IJ,ij}({{{\bf{q}}}}){e}_{J,j}^{\nu }({{{\bf{q}}}})={[{\omega }_{\nu }({{{\bf{q}}}})]}^{2}{e}_{I,i}^{\nu }({{{\bf{q}}}}).$$
(9)

IR and Raman spectroscopies utilize photons which carry a negligible momentum q ≈ 0, thus only probing phonons in the vicinity of the zone center. For exactly q = 0, the phase factor in Eq. (8) becomes the unit, allowing for the calculation of the IFCs via finite-displacements in the primitive cell only, as the displacement patterns are defined uniquely in such cell. Nevertheless, the evaluation of the dynamical matrix in the long-wavelength limit, i.e., when q → 0, in the case of polar materials requires a proper treatment of its non-analytical behavior4,5, accounting for the coupling between phonon polarization densities and electric fields, that adds an extra cost for displacements that create a macroscopic electric field, absent in periodic-boundary calculations of the primitive cell only. The analytical shape of this coupling depends on the dimensionality of the material4,5,31,32 and on the multipolar order33. At the dipolar level, the dynamical matrix in such limit reads

$${D}_{IJ,ij}({{{\bf{q}}}}\to {{{\bf{0}}}})={D}_{IJ,ij}({{{\bf{q}}}}={{{\bf{0}}}})+{D}_{IJ,ij}^{NA}({{{\bf{q}}}})$$
(10)

where the non-analytical contribution is

$${D}_{IJ,ij}^{NA}({{{\bf{q}}}})=\frac{1}{\sqrt{{m}_{I}{m}_{J}}}\frac{{W}^{d}({{{\bf{q}}}})}{\Omega }\left[\left(\mathop{\sum}\limits_{l}{q}_{l}{Z}_{I,li}^{* }\right)\left(\mathop{\sum}\limits_{{l}^{{\prime} }}{q}_{{l}^{{\prime} }}{Z}_{J,{l}^{{\prime} }j}^{* }\right)\right],$$
(11)

valid for q → 0 and where Wd is the Coulomb screening whose shape depends on the dimensionality d (see e.g., refs. 31,32). The directional dependence of the polar optical phonon wavevector q of the dynamical matrix gives rise to a shift in frequency and a change in eigenvector compared to the transverse optical modes (i.e., \({\bar{{{{\bf{Z}}}}}}^{\nu }({{{\bf{q}}}})\cdot {{{\bf{q}}}}=0\)), giving rise to the well known splitting between the longitudinal optical (LO) and transverse optical (TO) modes25; this shift is largest when \({\bar{{{{\bf{Z}}}}}}^{\nu }({{{\bf{q}}}})\parallel {{{\bf{q}}}}\). Analogously to the IFCs, the Born effective charges and Raman tensors can also be defined as derivatives of forces with respect to a macroscopic electric field \({{{\bf{{{{\mathcal{E}}}}}}}}\)4. For the former we have:

$${Z}_{I,ij}^{* }=\frac{\partial {F}_{I,j}}{\partial {{{{\mathcal{E}}}}}_{i}}$$
(12)

while for the latter, the Raman tensor reads:

$$\frac{\partial {\chi }_{ij}}{\partial {\tau }_{I,k}}=\frac{1}{\Omega }\frac{{\partial }^{2}{F}_{I,k}}{\partial {{{{\mathcal{E}}}}}_{i}\partial {{{{\mathcal{E}}}}}_{j}}.$$
(13)

In a finite-difference scheme, this means that a small homogeneous electric field must be applied in order to carry out the numerical differentiation. In periodic-boundary conditions, this can be accomplished by extending the energy functional E[ψ] to include a term12,13,34 accounting for the coupling of the electric field and the total polarization of the system (often referred as electric-enthalpy functional):

$${{{\mathcal{F}}}}[\psi ,{{{\boldsymbol{{{{\mathcal{E}}}}}}}}]=E[\psi ]-\Omega \,{{{\boldsymbol{{{{\mathcal{E}}}}}}}}\cdot [{{{{\bf{P}}}}}^{{{{\rm{ion}}}}}+{{{{\bf{P}}}}}^{{{{\rm{el}}}}}[\psi ]],$$
(14)

where Pion and Pel are the ionic and electronic polarizations, respectively; the latter being described by the modern theory of polarization35,36. Such functional, while not bounded from below, admits local minima representing self-consistent stationary solutions12,13, if \({{{\boldsymbol{{{{\mathcal{E}}}}}}}}\) is properly chosen. We note that in many implementations (such as the present one) the electric enthalpy functional is not directly minimized37,38, but it is recast in a non-local operator which couples neighboring k-points and which is solved self-consistently among all k-points (see refs. 39,40,41 for details). The self-consistent solution of the functional guarantees the simultaneous evaluation of Hellmann-Feynman forces, and electronic polarization, at convergence. As a consequence, the electronic polarization (that comes for free) can be exploited to extract its first and second-order derivatives with respect to an electric field7,13,18. These correspond respectively to the high-frequency dielectric tensor ϵ, used to calculate the screened Coulomb interaction in Eq. (11)4,31,32, the full complex dielctric tensor (Eq. (4)), and the non-linear optical susceptibility χ(2), key in non-centrosymmetric crystals where the Fröhlich contribution (see Eq. (17)) to the Raman tensor could be sizable10,11. Their relationship with the electronic polarization derivatives is as follows:

$${\epsilon }_{ij}^{\infty }={\delta }_{ij}+\frac{4\pi }{\Omega }\frac{\partial {{{{\rm{P}}}}}_{i}^{{{{\rm{el}}}}}}{\partial {{{{\mathcal{E}}}}}_{j}},$$
(15)
$${\chi }_{ijk}^{(2)}=\frac{2\pi }{\Omega }\frac{{\partial }^{2}{{{{\rm{P}}}}}_{i}^{{{{\rm{el}}}}}}{\partial {{{{\mathcal{E}}}}}_{j}\partial {{{{\mathcal{E}}}}}_{k}}.$$
(16)

For non-vanishing χ(2), the Raman tensor in 3D solids is modified as follows10,11,42:

$$\frac{\partial {\chi }_{ij}}{\partial {\tau }_{I,k}}({{{\bf{q}}}})=\frac{\partial {\chi }_{ij}}{\partial {\tau }_{I,k}}-\frac{8\pi }{\Omega }\frac{{\sum }_{l}{q}_{l}{Z}_{I,lk}^{* }}{{\sum }_{s,{s}^{{\prime} }}{q}_{s}{\epsilon }_{s{s}^{{\prime} }}^{\infty }{q}_{{s}^{{\prime} }}}\mathop{\sum}\limits_{{l}^{{\prime} }}{\chi }_{ij{l}^{{\prime} }}^{(2)}{q}_{{l}^{{\prime} }},$$
(17)

which gives a second q dependence contribution to the Raman spectra intensities (the first being given by the change in phonon eigenvectors and frequencies).

Numerical differentiation

The possibility of consistently describing homogenoues electric fields allows to access any derivative in atomic displacements and electric field, while being easily applicable to advanced functionals and pseudopotential formalisms15,17. We calculate here the tensors for infrared and Raman cross-sections using a central derivative formulation. These derivatives are performed around \({{{\boldsymbol{{{{\mathcal{E}}}}}}}}={{{\boldsymbol{0}}}}\), which resembles the common experimental setup where an external electromagnetic source is negligible, either natural or artificial. Indicating (by dropping the indices) as A either a force or the electronic polarization, we calculate its m-th derivatives with a numerical accuracy of n-th order via the discretization formula:

$$\frac{{\partial }^{m}A}{\partial {{{{\mathcal{E}}}}}_{i}^{m}}=\frac{1}{\Delta {{{{\mathcal{E}}}}}_{i}^{m}}\mathop{\sum }\limits_{l=-n/2}^{n/2}\,{c}_{l}^{m}\,A\left(l\cdot \Delta {{{{\mathcal{E}}}}}_{i}\right)+{{{\mathcal{O}}}}(\Delta {{{{\mathcal{E}}}}}_{i}^{n}),$$
(18)

where \(\Delta {{{{\mathcal{E}}}}}_{i} > 0\) is the small electric field, which we refer to as the finite difference step, along the i-th Cartesian direction, and \({c}_{l}^{m}\) are the central derivative coefficients that can be automatically found using the Fornberg’s algorithm43. The discretization is performed using uniform steps such that \(l=-\frac{n}{2},\ldots ,0,\ldots ,\frac{n}{2}\) is always an integer number and the applied fields are evenly spaced (see Fig. 1a). This is at variance with the approach of calculating gradients for Bravais lattices with finite differences of ref. 44, to use standard expressions for the higher-order and mixed derivatives. For mixed second-order derivatives of A, i.e., for the Raman and non-linear susceptibility tensors, we exploit a formula devised in ref. 18 to reduce the number of calculations: we assign \({{{{\mathcal{E}}}}}_{i}={{{{\mathcal{E}}}}}_{j}=\lambda\) and express the mixed derivative as:

$$\frac{{\partial }^{2}A}{\partial {{{{\mathcal{E}}}}}_{i}\partial {{{{\mathcal{E}}}}}_{j}}=\frac{1}{2}\left[\frac{{\partial }^{2}A}{\partial {\lambda }^{2}}-\frac{{\partial }^{2}A}{\partial {{{{\mathcal{E}}}}}_{i}^{2}}-\frac{{\partial }^{2}A}{\partial {{{{\mathcal{E}}}}}_{j}^{2}}\right],$$
(19)

where each second-order derivative is evaluated through Eq. (18); this can be visualized schematically in Fig. 1(a). For example, using a 2nd-order numerical accuracy, we would need only 12 self-consistent field (SCF) calculations with a non-zero electric (\(\Delta {{{\mathcal{E}}}}\)-SCF) field to determine all the tensors’ components needed both for IR and Raman spectra, even in low-symmetry systems such as amorphous materials18,20; this number can be reduced if one exploits the symmetries of the material. In fact, there could exist symmetries belonging to the point group of the crystal that transform an electric field direction into another. For example, if the crystal satisfies inversion symmetry, this is sufficient to reduce by a half the number of \(\Delta {{{\mathcal{E}}}}\)-SCF calculations needed, since forces and electronic polarization produced by \(\Delta {{{{\mathcal{E}}}}}_{i}\) are connected by a similarity transformation to the one produced by \(-\Delta {{{{\mathcal{E}}}}}_{i}\); keeping the previous numerical example, we would need then just 6 \(\Delta {{{\mathcal{E}}}}\)-SCF calculations. For highly-symmetric crystals, such as cubic Si, only two independent electric field directions must be evaluated (e.g., along Z and the mixed direction XZ); in this case, the number of calculations reduces further to only 2. In general, the number of \(\Delta {{{\mathcal{E}}}}\)-SCF calculations needed scales with the numerical accuracy n of the central formula as \({{{{\mathcal{N}}}}}_{n}=6\cdot n\), not accounting for symmetries. Interestingly, it can be noticed from Fig. 1 that the evaluation of the numerical derivatives at n > 2 provides automatically derivatives at lower accuracy n; this is helpful to check the convergence a posteriori with respect to the finite step size \(\Delta {{{\mathcal{E}}}}\). Some benchmarks and illustrations on a prototypical material are provided in the Supplementary Discussion.

Fig. 1: Illustration of the numerical derivative discretization and of the application of the directional sampling scheme applied to a simple lattice.
figure 1

a Schematic illustration of the discretization needed in Eqs. (18) and (19) for derivatives with respect to the electric field in the directions i = {x, y} and for mixed derivatives along (λ, λ). The black dots represent the applied electric fields used in the SCF calculations to evaluate the electric-field-dependent A (forces or polarization) used in Eqs. (18) and (19), while the dashed colored circles are associated to the accuracy n achieved in the numerical differentiation (here shown up to order n = 6). b, c Square reciprocal lattice showing possible k-point samplings (black dots) of the BZ generated via Eqs. (23)–(24) for the electric field \(\boldsymbol{\tilde{{{{{{{{\mathcal{E}}}}}}}}}}\) shown in crystal coordinates. b shows the case when the electric field is parallel to a lattice vector; in this scenario, more k-points are generated along such direction, by using d, where the induced polarization is expected to be larger. The increased number of k-points in such direction improves the convergence of the calculated polarization via Eq. (21). A more accurate polarization can then be obtained by decreasing the value of d, which in this case turns to linearly increasing the number of k-points. c shows the special case \({\tilde{{{{\mathcal{E}}}}}}_{1}={\tilde{{{{\mathcal{E}}}}}}_{2}\equiv \tilde{{{{\mathcal{E}}}}}/\sqrt{2}\), where the induced polarization is expected along the mixed direction. Since the polarization is a sum of the polarization projected along b1 and b2, Eq. (22), then the k-points are increased along both directions by using d. The generated mesh is equivalent to a uniform mesh defined by a single k-point distance d ≡ d. In this case, when more accurate values are desired, the number of k-points will scale quadratically when decreasing d.

While this approach is advantageous, we also highlight that the choice of the field magnitude is restricted. As already stated before, the electric-enthalpy functional (14) has no global minimum, and long-lived meta-stable states exist only below a certain critical field \({{{{\boldsymbol{{{{\mathcal{E}}}}}}}}}^{c}\), where Zener tunneling is suppressed12,34. An estimate of such critical value can be performed using12:

$$e| {{{{\boldsymbol{{{{\mathcal{E}}}}}}}}}^{{c}}\cdot {{{{\bf{a}}}}}_{i}| \simeq {E}_{{{{\rm{gap}}}}}/{N}_{i}$$
(20)

where e is the electric charge, ai the lattice vectors defining the unit cell, Egap the electronic band gap, and Ni the number of k-points sampling the Brillouin zone in the i-th crystal direction. For semiconductors with small band gaps this critical field can be very small, limiting in practice the convergence due to numerical noise. In these circumstances, a balance must be found; nevertheless, for the majority of cases this does not represent an actual limitation. The last subtlety lies in the choice of the logarithm branch when calculating the Berry-phase polarization; a detailed explanation of the issue along with practical solutions can be found in the Supplementary Methods.

Directional sampling

An additional subtle issue related to the Berry phase formalism used in the electric-enthalpy formulation is the dense sampling of the Brillouin zone required to achieve well converged values of the polarization. In fact, the polarization is a k-space integral of a Berry connection35,36, and the discretized formula for the gradient converges slowly with respect to the k-point distance14 (see also Supplementary Discussion). One can express the electronic polarization using the string-averaged discretized Berry phase formulation35,36 along the direction of a reciprocal lattice vector bi as:

$${{{{\bf{P}}}}}^{{{{\rm{el}}}}}\cdot {{{{\bf{b}}}}}_{i}=\frac{2e}{{N}_{\perp }^{(i)}\Omega }\mathop{\sum }\limits_{l=1}^{{N}_{\perp }^{(i)}}\,{{\mbox{Im}}}\,\ln \mathop{\prod }\limits_{j=0}^{{N}_{\parallel }^{(i)}-1}\det [S({\bf{k}^{(i)}_{l,j}},{{{{\bf{k}}}}}_{l,j+1}^{(i)})].$$
(21)

Here, \({S}_{nm}({{{\bf{k}}}},{{{{\bf{k}}}}}^{{\prime} })=\langle {u}_{n{{{\bf{k}}}}}| {u}_{m{{{{\bf{k}}}}}^{{\prime} }}\rangle\) represents the scalar product between Bloch’s state of band n and k-point k, and state of band m and k-point \({{{{\bf{k}}}}}^{{\prime} }\). Assigning momentarily i = 1 to bi as a way of example, then \({N}_{\perp }^{(1)}={N}_{2}\times {N}_{3}\) is the number of k-point strings parallel to b1, each such string having \({N}_{\parallel }^{(1)}={N}_{1}\) k-points defined as \({{{{\bf{k}}}}}_{l,j}^{(1)}={{{{\bf{k}}}}}_{l}^{(1)}+(j/{N}_{1}){{{{\bf{b}}}}}_{1}\), where \({{{{\bf{k}}}}}_{l}^{(1)}\) belongs to the plane (b2, b3), corresponding to a slice of the full mesh N1 × N2 × N3, and is indexed by l. The total electronic polarization is then given by

$${{{{\bf{P}}}}}^{{{{\rm{el}}}}}=\frac{1}{2\pi }\mathop{\sum }\limits_{i=1}^{3}{{{{\bf{a}}}}}_{i}({{{{\bf{P}}}}}^{{{{\rm{el}}}}}\cdot {{{{\bf{b}}}}}_{i}),$$
(22)

where ai are the direct lattice vectors. In this way, the calculation of the polarization in real space requires to evaluate Eq. (21) for each (reciprocal) lattice vector and on top of very dense meshes. Once the self-consistent electronic charge-density is found, hence the Kohn-Sham Hamiltonian is fixed, one can increase straightforwardly the amount of k-points needed for accurate polarization calculations, by diagonalizing non self-consistently the Kohn-Sham Hamiltonian at the desired grid and thus avoiding the expensive self-consistent cycle. Yet, such diagonalization can be computationally demanding. A smart solution is to compute each Pelbi contribution at a different sampling, noticing that the right-hand side of Eq. (21) converges faster with respect to \({N}_{\perp}^{(i)}\), and consequently one can simply increase the number of k-points along bi, i.e., by increasing Ni only. This allows to scale linearly with the number of points in the string, instead of increasing all Ni (cubic scaling), at the price of performing three calculations instead of a single, overall more expensive, calculation on a very dense mesh. Importantly, one needs to carefully check convergence with respect to both the number of “orthogonal” k-points \({N}_{\perp}^{(i)}\) and the number of k-points per string \({N}_{\parallel}^{(i)}={N}_{i}\). Unfortunately, in the case of a finite electric field, a non-local operator which couples neighboring k-points is introduced in the Hamiltonian39,40,41. This means that, on one hand, one cannot simply diagonalize in a post-processing step the Hamiltonian, and on the other hand, one is in principle not justified to split the calculation in three parts as formerly explained. We then seek a sampling strategy that can simultaneously alleviate the k-points scaling, and that can still provide accurate polarizations. The main idea is to perform a single calculation with a special k-point grid. We can exploit the fact that we are interested in calculating the induced polarization by an homogeneous electric field, contrary to other type of calculations where the direction of the induced polarization, e.g., due to atomic displacements, is less obvious (one can still exploit the strategy proposed above, if an electric field is absent). Let’s assume that the induced polarization by an electric field is larger in the direction of the applied electric field, meaning we can focus on computing it more accurately along such direction, and mimic the strategy reported previously, but using a sole, electric field-dependent, directional k-point mesh. To explain this further, let \({{{{{\tilde{{\boldsymbol{\mathcal{E}}}}}}}}}=({\tilde{{{{\mathcal{E}}}}}}_{1},{\tilde{{{{\mathcal{E}}}}}}_{2},{\tilde{{{{\mathcal{E}}}}}}_{3})\) be the electric field in the lattice reference system. The product Pelbi is then expected to be larger where \({\tilde{{{{\mathcal{E}}}}}}_{i}\) is larger, and, as a consequence, one can increase \({N}_{\parallel }^{(i)}={N}_{i}\) weighted upon the relative value of \({\tilde{{{{\mathcal{E}}}}}}_{i}\) with respect to the the other components of \({\tilde{\boldsymbol{{\mathcal{E}}}}}\). To automate the choice of Ni in a weighted manner, we start by defining two quantities: an orthogonal and a parallel k-point distance, d and d, respectively. The orthogonal distance represents a minimum distance between k-points in the BZ, thus usually producing small Ni - this quantity is used as a reference minimum for Ni in the unique mesh, resembling essentially Ni employed for orthogonal meshes in the three calculations strategy. The parallel distance instead is used to define a weighted Ni which should be greater than its reference minimum, defined previously by the orthogonal distance, when \({\tilde{{{{\mathcal{E}}}}}}_{i}\) is considered large enough (see Fig. 1b, c). To quantify the relative magnitude of \({\tilde{{{{\mathcal{E}}}}}}_{i}\), and consequently choosing the weighting, we assign the following weights:

$${w}_{i}=\frac{| {\tilde{{{{\mathcal{E}}}}}}_{i}| }{\max \{| {\tilde{{{{\mathcal{E}}}}}}_{1}| ,| {\tilde{{{{\mathcal{E}}}}}}_{2}| ,| {\tilde{{{{\mathcal{E}}}}}}_{3}| \}},$$
(23)

aiming at increasing Ni for lattice directions where the electric field is larger, and where we expect the induced electric polarization to be greater. Finally, we can assign the number Ni of the mesh as:

$${N}_{i}=\max \left\{{w}_{i}\frac{| {{{{\bf{b}}}}}_{i}| }{{d}_{\parallel }},\frac{| {{{{\bf{b}}}}}_{i}| }{{d}_{\perp }}\right\}.$$
(24)

This methodology is easy to implement and generates meshes that significantly reduce the number of k-points needed instead when using a uniform sampling, i.e., Ni = bi/d, where d is a constant k-points distance (see Supplementary Discussion for detailed numerical experiments). This scheme allows for linear scaling of k-points with respect to 1/d when the applied electric field is perfectly aligned along one of the lattice vectors, as it can be seen in the simple case of Fig. 1b. In orthorombic systems this is particularly convenient, as the three lattice vectors are parallel to the three Cartesian axis. In general, when the electric field direction is not parallel to one of the lattice vectors, the number of k-points scales as a power of 1/d. In the extreme case when \({\tilde{{{{\mathcal{E}}}}}}_{1}={\tilde{{{{\mathcal{E}}}}}}_{2}={\tilde{{{{\mathcal{E}}}}}}_{3}\), then the number of k-points will scale cubically with respect to the parallel distance, equivalent to a uniform mesh defined by a single k-point distance d ≡ d. This is schematically depicted in Fig. 1c for a simple case in 2D.

Computational workflow

In this section, we finally present the computational workflows that allows to simulate the desired spectra—infrared, Raman, or both—in an automated fashion. We designed two main independent workflows as AiiDA WorkChains22: one carrying out solely the finite displacement calculations for phonon modes to evaluate the IFCs, which we called PhononWorkChain, and the other for the mixed total-energy derivatives via the homogeneous electric fields, the DielectricWorkChain. When joined together, the above two provide the IRamanSpectraWorkChain, as schematically outlined in Fig. 2.

Fig. 2: Schematic representation of the automated workflow for the calculation of infrared and Raman spectra.
figure 2

Computational workflow scheme of the IRamanSpectraWorckChain and of its sub-workflows, the DielectricWorkChain and the PhononWorkChain. The inputs can be easily, fully defined via the get_builder_from_protocol while specifying only a StructureData and a Code. The black circles on top of boxes mean that the calculation starts using charge density and wavefunctions from a previous calculation.

The IRamanSpectraWorkChain takes as inputs a structure, a code and other details on how to run the workflows (e.g., SCF parameters, wall-time, parallelization options, and so on). These information are then split and/or shared between the two sub-workflows. Both start running an initial SCF ground-state calculation, meant to produce the charge density ρ0 and wavefunctions {ψi} that will be used as a starting point for the next runs. We represent this restart throughout the flowchart of Fig. 2 using a rotating white arrow in a black circle, and we use the dashed arrows to indicate that the files have been copied over to a fresh new folder. When these calculations are finished, the PhononWorkChain generates the structures with irreducible atomic displacements, using Phonopy16, and computes their forces. The latter are then used to produce the matrix of IFCs in the unit cell (although the PhononWorkChain is designed to compute the IFCs in a generic supercell), which are employed in a post-processing step to obtain the phonon frequencies and eigenvectors by diagonalizing the corresponding dynamical matrix, Eq. (10), for q → 0. In parallel, the DielectricWorkChain evaluates \({{{{\mathcal{E}}}}}^{c}\) through a non-SCF calculation and extracts the numerical accuracy n and the electric field step \(\Delta {{{\mathcal{E}}}}\), as follows: when the critical value is larger than 10−4 Ry a.u. (we use Rydberg atomic units; 1 Ry a.u. ≈ 36.3609 V/Å), a 4th-order numerical expansion is chosen, otherwise a 2nd order is used. The 4th-order allows to achieve a greater numerical accuracy for finite differences; thus, it is utilized whenever it is possible to apply an electric field above threshold. If the electric field that can be applied is smaller than 10−4 Ry a.u., a 2nd-order expansion is sufficient, thus avoiding calculations that would be affected by too much numerical noise28; the amplitude of the electric field step in fact may result too small to produce significant digit changes in forces and polarization, hence possibly worsening the numerical derivatives even if adding extra points to the formula. The step \(\Delta {{{\mathcal{E}}}}\) is instead selected according to:

$$\Delta {{{\mathcal{E}}}}=\left\{\begin{array}{ll}\frac{1{0}^{-3}}{n}\quad &\,{{\mbox{if}}}\,{{{{\mathcal{E}}}}}^{c} > 1{0}^{-3},\\ \frac{\,{{\mbox{round}}}\,({{{{\mathcal{E}}}}}^{c},5)}{n}\quad &\,{{\mbox{if}}}\,1{0}^{-4} < {{{{\mathcal{E}}}}}^{c}\le 1{0}^{-3},\\ \frac{\,{{\mbox{round}}}\,({{{{\mathcal{E}}}}}^{c},6)}{n}\quad &\,{{\mbox{if}}}\,{{{{\mathcal{E}}}}}^{c}\le 1{0}^{-4},\end{array}\right.$$
(25)

where the electric field units are again expressed in Ry a.u. and round(x,y) rounds the number x to the y digit after the decimal point. These choices should guarantee larger values of the finite step to reduce the numerical noise on forces and polarization, and at the same time higher accuracy to remove the step size dependence of the finite-difference formula, which can be verified a posteriori when n > 2 (see also Fig. 1a). We point out here that eventually the user can still enforce the accuracy n and/or the \(\Delta {{{\mathcal{E}}}}\) value that will be used in Eqs. (18) and (25). Once an electric field is chosen and the ground-state SCF calculation is finished, a symmetry analysis is performed to find the independent directions \({\hat{{{{\boldsymbol{{{{\mathcal{E}}}}}}}}}}\) of the electric fields to apply, where \({\hat{{{{\boldsymbol{{{{\mathcal{E}}}}}}}}}}\) is a versor. For each such independent direction a MP mesh is determined through Eq. (24) and a series of SCF calculations are then launched at \({{{\boldsymbol{{{{\mathcal{E}}}}}}}}={{{\bf{0}}}}\) with the corresponding mesh restarting from the ground-state density of the previous SCF. The reason for computing SCF calculations at \({{{\boldsymbol{{{{\mathcal{E}}}}}}}}={{{\bf{0}}}}\) with these meshes is twofold: first, they provide the ground-state charge density and wavefunctions for the next finite electric field calculations, resulting in faster convergence of the self-consistent cycles, and, second, they guarantee the same level of convergence on forces and polarization for the finite differentiation. Once finished, electric-enthalpy calculations start for each independent direction \({\hat{{{{\boldsymbol{{{{\mathcal{E}}}}}}}}}}\) at the smallest step value \(\Delta {{{\boldsymbol{{{{\mathcal{E}}}}}}}}=\Delta {{{\mathcal{E}}}}\cdot {\hat{{{{\boldsymbol{{{{\mathcal{E}}}}}}}}}}\), to provide an adiabatic switching of the perturbation. If the numerical accuracy n is greater than 2, further SCF calculations with homogeneous electric fields are run, restarting from the previous steps till the maximum value \((n/2)\Delta {{{\boldsymbol{{{{\mathcal{E}}}}}}}}\); this loop corresponds to increasing/decreasing the value of l in Eq. (18). At this point, the computed forces and polarizations are gathered together to perform the numerical differentiation following Eqs. (18) and (19) to obtain the second- and third-rank tensors (12)-(13)-(15). As a final step, the IRamanSpectraWorkChain joins all the information in a unique AiiDA data type, named VibrationalData, able to efficiently store large arrays and information in the AiiDA repository and database, and with provenance graph for full reproducibility22. This data type is a self-contained Python class, and it is provided with a number of post-processing methods and features that allow the user to compute powder and single-crystal polarized vibrational intensities and frequencies, along with the symmetry labels of the respective phonon modes. We also implemented an IntensitiesAverageWorkChain which performs the spherical-average spectra, important in Raman for non-centrosymmetric crystals11 when in a polycrystalline powder form.

As mentioned earlier, the inputs of these workflows can be fully customized further by the user. We do not report here the full list of these inputs, which can be explored through the usual command line interface of AiiDA22 and through the on-line documentation made available (https://aiida-vibroscopy.readthedocs.io/en/latest/). However, we emphasize the possibility of fully defining the entire set of inputs required via a limited subset, as already done in other AiiDA packages45: in similar fashion to ref. 45, we identify the fundamental inputs to be the code, i.e., the Quantum ESPRESSO46,47,48pw.x binary, associated with the computer, that runs the calculations, the relaxed structure and the protocol, a string defining in a general and user-friendly fashion the accuracy of the simulation. This minimal set, used through the get_builder_from_protocol method45 designed for all the workchains, provides the user with a pre-filled builder (the main unit in AiiDA used to run workflows) ready to be submitted. This is adequate for non-experts in the field that might be interested in simulating spectra of a given structure with minimal computational knowledge, but is also very precious in the context of high-throughput searches or for teaching or testing.

All-functionals LiNbO3 spectra

We showcase the strength of this approach by studying the ferroelectric phase of LiNbO3 (space group R3c, no. 161) for which the vibrational spectra have long been debated in the literature49,50,51,52 and exhibit large LO-TO phonon splittings at Γ49 that are ideal for exploring different exchange-correlation functionals. We selected three commonly used local and semi-local functionals, LDA, PBE and PBEsol; Hubbard-corrected PBEsol in the standard and extended version, namely DFT+U53,54 and DFT+U+V55,56,57; and two of the most used hybrids functionals for inorganic crystalline materials, HSE0658,59 and PBE060.

Through the use of the IRamanSpectraWorkChain, we carried out the simulation of the vibrational spectra for all the functionals above and compare our results to experimental measurements from the literature11,51,52,61,62. In particular, we compare the simulations presented in Fig. 3 with different experimental Raman single-crystal polarization setups where LO modes are filtered out52; in Fig. 4 with single-crystal and polycrystalline powder Raman spectra including the LO modes11,51,61; and in Fig. 5 with single-crystal infrared absorption62 and reflectivity spectra51. We make use of the Porto notation for Raman setups: the labels within the parenthesis refer to the polarization of light eL and eS, the external labels to the propagation of light kL and kS. When only TO modes are shown, the external labels are not specified. For spectra showing LO modes, we set qkL − kS in single crystals, while polycrystalline powder spectra are modeled via the spherical-average procedure, as outlined in ref. 11. The conventional cell is used to define the Cartesian directions, aligning the Z axis along the c axis and the X axis along the a axis (Y is chosen to obtain a right-handed reference system). The single-crystal data of ref. 52, reported in Fig. 3, allow us to compare directly the intensities (TO modes only). The experimental LO and TO frequencies were reported in ref. 52, and are summarized, along with the theoretical predictions, in Supplementary Table 1. We ranked the spectra in the plots in function of the statistical estimator \(\overline{| \Delta \omega | }=\mathop{\sum }\nolimits_{\nu = 1}^{N}| {\omega }_{\nu }^{\exp }-{\omega }_{\nu }^{{{{\rm{theo}}}}}| /N\), where N is the number of active modes detected. All the functionals show good agreement with experiments and with the results of the literature49,50,51,52. PBEsol + Usc + Vsc, PBE, and the two hybrids show competitive results among each other, while PBEsol, PBEsol+Usc and LDA have quantitative larger discrepancies. In particular in Table 1 we report statistical estimators for the comparison of the theoretical and experimental phonon frequencies (LO and TO) and intensities (only TO, Fig. 3). These spectra setups allowed to accurately estimate the error of the intensities evaluated through the minimization of the relative error:

$$\Delta I(f)=\sqrt{\frac{\mathop{\sum }\nolimits_{\nu = 1}^{N}{({I}_{\nu }^{{{{\rm{theo}}}}}-f{I}_{\nu }^{\exp })}^{2}}{\mathop{\sum }\nolimits_{\nu = 1}^{N}{(f{I}_{\nu }^{\exp })}^{2}}}$$
(26)

where f represents the unknown scaling factor between theoretical Itheo and experimental \({I}^{\exp }\) intensities, due to the use of arbitrary units in the experimental spectra. The smallest absolute error on frequencies \(\overline{| \Delta \omega | }\) is provided by the PBE0 functional with 7.3 cm−1, and on intensities \(\overline{| \Delta I| }\) by the PBEsol + Usc + Vsc functional with 16%. It is to note that the latter also shows a very good \(\overline{| \Delta \omega | }\) of 10.7 cm−1, about 3 cm−1 apart from the best performing functional for this material, whereas the former has 24% error for \(\overline{| \Delta I| }\), 8% more with respect to PBEsol + Usc + Vsc. We also report the renormalized absolute error \({\overline{| \Delta \omega | }}^{* }\), for which the frequencies are shifted by the bare mean error \(\overline{\Delta \omega }\) before the modulus average; this gives some insights whether the discrepancy arises from a systematic error, e.g., due to the geometry used. Interestingly, after renormalization, most of the functionals get rather close error values. While this might be due to the renormalization of the phonon frequencies due to the thermal expansion, which tends to soften the vibrational modes, all the theoretical spectra were performed at the experimental lattice geometry (see the Method section), meaning the systematic error is unrelated to this effect. While other thermal contributions should in principle be accounted for, their inclusion would require more sophisticated levels of theory63,64,65 which go beyond the scope of the present work. Moreover, at the conditions of the experiments, such contributions are expected to produce only minor phonon shifts51. Given these points we might conclude in this case that such errors are intrinsic to the functionals. We proceed in the following with a more qualitative analysis of the other calculated spectra, as the experimental data we refer to come from different sources. In Fig. 4 we show the result of the complex interplay of long-range interactions, Eq. (11), and the non-linear dielectric response which renormalizes the Raman intensities, Eq. (17). It can be noted again that all functionals are able to describe well both the peak positions and the intensities of the different experimental measurements. In particular, the intensity of the LO mode at around 870 cm−1 is reproduced correctly. The dashed lines in the figure highlight the error committed when neglecting the χ(2) contribution in Eq. (17), which is relevant for the accurate prediction of the intensity. As already found in ref. 11, the spherical average employed to compute the spectra of the polycrystalline sample of Fig. 4c correctly reproduces the asymmetric lineshapes of the experimental peaks, which can be understood as an average of all the possible q → 0 splitting modes which the incident light happens to activate in a polycrystalline powder sample. The absorption and reflectivity infrared spectra reported in Fig. 5 show very good agreement with the experimental measurements51,62. For a more quantitative comparison, here we compare in Table 2 the static dielectric tensor ϵij(ω = 0) for the ordinary and extraordinary components, which can be measured from absorption measurements. The theoretical predictions are close to the experimental values. We note that it is difficult here to assess accurately the theoretical errors, as the experimental evaluation of this quantity is usually subject to deviations, as it can be seen in Table 2. Nonetheless, once again, PBE, PBEsol + Usc + Vsc and the two hybrids show a remarkable agreement with the experimental results reported51,66.

Fig. 3: Polarized single-crystal Raman spectra of ferroelectric LiNbO3 as obtained with seven different exchange-correlation functionals, and compared to experimental measurements52.
figure 3

The scattering geometries are reported in parenthesis. The theoretical spectra are ordered according to the error \(\overline{| \Delta \omega | }\) (shown in Table 1), from smallest (pink, PBE0) to largest (blue, LDA). Hubbard-corrected PBEsol + Usc and PBEsol + Usc + Vsc are labeled just Usc and Usc + Vsc, the subscript sc refers to the self-consistent calculation of U and V77,78. Theoretical intensities are smeared with a 8 cm−1 wide Lorentzian.

Fig. 4: Polarized single-crystal and powder Raman spectra of ferroelectric LiNbO3 as obtained with seven different exchange-correlation functionals, and compared to experimental measurements51,62.
figure 4

a, b Raman spectra of single-crystal polarized setups; the scattering geometry is reported in the Porto notation. c Raman spectra of polycrystalline powder sample; the theoretical spectra are computed using the spherical average formula11. In each panel, the dashed lines show the computed spectra when the second term in Eq. (17) is neglected. Theoretical intensities are smeared with a constant 12 cm−1 broadened Lorentzian. The theoretical spectra are reported in order of decreasing error \(\overline{| \Delta \omega | }\), and Hubbard-corrected PBEsol are abbreviated only with their corrective parameters, as in Fig. 3.

Fig. 5: Absorption and reflectivity spectra in the IR regime of ferroelectric LiNbO3 as obtained with seven different exchange-correlation functionals, and compared to experimental measurements51,62.
figure 5

a Infrared absorption using polarized light for E (left panel) and A1 (right panel) symmetry modes. b Normal reflectivity spectra of Z-cut single crystal; upper and lower ticks for each panel correspond to 1 and 0, respectively. The order of theoretical spectra and the labels are as in Fig. 3. Theoretical intensities are smeared with a constant 12 cm−1 broadening; a Lorentzian function is used for (a).

Table 1 Statistical error estimators between predictions and experiments52 for E and A1 LO-TO modes
Table 2 Ordinary and extraordinary dielectric components of LiNbO3 from experiments and from seven different exchange-correlation functionals

Discussion

In this paper, we have presented a comprehensive and efficient approach that utilizes finite displacements and finite fields to calculate seamlessly various vibrational spectra, ranging from absorption and normal reflectivity spectra in the infrared regime, to Raman spectra, including non-centrosymmetric crystals and fine-grained materials (spherical-average method), with any modern exchange-correlation functional and pseudopotential formulation (norm-conserving, ultrasoft, PAW). This approach requires 12 self-consistent electric field calculations for the prediction of Raman tensors, as opposite to 6 Nat when taking the derivative of the dielectric tensor with respect to atomic displacements8,9, which remains impractical in large or low symmetry systems. The approach we employ becomes extremely useful when generating coupling tensors in low-symmetry supercells, Eq. (6), to incorporate temperature and quantum effects64,65,67, or to train a tensorial machine-learning potential for molecular dynamics simulations. The formalism has been implemented as a highly optimized, automatic workflow package for the prediction of vibrational spectra. The technical and practical challenges have been successfully addressed with the help of the AiiDA infrastructure22, which empowered the design of fully reproducible, reusable, user-friendly workflows for one of the most important class of spectroscopic techniques for materials characterization. As such, we believe it will be broadly useful to both the computational community and the experimental community at large. Furthermore, we have shown that the workflows can effectively operate with state-of-the-art functionals and can be employed for a comprehensive analysis of both single crystals and powder spectra. Importantly, all the code, workflows and the documentation are open and available to the community (see Code Availability). In conclusion, we believe that the present approach will be helpful for the computational and experimental community and will pave the way for accelerated materials characterization of materials displaying complex, challenging chemistry.

Methods

Computational details

The infrared and Raman calculations were carried out using the workflows developed, relying on aiida-phonopy68 for pre- and post-processing and aiida-quantumespresso22,23, having Quantum ESPRESSO46,47,48 as DFT quantum engine. Before performing the vibrational spectra calculations, the positions of the atoms in the LiNbO3 primitive cell are optimized at fixed experimental lattice geometry69 for all functionals until the total energy and forces acting on atoms are less than 10−4 Ry/atom and 5  10−5 Ry/Bohr, respectively. Norm-conserving pseudopotentials from the Pesudo-Dojo library70 are used for the LDA and hybrid functionals, employing PBE pseudopotentials for the latter, and pseudopotentials from the SSSP PBE(sol) precision (version 1.1)70,71,72,73,74,75,76 library for all other cases. A cutoff of 90 Ry is used for the wavefunctions; 4 and 12 times greater cutoffs are used for the charge density (respectively for Pseudo-Dojo and SSSP based pseudopotentials). The Brillouin zone is sampled uniformly with a 0.3 Å−1 k-points distance, leading to a 5 × 5 × 5 mesh for the primitive cell containing 10 atoms. The Hubbard parameters are computed following the self-consistent procedure exploiting density-functional perturbation theory, as explained in refs. 77,78,79, using a q-point distance of 0.4 Å−1, orthogonalized atomic orbitals78,80 for the occupation matrices, and with onsite (intersite) parameters converged within 0.01 (0.005) eV (a very conservative threshold). The hybrid calculations are performed using a 90 Ry cutoff and a single q-point mesh for the exact-exchange operator, and the adaptively compressed exchange (ACE) technique81 is used to speed up the convergence of the calculations. Finally, finite differences are carried out using a 0.01 Å displacement distance and a denser k-point distance of 0.15 Å−1 for the phonon calculations (in the PhononWorkChain), and an electric field step of 5  10−4 Ry a.u., a 2nd-order numerical accuracy, and a k-point distance of 0.15 Å−1 in the parallel direction of the applied electric field for the electric-field derivatives (as carried out in the DielectricWorkChain).