QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
spgsym.h File Reference

Space-group symmetry detection via the vendored spglib. More...

#include "qpms_types.h"
#include "groups.h"
#include "pergroups.h"
Include dependency graph for spgsym.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  qpms_spg_kind_symmetry_t
 Internal symmetry description of one particle kind. More...
 
struct  qpms_spg_detection_t
 Result of the point-group detection for a finite particle arrangement. More...
 

Macros

#define QPMS_SPG_MAXOPS   192
 Maximum number of operations spglib may return for a space group.
 

Typedefs

typedef struct qpms_spg_detection_t qpms_spg_detection_t
 Result of the point-group detection for a finite particle arrangement.
 

Enumerations

enum  qpms_spgsym_internal_t { QPMS_SPGSYM_INTERNAL_ANY = 0 , QPMS_SPGSYM_INTERNAL_AXIAL , QPMS_SPGSYM_INTERNAL_GROUP , QPMS_SPGSYM_INTERNAL_TRIVIAL }
 Internal symmetry class of a particle kind. More...
 

Functions

int qpms_spg_detect_pointgroup (qpms_spg_detection_t *out, const cart3_t *positions, const qpms_irot3_t *transforms, const int *types, const qpms_spg_kind_symmetry_t *kind_sym, size_t n, double symprec)
 Detects the point group symmetry of a finite particle arrangement.
 
int qpms_spg_detection_filter_ops (qpms_spg_detection_t *d, const int *keep, size_t nkeep)
 
int qpms_spg_match_pointgroup_ops (qpms_spg_detection_t *out, const qpms_irot3_t *ops, size_t nops)
 
void qpms_spg_detection_free (qpms_spg_detection_t *d)
 Frees the runtime-constructed parts of a detection result.
 
void qpms_finite_group_free_runtime (qpms_finite_group_t *G)
 
int qpms_spg_ops_from_hall_number (int(*rotations)[3][3], double(*translations)[3], int hall_number)
 Fetches the operations of a space group from the spglib database.
 
int qpms_spg_layer_ops (int(*rotations)[3][3], double(*translations)[3], char symbol[11], const double lattice[3][3], const double(*positions)[3], const int *types, int n, int aperiodic_axis, double symprec, int *number)
 
int qpms_spg_space_ops (int(*rotations)[3][3], double(*translations)[3], char symbol[11], const double lattice[3][3], const double(*positions)[3], const int *types, int n, double symprec, int *number)
 
int qpms_spg_detect_pointgroup_periodic (qpms_spg_detection_t *out, const cart3_t *lattice_basis, int latdim, const cart3_t *positions, const qpms_irot3_t *transforms, const int *types, const qpms_spg_kind_symmetry_t *kind_sym, size_t n, double symprec)
 Detects the point group symmetry of a 2D- or 3D-periodic arrangement.
 

Detailed Description

Space-group symmetry detection via the vendored spglib.

