Skip to content

Python API: single-crystal Fourier and pair distribution function - #35

Merged
tproffen merged 2 commits into
claude-python-appfrom
claude/fourier-pdf
Nov 16, 2026
Merged

tproffen merged 2 commits into
claude-python-appfrom
claude/fourier-pdf

Conversation

@tproffen

Copy link
Copy Markdown
Owner

Merges into claude-python-app (not master).

What this adds

  • diffuse.fourier(): single-crystal intensities on a line or plane in reciprocal space (corners ll/lr/ul as in DISCUS). Options: radiation, wavelength, ADPs, and subtract_average (100 leaves the diffuse scattering). Returns a FourierMap with the intensities, the (h, k, l) of every point, and an image/line plot with a sensible log dynamic range.
  • diffuse.pdf(): G(r) for a periodic crystal or a finite particle (particle_diameter), with Qmax termination, Qdamp/Qbroad, thermal broadening and correlated-motion corrections. Returns a PDFPattern with plot().
  • Gallery examples: fourier_demo.py (anatase hk0 map; diffuse scattering of a Cu/Au layer with short-range order) and pdf_demo.py (nickel termination effects; anatase X-ray vs neutron).
  • Bug fix: DISCUS's cd changed the working directory of the whole Python process, so relative paths in a user's script broke after any diffuse call. Session.run() now restores the caller's directory.
  • CLAUDE.md: pull requests target claude-python-app, never master.

How it was checked

Check Result
pdf() vs legacy 03.Pair_Distribution_Function/*.grcalc (histogram, thermal, Qmax 30, Qdamp 0.02) identical (R ≤ 1e-9)
fourier() line vs 02.Calculation_Scattering/RESULTS/1d.inte R = 1.7e-7
fourier() plane vs golden 02.2d identical
Map orientation (row of atoms along a, neutrons, no ADPs) varies only along h, exactly constant along k
Finite particle G(r) = 0 beyond the particle
anatase hk0 map peaks only at even h, k (I4₁/amd)

Locally: pytest tests/python 39 passed (33 legacy macro tests skipped without DISCUS_SUITE); Sphinx docs build with -W clean, three gallery examples.

Note: the PDF reference files were made from water_hex.cell (oxygen only), although pdf.mac's plot titles say nickel.

Suggested in-depth testing

  • Fourier maps of a structure you know well, especially non-orthogonal cells.
  • A nanoparticle PDF compared with pdf_nano.mac (needs a structure already cut to a sphere).
  • subtract_average on your own disordered models.

Generated by Claude Code

- diffuse.fourier(): intensities on a line or plane in reciprocal space
  (corners ll/lr/ul as in DISCUS), radiation, wavelength, ADPs, and
  subtract_average to leave the diffuse scattering. FourierMap holds the
  intensities, their (h, k, l) and an image/line plot with a sensible
  log dynamic range.
- diffuse.pdf(): G(r) for a periodic crystal or a finite particle, with
  Qmax termination, Qdamp/Qbroad, thermal broadening and correlated-motion
  corrections. PDFPattern with plot().
- Fix: DISCUS's cd changed the working directory of the whole Python
  process; Session.run() now restores the caller's.
- Tests (tests/python/test_fourier_pdf.py): PDF identical to the legacy
  .grcalc references, Fourier line/plane vs legacy RESULTS and golden data,
  map orientation, finite particles, option checks, plots; new golden data.
- Gallery: fourier_demo.py (anatase hk0, diffuse scattering of a Cu/Au
  layer with short-range order) and pdf_demo.py (nickel termination
  effects, anatase X-ray vs neutron). API docs, README and WP0 log updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yw8KkfPLawp8Po4f5Bc9v
@tproffen
tproffen merged commit 90e8190 into claude-python-app Nov 16, 2026
4 checks passed
@tproffen
tproffen deleted the claude/fourier-pdf branch November 16, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants