Skip to content

Commit

Permalink
Merge pull request #2573 from cajfisher/patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Jul 4, 2022
2 parents 0a5071f + e2b1aea commit 0a0bb8b
Showing 1 changed file with 41 additions and 43 deletions.
84 changes: 41 additions & 43 deletions pymatgen/symmetry/kpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class KPathBase(metaclass=abc.ABCMeta):
def __init__(self, structure, symprec=0.01, angle_tolerance=5, atol=1e-5, *args, **kwargs):
"""
Args:
structure (Structure): Structure object
symprec (float): Tolerance for symmetry finding
structure (Structure): Structure object.
symprec (float): Tolerance for symmetry finding.
angle_tolerance (float): Angle tolerance for symmetry finding.
atol (float): Absolute tolerance used to compare structures
and determine symmetric equivalence of points and lines
Expand Down Expand Up @@ -97,8 +97,8 @@ def kpath(self):
def get_kpoints(self, line_density=20, coords_are_cartesian=True):
"""
Returns:
the kpoints along the paths in Cartesian coordinates
together with the labels for symmetry points -Wei.
kpoints along the path in Cartesian coordinates
together with the critical-point labels.
"""
list_k_points = []
sym_point_labels = []
Expand Down Expand Up @@ -131,32 +131,32 @@ def get_kpoints(self, line_density=20, coords_are_cartesian=True):

class KPathSetyawanCurtarolo(KPathBase):
"""
This class looks for path along high symmetry lines in
the Brillouin Zone.
This class looks for a path along high-symmetry lines in
the Brillouin zone.
It is based on Setyawan, W., & Curtarolo, S. (2010).
High-throughput electronic band structure calculations:
Challenges and tools. Computational Materials Science,
49(2), 299-312. doi:10.1016/j.commatsci.2010.05.010
It should be used with primitive structures that
comply with the definition from the paper.
The symmetry is determined by spglib through the
comply with the definition given in the paper.
The symmetry is determined by spglib using the
SpacegroupAnalyzer class. The analyzer can be used to
produce the correct primitive structure (method
get_primitive_standard_structure(international_monoclinic=False)).
produce the correct primitive structure with the method
get_primitive_standard_structure(international_monoclinic=False).
A warning will signal possible compatibility problems
with the given structure. KPoints from get_kpoints() method
are returned in the reciprocal cell basis defined in the paper.
with the given structure. k-points generated using the get_kpoints() method
are returned for the reciprocal cell basis defined in the paper.
"""

def __init__(self, structure, symprec=0.01, angle_tolerance=5, atol=1e-5):
"""
Args:
structure (Structure): Structure object
symprec (float): Tolerance for symmetry finding
structure (Structure): Structure object.
symprec (float): Tolerance for symmetry finding.
angle_tolerance (float): Angle tolerance for symmetry finding.
atol (float): Absolute tolerance used to compare the input
structure with the one expected as primitive standard.
A warning will be issued if the lattices don't match.
A warning will be issued if the cells don't match.
"""
if "magmom" in structure.site_properties.keys():
warn(
Expand All @@ -172,12 +172,12 @@ def __init__(self, structure, symprec=0.01, angle_tolerance=5, atol=1e-5):
self._rec_lattice = self._prim.lattice.reciprocal_lattice

# Note: this warning will be issued for space groups 38-41, since the primitive cell must be
# reformatted to match Setyawan/Curtarolo convention in order to work with the current k-path
# reformatted to match the Setyawan/Curtarolo convention in order to work with the current k-path
# generation scheme.
if not np.allclose(self._structure.lattice.matrix, self._prim.lattice.matrix, atol=atol):
warn(
"The input structure does not match the expected standard primitive! "
"The path can be incorrect. Use at your own risk."
"The path may be incorrect. Use at your own risk."
)

lattice_type = self._sym.get_lattice_type()
Expand Down Expand Up @@ -934,22 +934,22 @@ def trib(self):

class KPathSeek(KPathBase):
"""
This class looks for path along high symmetry lines in
the Brillouin Zone.
This class looks for a path along high-symmetry lines in
the Brillouin sone.
It is based on Hinuma, Y., Pizzi, G., Kumagai, Y., Oba, F.,
& Tanaka, I. (2017). Band structure diagram paths based on
crystallography. Computational Materials Science, 128, 140–184.
https://doi.org/10.1016/j.commatsci.2016.10.015
It should be used with primitive structures that
comply with the definition from the paper.
The symmetry is determined by spglib through the
SpacegroupAnalyzer class. KPoints from get_kpoints() method
are returned in the reciprocal cell basis defined in the paper.
comply with the definition given in the paper.
The symmetry is determined by spglib using the
SpacegroupAnalyzer class. k-points are generated using the
get_kpoints() method for the reciprocal cell basis defined in the paper.
"""

@requires(
get_path is not None,
"SeeK-path is required to use the convention by Hinuma et al.",
"SeeK-path needs to be installed to use the convention of Hinuma et al. (2015)",
)
def __init__(self, structure, symprec=0.01, angle_tolerance=5, atol=1e-5, system_is_tri=True):
"""
Expand Down Expand Up @@ -1061,12 +1061,10 @@ def _trans_sc_to_Hin(sub_class):

