Skip to main content

A small utility to convert crystal structures in CIF format into TOPAS STR format.

Project description

This program converts an arbitrary number of CIF (Crystallographic Information Format) files, each containing an arbitrary number of crystal structures, into a number of individual STR files that are compatible with the Rietveld analysis software, TOPAS.

If the program is run with zero command line arguments, then a GUI is launched, otherwise it is command-line driven.

  • Free software: Apache Software License 2.0

Pre-installation

If you are on Windows, you must read this step. If you are on Linuz, you can continue.

ciftostr requires PyCifRW >= 4.4.3. If you install PyCifRW from PyPI via pip, then you will also need to compile the included C modules. To do so requires Microsoft Visual C++ 14.0 or greater. If you don’t have this installed, or do not wish to install it, precompiled wheel files are available. You must download the wheel file corresponding to your Python installation.

To obtain information about your Python installation, run the command:

python -VV

An example output is Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)], showing that this is 64 bit Python 3.9.

Using pip version 19.2 or newer, install your downloaded wheel file as:

pip install c:\path\to\file\name_of_file.whl

This should install PyCifRW, and you can move on to the next step. If you encounter any issues in the installation, please lodge an issue.

Installation

To install the release version of ciftostr from PyPI:

pip install ciftostr

You can also install the in-development version of ciftostr with:

pip install https://github.com/rowlesmr/ciftostr/archive/master.zip

How to run

If you would like to run it in the command line, you need to provide some command-line arguments:

ciftostr *.cif
ciftostr C:\user\username\some\directory\name.cif D:\data\file.cif
ciftostr /nfs/an/disks/jj/home/dir/file.cif home/folder/nest/deeper/important.cif

will convert all CIF files in the current directory or the two CIF files specifically - both Windows and Linux filepaths are accepted. The resulting STR files will be saved in the same path as their parent CIF file. Relative or absolute file paths can be used.

To launch the GUI:

ciftostr

Bonus Windows executable behaviour: You can drag a CIF file onto the program icon, and it will convert the CIF for you.

To see some other helpful information, try:

ciftostr --help
ciftostr --info

jEdit integration

Link text

John Evans has made available a number of macros for the text editor jEdit that make it integrate very well with TOPAS when operating in launch mode.

As a part of these macros, there is the ability to insert CIF files in STR format. If you wish to use ciftostr to generate the STR information, then you need to make the following changes:

  1. pip install ciftostr (or use ciftostr.exe)

  2. Replace your copy of TAInsertCIF.bsh with this one. (Your file is probably found in C:\Users\?????\AppData\Roaming\jEdit\macros)

Now, when you choose “Insert CIFs in INP format” from the plugin in jEdit, ciftostr will be used in the background to generate that format.

Documentation

https://ciftostr.readthedocs.io/

This program is designed to reformat data from a CIF format into the STR format suitable for use by the Rietveld analysis software, TOPAS. It doesn’t carry out any validation checks to ensure the data is consistent, but simply transcribes the data as given in the CIF.

Where similar or identical data could be given in several places, the values are taken in a specific order of precedence, as detailed in the sections below. In general, if a value exists in an earlier place, the later places are not looked at.

This program uses the PyCifRW library, written by James Hester, to parse the CIF files into a format easily used to remix the underlying data. The GUI was created using PySimpleGUI.

The STR’s phase_name is taken from _chemical_name_mineral, _chemical_name_common, _chemical_name_systematic, or _chemical_name_structure_type, in that order, appended with the value of the data block. If none of these keys are available, then the name of the data_ block is used. This is also used as the filename of the STR file.

The unit cell parameters are taken from _cell_length_a, _cell_length_b, _cell_length_c, _cell_angle_alpha, _cell_angle_beta, and _cell_angle_gamma. Some comparisons are made to enable some standard macros to be used (eg Cubic, Tetragonal…). In any of these fail, then all parameters are given as a fail safe.

