betaFeedback

WorksPhysics and Astronomy

Linear response for machine-learned interatomic potentials: phonons at arbitrary wave vectors from the primitive cell

Abstract

Phonon calculations with machine-learned interatomic potentials are almost exclusively performed with finite displacements in supercells, an approach that is exact only at wave vectors commensurate with the supercell and whose error depends on the range of the force constants. In message-passing networks this range grows with the number of layers, and reaches 140 angstrom for the deepest universal models. Here we show that the dynamical matrix of a message-passing potential can be obtained exactly in the primitive cell, at any wave vector, as the linear response of the forces to a displacement modulated by a Bloch phase, in the spirit of density-functional perturbation theory. The phase enters only where the features of neighboring atoms are gathered, and the trained model is used without modification. One further derivative yields group velocities and mode Grüneisen parameters analytically. We apply the method to NequIP and Prophet, and reproduce the Hessians of supercells to machine precision. Using these results as a reference, we find that the supercells commonly employed in high-throughput calculations lead to errors of several tenths of a THz in the phonon frequencies, and that these errors decrease slowly with the size of the supercell, in particular for deep models. For a low-symmetry silicate, the supercell predicts a dynamical instability that the model does not have. Quantities that depend on derivatives of the dispersion, such as the group velocities and the Grüneisen parameter at low temperature, are considerably more affected than the frequencies themselves. When both approaches are used to obtain the same force constants, their computational cost is comparable for crystals with symmetry.

Introduction

Lattice vibrations determine a large part of the thermodynamic and transport properties of solids. Knowing the phonon dispersion therefore gives access to the dynamical stability of a crystal, to its free energy and thermal expansion, and to its lattice thermal conductivity. The same vibrations also couple to the electrons, and in conventional superconductors this coupling mediates the formation of Cooper pairs. All these properties require the dynamical matrix D(q)D(\mathbf{q}) at wave vectors q\mathbf{q} that span the Brillouin zone. In density-functional theory, two routes to obtain D(q)D(\mathbf{q}) are well established. In the finite-displacement, or frozen-phonon, approach [1, 2, 3] [4], atoms are displaced in a supercell, the interatomic force constants are obtained from the resulting forces, and D(q)D(\mathbf{q}) follows from a Fourier interpolation. This approach is simple and independent of the underlying code, but it is exact only at wave vectors commensurate with the supercell, and its cost grows with the range of the force constants. Density-functional perturbation theory (DFPT) [5, 6, 7, 8] instead computes the linear response to a perturbation of arbitrary wave vector q\mathbf{q} directly in the primitive cell, at a cost independent of q\mathbf{q}. Furthermore, it extends naturally to higher orders, which gives access to anharmonic properties without numerical differentiation [9, 10].

Machine-learned interatomic potentials (MLIPs) [11, 12, 14] [13] have changed the scale at which such calculations can be performed. Universal models [15, 16, 17, 18, 19, 20] trained on large databases of density-functional calculations now yield phonon frequencies and the derived thermodynamic quantities for thousands of compounds with a good accuracy [21], and are being assessed for anharmonic properties such as the thermal conductivity [22]. Phonon calculations with MLIPs are, however, almost exclusively performed with finite displacements in supercells, a workflow inherited from density-functional theory. This choice has a consequence that is often overlooked. Most current MLIPs are message-passing networks, in which the energy of an atom depends on all atoms within a distance LrcLr_\mathrm{c}, where LL is the number of layers and rcr_\mathrm{c} the cutoff radius. The force constants therefore extend up to 2Lrc2Lr_\mathrm{c} [23], which can range roughly from 20 Å to 140 Å for common choices of LL and rcr_\mathrm{c}. A supercell that contains this range is seldom affordable. In practice, smaller supercells are used, resulting in truncated force constants, but the error is usually not controlled.

A supercell is, however, not required. For classical interatomic potentials, the dynamical matrix has long been evaluated analytically at arbitrary q\mathbf{q} from phased sums of the second derivatives of the energy [24, 25, 26], and its derivatives with respect to strain were obtained in the same way for the minimization of the free energy [27, 28]. For MLIPs, automatic differentiation gives the exact Hessian of the energy [29, 30], and its sparsity can be exploited to reduce the cost [23]. Fang et al. [31] showed that D(q)D(\mathbf{q}) of a message-passing network can be obtained without a supercell, by differentiating the energy of one cell with respect to the positions of all atoms in its receptive field and summing the result with the appropriate phases. Nondiagonal supercells [32, 33] reduce the cost of the finite-displacement approach at commensurate wave vectors. All these approaches build the force constants in real space, so that their cost and memory requirements grow with the volume of the receptive field. To the best of our knowledge, an approach that works at fixed qq in the primitive cell, in the spirit of DFPT, has not been proposed for MLIPs.

In this work, we show that the dynamical matrix of a message-passing MLIP can be obtained exactly from the primitive cell, for any qq. We consider a displacement of the atoms modulated by a Bloch phase and obtain the first-order change of the forces, i.e. the product of the dynamical matrix with this displacement, from a single forward-over-reverse pass of automatic differentiation. The phase enters in one place only, where the features of neighboring atoms are gathered. The trained model is used without retraining, and only small changes to a few of its operations are needed. Since qq and the strain are ordinary inputs of this calculation, one further derivative yields group velocities and mode Grüneisen parameters analytically.

The remainder of this article is organized as follows. In Sec. II we derive the equations for the dynamical matrix and for its derivatives with respect to qq and to strain, and discuss their implementation for NequIP [13] and for Prophet [34]. In Sec. III we validate the method against Hessians of supercells, and use it to assess the supercell approach for phonon dispersions, mode Grüneisen parameters, the thermodynamic Grüneisen parameter at low temperature, and group velocities. The advantages and limitations of the method are discussed in Sec. IV, and our conclusions are presented in Sec. V.

