Skip to content

Commit 2d73167

Browse files
committed
ENH: resolve CIF space group by its symops first
If symops are not working look it up by spacegroup identifier. Finally, build a new space group from a CIF list of symops.
1 parent e65abc8 commit 2d73167

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/diffpy/structure/parsers/p_cif.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import sys
2222
import re
23-
import copy
2423
from contextlib import contextmanager
2524
import numpy
2625
import six
@@ -447,6 +446,7 @@ def _parse_space_group_symop_operation_xyz(self, block):
447446
"""
448447
from diffpy.structure.spacegroups import IsSpaceGroupIdentifier
449448
from diffpy.structure.spacegroups import SpaceGroup, GetSpaceGroup
449+
from diffpy.structure.spacegroups import FindSpaceGroup
450450
self.asymmetric_unit = list(self.stru)
451451
sym_synonyms = ('_space_group_symop_operation_xyz',
452452
'_symmetry_equiv_pos_as_xyz')
@@ -469,21 +469,16 @@ def _parse_space_group_symop_operation_xyz(self, block):
469469
sgid = (int(block.get('_space_group_IT_number', '0')) or
470470
int(block.get('_symmetry_Int_Tables_number', '0')) or
471471
sg_nameHM)
472-
# try to reuse existing space group
473472
self.spacegroup = None
474-
if sgid and IsSpaceGroupIdentifier(sgid):
475-
sgstd = GetSpaceGroup(sgid)
476-
oprep_std = [str(op) for op in sgstd.iter_symops()]
477-
oprep_std.sort()
478-
oprep_cif = [str(op) for op in symop_list]
479-
oprep_cif.sort()
480-
# make sure symmetry operations have the same order
481-
if oprep_std == oprep_cif:
482-
self.spacegroup = copy.copy(sgstd)
483-
self.spacegroup.symop_list = symop_list
484-
# use standard definition when symmetry operations were not listed
485-
elif not symop_list:
486-
self.spacegroup = sgstd
473+
# try to reuse existing space group from symmetry operations
474+
if symop_list:
475+
try:
476+
self.spacegroup = FindSpaceGroup(symop_list)
477+
except ValueError:
478+
pass
479+
# otherwise lookup the space group from its identifier
480+
if self.spacegroup is None and sgid and IsSpaceGroupIdentifier(sgid):
481+
self.spacegroup = GetSpaceGroup(sgid)
487482
# define new spacegroup when symmetry operations were listed, but
488483
# there is no match to an existing definition
489484
if symop_list and self.spacegroup is None:

0 commit comments

Comments
 (0)