materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.52k stars 868 forks source link

CIF written after finding symmetry is in P1 space group #518

Closed nawagner closed 7 years ago

nawagner commented 7 years ago

System

Summary

I want to use pymatgen to read in a POSCAR and output a cif with the symmetry information included a la FINDSYM. However, when I write the cif file using the CifWriter, the spacegroup is still P1 and the symmetry equivalent position list is not included.

Example code

''' from pymatgen.io.vasp import Poscar from pymatgen.io.cif import CifWriter from pymatgen.symmetry import analyzer from pymatgen.io.cif import CifParser

p = Poscar.from_file('POSCAR') sga = analyzer.SpacegroupAnalyzer(p.structure) new_struct = sga.get_conventional_standard_structure() z = CifWriter(new_struct) z.write_file('new_struct.cif') '''

Suggested solution (if any)

If I supply a symprec argument to the CifWriter, a cif with the correct symmetry is written out, but not always in the standard setting. Is there a way to output a symmetrized cif in the standard setting?

Files (if any)

I have provided my POSCAR, pymatgen's written cif, and the output from aflow's implementation of findsym


[BaTiO3_hexagonal_findsym.cif.txt](https://github.com/materialsproject/pymatgen/files/610038/BaTiO3_hexagonal_findsym.cif.txt)
[POSCAR.txt](https://github.com/materialsproject/pymatgen/files/610039/POSCAR.txt)
[new_struct.cif.txt](https://github.com/materialsproject/pymatgen/files/610040/new_struct.cif.txt)
shyuep commented 7 years ago

Yes, you need to supply a symprec. If you want to try to get a standard setting, you can try using SpacegroupAnalyzer's get_conventional_standard_cell to get a conventional structure before writing it out with CifWriter. That still does not guarantee that a standard setting is always written though, but it should work in many instances.