This module wraps spglib (https://spglib.github.io, BSD-3-clause, vendored as the spglib/ submodule) for

Only the 32 crystallographic point groups can be detected; an arrangement with non-crystallographic symmetry (e.g. five-fold) is reported with the highest crystallographic subgroup found by spglib.

Enumeration Type Documentation

◆ qpms_spgsym_internal_t

Internal symmetry class of a particle kind.

The detection of the system symmetry must not only map the particle positions onto each other but also carry each particle's T-matrix onto its partner's; whether that succeeds depends on the internal symmetry of the particle kind (an anisotropic particle breaks operations that a spherical one survives).

Enumerator
QPMS_SPGSYM_INTERNAL_ANY 

invariant under any operation (spheres, dummy particles)

QPMS_SPGSYM_INTERNAL_AXIAL 

D-infinity-h symmetric (finite cylinder: any rotation about the particle's z axis, mirrors and C2s containing or perpendicular to it)

QPMS_SPGSYM_INTERNAL_GROUP 

invariant under the finite group given in the descriptor (e.g. a T-matrix symmetrised over a group)

QPMS_SPGSYM_INTERNAL_TRIVIAL 

fully anisotropic (generic scuff T-matrices)

Function Documentation

◆ qpms_finite_group_free_runtime()

void qpms_finite_group_free_runtime ( qpms_finite_group_t *  G)

Frees a runtime-constructed finite group (as returned by qpms_spg_detect_pointgroup() in oriented_group).

◆ qpms_spg_detect_pointgroup()

int qpms_spg_detect_pointgroup ( qpms_spg_detection_t *  out,
const cart3_t *  positions,
const qpms_irot3_t *  transforms,
const int *  types,
const qpms_spg_kind_symmetry_t *  kind_sym,
size_t  n,
double  symprec 
)

Detects the point group symmetry of a finite particle arrangement.

A candidate operation is accepted iff it maps every particle position onto another particle of the same kind and carries the particle's T-matrix onto its partner's: with transforms giving the per-particle T-matrix orientations (the rotate/mirror transforms of the placement) and kind_sym the internal symmetry class of each kind (indexed like types), the composition transforms[j]^-1 . g . transforms[i] must lie in the internal symmetry group of the kind. Pass transforms = NULL for all-identity transforms and kind_sym = NULL for QPMS_SPGSYM_INTERNAL_ANY (a purely geometric detection, appropriate only when all kinds are rotation-symmetric, e.g. spheres).

The accepted operation set is closed under multiplication and matched against the known finite groups (cf. groups.h) including the orientation: if successful, out->oriented_group contains a runtime-constructed group whose 3D representation is aligned with the actual arrangement and which can be used directly with the scattering-system symmetry machinery (qpms_scatsys_apply_symmetry()).

positions are cartesian particle positions, types are 0-based "species" indices; symprec is the position tolerance in cartesian length units (pick it proportional to the cluster size, e.g. 1e-4 * cluster radius).

Only crystallographic point groups can be detected; non-crystallographic arrangements yield a (possibly trivial) crystallographic subgroup. Returns 0 on success (even if no known group was matched), non-zero on failure.

◆ qpms_spg_detect_pointgroup_periodic()

int qpms_spg_detect_pointgroup_periodic ( qpms_spg_detection_t *  out,
const cart3_t *  lattice_basis,
int  latdim,
const cart3_t *  positions,
const qpms_irot3_t *  transforms,
const int *  types,
const qpms_spg_kind_symmetry_t *  kind_sym,
size_t  n,
double  symprec 
)

Detects the point group symmetry of a 2D- or 3D-periodic arrangement.

Like qpms_spg_detect_pointgroup(), but for the contents of a periodic unit cell: the candidate operations are taken from the spglib layer dataset (latdim = 2) or space-group dataset (latdim = 3) of the given cell (so they respect the lattice by construction), verified against the cell particles (positions, kinds, placement transforms, kinds' internal symmetries), and matched against the known finite groups including orientation; out->oriented_group can be used directly with qpms_scatsys_apply_symmetry(). On success out->international carries the layer-group symbol and out->spacegroup_number its number (1..80).

The detected affine operations are stored in out->affops (owned); their point parts map the cell contents onto itself modulo the lattice (verified, including the kinds and T-matrix-transform consistency), so nonsymmorphic settings (glides, screws) and origin-shifted cells are supported on the pergroups code path (the origin-fixed-point restriction of the orbit machinery does not apply there). lattice_basis are the two real-space basis vectors (expected to span the xy plane; z is the aperiodic axis), positions the Cartesian cell particle positions, and the rest matches qpms_spg_detect_pointgroup(). symprec is the position tolerance in Cartesian length units (scale it with the lattice constant).

Error codes: -1 bad arguments, -2 allocation failure, -3 the spglib layer detection failed, -5 an operation breaks the cell contents.

◆ qpms_spg_detection_filter_ops()

int qpms_spg_detection_filter_ops ( qpms_spg_detection_t *  d,
const int *  keep,
size_t  nkeep 
)

Filters a detection result down to the subgroup spanned by the given operations (in-place detection surgery). keep lists the indices of the retained operations (a subset of the current nops; the caller decides which operations to keep — e.g. the layer-preserving subgroup for a layered background, cf. qpms_scatspec); it must be closed under the detected group's multiplication (verified here). The affine operation list is subset in the same order and the oriented group is re-matched from the retained point parts, so the Schoenflies symbol and the irrep data refer to the subgroup afterwards. Returns the number of the dropped operations (nops − nkeep), or a negative value on error (including a non-closed keep set or a subgroup matching no known group). A detection without an oriented group is returned unchanged (the caller proceeds without symmetry).

◆ qpms_spg_layer_ops()

int qpms_spg_layer_ops ( int(*)  rotations[3][3],
double(*)  translations[3],
char  symbol[11],
const double  lattice[3][3],
const double(*)  positions[3],
const int *  types,
int  n,
int  aperiodic_axis,
double  symprec,
int *  number 
)

Fetches the operations of a layer (wallpaper) group detected in a quasi-2D periodic cell. The cell is described like for spg_get_layer_dataset(): lattice rows are the basis vectors, positions are fractional coordinates, and aperiodic_axis (0, 1 or 2) is the non-periodic direction. The found operations (at most QPMS_SPG_MAXOPS) are stored to rotations and translations (either may be NULL); symbol receives the international symbol of the layer group (if non-NULL), and number its number 1..80 (if non-NULL). Returns the number of operations or a negative value on error.

◆ qpms_spg_match_pointgroup_ops()

int qpms_spg_match_pointgroup_ops ( qpms_spg_detection_t *  out,
const qpms_irot3_t *  ops,
size_t  nops 
)

Matches a closed set of point-group operations against the known finite groups and fills a detection result accordingly. ops are the operations as quaternion + determinant (qpms_irot3_t); the set must be closed under multiplication (as produced e.g. by the symmetry detections or by filtering a group). On success (return 0), out->oriented_group is a runtime-constructed group usable directly with qpms_scatsys_apply_symmetry(), out->canonical_group its canonically oriented namesake and out->schoenflies its name; the other fields of out are left untouched. Returns 1 when no known group matches, negative on allocation failure.

◆ qpms_spg_ops_from_hall_number()

int qpms_spg_ops_from_hall_number ( int(*)  rotations[3][3],
double(*)  translations[3],
int  hall_number 
)

Fetches the operations of a space group from the spglib database.

rotations (nops entries) receive the integer rotation matrices and translations the fractional translations (in the basis of the standardised cell of the setting); either may be NULL if not needed. hall_number selects the setting (1..530). Returns the number of the operations or a negative value on error.

◆ qpms_spg_space_ops()

int qpms_spg_space_ops ( int(*)  rotations[3][3],
double(*)  translations[3],
char  symbol[11],
const double  lattice[3][3],
const double(*)  positions[3],
const int *  types,
int  n,
double  symprec,
int *  number 
)

The spglib space-group operations of a 3D-periodic cell (thin wrapper around spg_get_dataset(), cf. qpms_spg_layer_ops()). \p lattice rows are the basis vectors, \p positions fractional coordinates. The found operations (at most QPMS_SPG_MAXOPS) go to \p rotations and \p translations (either may be NULL); \p symbol receives the international symbol (if non-NULL) and \p number the space-group number 1..230 (if non-NULL). Returns the number of the operations or a negative value on error.