Skip to content

conic.h: avoid spurious re-hit (and absorption) on the surface just reflected from - #2794

Open
willend wants to merge 4 commits into
conic-followup-2787from
conic-rehit-fix
Open

willend wants to merge 4 commits into
conic-followup-2787from
conic-rehit-fix

Conversation

@willend

@willend willend commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2793 (base branch conic-followup-2787). Merge #2793 first, then retarget this PR to main. McStas only.

Problem

After a reflection, a neutron sits on the surface it just left, so that surface's quadric has a root at t = 0. Round-off in solveQuad turned this into small positive roots 1e-9 to 1e-4 m away. traceSingleNeutron then "hit" the same surface again from the outside, and reflectNeutronConic absorbed the neutron (vn > 0).

The bias depended strongly on the figure error. With exact normals about half of the doubly-reflected neutrons were lost, which made results sensitive to a 1 µrad figure error for no physical reason.

Fix

  • For the surface hit in the previous step, the next collision now comes from the exact factorisation (C = 0, other root t = −B/A), in new functions getTimeOfNextCollisionConic/Flat().
  • traceNeutronConic/Flat() now receive the collision time from traceSingleNeutron instead of recomputing it. Both functions are only called from traceSingleNeutron.
  • For all other surfaces nothing changes: the passed t is the value that used to be recomputed.

A post-reflection "nudge" was evaluated and rejected. The spurious roots extend to about 0.1 mm, so a nudge needs about 1 mm to remove all of them, and at that size it already loses genuine hits.

⚠️ Numerical behaviour change

Results of Conics_* change; intensities go up.

Test_Conics_pairs (1e6 rays, seed 1), reflections at the focus (2 m monitor):

Case Spurious absorptions before → after Double reflections before → after
OPTIC=1, σ = 0 12 809 → 0 13 198 → 26 007
OPTIC=1, σm = 1 µrad, σs = 0 3 043 → 0 22 947 → 25 990
OPTIC=1, default σ 1 408 → 0 24 582 → 25 990
OPTIC=2 (PH), default σ 3 139 → 0 9 788 → 12 927
OPTIC=4 (PP), default σ 66 → 0 25 942 → 26 008

Reference values (%Example) change by +6% (EH/HE), +33% (PH), +0.2% (PP), and 0% for the fs=8 fi=6 cases. They are updated in this PR.

Tested

  • macOS arm64, clang, CPU, 1e6 rays, --seed 1, single process, McStas 3.9.2 with this branch's files.
  • Bit-identical to the base branch:
    • Test_NMO and Test_FlatEllipse_finite_mirror, both with default settings and with a silicon substrate (mirror_width=0.0005, mb=0 and mb=4). The FlatSurf part is preventive; no FlatSurf configuration tested showed the problem.
    • Test_Mirror_conic and Test_Mirror_FlatEllipse.
    • WOFSANS width=0.15 (PSD_10 = 3.50e9 ± 0.57e9, stored reference 4e9).
  • -Wall -Wextra: no new warnings from conic.h.
  • Not tested: Linux, Windows/MSVC, GPU/OpenACC, MPI with more than one process.

🤖 Generated with Claude Code

willend and others added 2 commits October 13, 2026 07:59
After a reflection the particle sits on the surface, so the quadric of that
surface has a root at t = 0. Round-off turned this into small positive roots
(1e-9 to 1e-4 m away), and traceSingleNeutron then hit the same surface again
from the outside, upon which reflectNeutronConic absorbed the neutron. This
lost ~6% of the focused intensity in Test_Conics_pairs at default settings,
~25% for Paraboloid/Hyperboloid pairs, and ~half without figure error.

For the surface hit in the previous step, the next collision is now computed
from the exact factorisation (C = 0, other root t = -B/A) via the new
getTimeOfNextCollisionConic/Flat(). traceNeutronConic/Flat() now take the
collision time from traceSingleNeutron instead of recomputing it.

Changes simulation results of Conics_* (more intensity). FlatSurf-based
FlatEllipse_finite_mirror/NMO are unchanged in all tested configurations.

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

1 participant