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

Update phonons.py #2237

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/quacc/atoms/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import numpy as np
from monty.dev import requires
from pymatgen.io.ase import AseAtomsAdaptor
from pymatgen.core import Structure
from pymatgen.io.phonopy import get_phonopy_structure, get_pmg_structure
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

has_phonopy = bool(find_spec("phonopy"))

Expand Down Expand Up @@ -60,22 +59,19 @@ def get_phonopy(
"""
phonopy_kwargs = phonopy_kwargs or {}

symmetrized_structure = SpacegroupAnalyzer(
AseAtomsAdaptor().get_structure(atoms), symprec=symprec
).get_symmetrized_structure()

if supercell_matrix is None and min_lengths is not None:
supercell_matrix = np.diag(
np.round(np.ceil(min_lengths / np.array(symmetrized_structure.lattice.abc)))
np.round(np.ceil(min_lengths / atoms.cell.lengths()))
)

phonon = Phonopy(
get_phonopy_structure(symmetrized_structure),
get_phonopy_structure(Structure.from_ase_atoms(atoms)),
symprec=symprec,
supercell_matrix=supercell_matrix,
**phonopy_kwargs,
)
phonon.generate_displacements(distance=displacement)

return phonon


Expand Down
Loading