Fix pheasy anharmonic fitting and add fit options - #1558
Conversation
|
@hrushikesh-s thanks! Did you already test this on a smaller database? 😀 This would be great to know for additional context |
|
@JaGeo , yes, correct -- @ZKC19940412 is running the benchmarking tests on these, and will post the results in a few days for you to take a look 👍 |
Hi Hrushikesh, if you want, Maybe you also can add me into this branch, I can provide some good strategies and coding to make the anharmonic FCs fitting, finite-temperature phonon or phonon-related properties more efficient, accurate and useful for users, especially for high-throughput calculations and screening. Otherwise, if the phonon-related code is too slow and tedious, it could not attract too many users to try. best. |
|
@leslie-zheng , sounds good! Pls feel free to make edits/comments on this PR as you think necessary. |
# Conflicts: # pyproject.toml
|
Hi @JaGeo, this is ready for your review. I updated the description with the changes since the last round. The main one is that the anharmonic LASSO fit now runs with On your question about testing: we checked the fits against finite displacements with phono3py for six materials and three MACE potentials. The results are in the tutorial in #1559. |
|
Thanks. Where exactly did you adapt the tutorial? At least, I don't see a new output there for anharmonic data. Everything else looks good |
The tutorial for anharmonic CTE calcs is in PR #1559 |
|
@hrushikesh-s one last thing: should we add a note in the documentation that the workflow might undergo further changes and has not been as widely tested as the harmonic one? |
Yes, let me add that in now! |
|
@JaGeo , done! |
|
Will be merged as soon as all tests pass |
Summary
This PR fixes the anharmonic force constant fit in the pheasy workflow and adds options for it. The harmonic fit is unchanged, apart from a fixed LASSO seed.
Bug fixes:
num_disp_anhar.random_seed + 1.--nbodypassed to pheasy. The count now uses the same cutoffs andnbodyas the fit.FORCE_CONSTANTS, the anharmonic fit was skipped without an error. It now raises an error.check=True.min_lengthdefault and the supercell kwargs.Features:
anhar_max_order, 3 (default) or 4.anhar_fit_methods,"cocktail"(default),"one-shot", or both. Cocktail keeps fc2 fixed to the harmonic fit. One-shot fits all orders together and writes to aone_shotfolder.anhar_alpha_min, the lowest LASSO penalty in the cross-validation search. A warning is raised if the chosen penalty lands on either end of the search.num_disp_anharis used as given.common/jobs/phonons.pyas_get_num_irreducible_fcsand_get_num_harmonic_supercells. The pheasy and hiPhive workflows both use these helpers, so the hiPhive job no longer keeps its own copy.--scell SPOSCAR.--tolof 1e-4, the anharmonic LASSO fits at small penalties stopped before they converged. Cross-validation then picked a penalty that could change from one machine to another. The anharmonic fit now runs with--tol 1e-8, and the same penalty is picked on every machine.Removals:
renorm_phononandrenorm_temp.renorm_tempwas never read. The renormalization step only reran the fit with pheasy's default OLS and did nothing with the result, so no renormalization was done. I will soon be creating a new PR with temperature-dependent effective phonons.cal_ther_cond,ther_cond_meshandther_cond_temp. The phono3py command used flags that phono3py 4.5 does not have. The failure was ignored, and no result reached the output document.TypeError.Behaviour changes:
--seed, so repeated runs give the same force constants.Tests:
tests/common/jobs/test_pheasy.py(new) runs both jobs end to end with EMT forces on fcc Cu. It covers the dataset split, the supercell count, the penalty warnings, the cocktail and one-shot fits, and a fourth-order fit.tests/vasp/flows/test_pheasy.pychecks the input validation. It also checks that the maker passes the same settings to both jobs.Additional dependencies introduced (if any)
--scell, and it builds the sensing matrix for all displaced supercells at once. The second change gives the same force constants and is about 27 times faster for a 432-atom Si supercell. I will move the pin to a pheasy release once these changes are merged there.TODO (if any)
Checklist
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.