/atomistic-skills:mat-xrd-refinementfrom Atomistic Skills
Performs quantitative Rietveld refinement of powder XRD patterns using DARA (BGMN). Converts JSON/DIF to .xy format, runs refinement with known or auto-discovered CIFs, and outputs plots and summaries.
Ships in Atomistic Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Perform quantitative Rietveld refinement of powder X-ray diffraction (XRD) patterns using DARA (Data-driven Automated Rietveld Analysis) with BGMN. Use when you have an experimental (or theoretical) pattern in .xy format and candidate phase CIFs.
cpu (it includes dara-xrd and pymatgen; venv/run creates it on first use).kaleido, which needs Chrome or Chromium (on x86_64, plotly_get_chrome installs one).--bgmn_dir or DARA_BGMN_DIR to a local BGMN directory.| Script | Purpose |
|---|---|
scripts/refine.py | Run Rietveld refinement with known phases; writes plots and summary under refinement_results/. |
scripts/convert_xrd_to_xy.py | Convert XRD from JSON (xrd-spectrum) or DIF to .xy for DARA. |
scripts/dara_utils.py | Helpers (e.g. load_xrd_file); used by other scripts. |
.xy format)Two columns (2θ and intensity), space-separated. Options:
convert_xrd_to_xy.py with --input_file your_xrd.json. Output is written next to the input as your_xrd.xy.convert_xrd_to_xy.py with --input_file your_data.txt (or .dif). Format is auto-detected if the file contains a header with 2-THETA and INTENSITY.# From JSON (e.g. xrd-spectrum output)
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/convert_xrd_to_xy.py --input_file path/to/xrd.json
# From DIF
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/convert_xrd_to_xy.py --input_file path/to/scan.txt
Convert arguments:
--input_file: Path to JSON or DIF file.--format: auto (default), json, or dif to force format.refine.py)Refinement uses DARA’s do_refinement_no_saving (no BGMN working files left on disk). Output is written to refinement_results/ under the same directory as the XRD file (no --output_dir argument).
Refine arguments:
--xrd_data: (Required.) Path to the .xy pattern. Quote the path in the shell if it contains parentheses or spaces, e.g. --xrd_data "./path/with(Chem).xy".--cifs: (Optional.) List of CIF paths. If omitted, CIFs are auto-discovered: first from a cifs/ subfolder next to the XRD file, then from the XRD directory. Example layout: examples/LiFePO4/LiFePO4_xrd.xy and examples/LiFePO4/cifs/LiFePO4.cif, Li3PO4.cif.--instrument_profile: Default Aeris-fds-Pixcel1d-Medipix3.--phase_params: Path to a JSON file with phase refinement parameters (e.g. lattice_range, b1, k1, gewicht). See DARA tutorial.--refinement_params: Path to JSON for refinement options (e.g. wmin, wmax).--bgmn_dir: Local BGMN directory (avoids download). Or set DARA_BGMN_DIR.--quiet: Suppress progress output.Normalized intensity: If the pattern’s maximum intensity is < 10, the script scales intensities to ~1000 before refinement so Rwp is comparable to the DARA tutorial; the applied scale is printed and stored in refinement_result.json as intensity_scale_applied.
refine.py)All under <xrd_directory>/refinement_results/<stem>/ (e.g. refinement_results/LiFePO4/):
| File | Description |
|---|---|
refinement_result.json | Rwp, instrument_profile, phase_params, refinement_params, phases (lattice, gewicht), paths to plots and peak_data, optional intensity_scale_applied. |
<stem>_refinement.html | Interactive Plotly refinement plot (observed, calculated, difference). |
<stem>_refinement.png | Static plot (requires kaleido). |
<stem>_peak_data.csv | Simulated peaks (2θ, intensity, h, k, l, phase, etc.). |
No BGMN working files (.str, .par, .lst, etc.) are saved; DARA runs in a temporary directory.
cifs/ subfolder)Layout: examples/LiFePO4/LiFePO4_xrd.xy and examples/LiFePO4/cifs/LiFePO4.cif, Li3PO4.cif. No --cifs needed.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/refine.py \
--xrd_data ${CLAUDE_SKILL_DIR}/examples/LiFePO4/LiFePO4_xrd.xy
Results: examples/LiFePO4/refinement_results/LiFePO4/ (refinement_result.json, HTML/PNG, peak_data CSV).
# Quote the path because of (PO3), (OH), (NH4).
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/refine.py \
--xrd_data "${CLAUDE_SKILL_DIR}/examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO.xy"
CIFs are taken from examples/CaNi(PO3)4_.../cifs/ (NiO_225_sym.cif, CaNi(PO3)4_15_sym.cif). Results under that example’s refinement_results/.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/refine.py \
--xrd_data pattern.xy \
--cifs phase1.cif phase2.cif \
--phase_params phase_params.json \
--refinement_params refinement_params.json
plot.py)If you want to adjust the visualization (e.g. dimensions, font sizes, legend position) without re-running the heavy DARA refinement process, you can use the standalone plot.py script. This script reads the *_curve_data.csv exported by refine.py.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/plot.py \
--data_dir refinement_results/my_pattern \
--output refinement_results/my_pattern/reformatted_plot
You can independently edit plot.py directly to adjust any of the matplotlib/plotly formatting rules.
--bgmn_dir / DARA_BGMN_DIR on restricted networks.( ) or spaces.--phase_params (e.g. lattice_range, b1, k1, gewicht) per the DARA tutorial.Aeris-fds-Pixcel1d-Medipix3; change with --instrument_profile if needed for your diffractometer.mat-xrd-digitizer:
.xy file if you do not have raw experimental data.Author: Nofit Segal Contact: GitHub @nofitsegal
examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO.xy (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/README.md (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/cifs/CaNi(PO3)4_15_sym.cif (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/cifs/NiO_225_sym.cif (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/refinement_results/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO_curve_data.csv (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/refinement_results/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO_peak_data.csv (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/refinement_results/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO_refinement.png (opens in a new tab)examples/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/refinement_results/CaNi(PO3)4_800_240_Ca(OH)2_(NH4)2HPO4_NiO/refinement_result.json (opens in a new tab)examples/LiFePO4/LiFePO4_xrd.json (opens in a new tab)examples/LiFePO4/LiFePO4_xrd.xy (opens in a new tab)examples/LiFePO4/README.md (opens in a new tab)examples/LiFePO4/cifs/Li3PO4.cif (opens in a new tab)examples/LiFePO4/cifs/LiFePO4.cif (opens in a new tab)examples/LiFePO4/refinement_results/LiFePO4/LiFePO4_curve_data.csv (opens in a new tab)examples/LiFePO4/refinement_results/LiFePO4/LiFePO4_peak_data.csv (opens in a new tab)examples/LiFePO4/refinement_results/LiFePO4/LiFePO4_refinement.png (opens in a new tab)examples/LiFePO4/refinement_results/LiFePO4/LiFePO4_refinement.svg (opens in a new tab)examples/LiFePO4/refinement_results/LiFePO4/refinement_result.json (opens in a new tab)scripts/convert_xrd_to_xy.py (opens in a new tab)scripts/dara_utils.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skills133 skills in this plugin
/chem-bond-dissociationCalculate homolytic and heterolytic bond dissociation energies (BDEs) for all single bonds in a molecule using MLIPs with RDKit fragmentation./chem-conformer-searchGenerate molecular conformers with RDKit ETKDG, relax with MLIPs, and rank by energy with Boltzmann weighting./chem-db-mofQuery multiple MOF databases (QMOF via MPContribs; ARC-MOF DB7/Majumdar et al. via Materials Cloud) and download CIF structures with optional element or identifier filters.Other plugins' skills for the same job