Lattice dynamics workflow using Pheasy#1063
Lattice dynamics workflow using Pheasy#1063hrushikesh-s wants to merge 182 commits intomaterialsproject:mainfrom
Conversation
Modified some parts based on Janine's comments.
…atomate2 into atomate2_jz_pheasy
…group for crystals.
- Update thermo reference values for matgl-backed phonon workflows - Enable thermal displacement generation in pheasy test (create_thermal_displacements=True) - Relax force_constants type check (tuple --> list | tuple) - Update total_dft_energy expectation (per-atom normalization) - Fix CI dependency stack for torch-limited forcefields
|
Hi @JaGeo, does this look okay? |
|
@hrushikesh-s thanks! I think one point we need to discuss is the deprecation of the phonon related schema. Our codes actually depend on the old schema and i think we should handle this carefully. |
|
Hi @JaGeo , Thanks for bringing this up, that makes a lot of sense. I agree that switching directly to the Emmet models could be disruptive since earlier production codes may still rely on the current atomate2 schema. Would it be reasonable to handle this in a phased way? What I had in mind is:
This way we can move toward the new schema without introducing a breaking change immediately. Does that sound like a reasonable approach to you? If yes, then I can make these edits to the current PR. |
|
I do recall a discussion involving @esoteric-ephemera that we wanted to potentially keep both options. |
This commit restores support for the legacy atomate2 phonon document schemas while introducing optional support for the newer Emmet schemas across phonon-related workflows. Deprecation decision: No deprecation is introduced in this commit Both schemas are supported going forward Deprecation of legacy atomate2 phonon schemas is deferred and will be discussed separately with a proper timeline
…tomate2 data schema
|
I don't remember off hand how much the two schemas differ, can you point me to the fields that are needed in the legacy schema that are missing in the new emmet one @hrushikesh-s? |
|
Hi @esoteric-ephemera , I compared the legacy atomate2 phonon schema against the new emmet one. The main differences are:
Aside -- I tried to restore the legacy phonon schema functionality for the phonon, QHA, and Grüneisen workflows, and have fixed the associated test failures. Can you pls take a look and confirm whether these changes align with the goal of continuing to support the legacy schema for these workflows in the short term, with a plan to migrate to the emmet schema later? |
|
Also, it's worthwhile to mention that the current PR makes use of my fork of Pheasy repo, and the PR is underway on Pheasy to make it compatible with the current atomate2 style reading of .npy files for disp & force matrices |
|
Thanks! From the timeline: i will likely look at it after Easter (next week earliest). I have to grade and prepare my teaching this week. I would also like to test and explore the changes in detail. |
| return Response(output={"plus": plus_struct, "minus": minus_struct}) | ||
|
|
||
|
|
||
| @job(data=[PhononBSDOSDoc]) |
There was a problem hiding this comment.
With this new workflow, no object needs to be transferred to "data"?
| ) | ||
|
|
||
|
|
||
| @job(data=[PhononBSDOSDoc]) |
There was a problem hiding this comment.
Or at least a replacement for this one?
| from atomate2.common.schemas.phonons import ( | ||
| PhononBSDOSDoc, | ||
| PhononComputationalSettings, | ||
| PhononJobDirs, | ||
| PhononUUIDs, | ||
| ThermalDisplacementData, | ||
| ) |
There was a problem hiding this comment.
I understood that we keep this for now, yes? Why not keeping the tests as long as we keep the schema?
| @@ -0,0 +1,362 @@ | |||
| """Flow for calculating (an)harmonic FCs and phonon energy renorma. with pheasy.""" | |||
There was a problem hiding this comment.
| """Flow for calculating (an)harmonic FCs and phonon energy renorma. with pheasy.""" | |
| """Flow for calculating (an)harmonic FCs and phonon energy renormalisation with pheasy.""" |
| if cal_anhar_fcs: | ||
| # Due to the cutoff radius of the force constants use the unit of Borh in ALM, | ||
| # we need to convert the cutoff radius from Angstrom to Bohr. | ||
| with ALM(lattice * 1.89, positions, numbers) as alm: |
There was a problem hiding this comment.
I assume this is accurate enough for a cutoff but maybe more digits?
| force_constants = parse_FORCE_CONSTANTS(filename=new_fc_file) | ||
| phonon.force_constants = force_constants | ||
| phonon.symmetrize_force_constants() | ||
|
|
||
| phonon.save(_DEFAULT_FILE_PATHS["phonopy"]) | ||
|
|
||
| # get phonon band structure | ||
| kpath_dict, kpath_concrete = _get_kpath( | ||
| structure=get_pmg_structure(phonon.primitive), | ||
| kpath_scheme=kpath_scheme, | ||
| symprec=symprec, | ||
| ) | ||
|
|
||
| npoints_band = kwargs.get("npoints_band", 101) | ||
| qpoints, connections = get_band_qpoints_and_path_connections( | ||
| kpath_concrete, npoints=kwargs.get("npoints_band", 101) | ||
| ) | ||
|
|
||
| # phonon band structures will always be computed | ||
| phonon.run_band_structure( | ||
| qpoints, path_connections=connections, with_eigenvectors=True | ||
| ) | ||
| phonon.write_yaml_band_structure(filename=_DEFAULT_FILE_PATHS["band_structure"]) | ||
| bs_symm_line = get_ph_bs_symm_line( | ||
| _DEFAULT_FILE_PATHS["band_structure"], | ||
| labels_dict=kpath_dict, | ||
| has_nac=born is not None, | ||
| ) |
There was a problem hiding this comment.
can more code be reused from phonon.py? If we have an update for the plotting, we would need to fix it here as well. Same for the code below.
| from importlib.util import find_spec | ||
|
|
||
| if not find_spec("openff"): | ||
| raise ImportError( | ||
| "openff must be installed via conda forge to use with atomate2:\n" | ||
| "conda install -c conda-force openff" | ||
| ) | ||
|
|
There was a problem hiding this comment.
can you check if this is consistent with how we handle this accross atomate2?
| assert_allclose( | ||
| ph_doc.primitive_matrix, | ||
| [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], | ||
| rtol=1e-5, | ||
| atol=1e-10, | ||
| ) | ||
| assert ph_doc.code == "vasp" | ||
| assert isinstance( | ||
| ph_doc.post_process_settings, | ||
| PhononComputationalSettings, | ||
| ) | ||
| assert ph_doc.post_process_settings.npoints_band == 101 | ||
| assert ph_doc.post_process_settings.kpath_scheme == "seekpath" | ||
| assert ph_doc.post_process_settings.kpoint_density_dos == 7000 | ||
|
|
||
| assert ph_doc.chemsys == "Si" |
There was a problem hiding this comment.
I don't see a test that actually checks the new implemented functionality. How do we make sure that the results stay consistent?
|
Hi @hrushikesh-s , I left a few comments. My main points:
|
|
Hey @hrushikesh-s sorry I missed your messages. These schema changes are very much intentional:
This is to explicitly allow for storing these as separate objects.
There is an opt-in setting for using the new emmet models. The default is still to use the pymatgen models in atomate2 (opt-out).
There is no reason to store The
A model computed field will still be saved in the document if it has been calculated. It is just a way to defer calculating an expensive model field until the user requests it Regarding the other fields being renamed, the document model explicitly handles the migration internally. You don't have to do anything to coerce the fields. Put a decent amount of work into it to do that since it needed to migrate our existing data seamlessly too Please revert these changes regarding the schema or communicate what changes you need in the schema to get the workflows to run correctly |
|
Hi @JaGeo and @esoteric-ephemera, thanks for your detailed comments. I will start working on the comments this Friday and will keep you updated. |
Summary
Include a summary of major changes in bullet points:
Additional dependencies introduced (if any)
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.