[WIP] Refactor QHACalc and PhononCalc#154
Conversation
| t_max=self.t_max, | ||
| t_min=self.t_min, | ||
| relax_structure=False, | ||
| write_phonon=False, |
There was a problem hiding this comment.
Hard coding write_phonon as False seems like it may not be ideal. What if the user wants to store the phonon properties (i.e. the YAML) out for each run to inspect the results later? Currently, there is no mechanism to do so. Of course, even if one were able to set it to True, we'd need to make sure there is no overwriting with each scale factor, so the scale factor would need to be appended to the filename or the files stored in a unique subdirectory to prevent overwriting. Also, if someone passes phonon_calc_kwargs={"write_phonon": True}, they will currently get an error.
I recognize the original code has write_phonon=False, so we can make that a separate issue report and address later if preferred, but since the I/O may influence the refactoring, I bring it up here.
There was a problem hiding this comment.
A similar comment may hold for the phonon_calc_kwargs, since specifying any of the file I/O flags to True will cause each scale factor to overwrite the files of the prior scale factor run I think.
|
There are many changes here (like to the test suite) that seem superfluous. Given the presence of several bugs in the original |
|
Thank you for the feedback. I will take your suggestion into careful consideration. I plan to first review and merge your bugfix PRs and then revisit the refactoring to make sure it does not conflict with those changes. |
Summary
Major changes:
QHACalcnow works withrelax_structure=Falseand ASEAtomsinput (fixes [Bug]:QHACalcdoes not work withrelax_structure=Falseand anAtomsobject as input #152). Addedto_pmg_structure()conversion before lattice scaling to ensure the structure always hasapply_strain.temperaturesarray now has the same length as all other property arrays (fixes [Bug]: The QHACalc temperatures and Gibbs free energies are not the same length #150). Previouslytemperatureshad one extra element because PhonopyQHA internally clips output arrays for finite-difference derivatives.np.transpose()usage on thermal property lists by inlining the QHA construction, making the data shape self-evident from context (fixes Unclear whynp.transposeis being called on alist#130, supersedes Fix: Clarify np.transpose usage in QHA calculation (Issue #130) #146).QHACalcby removing unnecessary helper methods. Core logic is now inline incalc()for readability.__init__write parameter resolution and_write_output_fileswith data-driven loops.setuptoolstocianddevdependencies to fixmamltest failures (missingpkg_resourcesin Python 3.12+).Todos
test_qha.pymay need updating if the matgl model version differs from the one used to generate the original expected values.Checklist
ruff.mypy.duecredit@due.dcitedecorators to reference relevant papers by DOI.