Skip to content

Conversation

@niklasschmitz
Copy link
Collaborator

@niklasschmitz niklasschmitz commented Oct 15, 2025

Following up on the ideas at #1162.

This PR aims to automate the clamped-ion elastic constants as a convenient postprocessing function elastic_constants(scfres) for 1) the generic case of not using symmetry (most expensive, 6xDFPT on a fully unfolded kgrid...), 2.1) the most common case of cubic crystals (least expensive, 1xDFPT on a partially unfolded kgrid). Optimizations for other the point groups could be implemented later following a similar pattern.

progress:

  • Implement generic case
  • Implement cubic case
  • use SCF results from scfres and partially unfold
  • more testing
  • mention in elastic constants docs example


@test size(voigt_stress) == (6,)
@test size(C) == (6, 6)
# @test norm(C - Cref) < 3e-6 # ~0.1 GPa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fair to also compare against a reference from QE or similar here, just to make sure we agree. If too much effort, we could even compare against ourselves, I'm pretty convinced we do the right thing. just to make sure that we don't regress on this.

basis = PlaneWaveBasis(model0; Ecut, kgrid)

scfres = self_consistent_field(basis; tol)
(; voigt_stress, C) = DFTK.elastic_constants(scfres)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DFTK. not needed I guess ?

end

"""Computes the *clamped-ion* elastic constants (without ionic relaxation)"""
function elastic_constants(scfres::NamedTuple;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about elastic_tensor because that's what it is. The constants are the individual entries.

# TODO restart SCF from previous
lattice = DFTK.voigt_strain_to_full(voigt_strain) * model0.lattice
model = Model(model0; lattice, symmetries)
basis = PlaneWaveBasis(model; Ecut, kgrid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous as basis of the SCF may be very different (e.g. fft_grid may be set, symmetries may be customised, architecture etc.). We have to find a better mechanics here. I would be in favour of having a special PlaneWaveBasis constructor that essentially just changes the model under the hood and otherwise tries to keep as many of the settings of the "old basis". Would also be useful for https://github.com/JuliaMolSim/DFTK.jl/blob/master/src/postprocess/stresses.jl#L22.

Comment on lines +5 to +7
lattice = DFTK.voigt_strain_to_full(voigt_strain) * model0.lattice
model = Model(model0; lattice, symmetries=true)
model.symmetries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we directly invoke the symmetry detection here instead of constructing the full model and then throwing it away ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants