Output SymmetrizedStructure Data

Hi All,

A structure written using the Structure.to method will write the data in P1 symmetry, even if the structure contains higher symmetry. As an example, if we create a diamond-ish structure

cube = Structure.from_spacegroup('Fd-3m',[(4,0,0),(0,4,0),(0,0,4)] , ['C',], [(0,0,0),])

and write it to a .cif file

cube.to(fmt='cif'... )

the structure is recorded in P1 symmetry, even though the spacegroup is embedded in cube.

I see this has been brought up as an issue previously (issues:1230) and the explanation is that symmetry is computed on demand. Thus, the solution to recording the symmetrized data is to pass the keyword parameter symprec [float] (tolerance on adjacent atoms?) as a kwarg to the convenience method .to, as in

cube.to('cif', filename=join(base, 'diamond-ish.cif'), symprec=0.01)

which produces the expected behavior of a .cif file written in the appropriate spacegroup and asymmetric unit.

It seems like this is no longer a question, but since this wasn’t obvious to me when I started writing this comment, I’ll leave it here for posterity and to collect additional remarks on usage.

Happy computing.

Hi @petmetz,

Yes there are a few factors here:

  1. The to method is a “convenience” method, which tries to figure out what format you want to convert to. However, it relies on more powerful classes in pymatgen.io, and for CIF this is the CifWriter in pymatgen.io.cif. If you want full control over your output you can do this.

  2. As you figured out, you can also pass keyword arguments through, though this is slightly less intuitive since you may not know which keyword arguments are valid (symprec in this case)

  3. For SymmetrizedStructure specifically, this inherits from Structure.to but we should instead override the functinality to output a symmetrized CIF by default, since we have already performed the symmetrization routine in this case. We’ll look into this.