Skip to content
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

PhononMaker add options to calculate_pdos and save force constants to file #1008

Merged
merged 13 commits into from
Nov 14, 2024

Conversation

chouyoudou
Copy link
Contributor

@chouyoudou chouyoudou commented Oct 6, 2024

Summary

Include a summary of major changes in bullet points:

  • Feature: Added functionality to compute and save projected phonon density of states (PDOS). The feature can be controlled by the calculate_pdos parameter in BasePhononMaker.

  • Fix: Added functionality to control the saving of force constants in the phonopy parameters schema through the store_force_constants parameter in BasePhononMaker. This feature determines whether force constants are saved as part of the phonon data schema, and now it functions correctly as intended.

@JaGeo
Copy link
Member

JaGeo commented Oct 6, 2024

Hi @chouyoudou ,

Thanks. I will review this. Just to mention, the store_force_constants parameter was referring to the schema and not the file. Should maybe be made clearer in the documentation.

@chouyoudou
Copy link
Contributor Author

Hi @chouyoudou ,

Thanks. I will review this. Just to mention, the store_force_constants parameter was referring to the schema and not the file. Should maybe be made clearer in the documentation.

Thanks for pointing that out. I've updated the documentation to clarify that it refers to controlling whether the force constants are saved in the schema, rather than directly to a file.

Comment on lines 410 to 418
if kwargs.get("calculate_pdos", False):
phonon.run_mesh(kpoint.kpts[0], with_eigenvectors=True, is_mesh_symmetry=False)
phonon_dos_sigma = kwargs.get("phonon_dos_sigma", None)
dos_use_tetrahedron_method = kwargs.get("dos_use_tetrahedron_method", True)
phonon.run_projected_dos(
sigma=phonon_dos_sigma, use_tetrahedron_method=dos_use_tetrahedron_method
)
phonon.write_projected_dos()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to also add an automatic plot here? Likely a bit more work. I am fine with just adding this for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directly relates to the next question: do you want the option to save it in the schema? If so, you would need to develop a parser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to also add an automatic plot here? Likely a bit more work. I am fine with just adding this for now.

I think it could be useful to provide summed PDOS, for example by element type or symmetry-equivalent atoms. However, user needs in this area are often quite diverse, making it challenging to implement something that meets all needs as straightforwardly as the TDOS plot.

This directly relates to the next question: do you want the option to save it in the schema? If so, you would need to develop a parser.

The current approach saves the PDOS in an external file, similar to the TDOS format. I believe a simple adjustment to the default filename to match the style of atomate2 (e.g., phonon_pdos.yaml instead of the default projected_dos.dat in phonopy) would suffice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with this for now. But is it really a yaml? If not, rather keep the dat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it is not a yaml; it was just renamed with a .yaml extension in atomate2 for TDOS.

Copy link
Contributor Author

@chouyoudou chouyoudou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply pre-commit auto-fix for code formatting and linting issues

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 65.45%. Comparing base (ec1b598) to head (101e276).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/atomate2/common/schemas/phonons.py 14.28% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1008       +/-   ##
===========================================
- Coverage   76.09%   65.45%   -10.65%     
===========================================
  Files         174      175        +1     
  Lines       12690    12744       +54     
  Branches     1892     1899        +7     
===========================================
- Hits         9657     8342     -1315     
- Misses       2494     3853     +1359     
- Partials      539      549       +10     
Files with missing lines Coverage Δ
src/atomate2/common/flows/phonons.py 87.17% <100.00%> (+0.33%) ⬆️
src/atomate2/common/schemas/phonons.py 89.28% <14.28%> (-4.55%) ⬇️

... and 85 files with indirect coverage changes

@JaGeo JaGeo changed the title add calculate_pdos and make force constance can be save add calculate_pdos Oct 7, 2024
@JaGeo JaGeo changed the title add calculate_pdos add calculate_pdos and additionally provide option to save force constants in a file Oct 7, 2024
@JaGeo
Copy link
Member

JaGeo commented Oct 18, 2024

@chouyoudou could you make a new option for saving the force constants in a file? Maybe via the kwargs? I don't think storing the force constants in a file should always come with storing them in the database. This is why I haven't merged so far

Copy link
Contributor Author

@chouyoudou chouyoudou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add force_constants2file parameter for saving the force constants in a file

Comment on lines 157 to 158
force_constants2file: str = None
calculate_pdos: bool = False
Copy link
Member

@JaGeo JaGeo Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make them part of "generate_frequencies_eigenvectors_kwargs" or at least the filename? Additionally, please use "create_force_constants_file" as an additional kwarg in "generate_frequencies_eigenvectors_kwargs" to write the force constant file? Otherwise, this will get very messy. I would also rename "force_constants2file" to "force_constants_filename"

Yaotang Zhang and others added 4 commits October 22, 2024 00:00
- Add "create_force_constants_file" in "generate_frequencies_eigenvectors_kwargs"
- Move "force_constants_filename" and "calculate_pdos" to "generate_frequencies_eigenvectors_kwargs"
@janosh
Copy link
Member

janosh commented Nov 14, 2024

@JaGeo does this PR have approval?

@janosh janosh added enhancement Improvements to existing features phonon Phonon workflow related labels Nov 14, 2024
@janosh janosh changed the title add calculate_pdos and additionally provide option to save force constants in a file PhononMaker add options to calculate_pdos and save force constants to file Nov 14, 2024
@JaGeo
Copy link
Member

JaGeo commented Nov 14, 2024

@janosh with your updates, it is fine with me. 😀

Thanks!

@janosh janosh merged commit 7add7ca into materialsproject:main Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features phonon Phonon workflow related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants