Skip to content

PhononSimple_process, Phonon_simple: scale the one-phonon cross-section to Squires 3.120 - #2806

Open
henrikjacobsenfys wants to merge 3 commits into
mccode-dev:mainfrom
henrikjacobsenfys:fix-phonon-simple-scale
Open

henrikjacobsenfys wants to merge 3 commits into
mccode-dev:mainfrom
henrikjacobsenfys:fix-phonon-simple-scale

Conversation

@henrikjacobsenfys

Copy link
Copy Markdown
Contributor

Fixes #2792.

PhononSimple_process (Union) and Phonon_simple (samples) traced 1/(4π × 1.00866) ≈ 0.0789 of the one-phonon cross-section they implement (Squires Eq. 3.120). Two factors, one line each:

  • 4π. PhononSimple_process now returns μ = 4πρ dσ/dΩ, which is what Union's ΔΩ/4π direction weighting expects. Phonon_simple drops the / (4 * PI) from its focusing factor p2.
  • m_n/u. The recoil ħ²κ²/2m_n was divided by M as if it were in neutron masses. Both headers document M as an atomic mass, so the constant gains 1.00866 (m_n/u). The %P unit of M now reads [amu] in both components.

b stays the scattering length in fm, so existing instruments need no parameter change. Their phonon intensity goes up by 12.675.

Test targets

The test targets recorded at the old scale are updated, along with the generated READMEs that repeat them:

  • Samples_Phonon, both %Example lines.
  • Test_Dispersion_relation_TAS, the three phonon %Example lines and the phonon %Scan.
    • Its generate_phonon_dispersion.py deliberately reproduces Phonon_simple's cross-section, so it gets the same two factors. Otherwise Dispersion_relation and Phonon_simple would no longer agree.
    • The formula and the two phonon scan totals in its .md are updated to match.
  • Test_inhomogenous_process, sample=phonon.

For Phonon_simple, the fix rescales every ray's weight by a constant without touching the random number sequence. So at a fixed seed each result scales by exactly 4π × 1.00866 = 12.6752. I ran every affected example at mctest's settings (seed 1000, 1e6 rays, no MPI), before and after:

  • The ratio was 12.6752 for both Samples_Phonon lines, the three TAS examples, and all 25 points of the TAS %Scan. The same 17 points are zero before and after.
  • The new targets are therefore the old targets × 12.6752, rounded to the significant figures each had. I didn't replace them with numbers from my own platform.

The Union test is not a pure rescaling, because μ also changes which process Union picks. Its target moves by the measured ratio, +4.6% (0.00505839 → 0.00529178).

The magnon examples (sample_choice=2, 3) are unaffected.

Absolute check

A monochromatic 100 meV beam on a thin fcc Ni sample, with four 0.2 × 0.4 m detector elements 6 m away at 2θ = 20°, 35°, 50° and 65°. dσ/dΩ per atom from the monitors, compared with Squires 3.120:

before after
PhononSimple_process (Union box, 4 seeds × 5e4) 0.0790 0.9995 ± 0.0025
Phonon_simple (cylinder, 2θ = 50°, 20 seeds × 1e6) 0.0790 ± 0.0001 1.0004 ± 0.0009

Tested, and not

  • Tested: Windows 11, MSVC, conda-forge McStas 3.8.7, with this branch's components and test instruments, plus main's Union library files. In that setup the unpatched runs reproduce the committed targets (e.g. lin_det_I 0.00507 against 0.00506), which suggests the mix is sound.
  • Not tested: Linux, macOS, GPU, and a build of main itself.
  • Not touched:

🤖 Generated with Claude Code

…on to Squires 3.120

Both components traced 1/(4 pi x 1.00866) of the one-phonon cross-section
they implement (Squires Eq. 3.120), see mccode-dev#2792:

- 1/4pi: PhononSimple_process returned mu = rho b^2 X where Union expects
  mu = 4 pi rho dsigma/dOmega; Phonon_simple divided its weight by 4 pi.
- m_n/u: the recoil hbar^2 kappa^2/2m_n was divided by M as if M were in
  neutron masses, while both headers document M as an atomic mass.

The test targets that recorded the old scale are updated: the Phonon_simple
based ones (Samples_Phonon, Test_Dispersion_relation_TAS examples and scan)
scale by exactly 4 pi x 1.00866 at a fixed seed, and the Union one
(Test_inhomogenous_process, sample=phonon) moves by +4.6%. The TAS test's
dispersion generator mirrors Phonon_simple's cross-section, so it gets the
same two factors.

Fixes mccode-dev#2792

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willend
willend requested a review from Lomholy October 17, 2026 14:25
@willend

willend commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@henrikjacobsenfys thanks! As I remember @Lomholy recently looked into benchmarking of multiple inelastic comps, so I've requested him to review.

@Lomholy

Lomholy commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

@willend thank you for putting me on this. I will see when I have mental bandwidth to see if the factor 4 pi is supposed to be there or not, but i expect that it might be some time before i get to it!

@willend

willend commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

@henrikjacobsenfys current failures are a result of a not completely succesful merge with new content on main. I will fix that.

… 1.00866

The merge of main brought in the new scan mesh (h=0.8..1.2, l=1.1..1.3)
with references recorded before the Phonon_simple fix, so test 6 failed
at ~13x. The references (mean of 16 seeds) are scaled by the exact factor
12.6752 the fix applies at fixed seed. mctest with this branch (macOS
arm64, seed 1000): 25/25 points within 20% without MPI (worst 106%) and
with 2 MPI ranks (worst 105%).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

[BUG]: PhononSimple_process and Phonon_simple` scatter 1/(4π × 1.00866) of the one-phonon cross-section they implement

3 participants