Method

Bloch response of the forces

We consider a crystal with NN atoms in the primitive cell, at positions τκ+R\boldsymbol{\tau}_{\kappa}+\mathbf{R}, where R\mathbf{R} is a lattice vector. The interatomic force constants are the second derivatives of the energy EE with respect to the atomic displacements uκR\mathbf{u}_{\kappa\mathbf{R}},

Φκα,κ′β(R)=∂2E∂uκα0∂uκ′βR,(1)\Phi_{\kappa\alpha,\kappa'\beta}(\mathbf{R}) = \frac{\partial^{2}E}{\partial u_{\kappa\alpha0}\partial u_{\kappa'\beta\mathbf{R}}}, \tag*{(1)}

and the dynamical matrix reads Dκα,κ′β(q)=Mκα,κ′β(q)/mκmκ′D_{\kappa\alpha,\kappa'\beta}(\mathbf{q})=M_{\kappa\alpha,\kappa'\beta}(\mathbf{q})/\sqrt{m_{\kappa}m_{\kappa'}}, with mκm_{\kappa} the atomic masses and

Mκα,κ′β(q)=∑RΦκα,κ′β(R)eiq⋅R.(2)M_{\kappa\alpha,\kappa'\beta}(\mathbf{q}) = \sum_{\mathbf{R}}\Phi_{\kappa\alpha,\kappa'\beta}(\mathbf{R})e^{i\mathbf{q}\cdot\mathbf{R}}. \tag*{(2)}

In the supercell approach, the sum in eq. (2) is restricted to the lattice vectors of the supercell. We proceed differently, and note that the product of M(q)M(\mathbf{q}) with a vector u\mathbf{u} is

∑κ′βMκα,κ′β(q)uκ′β=−DFκα0Dλ∣λ=0,(3)\sum_{\kappa'\beta}M_{\kappa\alpha,\kappa'\beta}(\mathbf{q})u_{\kappa'\beta} = -\left.\frac{DF_{\kappa\alpha0}}{D\lambda}\right|_{\lambda=0}, \tag*{(3)}

where Fκα0F_{\kappa\alpha0} is the force on atom κ\kappa of the cell at the origin, and the derivative is taken along the displacement uκR=λuκeiq⋅R\mathbf{u}_{\kappa\mathbf{R}}=\lambda\mathbf{u}_{\kappa}e^{i\mathbf{q}\cdot\mathbf{R}} of all atoms of the crystal. The dynamical matrix is therefore the first-order response of the forces to a perturbation modulated by a Bloch phase, exactly as in DFPT [8]. As the unperturbed crystal is periodic, the first-order change of every quantity attached to an atom, or to a pair of atoms, has the same modulation, i.e., it is multiplied by eiq⋅Re^{i\mathbf{q}\cdot\mathbf{R}} under a translation by R\mathbf{R}. It is thus sufficient to know these first-order quantities in the primitive cell.

In a message-passing network, the features hi(l)\mathbf{h}_{i}^{(l)} of atom ii in layer ll are updated from the features of its neighbors and from the vectors that connect them. For a crystal this is evaluated on the graph of the primitive cell, where an edge ee connects a sender atom s(e)s(e) to a receiver atom t(e)t(e) and carries the lattice vector Re\mathbf{R}_{e} of the cell where the sender is located. The only operation of the network that connects different cells is the gather, which copies a quantity xx of the sender to the edge,

ye=xs(e).(4)y_{e}=x_{s(e)}. \tag*{(4)}

All other operations act on a single atom or on a single edge. The quantity xx can be a feature or the position of the atom, as the vector of an edge is re=τs(e)+Re−τt(e)\mathbf{r}_{e}=\boldsymbol{\tau}_{s(e)}+\mathbf{R}_{e}-\boldsymbol{\tau}_{t(e)}. The first-order change of xx in the cell Re\mathbf{R}_{e} differs from the one in the cell at the origin by the Bloch phase, so that the first-order change y˙\dot{y} of the gathered quantity is

y˙e=eiϕex˙s(e),ϕe=q⋅Re.(5)\dot{y}_{e}=e^{i\phi_{e}}\dot{x}_{s(e)},\qquad\phi_{e}=\mathbf{q}\cdot\mathbf{R}_{e}. \tag*{(5)}

The forces are obtained by reverse-mode differentiation of the energy, which propagates the adjoints xˉ=∂E/∂x\bar{x}=\partial E/\partial x from the energy back to the positions. The reverse of the gather is a scatter, xˉj=∑e:s(e)=jyˉe\bar{x}_{j}=\sum_{e:s(e)=j}\bar{y}_{e}. In the crystal, the atom jj of the cell at the origin sends to the receiver of edge ee located in the cell −Re-\mathbf{R}_{e}, and the first-order change of the adjoint therefore acquires the conjugate phase,

xˉ˙j=∑e:s(e)=je−iϕeyˉ˙e.(6)\dot{\bar{x}}_{j}=\sum_{e:s(e)=j}e^{-i\phi_{e}}\dot{\bar{y}}_{e}. \tag*{(6)}

Equations (5) and (6) are the only changes with respect to an ordinary calculation in the primitive cell. The left-hand side of eq. (3) is then obtained by one pass of forward-mode differentiation over the reverse-mode calculation of the forces, with the perturbation u\mathbf{u} at the positions. Across the LL layers of the forward and the LL layers of the reverse pass, a u\mathbf{u} travels along paths of up to 2L2L edges and accumulates their phases. The calculation in the primitive cell thus performs the sum of eq. (2)`` implicitly, over the full range 2Lrc2Lr_{c} of the force constants, without a supercell. The complete matrix M(q)M(\mathbf{q}) requires 3N3N such passes, each with the cost of a few force evaluations in the primitive cell, for any q\mathbf{q}, commensurate or not, and independently of the range of the force constants. No truncation is involved, and the result is the exact dynamical matrix of the model, up to rounding errors.

Derivatives with respect to wave vector and strain

The wave vector enters the calculation only through the phases ϕe\phi_e, and a homogeneous strain η\eta only through the atomic positions and the lattice vectors Re\mathbf{R}_e. Both are therefore ordinary differentiable inputs. For two vectors u\mathbf{u} and v\mathbf{v}, the scalar Re⁡[v†M(q,η)u]\operatorname{Re}[\mathbf{v}^{\dagger}M(\mathbf{q},\eta)\mathbf{u}] is obtained from eq. (3), and one reverse pass over this calculation yields its gradient with respect to the components of q\mathbf{q} and of η\eta. We keep the reduced coordinates of the atoms and of q\mathbf{q} fixed under strain, so that a mode is followed as the lattice is deformed.

For a nondegenerate mode of frequency ω\omega and eigenvector e\mathbf{e} of D(q)D(\mathbf{q}), the Hellmann–Feynman theorem gives ∂ω2/∂λ=e†(∂D/∂λ)e\partial\omega^2/\partial\lambda=\mathbf{e}^{\dagger}(\partial D/\partial\lambda)\mathbf{e} for any parameter λ\lambda. The group velocity and the mode Grüneisen tensor are then

vg=∂ω∂q=12ωe†∂D∂qe,(7)\mathbf{v}_{g}=\frac{\partial\omega}{\partial\mathbf{q}}=\frac{1}{2\omega}\mathbf{e}^{\dagger}\frac{\partial D}{\partial\mathbf{q}}\mathbf{e}, \tag*{(7)}
γαβ=−∂ln⁡ω∂ηαβ=−12ω2e†∂D∂ηαβe,(8)\gamma_{\alpha\beta}=-\frac{\partial\ln\omega}{\partial\eta_{\alpha\beta}}=-\frac{1}{2\omega^2}\mathbf{e}^{\dagger}\frac{\partial D}{\partial\eta_{\alpha\beta}}\mathbf{e}, \tag*{(8)}

and the usual mode Grüneisen parameter for an isotropic change of volume is γ=−∂ln⁡ω/∂ln⁡V=13∑αγαα\gamma=-\partial\ln\omega/\partial\ln V=\frac{1}{3}\sum_{\alpha}\gamma_{\alpha\alpha}. These derivatives are analytic, requiring no finite step in q\mathbf{q} or in η\eta, and hence no matching of modes between the calculations of a finite difference. For a degenerate multiplet, the Hellmann–Feynman expression does not apply directly. As in degenerate perturbation theory, we then evaluate ∂D/∂λ\partial D/\partial\lambda between all eigenvectors of the multiplet and diagonalize the resulting matrix, whose eigenvalues are the derivatives ∂ω2/∂λ\partial\omega^2/\partial\lambda of the individual modes.

Implementation

We implemented the method in PyTorch. The gather of eq. (5) and the scatter of eq. (6) are written as two differentiation rules, each being the reverse of the other. The networks that we consider are real, so that we represent a complex first order change by two replicas of the graph of the primitive cell, one for the real and one for the imaginary part, and the multiplication by the phase becomes a rotation between the two. The trained model is called without any change to its code. To this end, the index of the senders is passed to the model as an object that applies eq. (5) whenever it is used to gather a quantity. In this way we applied the method to NequIP [13], an equivariant message-passing network built with e3nn [35], and to Prophet [34]. The only modifications that were required concern three operations whose library routines do not support, or do not evaluate correctly, the additional reverse pass of section II B. These are the length and the normalization of the edge vectors, and the layer normalization of Prophet, which we wrote explicitly in terms of elementary operations. The calculation of M(q)M(\mathbf{q}) itself does not require them.

Several wave vectors and several columns of M(q)M(\mathbf{q}) can be computed in a single pass, by collecting the corresponding copies of the primitive cell in one disconnected graph. This is relevant in practice, as a graphics processing unit is far from being saturated by a calculation in a primitive cell with a few atoms.

The 3N3N passes at a given wave vector are not all independent. An operation of the space group that maps q\mathbf{q} onto itself, or onto −q-\mathbf{q}, relates the response to a displacement to the response to its image, so that only the displacements that are inequivalent under these operations have to be calculated. As in DFPT, the method can be used in two ways. The dynamical matrix can be calculated directly at the wave vectors of interest, or it can be calculated at the irreducible wave vectors of a regular grid, rotated to the complete grid, and Fourier interpolated. The latter contains exactly the same information as the non-truncated force constants of the supercell that is commensurate with the grid.

Results

Computational details

We used three models. The NequIP models combine a good accuracy with a very low computational cost, which makes them a natural choice for high-throughput calculations of phonons. Prophet is, at the time of writing, the model with the highest combined performance score in the Matbench Discovery benchmark [36], which includes the thermal conductivity, and represents the deep networks with a very long formal range of the force constants. NequIP-OAM-S and NequIP-OAM-M [37] have two and four layers and cutoff radii of 4.54.5 Å and 66 Å, so that their force constants extend to 1818 Å and 4848 Å, respectively. Prophet-OAME-MBD [34] has ten layers and cutoff radii of 33 Å and 77 Å, which leads to a formal range of 140140 Å. Unless stated otherwise, the results were obtained with NequIP-OAM-M.

All calculations were performed in double precision, with the exception of the largest supercells for Prophet, which were calculated in single precision on the central processing unit. We considered silicon, diamond, MgB2_2, bulk and monolayer MoS2_2, and kaolinite, Al2_2Si2_2O5_5(OH)4_4, a layered silicate with 17 atoms in the primitive cell and no symmetry besides the translations (space group P1). All structures are at the experimental lattice parameters [38, 39] and with the internal coordinates relaxed with each model.

As a reference we used two supercell calculations. In the first, the force constants were obtained with finite displacements of 0.010.01 Å using Phonopy [3] [4]. In the second, the rows of the Hessian of the supercell were computed exactly by automatic differentiation, which removes the error of the finite displacement and leaves only the truncation of the force constants. In both cases D(q)D(\mathbf{q}) was then obtained by the Fourier interpolation of PHONOPY. All timings were measured on a single NVIDIA RTX 4060 Ti graphics card with 16 GB of memory.

Validation

We first verified that the method reproduces the Hessian of a supercell. For a wave vector commensurate with the supercell, M(q)M(\mathbf{q}) can be assembled without approximation from the rows of the Hessian of the supercell obtained by automatic differentiation. We performed this test for a cell of silicon with displaced atoms and a sheared lattice, so that no element of the matrix vanishes by symmetry, and for wave vectors commensurate with supercells of up to 48 atoms. The largest difference between the two matrices is 2×10−132 \times10^{-13} eV Å−2^{-2} for NequIP-OAM-S, 2×10−142 \times10^{-14} eV Å−2^{-2} for NequIP-OAM-M, and 3×10−143 \times10^{-14} eV Å−2^{-2} for Prophet, while the largest elements of M(q)M(\mathbf{q}) are 1010 to 1717 eV Å−2^{-2}. For NequIP-OAM-M and the six materials of this work, the frequencies at the commensurate wave vectors of the paths of Figure 1 agree with those of the supercell Hessian to 10−610^{-6} THz. Note that for Prophet the largest supercell that we could differentiate in double precision had 12 atoms. At an incommensurate wave vector, where no such reference exists, M(q)M(\mathbf{q}) matrices of the NequIP models are Hermitian to the same precision, and at Γ\Gamma they fulfill the acoustic sum rule.

Image not extracted

Figure 1. Phonon dispersions calculated with NequIP-OAM-M from the linear response in the primitive cell (black) and from finite displacements in a supercell (red, dashed), with the number of atoms of the supercell indicated in each panel. Imaginary frequencies are shown as negative. For kaolinite we do not show the four O–H stretching modes, which lie around 110 THz.

The derivatives of section II B were validated in the same way. The analytic group velocities of silicon agree with finite differences of the frequencies with respect to q\mathbf{q} to 4×10−54 \times10^{-5} Å ps−1^{-1}. Furthermore, in the limit of long wavelengths the velocities of the acoustic modes have to reproduce the solutions of the Christoffel equation with the elastic constants of the model. We obtained the latter from the derivative of the stress with respect to strain, including the relaxation of the internal coordinates, and the two sets of velocities agree to a relative difference of 10−710^{-7}.

Phonon dispersions

In Figure 1 we compare the phonon dispersions obtained from the linear response with those of supercells with 27 to 136 atoms, which are typical sizes for high-throughput calculations of phonons. The two calculations coincide at the wave vectors commensurate with the supercell and deviate in between. For the five simpler materials the maximum deviations, listed in Table I, range from 0.34 THz for silicon to 0.66 THz for MgB2_2. For kaolinite, with a 2×2×22 \times2 \times2 supercell, the error reaches 3.4 THz. More importantly, the supercell calculation yields an acoustic branch with imaginary frequencies, down to 1.5i1.5i THz, at a quarter of the wave vectors of the path, while the exact dispersion of the model has no imaginary frequency.

AtomsΔω\Delta\omega (THz)tLRt_{\mathrm{LR}} (s)tFDt_{\mathrm{FD}} (s)
Si540.340.340.21
C (diamond)1280.450.510.98
MgB2_2810.660.700.57
MoS2_2 (bulk)540.440.370.21
MoS2_2 (monolayer)270.500.250.10
Kaolinite1363.412522

Table I. Maximum deviation Δω\Delta\omega between the frequencies of the supercell and of the linear response along the paths of Figure 1, for NequIP-OAM-M. The last two columns show the time required to obtain the same force constants with the linear response on the grid of wave vectors commensurate with the supercell (tLRt_{\mathrm{LR}}) and with finite displacements in the supercell (tFDt_{\mathrm{FD}}), both using the symmetry of the crystal.

The truncation of the force constants can therefore lead to the wrong conclusion that a compound is dynamically unstable. The deviations are essentially the same if the finite displacements are replaced by the exact Hessian of the supercell. The error is therefore due to the truncation of the force constants and not to the finite displacement.

The cost of the two approaches can be compared directly when they yield the same information, i.e., when the linear response is calculated on the grid of wave vectors commensurate with the supercell. The results are shown in Table I. For the five materials with high symmetry the two calculations take a comparable time, as only 4 to 14 passes are required for the complete grid. For kaolinite there is no symmetry to exploit, and the linear response is slower by a factor between five and six. The memory required by the linear response is that of the primitive cell multiplied by the number of perturbations that are calculated in one pass, which can be chosen freely, and does not increase with the size of the grid.

The two approaches differ, however, in how the cost increases with the accuracy required, as shown in Figure 2 for silicon. For NequIP-OAM-M the error of the supercell decreases from 0.91 THz for 16 atoms to 0.003 THz for 1024 atoms, a calculation that required 14 s. For larger supercells the error does not decrease below 0.001 THz, which is the error of the finite displacement, while the time increases to several minutes. The linear response yields the 60 wave vectors of the path without error in 1.5 s, i.e., in less than 0.03 s per wave vector on this high-symmetry path, and in 0.04 s at a general wave vector.

Image not extracted

Figure 2. Maximum error of the phonon frequencies of silicon obtained with the supercell approach along the path of Figure 1. Left: as a function of the number of atoms in the supercell, for models with two (NequIP-OAM-S), four (NequIP-OAM-M), and ten (Prophet) layers. Right: as a function of the time of the calculation with finite displacements, for NequIP-OAM-M and supercells with 16 to 3456 atoms. The dashed line marks the time required by the linear response for the same 60 wave vectors.

For NequIP-OAM-S model with only two layers, a supercell of moderate size (1024 atoms) does contain the complete range of the force constants. The situation is more severe for Prophet, for which the error decreases only slowly with the size of the supercell (Figure 2). It is still 0.27 THz with 128 atoms, and 0.10 THz with 432 atoms. The last of these was the largest cell that we could afford, and required 24 GB of memory in single precision. The linear response for the same 60 wave vectors took 68 s and 7.5 GB in double precision. On equal grids the cost of the two approaches is again comparable. For the 4×4×44 \times4 \times4 grid the linear response required 7.9 s and 7.5 GB, while the finite displacements in the corresponding supercell of

128 atoms 11.1 s and 13.2 GB.

Mode Grüneisen parameters

Mode Grüneisen parameters are usually calculated from the frequencies of two or three supercells at different volumes. In Figure 3 we compare such a calculation, for a strain of 0.02 % and the supercells of Figure 1, with the analytic derivatives of section II B. We consider separately the wave vectors that are commensurate with the supercell, where the only error of the supercell calculation is the finite strain, and non-commensurate wave vectors, where the truncation of the force constants also contributes.

Image not extracted

Figure 3. Mode Grüneisen parameters obtained from finite differences of the frequencies of strained supercells against the analytic values of the linear response, for wave vectors commensurate (left) and non-commensurate (right) with the supercell. The supercells are those of Figure 1 and the strain is 0.02 %. A few modes of kaolinite lie outside the range shown.

At commensurate wave vectors the two calculations coincide. With the exact Hessian of the supercell the largest difference is 10−510^{-5}, and with finite displacements the mean absolute difference is at most 0.0003, for the five materials with high symmetry. For kaolinite the mean absolute difference is 0.006, as several of its 51 branches are less than 0.02 THz apart and cross even under this strain. At non-commensurate wave vectors the mean absolute difference amounts to 0.02 for diamond, 0.03 for silicon, 0.04 for MgB2_2, 0.09 for bulk MoS2_2, and 0.12 for the MoS2_2 monolayer, with a maximum of 2.8 for the latter. These errors are due to the truncation of the force constants alone. For kaolinite the 2×2×22 \times2 \times2 supercell fails. Two thirds of the modes deviate by more than 0.1, the mean absolute difference is 0.3 for the modes above 5 THz, and the Grüneisen parameters of the lowest branches are meaningless, as the frequencies of the supercell are close to zero or imaginary.

The strain used above is considerably smaller than what is common in this type of calculation, and this choice turned out to be necessary. With a strain of 0.5%, the mean absolute difference at commensurate wave vectors is still below 0.02 for silicon, diamond, and MoS2_2, but for MgB2_2 it amounts to 0.09, with a maximum of 0.89. These large differences come from two branches that are only 0.03 THz apart at several wave vectors of the grid, and that have very different Grüneisen parameters. A strain of 0.5% shifts one of them, with γ=3.3\gamma= 3.3, by 0.8 THz, so that the two branches cross and the finite difference follows the wrong one. Reducing the strain to 0.1% is not sufficient, as the mean absolute difference only decreases to 0.06. The analytic derivative is free of this problem, as it does not require the identification of the modes at different volumes.

The analytic derivative has a different limitation, which we found with NequIP-OAM-S. In silicon at the experimental lattice parameter, the shell of third neighbors lies at 4.503 Å, just outside the cutoff radius of 4.5 Å of this model. A compression of the lattice brings these atoms inside the cutoff, and the derivatives of the frequencies with respect to strain are not continuous at this point. The analytic derivative and the finite difference then measure different quantities, and the thermodynamic Grüneisen parameter at 10 K, defined below, is −1.13-1.13 with the former and −5.85-5.85 with the latter. This is a deficiency of the model and not of either method, but it shows that derivatives of this order probe the smoothness of the potential at the cutoff.

Thermodynamic Grüneisen parameter at low temperature

The thermodynamic Grüneisen parameter is the average of the mode Grüneisen parameters weighted by the heat capacity cqνc_{q\nu} of each mode,

γ(T)=∑qνcqν(T)γqν∑qνcqν(T)(9)\gamma(T) = \frac{\sum_{q\nu} c_{q\nu}(T)\gamma_{q\nu}}{\sum_{q\nu} c_{q\nu}(T)} \tag*{(9)}

and determines the thermal expansion. At low temperature only the acoustic modes of long wavelength contribute, which in a supercell calculation are obtained entirely by interpolation. We calculated γ(T)\gamma(T) of silicon on a 60×60×6060 \times60 \times60 mesh of wave vectors, with 5216 points in the irreducible wedge of the Brillouin zone, which took 23 minutes with the linear response. The result changes by 0.01 at 10 K with respect to a 30×30×3030 \times30 \times30 mesh, and is not converged with respect to the mesh below this temperature.

The comparison with the supercells is shown in Figure 4. At 300 K the supercells with 54 atoms or more are within 0.01 of the linear response, which gives 0.693. At 10 K, however, the linear response yields 0.05, while the supercells with 16, 54, and 128 atoms give −0.61-0.61, 0.19, and 0.17, respectively. Supercells with 250 atoms or more are within 0.01 of the linear response. A supercell that is adequate at room temperature can therefore be wrong by a factor of three to four at low temperature. The other two approximations of the supercell approach are much less important here, as the finite strain and the finite displacement change γ(T)\gamma(T) by less than 0.01 and 0.001, respectively.

Image not extracted

Figure 4. Thermodynamic Grüneisen parameter of silicon as a function of temperature, calculated with NequIP-OAM-M from the linear response (black) and from the exact Hessians of supercells with 16 to 250 atoms (dashed).

The sign of γ(T)\gamma(T) is the sign of the thermal expansion coefficient, which allows for a comparison with experiment. Silicon is known to contract upon heating at low temperature [40, 41]. According to the measurements of Lyon et al. [40], the linear expansion coefficient is positive and very small below 18 K, where it does not exceed 1.4×10−9 K−11.4 \times10^{-9}\ \mathrm{K}^{-1}, negative from 18 K to 125 K, with a minimum of −4.7×10−7 K−1-4.7 \times10^{-7}\ \mathrm{K}^{-1} close to 78 K, and positive above. More recent interferometric measurements [41] place the upper change of sign at 124 K. NequIP-OAM-M reproduces the three regimes, as γ(T)\gamma(T) calculated with the linear response is positive and small around 10 K, negative between 14 K and 91 K, and positive above. The supercell with 16 atoms misses the first regime entirely, as it yields a negative γ(T)\gamma(T) down to the lowest temperatures, while those with 54 and 128 atoms overestimate it by a factor of three to four (see fig. 4).

Image not extracted

Figure 5. Relative root-mean-square error of the group velocities of silicon obtained from the exact Hessian of a supercell, as a function of the number of atoms in the supercell, for random wave vectors and for the wave vectors of the 4×4×44 \times4 \times4 grid. The reference is the analytic derivative of the linear response with NequIP-OAM-M.

Group velocities and the elastic limit

Group velocities enter the lattice thermal conductivity, and are usually obtained from the derivative of the Fourier-interpolated dynamical matrix. In fig. 5 we show the error of this procedure for silicon. For random wave vectors the relative error amounts to 28 %, 15 %, and 5.9 % for supercells with 16, 54, and 128 atoms, and falls below 1 % only for 432 atoms. The velocities converge more slowly than the frequencies. This is clearest at the wave vectors of the 4×4×44 \times4 \times4 grid, which are commensurate with the supercell of 128 atoms. There the frequencies of this supercell are exact, to 10−1410^{-14} THz, but the velocities are in error by 6.9 %, or 0.96 Å ps−1^{-1}. The Fourier interpolation reproduces the values of the dynamical matrix at the commensurate wave vectors, but not its slope.

The same occurs in the limit of long wavelengths, which gives the elastic constants. A fit of the cubic elastic tensor to the sound velocities of the linear response yields C11=115.4C_{11} = 115.4 GPa, C12=58.1C_{12} = 58.1 GPa, and C44=45.5C_{44} = 45.5 GPa, identical to the values obtained from the derivative of the stress with respect to strain. The same fit to the velocities of the supercell with 54 atoms gives 131.0 GPa, 73.1 GPa, and 54.4 GPa, i.e., errors of 14 % to 26 %, and with 128 atoms the error of C44C_{44} is still 7 %. We note that these are the elastic constants of the model at the experimental lattice parameter, where it has a residual pressure of 0.8 GPa.

Discussion

The main advantage of the method is that it removes the supercell as a convergence parameter. The dynamical matrix is that of the model, at any wave vector, and its accuracy does not depend on the range of the force constants. This is the argument that favors DFPT over finite displacements in density-functional theory, and it is particularly relevant for MLIPs. In a message-passing network the formal range of the force constants grows with the number of layers, and reaches distances that no supercell can contain for the deepest models. As a consequence, the error of the model and the error of the numerical procedure cannot be separated in a supercell calculation, while they are separated by construction in the linear response. The same holds for incommensurate wave vectors, such as those of charge-density waves or of nesting instabilities, which are accessible directly and not through a sequence of increasingly large supercells.

The second advantage is the access to analytic derivatives. Group velocities and mode Grüneisen parameters are obtained without a finite step and without the identification of modes between calculations. The results of section III D for MgB2_2 show that this is not a marginal issue. A finite strain has to be small with respect to the smallest separation between branches divided by their Grüneisen parameters, a quantity that is not known beforehand, and for MgB2_2 a strain of 0.1 % was still too large. The strain cannot be reduced indefinitely either, as the numerical noise of the frequencies is divided by it. For the group velocities, we found that the Fourier interpolation yields errors of several percent even where the frequencies are exact, and that the elastic constants obtained from the long-wavelength limit inherit these errors. Quantities that depend on the slope of the dispersion, such as the lattice thermal conductivity, are therefore more sensitive to the size of the supercell than the dispersion itself.

The method is also simple to apply. The trained model is used as it is, and the only operation that has to be modified is the gather of the features of the neighbors. We applied it to two different architectures without retraining, and with changes to their code that are limited to the three operations mentioned in section II C. These operations illustrate, however, that higher-order derivatives are not exercised during training or in standard applications, and that an implementation for a new architecture should be validated against a small supercell, as we did here.

Concerning the computational cost, one has to distinguish two situations. If the linear response is calculated on a regular grid and interpolated, it yields the same force constants as the corresponding supercell, at a similar cost when the crystal has symmetry and at a higher cost, by a factor between five and six in our example, when it has none. In our tests a pass of the linear response is in fact 6 to 11 times more expensive than a force evaluation for the same number of atoms, which is compensated by the smaller number of calculations that are required. Any quantity integrated over the Brillouin zone has to be converged with respect to this grid, exactly as it has to be converged with respect to the supercell. The difference is that the linear response can also be evaluated at any other wave vector, which provides a direct measure of the error of the interpolation, and that the grid can be refined without increasing the memory. If, on the other hand, the dynamical matrix is calculated directly at many wave vectors, the cost is proportional to their number, and a dense mesh is expensive. We believe that there is room for improvement, as the forward-over-reverse pass is not compiled and the batching of wave vectors and perturbations was not optimized. We recall that the efficiency of DFPT is also the result of many years of development.

Regarding previous work, the approach of Fang et al. [31] also yields the exact dynamical matrix without a supercell, from the second derivatives of the energy with respect to the positions of all atoms within the receptive field of the primitive cell. The two approaches differ in the same way as the real-space and the reciprocal-space formulations of lattice dynamics. In the former, the cost and the memory are determined by the size of the receptive field, and all wave vectors are then obtained at once. In the latter, they are those of the primitive cell for each wave vector, independently of the receptive field.

Conclusions

We presented a method to calculate the dynamical matrix of a message-passing interatomic potential in the primitive cell, at an arbitrary wave vector and without approximations. The method follows the logic of density-functional perturbation theory. The first-order response of the forces to a displacement modulated by a Bloch phase is propagated through the network, and the phase enters only in the operation that gathers the features of the neighboring atoms. The trained model is not modified, and we applied the method to two different architectures. As the wave vector and the strain are differentiable inputs, group velocities and mode Grüneisen parameters are obtained analytically, and the symmetry of the crystal is used to reduce the number of perturbations at each wave vector.

Having an exact reference, we could quantify the error of the supercell approach. For a model with four layers and supercells with 27 to 128 atoms, the phonon frequencies of the materials that we considered are in error by 0.3 THz to 0.7 THz, and for a model with ten layers the largest supercell that we could afford still deviates by 0.10 THz. For kaolinite, a low-symmetry silicate, the supercell yields imaginary frequencies that are absent from the exact dispersion of the model, i.e., a spurious dynamical instability. Quantities that depend on derivatives of the dispersion are more sensitive. The group velocities of silicon obtained with a supercell of 128 atoms are in error by 6%, also at the wave vectors where its frequencies are exact, and the thermodynamic Grüneisen parameter at low temperature is overestimated by a factor of three. Furthermore, mode Grüneisen parameters obtained from finite strains can follow the wrong branch when two modes are close in frequency, a problem that does not exist for the analytic derivative. When both approaches are used to obtain the same force constants, their cost is similar for crystals with high symmetry.

The natural extension of this work is the third order, which gives access to the phonon lifetimes and to the lattice thermal conductivity. The three-phonon matrix elements are the second-order response of the forces to two displacements modulated by the wave vectors q\mathbf{q} and q′\mathbf{q}'. In a message-passing network this requires that the gather multiplies each of the two first-order tangents by its own phase, and the mixed second-order change by the phase of q+q′\mathbf{q}+\mathbf{q}'. The rest of the calculation is again the unmodified model, and we verified for a model potential that this construction reproduces the third derivatives obtained from an explicit supercell. As in density-functional perturbation theory [9, 10, 42], the third-order matrices can then be calculated on a coarse grid of pairs of wave vectors and Fourier interpolated, and we expect that the range of the third-order force constants will be as relevant for the convergence of the thermal conductivity as the range of the second-order ones is for the quantities studied here. We leave this for future work.

Data availability

Not applicable.

Code availability

The code will be made available at https://github.com/hyllios/utils/tree/main/mlips-analytic-derivatives.

Acknowledgements

T.H.B.S. and M.A.L.M. were supported by a collaboration between the Kavli Foundation, Klaus Tschira Stiftung, and Kevin Wells, as part of the SuperC collaboration. M.A.L.M. was supported by the Simons Foundation through the Collaboration on New Frontiers in Superconductivity (Grant No. SFI-MPS-NFS-000067411-10). Part of the calculations were performed on the HPC cluster Elysium of the Ruhr University Bochum, subsidised by the DFG (INST 213/1055-1).

Author Contributions

T.H.B.S. and H.-C.W. developed the method, wrote the code, and performed the tests. M.A.L.M. conceived and directed the research. All authors contributed to the interpretation of the results and to the writing of the manuscript.

Competing Interests

The authors declare that they have no competing interests.

References

References

  1. [1]G. Kresse, J. Furthmüller, and J. Hafner, Ab initio force constant approach to phonon dispersion relations of diamond and graphite, Europhys. Lett. 32, 729 (1995).DOI
  2. [2]Parlinski, K., Li, Z. Q., & Kawazoe, Y. (1997). First-principles determination of the soft mode in cubic ZrO₂. Phys. Rev. Lett., 78, 4063.
  3. [3]A. Togo and I. Tanaka. First principles phonon calculations in materials science. Scripta Materialia 108, 1–5 (2015).arxiv.org/abs/1506.08498
  4. [5]S. Baroni, P. Giannozzi, and A. Testa, Green’s-function approach to linear response in solids, Phys. Rev. Lett. 58, 1861 (1987).pubmed.ncbi.nlm.nih.gov/10034557
  5. [6]P. Giannozzi, S. de Gironcoli, P. Pavone, and S. Baroni, Ab initio calculation of phonon dispersions in semiconductors, Phys. Rev. B 43, 7231 (1991).pubmed.ncbi.nlm.nih.gov/9998187
  6. [7]X. Gonze and C. Lee, Dynamical matrices, Born effective charges, dielectric permittivity tensors, and interatomic force constants from density-functional perturbation theory, Phys. Rev. B 55, 10355 (1997).DOI
  7. [8]S. Baroni, S. de Gironcoli, A. Dal Corso, and P. Giannozzi, Phonons and related crystal properties from density-functional perturbation theory, Rev. Mod. Phys. 73, 515 (2001).DOI
  8. [9]X. Gonze and J.-P. Vigneron, Density-functional approach to nonlinear-response coefficients of solids, Phys. Rev. B 39, 13120 (1989).pubmed.ncbi.nlm.nih.gov/9948209
  9. [10]A. Debernardi, S. Baroni, and E. Molinari, Anharmonic phonon lifetimes in semiconductors from density-functional perturbation theory, Phys. Rev. Lett. 75, 1819 (1995).pubmed.ncbi.nlm.nih.gov/10060399
  10. [11]J. Behler and M. Parrinello, Generalized neural-network representation of high-dimensional potential-energy surfaces, Phys. Rev. Lett. 98, 146401 (2007).pubmed.ncbi.nlm.nih.gov/17501293
  11. [12]A. P. Bartók, M. C. Payne, R. Kondor, and G. Csányi, Gaussian approximation potentials: The accuracy of quantum mechanics, without the electrons, Phys. Rev. Lett. 104, 136403 (2010).DOI
  12. [14]I. Batatia, D. P. Kovács, G. N. C. Simm, C. Ortner, and G. Csányi, MACE: Higher order equivariant message passing neural networks for fast and accurate force fields, in Advances in Neural Information Processing Systems, Vol. 35 (2022) pp. 11423–11436.arxiv.org/abs/2206.07697
  13. [15]C. Chen and S. P. Ong, A universal graph deep learning interatomic potential for the periodic table, Nat. Comput. Sci. 2, 718 (2022).DOI
  14. [16]B. Deng, P. Zhong, K. Jun, J. Riebesell, K. Han, C. J. Bartel, and G. Ceder, CHGNet as a pretrained universal neural network potential for charge-informed atomistic modelling, Nat. Mach. Intell. 5, 1031 (2023).DOI
  15. [17]Batatia, I., Benner, P., Chiang, Y., Elena, A. M., Kovács, D. P., Riebesell, J., & al., . et . (2025). A foundation model for atomistic materials chemistry. J. Chem. Phys., 163, 184110.
  16. [18]Yang, H., Hu, C., Zhou, Y., Liu, X., Shi, Y., Li, J., & al., . et . (2024). MatterSim: A deep learning atomistic model across elements, temperatures and pressures. arXiv:2405.04967
  17. [19]X. Fu, B. M. Wood, L. Barroso-Luque, D. S. Levine, M. Gao, M. Dzamba, and C. L. Zitnick, Learning smooth and expressive interatomic potentials for physical property prediction (2025), arXiv:2502.12147.arXiv
  18. [20]Wood, B. M., Dzamba, M., Fu, X., Gao, M., Shuaibi, M., Barroso-Luque, L., & al., . et . (2025). UMA: A family of universal models for atoms. In Advances in Neural Information Processing Systems (Vol. 38, pp. 143528–143564).
  19. [21]Loew, A., Sun, D., Wang, H.-C., Botti, S., & A., L. M. (2025). Universal machine learning interatomic potentials are ready for phonons. Npj Comput. Mater., 11, 178.
  20. [22]B. Póta, P. Ahlawat, G. Csányi, and M. Simoncelli, Thermal conductivity predictions with foundation atomistic models, Nat. Commun. 17, 10566 (2026).DOI
  21. [23]M. F. Langer, A. Hill, and M. Ceriotti, Truncated automatic sparse differentiation for machine learning interatomic potentials (2026), arXiv:2609.20510.arXiv
  22. [24]Born, M., & Huang, K. (1954). Dynamical Theory of Crystal Lattices. In Oxford University Press.
  23. [25]J. D. Gale, GULP: A computer program for the symmetry-adapted simulation of solids, J. Chem. Soc., Faraday Trans. 93, 629 (1997).DOI
  24. [26]J. D. Gale and A. L. Rohl, The general utility lattice program (GULP), Mol. Simul. 29, 291 (2003).DOI
  25. [27]L. N. Kantorovich, Thermoelastic properties of perfect crystals with nonprimitive lattices. I. General theory, Phys. Rev. B 51, 3520 (1995).pubmed.ncbi.nlm.nih.gov/9979162
  26. [28]J. D. Gale, Analytical free energy minimization of silica polymorphs, J. Phys. Chem. B 102, 5423 (1998).DOI
  27. [29]N. Gönnheimer, K. Reuter, and J. T. Margraf, Beyond numerical Hessians: Higher-order derivatives for machine learning interatomic potentials via automatic differentiation, J. Chem. Theory Comput. 21, 4742 (2025).DOI
  28. [30]T. Koker, A. Gangan, M. Kotak, K. J. Marian, and T. Smidt, PFT: Phonon fine-tuning for machine learned interatomic potentials (2026), arXiv:2601.07742.arXiv
  29. [31]Fang, S., Geiger, M., Checkslevy, J., & Smidt, T. (2024). Phonon predictions with E(3)-equivariant graph neural networks. arXiv:2403.11347
  30. [32]J. H. Lloyd-Williams and B. Monserrat, Lattice dynamics and electron-phonon coupling calculations using nondiagonal supercells, Phys. Rev. B 92, 184301 (2015).DOI
  31. [33]Wang, Q., Li, J., & Xie, Y. (2025). ARES-Phonon: Phonon calculation package using nondiagonal supercell finite displacement method with machine learning. 2503.11013
  32. [40]K. G. Lyon, G. L. Salinger, C. A. Swenson, and G. K. White, Linear thermal expansion measurements on silicon from 6 to 340 K, J. Appl. Phys. 48, 865 (1977).DOI
  33. [41]T. Middelmann, A. Walkov, G. Bartl, and R. Schödel, Thermal expansion coefficient of single-crystal silicon from 7 K to 293 K, Phys. Rev. B 92, 174113 (2015).DOI
  34. [42]L. Paulatto, F. Mauri, and M. Lazzeri, Anharmonic properties from a generalized third-order ab initio approach: Theory and applications to graphite and graphene, Phys. Rev. B 87, 214303 (2013).DOI

Paper details

vlnc:W_36kvxeaj
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 9

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents