Skip to content

WP0 0.6/0.7: golden data and coverage for structures (WP3) and Fourier (WP4) - #37

Merged
tproffen merged 2 commits into
claude-python-appfrom
claude/inspiring-brahmagupta-ne81m7
Nov 16, 2026
Merged

tproffen merged 2 commits into
claude-python-appfrom
claude/inspiring-brahmagupta-ne81m7

Conversation

@tproffen

@tproffen tproffen commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

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

Step 1 of finishing WP0: the safety net for the first two work packages that get rewired (WP3 structures and I/O, WP4 single-crystal Fourier). Wherever possible the tests compare DISCUS with an independent reference (gemmi's space groups and form factors, or physics), not only with an earlier DISCUS run.

New tests

tests/python/test_wp3_structures.py (27 tests)

  • Space-group expansion of 10 structures (C2/c, Cmcm, Cmc2₁, Cmm2 with molecules, F-43m, Pn-3m origin 1, Fm-3m, P4mm, P6₃/mmc, I4₁/amd CIF) agrees site by site with gemmi.
  • Supercells contain every unit-cell site exactly once per cell.
  • save → read stru, CIF and RMCProfile export → import round trips; DISCUS's CIF read by gemmi; VASP export parsed and checked.
  • .cell atom formats: expressions such as 1./3. in the comma format; the legacy-format behaviour (finding 4).
  • SHELX round trip: strict known failure (see findings).

tests/python/test_wp4_fourier.py (16 tests)

  • fcc extinctions, Debye–Waller factor exp(−B|d*|²/2), X-ray form factors within 1 % of the International Tables (IT92).
  • Anomalous dispersion: ZnSe Friedel pairs differ by the ratio the structure factor predicts (within 0.5 %); nickel stays symmetric; tabulated moa1 values (golden).
  • Golden maps for X-rays, neutrons, electrons; energy = wvle.
  • Seeded lots repeat exactly with 1 and 4 threads (golden).
  • NUFFT vs the standard technique: agrees for the 50×50 layer on the 04.sro3 grid; strict known failure for small crystals.

Also: Crystal.atoms() now handles structures with molecules (it crashed on them); tests/requirements.txt adds gemmi, and CI runs pytest and the docs from one virtual environment with it.

Findings (details in migration/WP0_Test_Coverage_Gaps.md and the WP0 log)

  1. NUFFT gives wrong maps for small crystals on many grids (Ni 4×4×4, hk0 −3…3: R = 1.7, spurious maxima every 0.08–0.16 in h), while some size/grid combinations are exact. The default technique is unaffected. Likely related to the rare Infinity/NaN map in 04.sro3, which uses NUFFT.
  2. SHELX export writes every atom of the cell together with the space-group symmetry and occupancy 0.5; re-reading CuO gives 32 atoms instead of 8.
  3. disp on does not switch on anomalous dispersion; only disp anom does, so macros using disp on silently get none.
  4. Fractions in the legacy .cell atom format are silently misread. The comma format with a column header (atoms x, y, z, Biso) evaluates expressions such as 1./3. correctly. The legacy format (bare atoms, blank-separated values) stops reading at /, so 1./3. becomes 1. without a warning; mixing the two formats gives an error. 01.Simulation/calculate.cell uses the legacy format and gets Co at (0,0,0) instead of (1/3,2/3,0).
  5. 01.Simulation/export.mac: most failures are outdated reference files and typos; two checks pass falsely because compare_files.mac treats a missing file as "no differences".

Known failures are marked xfail(strict=True): they turn red when the bug is fixed, so the mark gets removed.

Checked

  • pytest tests/python: 81 passed, 2 known failures (33 legacy macro tests skipped without DISCUS_SUITE); the same with OMP_NUM_THREADS 1 and 4, and on repeat.
  • Sphinx docs build with -W: clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yw8KkfPLawp8Po4f5Bc9v

…r (WP4)

Tests checked against independent references where possible:

- test_wp3_structures.py: space-group expansion of 10 structures agrees
  site by site with gemmi; supercells; save/read, CIF and RMCProfile
  export/import round trips; DISCUS CIF read by gemmi; VASP export parsed.
  SHELX round trip is a strict known failure.
- test_wp4_fourier.py: fcc extinctions, Debye-Waller factor, X-ray form
  factors vs IT92, anomalous dispersion (Friedel pairs in ZnSe match the
  structure-factor prediction; nickel stays symmetric), energy = wvle,
  golden maps for X-ray/neutron/electron and moa1 dispersion, seeded lots
  repeat exactly (golden). NUFFT agrees for the 50x50 layer; for small
  crystals it is a strict known failure.
- Crystal.atoms() now skips the molecule blocks of saved .stru files.
- tests/requirements.txt (gemmi); CI runs pytest and the docs from one
  venv with it.

Findings, documented in the WP0 log and the coverage-gap document: NUFFT
gives wrong maps for small crystals; SHELX export writes the whole cell
with the symmetry; 'disp on' does not switch on dispersion (only 'anom');
fractions like 1./3. in .cell files are misread; export.mac has outdated
references, typos and two false passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yw8KkfPLawp8Po4f5Bc9v
The comma format with a column header ('atoms x, y, z, Biso') runs atom
values through the interpreter, so 1./3. is evaluated. Only the legacy
format (bare 'atoms', blank-separated values) uses a list-directed read
that stops at '/' and silently reads 1./3. as 1.; mixing the two formats
gives an error. New test for the comma format; the legacy test and the
WP0 log / coverage notes say this precisely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yw8KkfPLawp8Po4f5Bc9v
@tproffen
tproffen merged commit 59627e0 into claude-python-app Nov 16, 2026
4 checks passed
@tproffen
tproffen deleted the claude/inspiring-brahmagupta-ne81m7 branch November 16, 2026 18:46
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