DanPorter/Dans_Diffraction
Description
Dans_Diffraction is package to read cif files and simulate diffraction patterns, among other things.
It uses python and should work in version 2+ and 3+. Python libraries numpy, matplotlib and scipy are required, plus tkinter for gui programming.
Full code documentation available here.
For comments, queries or bugs - email dan.porter@diamond.ac.uk
Installation
Requirements: Python 2.7+/3+ with packages: Numpy, Matplotlib, Scipy
Stable version from PyPI:
$ pip install Dans-Diffraction
Latest version from GitHub:
$ git clone https://github.com/DanPorter/Dans_Diffraction.git
Operation
Dans_Diffraction is best run within an interactive python environment:
$ ipython -i -m Dans_Diffraction
Dans_Diffraction can also be run in scripts as an import, example scripts are provided in the Examples folder.
Read CIF file
import Dans_Diffraction as dif
xtl = dif.Crystal('some_file.cif')
xtl.info() # print Crystal structure parameters
Alter atomic positions
xtl.Cell.latt([2.85,2.85,10.8,90,90,120]) # set lattice parameters
xtl.Atoms.info() # Print Symmetric positions
xtl.Structure.info() # Print All positions in P1 symmetry (same structure and functions as xtl.Atoms)
# Symmetric positions
xtl.Atoms.changeatom(idx=0, u=0, v=0, w=0, type='Co', label='Co1')
xtl.Atoms.addatom(idx=0, u=0, v=0, w=0, type='Co', label='Co1')
# After adding or changing an atom in the Atoms class, re-generate the full structure using symmetry arguments:
xtl.generate_lattice()
# Full atomic structure in P1 symmetry
xtl.Structure.changeatom(idx=0, u=0, v=0, w=0, type='Co', label='Co1')
xtl.Structure.addatom(idx=0, u=0, v=0, w=0, type='Co', label='Co1')
# Plot crystal Structure
xtl.Plot.plot_crystal() # 3D plot
xtl.Plot.plot_layers() # 2D plot for layered materials
Calculate Structure Factors
X-ray or neutron structure factors/ intensities are calculated based on the full unit cell structure, including atomic form-factors (x-rays) or coherent scattering lengths (neutrons). Isotropic thermal factors are also included. Calculation of polarised neutron and x-ray magnetic scattering is also included (see Examples).
# Choose scattering options (see help(xtl.Scatter.setup_scatter))
xtl.Scatter.setup_scatter(type='x-ray', energy_keV=8.0)
# Allowed radiation types:
# 'xray','neutron','xray magnetic','neutron magnetic','xray resonant'
xtl.intensity([h,k,l]) # Returns intensity
xtl.print_all_refelctions() # Returns formated string of all allowed reflections
# Plot Experimental Intensities
xtl.Plot.simulate_powder() # Powder pattern
xtl.Plot.simulate_hk0() # Reciprocal space plane
Graphical User Interface
A simple GUI that contains much of the base functionality in a simple set of windows. The graphical user interface requires: tkinter
To start the GUI:
$ python Dans_Diffraction gui
or
>> dif.start_gui()
Other Functionality
There are a number of other aspects to the software not mentioned here, including the calculation of Multiple Scattering (by G. Nisbet, Diamond) and the ability to prepare and analyse files for FDMNES.
Data sources
The tabulated atomic data in Dans_Diffraction/data is not attributed to the author and not covered by the software licence. It is taken from a number of sources:
- Neutron scattering lengths: NIST
- X-ray Form factor: International Tables of Crystallography Vol. C, Table 6.1.1.4.
- Magnetic Form Factor: ILL
- Element weights and radii: Wikipedia
- X-ray edges: x-ray database
- Electron configurations: Wikipedia)
- Space Group symmetry operations: Bilbao Crystallographic Server
The CIF files given as examples in Dans_Diffraction/structures are not attributed to the author and not covered by the software licence. They have been downloaded or generated from a range of data sources and are intended purely as examples, for example:
Copyright 2020 Diamond Light Source Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Files in this package covered by this licence: classes_crystal.py classes_scattering.py classes_plotting.py classes_properties.py classes_multicrystal.py classes_orbitals.py functions_general.py functions_plotting.py functions_crystallography.py tkgui/*.py
Other files are either covered by their own licence or not licenced for other use.
Dr Daniel G Porter, dan.porter@diamond.ac.uk, www.diamond.ac.uk, Diamond Light Source, Chilton, Didcot, Oxon, OX11 0DE, U.K.
Files
DanPorter/Dans_Diffraction-v1.8.2.zip
Files
(6.3 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:43af35e8ccbc6dd946b66e711076031f
|
6.3 MB | Preview Download |
Additional details
Related works
- Is documented by
- Software documentation: https://danporter.github.io/Dans_Diffraction/ (URL)
- Is identical to
- Software: https://pypi.org/project/Dans-Diffraction/1.8.2/ (URL)
- Is supplement to
- Software: https://github.com/DanPorter/Dans_Diffraction/tree/v1.8.2 (URL)