Skip to content

Space Groups

SpaceGroup

Represent a crystallographic space group, including all necessary symmetry operations in fractional coordinates, the international tables number from 1-230, and the international tables symbol.

Attributes:

Name Type Description
symbol str

The international tables short space group symbol

full_symbol str

The full international tables space group symbol

choice str

The space group choice (if applicable)

centering str

The space group centering (if applicable)

schoenflies str

The Schoenflies space group symbol

centrosymmetric bool

Whether or not the space group is centrosymmetric

symmetry_operations List[SymmetryOperation]

List of symmetry operations making up this space group

cif_section: str property readonly

Representation of the SpaceGroup in CIF files

crystal_system: str property readonly

The crystal system of the space group e.g. triclinic, monoclinic etc.

latt: int property readonly

The SHELX LATT number associated with this space group. Returns a negative if there is no inversion.

Options are

1: P,
2: I,
3: rhombohedral obverse on hexagonal axes,
4: F,
5: A,
6: B,
7: C

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
>>> P1 = SpaceGroup(1)
>>> P21c = SpaceGroup(14)
>>> I41 = SpaceGroup(14)
>>> R3bar = SpaceGroup(148)
>>> P1.latt
-1
>>> P21c.latt
1
>>> R3bar.latt
3

Returns:

Type Description
int

int: the SHELX LATT number of this space group

lattice_type: str property readonly

the lattice type of this space group e.g. rhombohedral, hexagonal etc.

laue_class: str property readonly

the Laue class of the point group associated with this space group

pg property readonly

alias for self.point_group

point_group property readonly

the point group of this space group

sym: str property readonly

alias for self.symbol

symbol_unicode: str property readonly

the space group symbol with unicode subscripts

symops property readonly

alias for self.symmetry_operations

apply_all_symops(self, coordinates)

For a given set of coordinates, apply all symmetry operations in this space group, yielding a set subject to only translational symmetry (i.e. a unit cell). Assumes the input coordinates are fractional.

Parameters:

Name Type Description Default
coordinates ndarray

(N, 3) set of fractional coordinates

required

Returns:

Type Description
Tuple[np.ndarray, np.ndarray]

a (MxN) array of generator symop integers and an (MxN, 3) array of coordinates where M is the number of symmetry operations in this space group.

Source code in chmpy/crystal/space_group.py
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def apply_all_symops(self, coordinates: np.ndarray):
    """
    For a given set of coordinates, apply all symmetry
    operations in this space group, yielding a set subject
    to only translational symmetry (i.e. a unit cell).
    Assumes the input coordinates are fractional.

    Args:
        coordinates (np.ndarray): (N, 3) set of fractional coordinates

    Returns:
        Tuple[np.ndarray, np.ndarray]: a (MxN) array of generator symop integers
            and an (MxN, 3) array of coordinates where M is the number of symmetry
            operations in this space group.
    """
    nsites = len(coordinates)
    transformed = np.empty((nsites * len(self), 3))
    generator_symop = np.empty(nsites * len(self), dtype=np.int32)

    # make sure we do the unit symop first
    unity = 0
    for i, s in enumerate(self.symmetry_operations):
        if s.integer_code == 16484:
            unity = i
            break
    transformed[0:nsites] = coordinates
    generator_symop[0:nsites] = 16484
    other_symops = (
        self.symmetry_operations[:unity] + self.symmetry_operations[unity + 1 :]
    )
    for i, s in enumerate(other_symops, start=1):
        transformed[i * nsites : (i + 1) * nsites] = s(coordinates)
        generator_symop[i * nsites : (i + 1) * nsites] = s.integer_code
    return generator_symop, transformed

from_symmetry_operations(symops, expand_latt=None) classmethod

Find a matching spacegroup for a given set of symmetry operations, optionally treating them as a reduced set of symmetry operations and expanding them based on the lattice type.

Parameters:

Name Type Description Default
symops List[SymmetryOperation]

a reduced or full list of symmetry operations

required
expand_latt int

the SHELX LATT number to expand this list of symmetry operations

None

Returns:

Type Description
SpaceGroup

the matching SpaceGroup for the provided symmetry operations and LATT

Source code in chmpy/crystal/space_group.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
@classmethod
def from_symmetry_operations(cls, symops, expand_latt=None):
    """
    Find a matching spacegroup for a given set of symmetry
    operations, optionally treating them as a reduced set of
    symmetry operations and expanding them based on the lattice
    type.

    Args:
        symops (List[SymmetryOperation]): a reduced or full list of symmetry operations
        expand_latt (int, optional): the SHELX LATT number to expand this list of symmetry operations

    Returns:
        SpaceGroup: the matching `SpaceGroup` for the provided symmetry operations and LATT

    """
    if expand_latt is not None:
        if not -8 < expand_latt < 8:
            raise ValueError("expand_latt must be between [-7, 7]")
        symops = expanded_symmetry_list(symops, expand_latt)
    encoded = tuple(sorted(s.integer_code for s in symops))
    if encoded not in SG_FROM_SYMOPS:
        raise ValueError(
            "Could not find matching spacegroup for "
            "the following symops:\n{}".format(
                "\n".join(str(s) for s in sorted(symops))
            )
        )
    else:
        sgdata = SG_FROM_SYMOPS[encoded]
        return SpaceGroup(sgdata.number, choice=sgdata.choice)

has_hexagonal_rhombohedral_choices(self)

returns true if this space group could be represented as hexagonal or rhombohedral

Source code in chmpy/crystal/space_group.py
275
276
277
def has_hexagonal_rhombohedral_choices(self) -> bool:
    "returns true if this space group could be represented as hexagonal or rhombohedral"
    return self.international_tables_number in (146, 148, 155, 160, 161, 166, 167)

ordered_symmetry_operations(self)

The symmetry operations of this space group in order (with identiy first)

Source code in chmpy/crystal/space_group.py
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
def ordered_symmetry_operations(self):
    "The symmetry operations of this space group in order (with identiy first)"
    # make sure we do the unit symop first
    unity = 0
    for i, s in enumerate(self.symmetry_operations):
        if s.is_identity():
            unity = i
            break
    else:
        raise ValueError(
            "Could not find identity symmetry_operation -- invalide space group"
        )
    other_symops = (
        self.symmetry_operations[:unity] + self.symmetry_operations[unity + 1 :]
    )
    return [self.symmetry_operations[unity]] + other_symops

reduced_symmetry_operations(self)

returns a reduced list of symmetry operations

Source code in chmpy/crystal/space_group.py
271
272
273
def reduced_symmetry_operations(self):
    "returns a reduced list of symmetry operations"
    return reduced_symmetry_list(self.symmetry_operations, self.latt)