Elastic constants
We compute clamped-ion elastic constants of a crystal using the algorithmic differentiation density-functional perturbation theory (AD-DFPT) approach as introduced in [SPH25].
We consider a crystal in its equilibrium configuration, where all atomic forces and stresses vanish. Homogeneous strains $η$ are then applied relative to this relaxed structure. The elastic constants are derived from the stress-strain relationship. In Voigt notation, the stress $\sigma$ and strain $\eta$ tensors are represented as 6-component vectors. The elastic constants $C$ are then given by the Jacobian of the stress with respect to strain, forming a $6 \times 6$ matrix
\[ C = \frac{\partial \sigma}{\partial \eta}.\]
The sparsity pattern of the matrix $C$ follows from crystal symmetry and is tabulated in standard references (eg. Table 9 in [Nye1985]). This sparsity can be used a priori to reduce the number of strain patterns that need to be probed to extract all independent components of $C$. For example, cubic crystals have only three independent elastic constants $C_{11}$, $C_{12}$ and $C_{44}$, with the pattern
\[C = \begin{pmatrix} C_{11} & C_{12} & C_{12} & 0 & 0 & 0 \\ C_{12} & C_{11} & C_{12} & 0 & 0 & 0 \\ C_{12} & C_{12} & C_{11} & 0 & 0 & 0 \\ 0 & 0 & 0 & C_{44} & 0 & 0 \\ 0 & 0 & 0 & 0 & C_{44} & 0 \\ 0 & 0 & 0 & 0 & 0 & C_{44} \\ \end{pmatrix}.\]
Thus we can just choose a suitable strain pattern $\dot{\eta} = (1, 0, 0, 1, 0, 0)^\top$, such that $C\dot{\eta} = (C_{11}, C_{12}, C_{12}, C_{44}, 0, 0)^\top$. That is, for cubic crystals like diamond silicon we obtain all independent elastic constants from a single Jacobian-vector product on the stress-strain function.
This example computes the clamped-ion elastic tensor, keeping internal atomic positions fixed under strain. The relaxed-ion tensor includes additional corrections from internal relaxations, which can be obtained from first-order atomic displacements in DFPT (see [Wu2005]).
using DFTK
using PseudoPotentialData
using LinearAlgebra
using ForwardDiff
using DifferentiationInterface
using AtomsBuilder
using Unitful
using UnitfulAtomic
pseudopotentials = PseudoFamily("dojo.nc.sr.pbe.v0_4_1.standard.upf")
a0_pbe = 10.33u"bohr" # Equilibrium lattice constant of silicon with PBE
model0 = model_DFT(bulk(:Si; a=a0_pbe); pseudopotentials, functionals=PBE())
Ecut = recommended_cutoff(model0).Ecut
kgrid = [4, 4, 4]
tol = 1e-6
function symmetries_from_strain(model0, voigt_strain)
lattice = DFTK.voigt_strain_to_full(voigt_strain) * model0.lattice
model = Model(model0; lattice, symmetries=true)
model.symmetries
end
strain_pattern = [1., 0., 0., 1., 0., 0.]; # recovers [c11, c12, c12, c44, 0, 0]
For elastic constants beyond the bulk modulus, symmetry-breaking strains are required. That is, the symmetry group of the crystal is reduced. Here we simply precompute the relevant subgroup by applying the automatic symmetry detection (spglib) to the finitely perturbed crystal.
symmetries_strain = symmetries_from_strain(model0, 0.01 * strain_pattern)
function stress_from_strain(model0, voigt_strain; symmetries, Ecut, kgrid, tol)
lattice = DFTK.voigt_strain_to_full(voigt_strain) * model0.lattice
model = Model(model0; lattice, symmetries)
basis = PlaneWaveBasis(model; Ecut, kgrid)
scfres = self_consistent_field(basis; tol)
DFTK.full_stress_to_voigt(compute_stresses_cart(scfres))
end
stress_fn(voigt_strain) = stress_from_strain(model0, voigt_strain;
symmetries=symmetries_strain,
Ecut, kgrid, tol)
stress, (dstress,) = value_and_pushforward(stress_fn, AutoForwardDiff(),
zeros(6), (strain_pattern,));
n Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.453546123478 -0.94 5.3 1.70s
2 -8.455637947495 -2.68 -1.77 1.0 167ms
3 -8.455776508110 -3.86 -2.89 1.9 221ms
4 -8.455790064908 -4.87 -3.27 3.0 299ms
5 -8.455790173141 -6.97 -3.75 1.1 215ms
6 -8.455790186480 -7.87 -4.73 1.3 192ms
7 -8.455790187689 -8.92 -5.26 2.7 282ms
8 -8.455790187711 -10.65 -5.80 1.9 224ms
9 -8.455790187713 -11.72 -6.63 1.7 190ms
Solving response problem
Iter Restart Krydim log10(res) avg(CG) Δtime Comment
---- ------- ------ ---------- ------- ------ ---------------
66.8 1.41s Non-interacting
1 0 1 0.11 51.1 2.00s
2 0 2 -0.70 46.3 794ms
3 0 3 -1.71 40.5 707ms
4 0 4 -2.78 32.8 601ms
5 0 5 -4.04 23.9 480ms
6 0 6 -5.56 9.9 292ms
7 0 7 -7.75 4.0 212ms
8 1 1 -6.70 66.4 1.26s Restart
65.8 1.01s Final orbitals
We can inspect the stress to verify it is small (close to equilibrium):
stress
6-element StaticArraysCore.SVector{6, Float64} with indices SOneTo(6):
-2.3121258454011262e-5
-2.3121162563459938e-5
-2.3121162563459924e-5
-2.685555996313382e-10
0.0
0.0
The response of the stress to strain_pattern
contains the elastic constants in atomic units, with the expected pattern $(c11, c12, c12, c44, 0, 0)$:
dstress
6-element StaticArraysCore.SVector{6, Float64} with indices SOneTo(6):
0.005319943610176459
0.0020248999112305924
0.002024899911230593
0.003351909457157833
0.0
0.0
Convert to GPa:
println("C11: ", uconvert(u"GPa", dstress[1] * u"hartree" / u"bohr"^3))
println("C12: ", uconvert(u"GPa", dstress[2] * u"hartree" / u"bohr"^3))
println("C44: ", uconvert(u"GPa", dstress[4] * u"hartree" / u"bohr"^3))
C11: 156.51814446019478 GPa
C12: 59.574612072422504 GPa
C44: 98.61658075272737 GPa
These results can be compared directly to finite differences of the stress_fn:
h = 1e-3
dstress_fd = (stress_fn(h * strain_pattern) - stress_fn(-h * strain_pattern)) / 2h
println("C11 (FD): ", uconvert(u"GPa", dstress_fd[1] * u"hartree" / u"bohr"^3))
println("C12 (FD): ", uconvert(u"GPa", dstress_fd[2] * u"hartree" / u"bohr"^3))
println("C44 (FD): ", uconvert(u"GPa", dstress_fd[4] * u"hartree" / u"bohr"^3))
n Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.453486110185 -0.94 5.3 472ms
2 -8.455635246983 -2.67 -1.77 1.0 294ms
3 -8.455780767234 -3.84 -2.89 1.9 1.43s
4 -8.455795182999 -4.84 -3.23 2.9 273ms
5 -8.455795298194 -6.94 -3.68 1.2 161ms
6 -8.455795313549 -7.81 -4.81 1.2 167ms
7 -8.455795315178 -8.79 -5.23 3.0 300ms
8 -8.455795315195 -10.78 -5.53 1.3 198ms
9 -8.455795315198 -11.48 -6.85 1.1 172ms
n Energy log10(ΔE) log10(Δρ) Diag Δtime
--- --------------- --------- --------- ---- ------
1 -8.453498292602 -0.94 5.4 415ms
2 -8.455621833645 -2.67 -1.77 1.0 161ms
3 -8.455770104579 -3.83 -2.89 1.9 203ms
4 -8.455782157743 -4.92 -3.32 3.1 297ms
5 -8.455782244159 -7.06 -3.84 1.1 162ms
6 -8.455782253624 -8.02 -4.91 1.4 180ms
7 -8.455782254361 -9.13 -5.36 2.9 275ms
8 -8.455782254371 -11.02 -6.02 1.3 179ms
C11 (FD): 156.3220679246998 GPa
C12 (FD): 59.547048295814186 GPa
C44 (FD): 98.53463444090713 GPa
Here are AD-DFPT results from increasing discretization parameters:
Ecut | kgrid | c11 | c12 | c44 |
---|---|---|---|---|
18 | [4, 4, 4] | 156.51 | 59.57 | 98.61 |
18 | [8, 8, 8] | 153.53 | 56.90 | 100.07 |
24 | [8, 8, 8] | 153.26 | 56.82 | 99.97 |
24 | [14, 14, 14] | 153.03 | 56.71 | 100.09 |
For comparison, Materials Project for PBE relaxed-ion elastic constants of silicon mp-149: c11 = 153 GPa, c12 = 57 GPa, c44 = 74 GPa. Note the discrepancy in c44, which is due to us not yet including ionic relaxation in this example.
- SPH25Schmitz, N. F., Ploumhans, B., & Herbst, M. F. (2025) Algorithmic differentiation for plane-wave DFT: materials design, error control and learning model parameters. arXiv:2509.07785
- Nye1985Nye, J. F. (1985). Physical Properties of Crystals. Oxford University Press. Comment: Since the elastic tensor transforms equivariantly under rotations, its numerical components depend on the chosen Cartesian coordinate frame. These tabulated patterns assume a standardized orientation of the structure with respect to conventional crystallographic axes.
- Wu2005Wu, X., Vanderbilt, D., & Hamann, D. R. (2005). Systematic treatment of displacements, strains, and electric fields in density-functional perturbation theory. Physical Review B, 72(3), 035105.