mat-xrd-calculator

Calculate XRD spectra from crystal structures using pymatgen.

144|21|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/learningmatter-mit/AtomisticSkills --skill mat-xrd-calculator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mat-xrd-calculator
Source: https://github.com/learningmatter-mit/AtomisticSkills/tree/main/.agents/skills/mat-xrd-calculator
Command: npx skills add https://github.com/learningmatter-mit/AtomisticSkills --skill mat-xrd-calculator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires argparse, os, json, matplotlib, pymatgen, numpy, pathlib, and includes scripts (resource) components.

What problem does it solve?

This Skill calculates the X-ray Diffraction (XRD) spectrum of a material from a provided crystal structure, producing diffraction peak positions, intensities, and associated (hkl) indices without requiring a full simulation workflow.

Core Features & Use Cases

  • XRD pattern computation: Computes diffraction peak information from an input structure using pymatgen.
  • Simulated spectrum generation: Converts the discrete diffraction pattern into a pseudo-Voigt simulated intensity curve versus 2θ.
  • Actionable outputs: Writes a JSON file containing 2θ and intensity data (plus HKL and d-spacings) and saves a plotted spectrum image.
  • Use case: Use this to compare expected diffraction features of phases (e.g., LiFePO4) or to generate baseline spectra for downstream analysis or benchmarking.

Quick Start

Run this to generate the XRD JSON and plot for a structure file: conda activate base-agent, then run python .agents/skills/mat-xrd-calculator/scripts/calculate_xrd.py <structure_file> --output_dir <output_dir> --wavelength CuKa.

Frequently Asked Questions about mat-xrd-calculator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate an XRD spectrum from a CIF or POSCAR crystal structure file?

To calculate an XRD spectrum from a crystal structure, run the local Python script using pymatgen's XRDCalculator on your CIF or POSCAR input to generate peak positions, intensities, and HKL indices. The script outputs a JSON file with the diffraction data and saves a plotted spectrum image.

Can I simulate a diffraction pattern with specific X-ray wavelengths like Cu K-alpha?

Yes, you can simulate a diffraction pattern with specific X-ray wavelengths by passing the wavelength argument, such as CuKa, to the Python script. The calculator uses this wavelength to compute accurate peak positions and converts the discrete pattern into a pseudo-Voigt simulated intensity curve.

What information is included in the XRD pattern JSON output?

The XRD pattern JSON output includes the diffraction peak positions, intensities, associated HKL indices, and d-spacings. This actionable data allows for structure-based phase inspection and synthetic diffraction comparisons for materials characterization tasks.

Do I need pymatgen installed to generate simulated XRD plots?

Yes, you need pymatgen installed in your Python environment to generate simulated XRD plots, as the script relies on pymatgen's XRDCalculator. You also need matplotlib and numpy to produce the pseudo-Voigt intensity plot and save the visual spectrum output.

What is the best way to compare expected diffraction features for materials like LiFePO4?

The best way to compare expected diffraction features for phases like LiFePO4 is to generate baseline XRD spectra from their crystal structure files. This script computes the theoretical diffraction pattern and saves a pseudo-Voigt simulated curve for direct synthetic diffraction comparisons.

How does the pseudo-Voigt simulation convert discrete diffraction peaks into a continuous spectrum?

The pseudo-Voigt simulation converts discrete diffraction peaks into a continuous XRD spectrum by applying a pseudo-Voigt profile function to the calculated peak intensities. This generates a realistic simulated intensity curve versus 2-theta, which is then saved as a plotted spectrum image.