Skip to content

Lattice dynamics workflow using Pheasy #1063

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

Open
wants to merge 134 commits into
base: main
Choose a base branch
from

Conversation

hrushikesh-s
Copy link
Collaborator

Summary

Include a summary of major changes in bullet points:

  • Feature 1
  • Fix 1

Additional dependencies introduced (if any)

  • List all new dependencies needed and justify why. While adding dependencies that bring
    significantly useful functionality is perfectly fine, adding ones that add trivial
    functionality, e.g., to use one single easily implementable function, is frowned upon.
    Justify why that dependency is needed. Especially frowned upon are circular dependencies.

TODO (if any)

If this is a work-in-progress, write something about what else needs to be done.

  • Feature 1 supports A, but not B.

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP] in the pull request
title.

Before a pull request can be merged, the following items must be checked:

  • Code is in the standard Python style.
    The easiest way to handle this is to run the following in the correct sequence on
    your local machine. Start with running ruff and ruff format on your new code. This will
    automatically reformat your code to PEP8 conventions and fix many linting issues.
  • Doc strings have been added in the Numpy docstring format.
    Run ruff on your code.
  • Type annotations are highly encouraged. Run mypy to
    type check your code.
  • Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

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 install and a check will be run prior to allowing commits.

Comment on lines 366 to 374
displacement_calcs = run_phonon_displacements(
displacements=displacements.output,
structure=structure,
supercell_matrix=supercell_matrix,
phonon_maker=self.phonon_displacement_maker,
socket=self.socket,
prev_dir_argname=self.prev_calc_dir_argname,
prev_dir=prev_dir,
)
Copy link
Member

Choose a reason for hiding this comment

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

This is also different than in phonon.BasePhononMaker

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is currently getting imported like this:

from atomate2.common.jobs.pheasy import (
    generate_frequencies_eigenvectors,
    generate_phonon_displacements,
    get_supercell_size,
    run_phonon_displacements,
)

This is also different than in phonon.BasePhononMaker

What should be done to fix this then?

Copy link
Member

Choose a reason for hiding this comment

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

I will draft something 😃

Comment on lines 396 to 408
phonon_collect = generate_frequencies_eigenvectors(
supercell_matrix=supercell_matrix,
displacement=self.displacement,
num_displaced_supercells=self.num_displaced_supercells,
cal_anhar_fcs=self.cal_anhar_fcs,
displacement_anhar=self.displacement_anhar,
num_disp_anhar=self.num_disp_anhar,
fcs_cutoff_radius=self.fcs_cutoff_radius,
renorm_phonon=self.renorm_phonon,
renorm_temp=self.renorm_temp,
cal_ther_cond=self.cal_ther_cond,
ther_cond_mesh=self.ther_cond_mesh,
ther_cond_temp=self.ther_cond_temp,
Copy link
Member

Choose a reason for hiding this comment

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

Again, different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since we have many job(s) which are similar yet different in pheasy.py & phonons.py, do you think it would be a good idea to create another file for eg: core_phonons.py, and place these repeated job(s) in this file?

We can then rename phonons.py to lets say phonopy.py.

So, in that way, we will have three files in common/flows :

- core_phonons.py
- phonopy.,py
- pheasy.py

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

This would be one option but it might be a breaking change.

@hrushikesh-s
Copy link
Collaborator Author

@hrushikesh-s Thank you for this pull-request. I have a list of TODOs:

  • Solve conflicts with the current main branch
  • Check if the tests run through here on github actions
  • Add a real test for the whole pheasy workflow (ML potential and VASP) (only see schema tests so far)
  • Add new documentation

Let me know if you need help with individual parts.

@JaGeo , can you pls check if the PR looks okay?

job = PhononMaker(
force_diagonal=True,
min_length=12,
mp_id="mp-149",
Copy link
Member

Choose a reason for hiding this comment

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

mp_id still shows up here.

Comment on lines +63 to +72
- name: Install ALA-Mode
run: |
micromamba activate a2
micromamba install -n a2 -c conda-forge "numpy<=2.2" scipy h5py compilers “libblas=*=*mkl” spglib boost eigen cmake ipython mkl-include openmpi --yes
git clone https://github.com/ttadano/ALM.git # do I need to modify this?
cd ALM # do I need to modify this?
cd python
python setup.py build # do I need to modify this?
uv pip install -e . # do I need to modify this?

Copy link
Member

Choose a reason for hiding this comment

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

Could you add these instructions to the documentation?

run: |
micromamba activate a2
micromamba install -n a2 -c conda-forge "numpy<=2.2" scipy h5py compilers “libblas=*=*mkl” spglib boost eigen cmake ipython mkl-include openmpi --yes
git clone https://github.com/ttadano/ALM.git # do I need to modify this?
Copy link
Member

Choose a reason for hiding this comment

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

https://anaconda.org/conda-forge/alm why not installing it directly from conda? Is a different version needed?

Comment on lines 21 to 31
"""
Maker to calculate harmonic phonons with VASP and Phonopy.

Calculate the harmonic phonons of a material. Initially, a tight structural
relaxation is performed to obtain a structure without forces on the atoms.
Subsequently, supercells with one displaced atom are generated and accurate
forces are computed for these structures. With the help of phonopy, these
forces are then converted into a dynamical matrix. To correct for polarization
effects, a correction of the dynamical matrix based on BORN charges can
be performed. Finally, phonon densities of states, phonon band structures
and thermodynamic properties are computed.
Copy link
Member

Choose a reason for hiding this comment

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

Doc strings would need to be updated.

@JaGeo
Copy link
Member

JaGeo commented Jun 14, 2025

@hrushikesh-s I increased code reuse in the pheasy code. The other changes already look great!

What is missing:

  • please add instructions for the installation in the documentation, please also add a small section in the documentation on the pheasy workflow
  • please check all doc strings (vasp.pheasy and forcefield.pheasy) and check if you added all required parameters
  • please add a test for the forcefield implementation
  • please switch to alm installation via conda-forge which should make the installation more stable
  • get rid of code duplication in common.jobs.pheasy and common.jobs.phonons

Comment on lines +123 to +129
warnings.warn(
"Initial magnetic moments will not be considered for the determination "
"of the symmetry of the structure and thus will be removed now.",
stacklevel=1,
)
cell = get_phonopy_structure(
structure.remove_site_property(property_name="magmom")
Copy link
Member

Choose a reason for hiding this comment

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

ideally, we export the common parts from the phonons and pheasy jobs into a method and reuse it? This would then also make it easier when we change anything here in the future in either of the jobs in pheasy.py or phonons.py

Comment on lines +378 to +390
# I did not directly import this job from the phonon module
# because I modified the job to pass the displaced structures
# to the output.
@job(data=["forces", "displaced_structures"])
def run_phonon_displacements(
displacements: list[Structure],
structure: Structure,
supercell_matrix: Matrix3D,
phonon_maker: BaseVaspMaker | ForceFieldStaticMaker | BaseAimsMaker = None,
prev_dir: str | Path = None,
prev_dir_argname: str = None,
socket: bool = False,
) -> Flow:
Copy link
Member

Choose a reason for hiding this comment

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

if possible, i would modify the phonons.py job instead to avoid code duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants