Skip to content

Commit

Permalink
Merge pull request #64 from pyiron/phonopy
Browse files Browse the repository at this point in the history
Convert from phonopy to ASE
  • Loading branch information
jan-janssen authored Sep 5, 2023
2 parents a9d5c3b + 9f98141 commit d971f02
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions structuretoolkit/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
pymatgen_to_ase,
)
from structuretoolkit.common.pyscal import ase_to_pyscal
from structuretoolkit.common.phonopy import phonopy_to_atoms, atoms_to_phonopy
36 changes: 36 additions & 0 deletions structuretoolkit/common/phonopy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
def phonopy_to_atoms(ph_atoms):
"""
Convert Phonopy Atoms to ASE-like Atoms
Args:
ph_atoms: Phonopy Atoms object
Returns: ASE-like Atoms object
"""
from ase.atoms import Atoms

return Atoms(
symbols=list(ph_atoms.get_chemical_symbols()),
positions=list(ph_atoms.get_positions()),
cell=list(ph_atoms.get_cell()),
pbc=True,
)


def atoms_to_phonopy(atom):
"""
Convert ASE-like Atoms to Phonopy Atoms
Args:
atom: ASE-like Atoms
Returns:
Phonopy Atoms
"""
from phonopy.structure.atoms import PhonopyAtoms

return PhonopyAtoms(
symbols=list(atom.get_chemical_symbols()),
scaled_positions=list(atom.get_scaled_positions()),
cell=list(atom.get_cell()),
)

0 comments on commit d971f02

Please sign in to comment.