The space_group is taken from _symmetry_space_group_name_H-M, _space_group_name_H-M_alt, _symmetry_Int_Tables_number, or _space_group_IT_number, in that order. If none of these keys are available, then an empty string is written as the space group. The value of the space group is as exactly given in the CIF. No validation or editing is done.

The atomic sites are constructed as follows: The atom labels are taken from _atom_site_label, with the fractional x, y, and z coordinates given by _atom_site_fract_x, _y, and _z. If the decimal values of the fractional coordinates are consistent with the fractions 1/6, 1/3, 2/3, or 5/6, then the decimal value is replaced by the fractions. The site occupancy is given by _atom_site_occupancy, or by 1, if that key is not given. The atom type is given by _atom_site_type_symbol, where available, or by the first one or two characters of the site label. If these characters match an element symbol, then that is used, otherwise, the label is used in it’s entirety, and the user must decide the correct atom type to use. If the site label starts with Wat, (and no atom type is given) it is assumed that oxygen (from water) is correct. An attempt is also made to reorder the charge given on an atom, to ensure it is compatible with TOPAS ordering, eg Fe+2, not Fe2+.

Isotropic Atomic Displacement Parameters (ADPs; Biso), are taken from _atom_site_B_iso_or_equiv, or from _atom_site_U_iso_or_equiv, where they are then multiplied by 8*Pi^2 to give B values. If anisotropic ADPs are given, then _atom_site_aniso_B_11, _atom_site_aniso_B_22, and _atom_site_aniso_B_33 are averaged to give an equivalent Biso value. Alternatively, the equivalent U values are used to calculate Biso. As anisotropic values could be given for a subset of the atoms in the structure, the labels given by _atom_site_label and _atom_site_aniso_label are matched, and if an atom doesn``t have an anisotropic value, it takes its isotropic value, or is assigned a value of 1.

The atomic site is also given a num_posns 0 entry, which will update with the multiplicity of the site following a refinement. This will allow the user to compare this value with the CIF or Vol A to help ensure that the correct symmetry is being applied.

Finally, the STR is given a fixed Lorentzian crystallite size of 200 nm, and a refinable scale factor of 0.0001 to allow for an easy start to a refinement. All other values given in the STR are fixed, and require active intervention to name, refine, constrain, or restrain them.

If you have any feedback, please contact me. If you find any bugs, please provide the CIF which caused the error, a description of the error, and a description of how you believe the program should work in that instance.

Development

Come and talk to me!

Changelog

0.1.1 (2022-01-05)

  • Now checks for negative fractional coordinates

  • Adds MVW(0,0,0) to strs

  • Adds a comment containing the original unit cell prms so you can easily undo them

0.1.0 (2021-11-07)

  • It looks like everything is working!

0.0.0 (2021-11-07)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ciftostr-0.1.1.tar.gz (235.4 kB view details)

Uploaded Source

Built Distribution

ciftostr-0.1.1-py2.py3-none-any.whl (20.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ciftostr-0.1.1.tar.gz.

File metadata

  • Download URL: ciftostr-0.1.1.tar.gz
  • Upload date:
  • Size: 235.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for ciftostr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 944d06579f3fcb3aac4aeeeb13e2fd3d076c683894b47201dc20936d05556374
MD5 6bd46cb66cb2fce8279bfbb4302b4396
BLAKE2b-256 bcbb23ebac174df037e22eef61c620399f28fd06102f5296f57cf089fcb9dd32

See more details on using hashes here.

File details

Details for the file ciftostr-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: ciftostr-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for ciftostr-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3ed932832ed037a96b75dcf25b8f245b8efe20d2ced3356b24bd7866e53b04a4
MD5 a3ff7fead5e8d5fe169076d9fa9c6964
BLAKE2b-256 c58ed3d4022860eaa2025fd52dc9cb6aefaa0097a5e1145da35ed4d98cddb43a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page