Repository navigation
Conversation
ac44a99 to
6efd329
Compare
TODO
Review of the 3-point root finder. CI is green and the branch merges cleanly; the issues below were found with a standalone harness that runs the PR's BlockingBoth fixed in 0b6891b.
Should fixCode items done in f680ef6.
Cleanup
|
Root-count comparison: old
|
e_steps |
c=8, E_i 3–40 | c=10, E_i 3–40 | c=8, E_i 3–150 | c=10, random incident direction | omega_q calls per state (old / new) |
|---|---|---|---|---|---|
| 1 | 0.55 / 0.08 | 0.75 / 0.25 | 0.12 / 0.02 | 0.80 / 0.20 | 26 / 21 |
| 2 | 0.27 / 0.015 | 0.42 / 0.06 | 0.06 / 0.005 | 0.36 / 0.03 | 28 / 24 |
| 5 | 0.03 / 0 | 0.05 / 0.005 | 0.005 / 0 | 0.08 / 0 | 37 / 34 |
| 10 | 0 / 0 | 0.02 / 0 | 0.005 / 0 | 0.01 / 0 | 55 / 53 |
| 20 | 0 / 0 | 0.01 / 0 | 0 / 0 | 0 / 0 | 94 / 92 |
| 50 | 0 / 0 | 0.005 / 0 | 0 / 0 | 0 / 0 | 212 / 212 |
- At the same
e_steps, the new scan misses 3–7× fewer roots; neither scan ever reports an extra root. - The new scan has no misses from
e_steps=10 in every case. With c=10 the old scan still missed roots at the old default of 50. - So the defaults are lowered to 10 in f2910de: about 4× fewer
omega_qcalls in the root search. - At the new default, Samples_Phonon (seeded, 2e6 rays) gives output identical to
mainin 7.4 s against 17.0 s. TheTest_Dispersion_relation_TASphonon%Testcase is also identical (1.79066e-10). - Not covered:
gap > 0, other lattice parameters, GPU.
Following an idea by Kim Lefmann, each sub-interval of the k_f scan is sampled at its ends and midpoint: - a half with a sign change is refined with the Illinois variant of regula falsi; - if all three samples share a sign, the parabola through them flags a possible hidden pair of roots around a dispersion extremum, accepted only if omega_q really changes sign at the parabola's vertex. This drops the Numerical Recipes zridd (Ridder's method), reports each root once (also when it falls on a sample point), evaluates every grid point once, and uses a single #pragma acc routine path for CPU and GPU. Unused fatalerror helpers removed. Root sets can differ from before where the old scan missed or split a pair of roots within one sub-interval; otherwise roots agree within ROOTACC. Samples_Phonon and the Test_Dispersion_relation_TAS phonon test give identical output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A root-count comparison (real omega_q, 2e4 random states per case, Pb-like parameters, against a 2e4-step reference scan) finds all roots at 10 with the 3-point scan, while the old zridd scan still missed some at 50. Default runs make ~4x fewer omega_q calls in the root search. Samples_Phonon and the Test_Dispersion_relation_TAS phonon test give identical output to main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f2910de to
27ad31a
Compare


Free-form text area
Please describe what your PR is adding in terms of features or bugfixes:
Replaces the
zridd(Ridder's method, Numerical Recipes) root scan inPhonon_simplewith a 3-point scan per sub-interval, following an idea by Kim Lefmann:omega_qreally changes sign at the parabola's vertex.Numerical behaviour: the root set can differ from
mainwhere the old scan missed or split a pair of roots inside one sub-interval; roots agree withinROOTACCotherwise. Samples_Phonon (seeded, 2e6) and theTest_Dispersion_relation_TASphonon%Testcase give bit-identical output tomain. Thee_steps_low/e_steps_highdefaults are lowered from 50 to 10, backed by a root-count comparison posted below; at the new default Samples_Phonon runs in 7.4 s instead of 17.0 s.Declaration of use of AI-tools
Claude used to write revised algorithm based on inputs from Kim Lefmann in an email thread.
Development OS / boundary conditions
Please describe what OS you developed and tested your additions on, and if any special dependencies are required:
Developed on macOS Tahoe 26.x, Silicon/arm64
PR Checklist for contributing to McStas/McXtrace
For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:
My contribution includes patches to an existing component file
mcdocutility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)mctestutility to test one or more instruments making use of the component (please attachmcviewtestreport as screenshot in comments)mccode-clangformattool to apply the standard McCode component indentation schememcrun --c-lint"linter" and followed advice to remove most / all warnings that are raised