Avogadro::Core::SpaceGroups#
-
class SpaceGroups#
The Spacegroups class stores basic data about crystal spacegroups.
The spacegroups class gives a simple interface to basic data about crystal spacegroups. The data is generated from information in spglib.
Public Static Functions
-
static unsigned short hallNumber(const std::string &spaceGroup)#
Besides the strings in the table (Hall symbol, international symbols), this accepts the spellings other programs write: screw axes without the underscore (“P 63 m c”, “P 1 21/c 1”), a trailing setting that selects an origin choice or the hexagonal / rhombohedral axes (“F d -3 m :2”, “R -3 m :H”), the pre-1983 cubic notation (“I m 3 m”) and a bare international table number (“229”).
A symbol or number that fits several settings (origin choice, axes) is not guessed: 0 is returned. See internationalNumberFromString().
- Returns:
The hall number of the matching space group string or 0 if not found
-
static unsigned short hallNumberFromHallSymbol(const std::string &hallSymbol)#
Unlike hallNumber(), the international symbols and numbers are not accepted: a string that is not a Hall symbol of the table gives 0. Runs of white space are collapsed and a double quote is read as ‘=’, as in the table, so “-P 2yn” and “P 3 2"” (the table’s “P 3 2=”) match.
- Returns:
the hall number whose Hall symbol is exactly
hallSymbol, or 0 if there is none.
-
static std::string normalizeHallSymbol(const std::string &hallSymbol)#
- Returns:
hallSymbolin the spelling of the table: runs of white space (spaces, tabs and line endings) collapsed to one space, the ends trimmed, and ‘=’ where a file has a double quote. The result is not checked against the table.
-
static unsigned short hallNumberFromTransforms(const std::vector<std::string> &operations)#
This is how most crystallography programs resolve a setting: the symmetry operations a CIF file lists identify the origin choice and axes (which an H-M symbol often leaves out), and cannot disagree with the coordinates.
Each operation is written like “x,y,z”, “-x+1/2,y,-z”, “1/2+x,y,z” or “x-y,x,z+1/6”. Letters may be upper case, spaces and quotes are ignored, and constants may be decimals (0.5, 0.3333, 0.6667) if they are close to a multiple of 1/12. Translations are taken modulo one. The order of the operations and repeats do not matter. All operations must be present and none may be extra. Text that is not an operation, or an empty list, gives 0.
Three pairs of entries in the table (hall numbers 322 and 324, 326 and 328, 330 and 332, all group 68) have the same operations and the same Hall symbol, and differ only in a setting label. The lower number is returned.
- Returns:
the hall number of the space group whose symmetry operations are exactly
operations, or 0 if no entry of the table has this set.
-
static unsigned short internationalNumberFromString(const std::string &spaceGroup)#
- Returns:
the international table number (1-230) that the string refers to, even if hallNumber() cannot pick one setting for it (e.g. “74”), or 0 if the string is not recognized.
-
static bool setSpaceGroup(Molecule &molecule, const std::string &spaceGroup)#
Record the space group that a file gives as a string (a symbol, with or without a setting, or a bare international table number) in
molecule.If the string identifies one setting, the Hall number of the molecule is set (see hallNumber()). If it only identifies the group, because several settings fit (origin choice, axes), the international table number is kept in the data map under internationalNumberKey(), so that the user can be asked for just those settings. A Hall number set later removes it.
The string is resolved once. A space group that is not recognized leaves the molecule unchanged.
- Returns:
true if the Hall number or the international number was set.
-
static const char *internationalNumberKey()#
- Returns:
the key of the Molecule data map entry (an int) in which file readers keep the international table number of a space group whose Hall number is ambiguous. Molecule::setHallNumber() removes it once a Hall number is known. It is never written to files: the file writers and the molecular properties table skip it.
-
static CrystalSystem crystalSystem(unsigned short hallNumber)#
- Returns:
an enum representing the crystal system for a given hall number. If an invalid hall number is given, None will be returned.
-
static unsigned short internationalNumber(unsigned short hallNumber)#
- Returns:
the international number for a given hall number. If an invalid hall number is given, 0 will be returned.
-
static const char *schoenflies(unsigned short hallNumber)#
- Returns:
the Schoenflies symbol for a given hall number. If an invalid hall number is given, an empty string will be returned.
-
static const char *hallSymbol(unsigned short hallNumber)#
- Returns:
the Hall symbol for a given hall number. ‘=’ is used instead of ‘”’. If an invalid hall number is given, an empty string will be returned.
-
static const char *international(unsigned short hallNumber)#
- Returns:
the international symbol for a given hall number. If an invalid hall number is given, an empty string will be returned.
-
static const char *internationalFull(unsigned short hallNumber)#
- Returns:
the full international symbol for a given hall number. If an invalid hall number is given, an empty string will be returned.
-
static const char *internationalShort(unsigned short hallNumber)#
- Returns:
the short international symbol for a given hall number. If an invalid hall number is given, an empty string will be returned.
-
static const char *setting(unsigned short hallNumber)#
- Returns:
the setting for a given hall number. If an invalid hall number is given, an empty string will be returned. An empty string may also be returned if there are no settings for this space group.
-
static unsigned short transformsCount(unsigned short hallNumber)#
- Returns:
the number of transforms for a given hall number. If an invalid hall number is given, 0 will be returned.
-
static Array<Vector3> getTransforms(unsigned short hallNumber, const Vector3 &v)#
- Returns:
an array of transforms for a given hall number and a vector v. The vector should be in fractional coordinates. If an invalid hall number is given, an empty array will be returned.
-
static void fillUnitCell(Molecule &mol, unsigned short hallNumber, double cartTol = 1e-5, bool wrapToCell = true, bool allCopies = false)#
Fill a crystal with atoms by using transforms from a hall number. Nothing will be done if the molecule does not have a unit cell. The cartesian tolerance is used to check if an atom is already present at that location. If there is another atom within that distance, the new atom will not be placed there.
-
static void fillTranslationalCopies(Molecule &mol, double cartTol = 1e-5)#
Add translational copies of atoms on the unit cell boundary. For atoms at fractional coordinate ~0, a copy is placed at ~1 and vice versa, plus edge and corner combinations. No symmetry operations are applied.
-
static void reduceToAsymmetricUnit(Molecule &mol, unsigned short hallNumber, double cartTol = 1e-5)#
Reduce a cell to its asymmetric unit. Nothing will be done if the molecule does not have a unit cell. The cartesian tolerance is used to check if an atom is present at a location within the tolerance distance. If an atom is present, the atom gets removed.
-
static Array<Index> translationalUniqueAtoms(const Molecule &mol, double tolerance = 0.001)#
Get indices of translationally unique atoms, filtering out duplicates. Atoms with fractional coordinates near 1.0 that duplicate atoms near 0.0 (due to periodic boundary conditions) are excluded.
- Parameters:
mol – The molecule with a unit cell
tolerance – Fractional coordinate tolerance for duplicate detection
- Returns:
Array of atom indices to include (empty if no unit cell)
Public Static Attributes
-
static constexpr unsigned short lastHallNumber = 530#
The highest Hall number. The Hall numbers run from 1 to this value; 0 means “no space group” throughout this class.
-
static unsigned short hallNumber(const std::string &spaceGroup)#