Skip to content

[Requirement] Calculate peak positions from CIF #201

@celinedurniak

Description

@celinedurniak

Executive summary

Calculate theoretical peak positions in d-spacing from CIF

Context and background knowledge

This requirement will be used for

  • the modulation correction for BEER data. There are 2 methods currently implemented for this correction and one of them relies on knowing the peak positions
  • the live data reduction for Powder Diffraction experiments. (overplot of the theoretical positions of the expected composition of the sample with the live reduced spectra)

Inputs

CIF file from COD or other online databases

Methodology

We could store all the theoretical peak positions or only those with an intensity larger than a given threshold (intensity threshold).
The implementation could be done using ncrystal or pymatgen. Below are examples showing how to access the relevant information.

  • Option 1 using ncrystal
import matplotlib.pyplot as plt
import NCrystal as NC
import NCrystal.cifutils as nccif
import numpy as np
nc_cif = NC.NCMATComposer.from_cif('1000236.cif').register_as('new_mat.ncmat')
info = NC.createInfo('new_mat.ncmat')

list_dsp = [hkl.d for hkl in info.hklObjects() if hkl.f2 > intensity_threshold]
from pymatgen.io.cif import CifParser
from pymatgen.analysis.diffraction.neutron import NDCalculator

parser = CifParser("1000236.cif") 
structure = parser.parse_structures(primitive=True)[0]
neut_calc = NDCalculator() 
pattern = neut_calc.get_pattern(structure)

list_dsps = [ d_hkl for d_hkl, intensity in zip(pattern.d_hkls, pattern.y) if intensity > intensity_threshold]]

Note that additional arguments could be used when loading CIF such as removing duplicates, changing the space group...

See https://github.com/mctools/ncrystal-notebooks/blob/main/notebooks/ncrystal2_advanced_02_Import_crystal_structure_from_CIF_or_databases.ipynb for examples with ncrystal

Outputs

List of d-spacing values in angstrom or scipp array containing these values

Which interfaces are required?

Integrated into reduction workflow, Python module / function

Test cases

See Methodology section for examples
An example of CIF can be downloaded from https://www.crystallography.net/cod/1000236.html

Existing implementations

See Methodology section for examples

Comments

No strong opinion on which of the 2 options to implement.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions