-
Notifications
You must be signed in to change notification settings - Fork 97
Automate elastic_constants by AD-DFPT as a postprocessing
#1172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| @test size(voigt_stress) == (6,) | ||
| @test size(C) == (6, 6) | ||
| # @test norm(C - Cref) < 3e-6 # ~0.1 GPa |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
| lattice = DFTK.voigt_strain_to_full(voigt_strain) * model0.lattice | ||
| model = Model(model0; lattice, symmetries=true) | ||
| model.symmetries |
There was a problem hiding this comment.
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 ?
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: