-
Notifications
You must be signed in to change notification settings - Fork 121
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
base: main
Are you sure you want to change the base?
Lattice dynamics workflow using Pheasy #1063
Conversation
Modified some parts based on Janine's comments.
…atomate2 into atomate2_jz_pheasy
…group for crystals.
src/atomate2/common/flows/pheasy.py
Outdated
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, | ||
) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will draft something 😃
src/atomate2/common/flows/pheasy.py
Outdated
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, different.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…_pheasy_anharmonic
HipHive leverages Numba under the hood for its force-constant calculators, and numba only works with NumPy ≤ 2.2.
@JaGeo , can you pls check if the PR looks okay? |
tests/vasp/flows/test_pheasy.py
Outdated
job = PhononMaker( | ||
force_diagonal=True, | ||
min_length=12, | ||
mp_id="mp-149", |
There was a problem hiding this comment.
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.
- 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? | ||
|
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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?
src/atomate2/vasp/flows/pheasy.py
Outdated
""" | ||
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. |
There was a problem hiding this comment.
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.
@hrushikesh-s I increased code reuse in the pheasy code. The other changes already look great! What is missing:
|
…ng/atomate2 into atomate2_jz_pheasy_anharmonic
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") |
There was a problem hiding this comment.
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
# 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: |
There was a problem hiding this comment.
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
Summary
Include a summary of major changes in bullet points:
Additional dependencies introduced (if any)
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.
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:
The easiest way to handle this is to run the following in the correct sequence on
your local machine. Start with running
ruff
andruff format
on 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.
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.