Skip to content

McXtrace Single_crystal: absorption from mu/rho times mass density - #2938

Merged
willend merged 2 commits into
mainfrom
2026-10-sx-abs-density
Oct 30, 2026
Merged

willend merged 2 commits into
mainfrom
2026-10-sx-abs-density

Conversation

@willend

@willend willend commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Follows the open question in #2880. Stacked on #2937 (same lines); merge that first, then retarget this to main.

Problem. The absorption cross-section is per atom (atomic weight from material_datafile, e.g. Si.txt A[r] = 28.09 g/mol) but was divided by the volume of the whole unit cell (V0). For Si.lau (8 atoms per cell, no weight header) this makes absorption 8× too weak: the attenuation length at 6.9 keV came out as 360 µm, against the textbook 45 µm.

cif2hkl output is not affected: its weight header is per formula unit, consistent with V0 (LaB6: 203.77 g/mol, Z=1).

Fix. Use the textbook linear attenuation, (μ/ρ) [cm²/g] × density [g/cm³] → 1/cm, ×100 → 1/m. This needs no atomic weight, atom count or barns/fm² conversion. The density comes from the reflections file header (density, written by cif2hkl and present in Si.lau), else from the nominal rho of the material_datafile (all 110 files in mcxtrace-comps/data have one). The old expression is kept only as a fallback when no density is known, marked with a ponytail: comment.

Numerical change (1e6 rays, seed 1001, vs #2937):

Instrument Ratio new/old
Test_PowderN index=2, Test_FluoPowder index=2 (LaB6 from CIF) 1.0000 (identical)
SSRL_bl_11_2_white_src EnergyMonitor_first 0.225
SSRL_bl_11_2_not_white_src EnergyMonitor_first 0.469
Test_Mono Mono=6 (Si.lau) changes; no target

Updated references (same recipe as in #2880):

  • SSRL_bl_11_2_white_src %Example: 1.65837e+10 → 3.74674e+09 ± 1.6e7 (3 runs at 1e6 rays, seeds 1001, 2002, 3003, plus 1 run at 1e7 rays, seed 4004, inverse-variance weighted)
  • SSRL_bl_11_2_not_white_src Example (still disabled): 4.17271e+11 → 1.94915e+11
  • Both %Scan arrays regenerated from two 1e7-ray scans (seeds 11, 22), weighted; seeds agree within 6% per point. New ranges: white_src 5.0e8 to 1.9e9, not_white_src 1.7e11 to 2.4e11.

Not touched: the unused delta_prefactor, which mixes hkl_info.rho (atoms/ų) with the material file's mass density. It is computed but never read.

Tested on macOS arm64 (clang) only.

🤖 Generated with Claude Code

willend and others added 2 commits October 30, 2026 07:52
The absorption cross-section was the per-atom value (atomic weight from
e.g. Si.txt A[r]) divided by the full unit cell volume, so multi-atom
cells absorbed too little: Si.lau (8 atoms/cell) gave an attenuation
length of 360 um at 6.9 keV instead of 45 um.

Use the textbook linear attenuation mu/rho [cm^2/g] * density [g/cm^3],
with the density from the reflections file header, else the nominal
density of the material_datafile. Keep the old expression only as a
fallback when no density is known.

Numerical change: unchanged for cif2hkl output where weight is per
formula unit (LaB6 Test_PowderN/Test_FluoPowder identical); stronger
absorption for Si.lau (SSRL_bl_11_2_*, Test_Mono Mono=6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… absorption

Example targets: inverse-variance weighted mean of 3x 1e6 (seeds 1001,
2002, 3003) and 1x 1e7 (seed 4004). Scan references: weighted mean of
two 1e7-ray scans (seeds 11, 22), seeds agree within 6%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willend
willend changed the base branch from 2026-10-sx-abs-cleanup to main October 30, 2026 10:36
@willend
willend merged commit 1c723c8 into main Oct 30, 2026
21 checks passed
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.

1 participant