Crystallographic Information File (CIF) is a standard text file format for representing crystallographic information. This file format is relevant for users of programs such as CRYSTAL, Quantum Espresso, VASP, etc. In these quantum simulations, exploiting the use of symmetry can accelerate the calculation process. One of the easiest ways to symmetrize a structure is by using FINDSYM.[1][2] This tool finds the space group symmetry of a system and creates a corresponding symmetrized CIF file.
If only a few structures are being symmetrized, the FINDSYM online tool is perfectly suitable. However, when symmetrizing a large number of structures, it is preferable to make a local installation of the program and set up a script to symmetrize all structures automatically. Here, we describe this process.
To use FINDSYM locally, we need to install the ISOTROPY software suite. The instructions for installing this suite (on Linux) are shown on this web page.
Note that step 5 is to "Add an environment variable ISODATA which contains the full path to the isobyu directory". To set up this environment variable, I added the following line to my .bashrc file (if using arch-based systems, a similar line is required in your .zshrc file):
export ISODATA="/folder/path/isobyu/"
Remember to do source ~/.bashrc after adding this line.
Once ISOTROPY is correctly installed in your system, you can use a Python script to automatically generate symmetrized CIFs from non-symmetrized CIFs in a directory. The following is a sample script that I used. Modifications can be made depending on the systems that you are trying to symmetrize.
There are two necessary and four optional changes to be made in this version of the script.
Necessary changes
1) Specify the CIF file path (DIR variable)
2) Specify the isobyu installation path (findsym_path variable)
Optional changes
1) Lattice tolerance (default = 0.1E-4)
2) Atomic position tolerance (default = 0.1E-2)
3) Atomic position max tolerance (default = 0.33E+00)
4) Occupation tolerance (default = 0.1E-2)
import subprocess,glob,os
# Set this path to where your CIFs are. You can also set the variable to os.getcwd()+'/' to automatically set the path to the current working directory
DIR = '/folder/path/for/CIFs/' #(os.getcwd()+'/')
# Change the tolerance according to your needs
latticeTolerance = 0.1E-4
atomicPositionTolerance = 0.100E-02
atomicPositionMaxTolerance = 0.330E+00
occupationTolerance = 0.100E-02
def findsym(material):
# Set the path to the FINDSYM executable
findsym_path = '/folder/path/isobyu/'
# Set the input file name and path
input_file_name = str(material)+'.cif'
input_file = DIR+input_file_name
# Run findsym_cifinput as an external command. This generates a FINDSYM input (called tempfile) from a non-symmetrized CIF file.
command_cifinput = findsym_path+'findsym_cifinput '+input_file+' > tempfile'
subprocess.run(command_cifinput,shell=True)
# Change the tolerances in the tempfile to what was specified above
lines = []
with open('tempfile') as f:
for i, line in enumerate(f):
lines.append(line)
lines[4] = str(latticeTolerance)+'\n'
lines[6] = str(atomicPositionTolerance)+'\n'
lines[8] = str(atomicPositionMaxTolerance)+'\n'
lines[10] = str(occupationTolerance)+'\n'
new_tempfile = open('tempfile_new','w+')
for item in lines:
new_tempfile.write(item)
new_tempfile.close()
# Run findsym to generate the symmetrized CIF
command_findsym = findsym_path+'findsym tempfile_new'
subprocess.run(command_findsym,shell=True)
# Change the default CIF name to <Material>_sym.cif
change_name = 'mv findsym.cif '+str(material)+'_sym.cif'
subprocess.run(change_name,shell=True)
# Iterate over all CIFs in the DIR path
nDIR = len(DIR)
ntype = len(".cif")
pathlist = glob.glob(DIR+'*.cif')
for path in pathlist:
path_in_str = str(path)
material = path_in_str[nDIR:-ntype]
if material == "":break
findsym(material)
References:
[1] H. T. Stokes, D. M. Hatch, and B. J. Campbell, FINDSYM, ISOTROPY Software Suite, iso.byu.edu.
[2] H. T. Stokes and D. M. Hatch, "Program for Identifying the Space Group Symmetry of a Crystal", J. Appl. Cryst. 38, 237-238 (2005).