Code Monkey home page Code Monkey logo

xrd-simulate's Introduction

xrd-simulate

MATLAB Code to Simulate XRD Patterns

Getting Started

This collection of MATLAB scripts is designed to simulate relative-intensity XRD patterns using the basic theory of x-ray interaction with atoms in a bulk material. The calculations are based off of information that can be found in Structure of Materials: An Introduction to Crystallography, Diffraction, and Symmetry by Marc De Gaef and Michael E. McHenry.

If the user is unfamiliar with the basics mathematics behind XRD, a brief background math section is provided below. If the user is unfamiliar with crystallography the McHenry text or another basic text is strongly suggested.

Installing

The script XRD_Intensity_Simulation.m controls the entirity of the simulation. To begin the program simply run this script with the following functions and files in the same directory:

  • dialogue.m
  • dspace.m
  • theta_s_calc.m
  • scatterfactor.m
  • scatterfactorcalc.m
  • Scatteringdata.xlsx
  • structurefactor.m
  • intensitycalc.m
  • lorentz.m
  • compareintensity.m

Simulating XRD Patterns

In its current form, this script is designed to simulate a crystalline substance's XRD pattern the user-defined parameters:

  1. Type of X-Ray source (Cu, Co, Mo, Cr, Fe)
  2. Crystal Structure (BCC, FCC, SC, CsCl, HCP, Diamond)
  3. Elemental Components
  4. Lattice Spacing

The curvature of the XRD peaks plotted are provided for visualization's sake and do not represent expected FWHM. Modifying the compareintesity.m code can easily configure the plotting characteristics. Likewise, mixtures of components can be achieved by using rule of mixtures for the atomic scattering factors of various components - though caution should be taken at the validity of the results.

Input

No parameters need to be pre-defined unless the user requires a rule of mixtures component. In this case, the user should edit Scatteringdata.xlsx and add the desired component to the end of the sheet.

To operate the program, use the following procedure:

  1. Run XRD_Intensity_Simulation.m
  2. Select X-Ray source

  1. Select a crystal type

  1. Select atom type

  1. Enter the lattice parameter (angstroms)

Output

Following the input of the above information (Source: Cu K Alpha, Crystal: BCC, Atom: W, Lattice Parameter: 3.165), the program will output:

Basic results can be confirmed using crystallographic databases such as ICSD (https://www.fiz-karlsruhe.de/en/produkte-und-dienstleistungen/inorganic-crystal-structure-database-icsd)

An experimentally-generated XRD spectrum from analysis of a W specimen is shown below.

Background math

xrd-simulate's People

Contributors

cameronmcelfresh avatar

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.