Skip to content

Commit

Permalink
Update phonons.py (#2237)
Browse files Browse the repository at this point in the history
Incorporate some of the changes from #2110.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Andrew-S-Rosen and pre-commit-ci[bot] authored Jun 12, 2024
1 parent 0138a37 commit 57882d6
Showing 1 changed file with 4 additions and 8 deletions.
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

0 comments on commit 57882d6

Please sign in to comment.