class KPathLatimerMunro(KPathBase):
"""
This class looks for a path along high symmetry lines in the
This class looks for a path along high-symmetry lines in the
Brillouin zone. It is based on the method outlined in:
npj Comput Mater 6, 112 (2020). 10.1038/s41524-020-00383-7
The user should ensure that the lattice of the input structure
The user should ensure that the unit cell of the input structure
is as reduced as possible, i.e. that there is no linear
combination of lattice vectors which can produce a vector of
lesser magnitude than the given set (this is required to
Expand All @@ -1076,9 +1074,9 @@ class KPathLatimerMunro(KPathBase):
In the case of magnetic structures, care must also be taken to
provide the magnetic primitive cell (i.e. that which reproduces
the entire crystal, including the correct magnetic ordering,
upon application of lattice translations). There is no way to
programmatically check for this, so if the input structure is
incorrect, the class will output the incorrect kpath without
upon application of lattice translations). There is no algorithm to
check for this, so if the input structure is
incorrect, the class will output the incorrect k-path without
any warning being issued.
"""

Expand Down Expand Up @@ -1107,11 +1105,11 @@ def __init__(
symprec (float): Tolerance for symmetry finding
angle_tolerance (float): Angle tolerance for symmetry finding.
atol (float): Absolute tolerance used to determine symmetric
equivalence of points and lines on the BZ.
equivalence of points and lines in the BZ.
"""
super().__init__(structure, symprec=symprec, angle_tolerance=angle_tolerance, atol=atol)

# Check to see if input lattice is reducible. Ref: B Gruber in Acta. Cryst. Vol. A29,
# Check to see if input cell is reducible. Ref: B Gruber in Acta. Cryst. Vol. A29,
# pp. 433-440 ('The Relationship between Reduced Cells in a General Bravais lattice').
# The correct BZ will still be obtained if the lattice vectors are reducible by any
# linear combination of themselves with coefficients of absolute value less than 2,
Expand All @@ -1135,8 +1133,8 @@ def __init__(
if np.any(reducible):
print("reducible")
warn(
"The lattice of the input structure is not fully reduced!"
"The path can be incorrect. Use at your own risk."
"The unit cell of the input structure is not fully reduced!"
"The path may be incorrect. Use at your own risk."
)

if magmom_axis is None:
Expand Down Expand Up @@ -1240,16 +1238,16 @@ def _get_ksymm_kpath(self, has_magmoms, magmom_axis, axis_specified, symprec, an

# 3: Find symmetry-equivalent points, which can be mapped to each other by a combination of point group
# operations and integer translations by lattice vectors. The integers will only be -1, 0, or 1, since
# we are restricting to the BZ.
# we are restricted to the BZ.

key_points_inds_orbits = self._get_key_point_orbits(key_points=key_points)

# 4: Get all lines on BZ between adjacent key points and between gamma
# 4: Get all lines in BZ between adjacent key points and between gamma
# and key points ("key lines")

key_lines = self._get_key_lines(key_points=key_points, bz_as_key_point_inds=bz_as_key_point_inds)

# 5: Find symmetry-equivalent key lines, defined as endpoints of first line being equivalent
# 5: Find symmetry-equivalent key lines, defined as end points of first line being equivalent
# to end points of second line, and a random point in between being equivalent to the mapped
# random point.

Expand Down Expand Up @@ -1283,9 +1281,9 @@ def _get_ksymm_kpath(self, has_magmoms, magmom_axis, axis_specified, symprec, an
little_groups_lines=little_groups_lines,
)

# 10: Consolidate selected segments into a single irreducible section of the Brilouin zone (as determined
# 10: Consolidate selected segments into a single irreducible section of the BZ (as determined
# by the reciprocal point and lattice symmetries). This is accomplished by identifying the boundary
# planes of the IRBZ. Also, get labels for points according to distance away from axes.
# planes of the IRBZ. Also, get labels for points according to distance from axes.

IRBZ_points_inds = self._get_IRBZ(recip_point_group, W, key_points, face_center_inds, atol)
lines_in_path_inds = []
Expand Down Expand Up @@ -1532,7 +1530,7 @@ def _get_key_points(self):

def _get_key_point_orbits(self, key_points):
key_points_copy = dict(zip(range(len(key_points) - 1), key_points[0 : len(key_points) - 1]))
# gamma not equivalent to any on BZ and is last point added to
# gamma not equivalent to any in BZ and is last point added to
# key_points
key_points_inds_orbits = []

Expand Down Expand Up @@ -1845,7 +1843,7 @@ def _get_coset_factor(self, G, H):
gH.append(op1)

for op in gH:
opH = [op * h for h in H]
opH = [op.__mul__(h) for h in H]
is_coset_factor = True
for op1 in opH:
for op2 in H:
Expand Down Expand Up @@ -2324,7 +2322,7 @@ def LabelPoints(index):
@staticmethod
def LabelSymbol(index):
"""
Letters used in generating labels for Latimer-Munro convention
Letters used in generating labels for the Latimer-Munro convention
"""

symbols = [
Expand Down

0 comments on commit 0a0bb8b

Please sign in to comment.