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
4 changes: 4 additions & 0 deletions src/atomate2/common/flows/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class BasePhononMaker(Maker, ABC):
determines the dft or force field code.
store_force_constants: bool
if True, force constants will be stored
calculate_pdos: bool
if True, the projected phonon density of states will be calculated
socket: bool
If True, use the socket for the calculation
"""
Expand Down Expand Up @@ -150,6 +152,7 @@ class BasePhononMaker(Maker, ABC):
kpath_scheme: str = "seekpath"
code: str = None
store_force_constants: bool = True
calculate_pdos: bool = False
socket: bool = False

def make(
Expand Down Expand Up @@ -355,6 +358,7 @@ def make(
optimization_run_uuid=optimization_run_uuid,
create_thermal_displacements=self.create_thermal_displacements,
store_force_constants=self.store_force_constants,
calculate_pdos=self.calculate_pdos,
**self.generate_frequencies_eigenvectors_kwargs,
)

Expand Down
12 changes: 11 additions & 1 deletion src/atomate2/common/schemas/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def from_forces_born(
# kwargs["filename_phonopy_yaml"] = "phonopy.yaml"

# with phonopy.load("phonopy.yaml") the phonopy API can be used
phonon.save(filename_phonopy_yaml)
phonon.save(filename_phonopy_yaml, settings={'force_constants': kwargs.get("store_force_constants", True)})

# get phonon band structure
kpath_dict, kpath_concrete = PhononBSDOSDoc.get_kpath(
Expand Down Expand Up @@ -406,6 +406,16 @@ def from_forces_born(
kppa=kpoint_density_dos,
force_gamma=True,
)
# projected dos
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.

phonon.run_mesh(kpoint.kpts[0])
phonon_dos_sigma = kwargs.get("phonon_dos_sigma", None)
dos_use_tetrahedron_method = kwargs.get("dos_use_tetrahedron_method", True)
Expand Down
Loading