Giter Site home page Giter Site logo

rytheranderson / xrd-matching Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 30.91 MB

A genetic algorithm for powder refinement focused on matching peak positions and unit cell parameters.

License: MIT License

Python 86.43% R 13.57%
crystallography x-ray-diffraction metal-organic-frameworks

xrd-matching's Introduction

XRD_matching

Authors

  • Ryther Anderson

Motivation

XRD_matching is a Python 3 program which matches the XRD pattern of a simulated material with an experimental XRD pattern by varying the lattice parameters of the simulated material. This is what Rietveld refinement seeks to do. However, Rietveld refinement uses least squares, which does not work well for complex materials such as MOFs, or when significant peak splitting is occuring. Currently, this code is appropriate to find an initial guess for a further Rietveld refinement. The implementation here uses differential evolution (from scipy) to find a global minimum of an arbitrary similarity metric (i.e. error function).

Current Status

The code has been tested on 10 materials using 10 error functions by perturbing the unit cell parameters of each material by random amounts and seeing if they can be returned to their original values. Perturbations of up to 12% of the original parameter value were used (this is a very large perturbation in crystallography). The results show that this code is capable of quickly refining structures even with these large perturbations (that often result in significant peak splitting). An experimental XRD pattern can be represented as a linear interpolation function, which is appropriate when the pattern has distinct peaks without much background. Alternatively, each peak in the experimental pattern can be represented as a Gaussian function (the peaks are automatically identified) of corresponding height and center (currently a constant standard deviation is used). This procedure removes any background and peak broadening.

Usage

Generally speaking, just run:

python XRD_match_main.py -E experimental_pattern_file -S simulated_cif -O differential_evolution

where "experimental_pattern_file" is the experimental pattern (the first two columns should be 2theta and intensity, respectively), "simulated_cif" is the CIF of the structure to be refined (it can be in a variety of formats readable by pymatgen), and -O is the optimization method to use. Differential evolution seems to be the most robust optimization method (I will do more testing), but basin hopping and dual annealing can also be used. The configuration.py can also be used to alter other variables that may influence fitting, see the comments in this file for a brief description of each of these variables. The values currently in configuration.py are good defaults, but may not be appropriate for all refinements.

Requirements

The Anaconda distribution of Python 3.X with pymatgen will work, otherwise have numpy, scipy, matplotlib, and pymatgen. Install instructions for pymatgen can be found here: https://pymatgen.org/installation.html.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.