Skip to content

Commit

Permalink
Merge 8a05fce into 5d600ca
Browse files Browse the repository at this point in the history
  • Loading branch information
CompRhys committed Jul 14, 2021
2 parents 5d600ca + 8a05fce commit 18d52ee
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions pymatgen/symmetry/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SpacegroupAnalyzer:
Uses spglib to perform various symmetry finding operations.
"""

def __init__(self, structure, symprec=0.01, angle_tolerance=5.0):
def __init__(self, structure, symprec=0.01, angle_tolerance=5.0, inc_magmoms=True):
"""
Args:
structure (Structure/IStructure): Structure to find symmetry
Expand All @@ -51,6 +51,7 @@ def __init__(self, structure, symprec=0.01, angle_tolerance=5.0):
codes), a looser tolerance of 0.1 (the value used in Materials
Project) is often needed.
angle_tolerance (float): Angle tolerance for symmetry finding.
inc_magmoms (bool): Include magmom properties in spglib inputs
"""
self._symprec = symprec
self._angle_tol = angle_tolerance
Expand All @@ -59,7 +60,6 @@ def __init__(self, structure, symprec=0.01, angle_tolerance=5.0):
positions = structure.frac_coords
unique_species = []
zs = []
magmoms = []

for species, g in itertools.groupby(structure, key=lambda s: s.species):
if species in unique_species:
Expand All @@ -69,18 +69,23 @@ def __init__(self, structure, symprec=0.01, angle_tolerance=5.0):
unique_species.append(species)
zs.extend([len(unique_species)] * len(tuple(g)))

for site in structure:
if hasattr(site, "magmom"):
magmoms.append(site.magmom)
elif site.is_ordered and hasattr(site.specie, "spin"):
magmoms.append(site.specie.spin)
else:
magmoms.append(0)

self._unique_species = unique_species
self._numbers = zs
# For now, we are setting magmom to zero.
self._cell = latt, positions, zs, magmoms
self._cell = latt, positions, zs

if inc_magmoms:
magmoms = []

for site in structure:
if hasattr(site, "magmom"):
magmoms.append(site.magmom)
elif site.is_ordered and hasattr(site.specie, "spin"):
magmoms.append(site.specie.spin)
else:
magmoms.append(0)

self._cell += (magmoms,)

self._space_group_data = spglib.get_symmetry_dataset(
self._cell, symprec=self._symprec, angle_tolerance=angle_tolerance
Expand Down

0 comments on commit 18d52ee

Please sign in to comment.