# Enforce a space group on a given crystal structure

If I have a CIF that is P1, is there a (preferably free) code that can map the structure to some user-specified space group? I know that there are ways to do similar things with molecular systems. For instance, ChemCraft has an option to detect the nearest point group and then apply it to the molecule. I'd like to do the same for a crystalline structure given a space group.

• Do you mean, identifying underlying symmetry of the crystal? – Thomas May 2 '20 at 2:17
• I primarily mean updating the atomic positions to fit a given space group. While it'd be nice if the code can detect the closest symmetry, that is not a requirement. For instance, let's say you have a DFT-optimized structure. It'll probably have no symmetry unless the tolerances to detect the symmetry are somewhat loose. Are there codes that could map the structure to match a given symmetry? – Andrew Rosen May 2 '20 at 2:21
• As an aside, I know this can be done in Materials Studio, but that's paid software. For context to my question, my machine with Materials Studio is in lab, which I can't access because of the global pandemic, so I'm looking for an alternative... – Andrew Rosen May 2 '20 at 2:24

While there are undoubtedly other programs that do this, it's fairly easy to do in Avogadro.

• I start with a calculation on hexagonal SiC. As mentioned, it starts as $$P_1$$:

• Go to Crystallography -> Space Group -> Perceive Space Group

• The unit cell should update, including symmetrization if needed

• Beautiful, thank you! I admit... I am feeling quite silly that I didn't realize this! I'll keep the question unanswered for now so others feel inclined to comment too. – Andrew Rosen May 2 '20 at 4:05
• It's a fairly common task - I don't know other materials builders well, but I suspect others can do this. – Geoff Hutchison May 2 '20 at 4:11
• Since I was curious, just for completeness: like ASE below, avogadro actually also uses spglib to achieve this, specifically spg_get_dataset – leopold.talirz Jul 5 at 22:58

This can be done using PyMOL (which, while not free for general use, does have a free student license) via the set_symmetry argument, as documented here. This allows for a user-specified spacegroup and will update the CIF to match.

• PyMOL also has Open Source version, which is free for all users and has set_symmetry. – marcin May 5 '20 at 17:03

This is possible via ASE as well. There are modules which can handle space groups via spglib. I will focus on an application that hasn't been discussed yet.

ASE has an advantage that you can enforce symmetry during an optimization of cell size / positions. Here is an example that can be run with GPAW which will load a geometry (POSCAR) and optimize the cell size and shape while keeping the original symmetry.

from ase.io import read
from ase.optimize.bfgs import BFGS
from ase.constraints import UnitCellFilter
from ase.spacegroup.symmetrize import FixSymmetry
from gpaw import GPAW, PW


The full trajectory will be contained in stress.txt. Other calculators that ASE supports can be used by simply changing the GPAW based lines to another calculator. It will need to implement a stress tensor though, so this restricts use somewhat. For example, GPAW does not support stress tensor calculations in FD or LCAO modes currently.