Skip to content

Commit

Permalink
Added compatibility with spglib 1.15.
Browse files Browse the repository at this point in the history
  • Loading branch information
mesonepigreco committed Jun 9, 2020
1 parent b755e73 commit 1c1db0b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cellconstructor/symmetries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ def SetupFromSPGLIB(self):
raise ImportError("Error, this function works only if spglib is available")

# Get the symmetries
spg_syms = spglib.get_symmetry(self.structure.get_ase_atoms(), self.threshold)
spg_syms = spglib.get_symmetry(self.structure.get_ase_atoms(), symprec = self.threshold)
symmetries = GetSymmetriesFromSPGLIB(spg_syms, regolarize= False)

trans_irt = 0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ setuptools
numpy
scipy
ase
spglib==1.14.1.post0
spglib
41 changes: 21 additions & 20 deletions tests/TestImposeSymmetries/test_impose_symmetries.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,31 @@

import sys, os

total_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(total_path)
def test_impose_symmetry():
total_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(total_path)


# initialize the dynamical matrix
dyn = CC.Phonons.Phonons("old_dyn", full_name=True)
# initialize the dynamical matrix
dyn = CC.Phonons.Phonons("old_dyn", full_name=True)

# Print the symmetry group at high threshold
GROUP = spglib.get_spacegroup(dyn.structure.get_ase_atoms(), 0.05)
s_group_expected = spglib.get_spacegroup(dyn.structure.get_ase_atoms())
print ("Space group with high threshold:", s_group_expected)
print ("Space group with low threshold:", GROUP)
# Print the symmetry group at high threshold
GROUP = spglib.get_spacegroup(dyn.structure.get_ase_atoms(), 0.05)
s_group_expected = spglib.get_spacegroup(dyn.structure.get_ase_atoms())
print ("Space group with high threshold:", s_group_expected)
print ("Space group with low threshold:", GROUP)

# Get the symmetries from the new spacegroup
symmetries = spglib.get_symmetry(dyn.structure.get_ase_atoms(), 0.05)
print("Number of symmetries: {}".format(len(symmetries["rotations"])))
# Get the symmetries from the new spacegroup
symmetries = spglib.get_symmetry(dyn.structure.get_ase_atoms(), symprec = 0.05)
print("Number of symmetries: {}".format(len(symmetries["rotations"])))

# Transform the spglib symmetries into the CellConstructor data type
sym_mats = CC.symmetries.GetSymmetriesFromSPGLIB(symmetries, True)
# Force the symmetrization
dyn.structure.impose_symmetries(sym_mats)
# Transform the spglib symmetries into the CellConstructor data type
sym_mats = CC.symmetries.GetSymmetriesFromSPGLIB(symmetries, True)
# Force the symmetrization
dyn.structure.impose_symmetries(sym_mats)

# Check once again the symetry
s_group_after = spglib.get_spacegroup(dyn.structure.get_ase_atoms())
print ("New space group with high threshold:", s_group_after)
# Check once again the symetry
s_group_after = spglib.get_spacegroup(dyn.structure.get_ase_atoms())
print ("New space group with high threshold:", s_group_after)

assert s_group_after == GROUP
assert s_group_after == GROUP

0 comments on commit 1c1db0b

Please sign in to comment.