Add thermal expansion workflow (CTEMaker) - #1559
Conversation
|
Hi @JaGeo, we will also share benchmarking results for this PR. |
|
@hrushikesh-s is there a connection to the qha Maker that one could exploit? |
10c9ee2 to
4ad570c
Compare
389bfe9 to
5bee251
Compare
…displacement references
I went through the QHA workflow for parts to reuse. The two workflows get the thermal expansion in different ways. QhaMaker runs harmonic phonons at several volumes, and phonopy's QHA fits the free energy against volume. CTEMaker runs one pheasy fit with third-order force constants at one volume, and phono3py gives the mode Grüneisen tensors from them. The thermal expansion tensor then follows from these tensors and the elastic compliance. So the volume scan, the EOS fit and PhonopyQHA have no counterpart in CTEMaker. CTEMaker already reuses the pheasy PhononMaker, the ElasticMaker, structure_to_primitive and structure_to_conventional, and the PhononDoc type and job folder lookup from the Grüneisen jobs. |
|
Hi @JaGeo, this is ready for review as well. It builds on #1558 and includes the same |
|
Let's start with the other one |
# Conflicts: # docs/user/codes/vasp.md # pyproject.toml
|
|
||
| Alternatively, users can accelerate the calculation of interatomic force constants using the machine-learning-based [Pheasy code](https://doi.org/10.48550/arXiv.2508.01020). | ||
| The `pheasy` extra, `pip install "atomate2[pheasy]"`, installs the pheasy version this workflow needs, together with phonopy and ALM. | ||
| It also installs phono3py for the thermal expansion workflow. |
There was a problem hiding this comment.
Should we have an additional field for that? historically, phono3py had lots of installation issues and I would only install it of necessary
There was a problem hiding this comment.
Yess valid point. I have now moved phono3py installation out of the pheasy extra into a new phono3py extra!
| return np.array(alphas), mean_gruneisen | ||
|
|
||
|
|
||
| def _expand_born_to_unitcell(phonon: Phonopy) -> np.ndarray: |
There was a problem hiding this comment.
This is a specific requirement of this workflow, right? Or do we need this elsewhere as well?
There was a problem hiding this comment.
Yes, this is specific to this workflow.. The other phonon workflows pass the Born charges to phonopy, which maps them onto its cells itself.
phonopy.yaml stores the Born charges for phonopy's primitive cell, but phono3py uses the whole unit cell as its primitive cell. With the default primitive cell the two are the same and the charges are passed through. With use_symmetrized_structure="conventional" the unit cell is larger, so the charges are copied onto the matching unit cell atoms.
Nothing else in atomate2 builds a phono3py object from phonopy output, so I have kept it as a private helper next to the code that uses it...
|
Rest looks good. I would make a note in the Workflow itself and the documentation that more testing might be required |
@JaGeo, I have now added this note! |
|
@JaGeo, does this PR look good now? |
|
It does look good but from the current workflow ouput, I cannot see if the tests actually run. Can you try to change the verbosity of the pytest outputs so that we can confirm all tests are running? |
|
The time difference makes the PRs always a bit challenging 😅. |
Done @JaGeo! I have now added -v to the pytest command of the test-non-ase jobs, so each test now prints its own line.
Yeah 😅 |
|
thanks! Can you also do that for all forcefield tests? Then, I think we are good to merge 😃 |
@JaGeo, done! |
|
@hrushikesh-s thanks! I did not find the tests yet? Could you check that the forcfield ones run? |
|
Ah, they are in common! but you do use a forcefield right? |
Yes, correct. I have now moved the two force field CTE tests to tests/forcefields/flows/test_cte.py. They only need EMT, so the numpy-limited forcefield job now also installs pheasy, ALM and phono3py and runs them there. |
|
Just to make sure: the pheasy tests are also running in forcefields, right? |
No, they are not... I think they are in common.. Let me fix those as well. |
|
Thanks and sorry that I overlooked this as well! |
|
Maybe as an addition: so far, we had all workflows that can be run with focefields in the 'forcefield/flows' folder as well. |
|
@JaGeo, thanks for checking these issues! |
|
Thank you @hrushikesh-s ! |
Summary
This PR adds a workflow for the thermal expansion tensor from third-order force constants. It builds on #1558 and needs its anharmonic fit options. Until #1558 is merged, this PR also shows its changes.
CTEMakerfor VASP (atomate2.vasp.flows.cte) and for force fields (atomate2.forcefields.flows.cte), with a sharedBaseCTEMakerinatomate2.common.flows.cte.PhononMakerand to the existingElasticMaker, with no second relaxation in either. The two sub-flows do not depend on each other. The elastic fit gets the stress of the relaxation, as in the elastic flow.cal_anhar_fcs=True, the one-shot fit, 0.03 Å displacements andmin_length=12.0. The fit methods are set byanhar_fit_methodsof the phonon maker, so the cocktail fit can be used too.compute_ctereads the force constants from the pheasy job folder.CTEDocument.from_force_constantsthen gets the mode Grüneisen tensors from phono3py and computes the thermal expansion tensor from the mode heat capacities, the Grüneisen tensors and the elastic compliance.-tol_imaginary_modes(0.1 THz by default), a warning is raised and the thermal expansion of that fit is not computed.CTEDocument, with oneCTEResultper fit method. Each result holds the thermal expansion tensor and the volumetric thermal expansion at each temperature, the heat-capacity weighted mean Grüneisen tensor, and the lowest frequency on the mesh.docs/user/codes/vasp.md, with an example and a note on r2SCAN.tutorials/cte_workflow.ipynbruns the workflow with three MACE potentials. Section 1 runs NaCl, KCl, MgO, CaO and GaAs at the default settings and checks the results against finite displacements with phono3py. Section 2 converges the third-order cutoff and the supercell for Si.Additional dependencies introduced (if any)
phono3py>=4.5is added to thepheasyextra. It computes the mode Grüneisen tensors from the second- and third-order force constants. phono3py 4.5.0 requires phonopy 4.5, soatomate2[pheasy]installs phonopy 4.5.TODO (if any)
main.Checklist
Before a pull request can be merged, the following items must be checked:
The easiest way to handle this is to run the following in the correct sequence on
your local machine. Start with running
ruffandruff formaton your new code. This willautomatically reformat your code to PEP8 conventions and fix many linting issues.
Run ruff on your code.
type check your code.
Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply run
pre-commit installand a check will be run prior to allowing commits.