Fix wrong k-labels if path contains symmetry equivalent points

This commit is contained in:
Matteo Giantomassi 2018-08-09 20:59:31 +02:00
parent 7d06162e2f
commit 7b9b18fd23
2 changed files with 23 additions and 2 deletions

View File

@ -992,10 +992,27 @@ class Structure(pymatgen.Structure, NotebookWriter):
return self.__class__.from_sites(sorted(self.sites, key=lambda site: site.specie.Z))
def findname_in_hsym_stars(self, kpoint):
"""Returns the name of the special k-point, None if kpoint is unknown."""
"""
Returns the name of the special k-point, None if kpoint is unknown.
"""
if self.abi_spacegroup is None: return None
from .kpoints import Kpoint
kpoint = Kpoint.as_kpoint(kpoint, self.reciprocal_lattice)
# Try to find kpoint in hsym_stars without taking into accout symmetry operation (compare with base_point)
# Important if there are symmetry equivalent k-points in hsym_kpoints e.g. K and U in FCC lattice
# as U should not be mapped onto K as done in the second loop below.
from .kpoints import issamek
for star in self.hsym_stars:
if star.find(kpoint) != -1:
if issamek(kpoint.frac_coords, star.base_point.frac_coords):
return star.name
# Now check if kpoint is in one of the stars.
for star in self.hsym_stars:
i = star.find(kpoint)
if i != -1:
#print("input kpt:", kpoint, "star image", star[i], star[i].name)
return star.name
else:
return None

View File

@ -72,6 +72,10 @@ class TestStructure(AbipyTest):
with self.assertRaises(ValueError):
si_wfk.spgset_abi_spacegroup(has_timerev=True)
# K and U are equivalent. [5/8, 1/4, 5/8] should return U
assert si_wfk.findname_in_hsym_stars([3/8, 3/8, 3/4]) == "K"
assert si_wfk.findname_in_hsym_stars([5/8, 1/4, 5/8]) == "U"
# TODO: Fix order of atoms in supercells.
# Test __mul__, __rmul__ (should return Abipy structures)
assert si_wfk == 1 * si_wfk