Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

XRD-NanoSize-Lab

🚀 Conceived, Engineered & Presented by Youssef Attia
🎓 University spin-off competition
📅 Advanced Materials Research & Engineering Initiative | 2025

XRD-NanoSize-Lab was developed as part of a technical competition organized in collaboration with a materials science spin-off, with the objective of designing a robust and reproducible computational tool for quantitative X-ray diffraction (XRD) analysis.


Math Physics C++

This project provides a C++ pipeline for analyzing X-ray diffraction (XRD) data of alumina samples. It fits peaks using a pseudo-Voigt profile and calculates crystallite sizes using the Scherrer equation. The Levenberg-Marquardt fitting is implemented using Eigen for accurate and robust optimization.


Pseudo-Voigt Profile

The pseudo-Voigt function used for peak fitting is:

$$ V(x, A, \mu, \sigma, \gamma) = \eta \cdot G(x, A, \mu, \sigma) + (1 - \eta) \cdot L(x, A, \mu, \gamma) $$

where:

  • G(x, A, μ, σ) is the Gaussian component
  • L(x, A, μ, γ) is the Lorentzian component
  • η is the mixing factor (0 ≤ η ≤ 1)
  • A is the amplitude
  • μ is the peak center
  • σ is the Gaussian width
  • γ is the Lorentzian widthth

Features

  • Load XRD data from CSV files
  • Preprocess data with smoothing and normalization
  • Detect peaks in 2θ space
  • Fit Voigt peaks using Levenberg-Marquardt (Eigen)
  • Calculate FWHM and crystallite size
  • Monte Carlo estimation of FWHM uncertainty
  • Compute residuals and statistical anomaly score

Scientific Highlights

  • Fully self-contained nonlinear Voigt fitting implemented from first principles
  • Analytical Jacobian construction and LDLT-based Levenberg-Marquardt solver
  • Physics-constrained peak parameters for meaningful and reproducible results
  • Monte Carlo uncertainty propagation using residual-driven noise injection
  • Statistical residual anomaly scoring to detect peak asymmetry, secondary phases, or fitting inadequacy
  • Designed for longitudinal and comparative XRD analysis across multiple datasets

Available databases


Dependencies

  • C++17 compatible compiler (GCC ≥ 9, Clang ≥ 10, MSVC ≥ 2019)
  • Eigen (header-only library, version 3.4+)

No other external libraries are required. All other functionality uses standard C++17 libraries.


Compilation

g++ -std=c++17 main.cpp xrd_analysis.cpp -I /path/to/eigen -o xrd_analysis

About

A C++ tool for peak profile analysis of XRD data using pseudo-Voigt fitting and the Scherrer equation to determine crystallite sizes, compare samples over time, and perform statistical residual analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages