Skip to content

mcstas-comps: inventory cleanup and test coverage - #3219

Merged
willend merged 47 commits into
mainfrom
mcstas-comps-consolidation
Nov 30, 2026
Merged

willend merged 47 commits into
mainfrom
mcstas-comps-consolidation

Conversation

@willend

@willend willend commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Free-form text area

First step of a McStas component cleanup toward better test coverage: remove dead event-file components, fix bugs found while adding cross-check tests.

⚠️ = changes simulation results · ★ = new test, previously untested

Removed

  • Vitess, MCNP and Tripoli4 event-file components, vitess-lib, the neutronics library and ENABLE_NEUTRONICS.
  • Vitess_ChopperFermi (did not build in 3.x), Beam_spy, SasView_model + share/sasview_proxy.c.
  • Instruments Vin_test, Vout_test, vinput2mcpl.
  • Virtual_input/Virtual_output kept in obsolete, but stop with an error pointing to MCPL_input/MCPL_output.
  • Histogrammer: MCPL input only (MODE, bufsize removed).
  • Unreferenced vitess_fc_* manual figures.

Component fixes

  • ⚠️ Guide_four_side ★: R0 applied once per reflection, m<1 handled, reflectivity files scale the weight, uninitialised wall index.
  • ⚠️ multi_pipe ★: hole grid never ran; even hole count propagated twice.
  • ⚠️ Pol_bender_tapering ★: absorbed at top/bottom past the channel exit.
  • ⚠️ Sapphire_Filter ★: exit aperture added.
  • ⚠️ Mirror_Elliptic_Bispectral ★: uninitialised hit_back_flag; wrong sign in the transmit=1 reflection.
  • ⚠️ Mirror_Curved_Bispectral ★: intersections 2 and 3 used the wrong mirror height.
  • ⚠️ TOF_cylPSD_monitor ★: counted exits through the cylinder ends; absorbed misses despite restore_neutron=1.
  • ⚠️ TOF2Q_cylPSD_monitor ★: same two fixes.
  • ⚠️ TOF2Q_cyl_monitor ★: restore_neutron fix; 2theta binning off by half a bin; t_chop now really in ms (default 4).
  • ⚠️ Pol_bender: at large radius, rounding made a wall just reflected on get hit again (9% low at R=1e5); distance threshold now scales with radius.
  • Vertical_Bender: same threshold fix (no change seen in Test_Vertical_Bender).
  • ⚠️ SANS_Liposomes_Abs ★: uninitialised inner radius gave zero output.
  • ⚠️ Source_adapt ★: did not compile (multi-variable DECLARE line); under MPI, the adaption ramp assumed all rays on one process (−33% at 2 processes).
  • PerfectCrystal: builds with OpenACC (NAN fallback for nvc; GPU-callable grandvec_target_circle).
  • From clang --analyze: TOF2Q_cyl_monitor lambda unset for pixel ∉ {0,1}; Pol_bender_tapering propagated by an unset time on entry miss; FermiChopper root finder read an unset value. No change in tests.
  • Source_div: exit(-1) with a visible message on zero divergence.
  • AF_HB_1D_process ★: exit(-1).

Documentation

  • SiC ★: documented from the code (Born approximation, corner origin, built-in 80 AA layer on Si; marked AI-written); MCDISPLAY added.
  • Sapphire_Filter, Mirror_Elliptic_Bispectral, Mirror_Curved_Bispectral: docs rewritten (frame, orientation, examples).
  • PerfectCrystal ★: changelog moved from %I into %D.
  • Union_abs_logger_1D_time ★: %D described a height histogram; it bins absorption time.
  • Pol_bender: reflectivity defaults described correctly.
  • SiC, Mirror_Elliptic_Bispectral, Mirror_Curved_Bispectral: plate ranges in LaTeX math mode; a bare <x cut the mcdoc HTML description short.
  • Example instruments (6 McStas, 4 McXtrace): [parameters=values] instead of <parameters=values>, which mcdoc HTML dropped as a tag.
  • Author/origin headers: SANSsimple (Linda Udby, NBI), Source_div (Kim Lefmann), Reflectometer typo, Test_shellguides mailto link.

New and extended tests

  • Test_Guide_four_side: vs Guide, Elliptic_guide_gravity.
  • Test_multi_pipe: vs analytic open fraction.
  • Test_Pol_bender_tapering: vs Pol_bender.
  • Test_Sapphire_filter: vs NCrystal_filter.
  • Test_PerfectCrystal: Si(111) backscattering vs NCrystal.
  • Test_SiC: vs Multilayer_Sample.
  • Test_AF_HB_1D: spinon continuum, 1e5 rays via an Ncount parameter.
  • Test_Bispectral_mirrors: both Bispectral mirrors vs Mirror, pencil beam.
  • Test_Monitors_flat: EPSD_monitor, PSD_TOF_monitor, PSD_monitor_psf, TOFlog_monitor, TOF_PSD_monitor_rad, TOF_PSDmonitor, Flex_monitor_3D (all ★) vs PSD_monitor.
  • Test_Monitors_cyl: the three cylindrical TOF monitors vs Monitor_nD banana; Monitor_4PI ★ vs Monitor_nD sphere.
  • Test_Source_adapt: Source_adapt + Adapt_check ★ vs Source_simple.
  • Test_Source_multi_surfaces ★: mock spectra vs analytic value.
  • Test_abs_logger_1D_time: Union_abs_logger_1D_time ★ vs Union_abs_logger_1D_space_tof, plain and conditional.
  • SANSsimple: SANS_Liposomes_Abs ★ enabled as SAMPLE=2.
  • Test_SANS: SANSCurve ★ as SAMPLE=8, mock sphere curve vs SANSSpheres.
  • Test_Pol_Bender: reference updated (0.704 → 0.655; stale before this PR).
  • Test_Mask (Mask, Absorber ★); %Test for Test_NMO (NMO ★) and Test_FlatEllipse_finite_mirror.
  • Test_Guides: cases for Guide_gravity_psd, Guide_multichannel ★.
  • RITA-II: defaults (EF=5) and %Test restored; E_monitors get a real range; ⚠️ GPU only: SPLIT counts and PSD windows on the GPU.
  • compmatrix.sh: LC_ALL=C for a locale-independent order.
  • Refreshed *_examples.txt, comps_no_examples.txt and the affected manual pages.

Open


Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Claude Code: removals, component fixes, docs, tests, commit split. Commits carry Co-Authored-By.

Development OS / boundary conditions

macOS arm64, clang, conda env. All new and extended tests run on CPU (1e5-1e7 rays), plus Test_NMO, Test_FlatEllipse_finite_mirror, Histogrammer with MCPL, SNS_ARCS, Test_Fermi, templateSasView, RITA-II. GPU: RITA-II run by hand on the GPU workflow. Not tested locally: Linux, Windows, PDF manual build.


PR Checklist for contributing to McStas/McXtrace

  • My contribution includes patches to an existing instrument file

    • I have reviewed the mcdoc page of the instrument in the mcdoc-pages artifact of the check-doc-params CI run
    • I have used the mcrun --c-lint "linter" and followed advice to remove most / all warnings that are raised
      (all touched instruments linted; real issues in touched components fixed, the rest are false positives, shared runtime/library code or untouched components)
  • My contribution includes a new instrument file

    • I have reviewed the mcdoc page of the instrument in the mcdoc-pages artifact of the check-doc-params CI run
    • I have ensured that basic use of the instrument is OK (e.g. it compiles?)
    • ... and maybe even added a %Test: line (or a %TestScan: line for a parameter scan) to describe expected behaviour
  • My contribution contains something else

    • Explanation is added in free form text above or below the checklist

Tip for reviewers: Visit https://blueblazin.github.io/blockviz/#github=[URL_of_this_PR] for a visual look at code changes

🤖 Generated with Claude Code

willend and others added 9 commits November 29, 2026 11:07
Not used by any example. FermiChopper and FermiChopper_ILL remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No example uses them. The sasmodels SasView_* components replace
SasView_model, so share/sasview_proxy.c goes too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vitess, MCNP and Tripoli4 readers/writers go, with vitess-lib and the
neutronics library. Virtual_input/Virtual_output stay in obsolete but
stop with an error. Examples and manuals point to MCPL_input/MCPL_output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gives Mask a test instrument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Default EF=5: with EI=EF=EN=0 the angle branch gave EI=inf and the
HKL calculator failed. psd_detector is unchanged for the documented
examples; only the post-analyser E_monitors now get a real range.
Example: -> %Test: with the reference refreshed (220.701). The slow
Pb(200) scan stays disabled as TestScan:. Error exit uses exit(-1),
and commented-out Virtual_* blocks use MCPL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They are set in INITIALIZE and read in TRACE, but were never updated
on the device. Changes GPU results; CPU is unchanged.

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

willend commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Hand-held GPU run of RITA-II model (slow workstation-GPU)

Compiling instruments [seconds]...
RITA-II : 153.67

Running tests / getting status...
RITA-II  :   Display OK (2s)
RITA-II  :  24.48    [val: 220.835 / 220.701 = 100 %]
 - Test 1 plots generated OK
Moved 5 copies of shared js libraries to a single _lib/
======================================
Compilation time: 0:02:36
Simulation time: 0:01:08
Total runtime: 0:03:48
Overall test result:
SUCCESS

willend and others added 20 commits November 29, 2026 11:34
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dd test

Reflect through StdReflecFunc so R0 applies only on reflections and m<1 is
handled; reflectivity files now scale the weight. Changes results for R0<1.
Test_Guide_four_side compares with Guide and Elliptic_guide_gravity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The default empty filename skipped the grid, so nothing was transmitted. An
even hole count re-tested a stale column and propagated twice. Bounds now
default to 0 so xwidth/yheight work alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Neutrons were absorbed whenever the outer wall cylinder was left through top
or bottom, even past the channel exit. Changes results with vertical
divergence. Test_Pol_bender_tapering compares with Pol_bender.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on misses, fix 2theta binning; add Test_Monitors_cyl

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
willend and others added 4 commits November 29, 2026 13:57
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At large radius, rounding in the cylinder intersection exceeded the fixed
1e-10 m threshold, so a wall just reflected on was hit again at the same
point, costing an extra reflectivity factor each time (9% low at R=1e5).

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

willend commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Almost full coverage in McStas. May add the 2 SANS-comps and the optimiser-pair..

---------------------------------------
Comps with no examples (disregarding
sasmodels and obsolete categories)
---------------------------------------
Missing examples from contrib
- SANSCurve in contrib is not in any example
- SANS_Liposomes_Abs in contrib is not in any example
---------------------------------------
Missing examples from misc
- Shape_simple in misc is not in any example
---------------------------------------
Missing examples from monitors
---------------------------------------
Missing examples from obsolete
... Not reporting comps in obsolete
---------------------------------------
Missing examples from optics
- Place in optics is not in any example
---------------------------------------
Missing examples from samples
---------------------------------------
Missing examples from sasmodels
... Not reporting comps in sasmodels
---------------------------------------
Missing examples from sources
- Monitor_Optimizer in sources is not in any example
- Source_Optimizer in sources is not in any example
---------------------------------------
Missing examples from union
- Non_process in union is not in any example
- Template_process in union is not in any example
- Template_surface in union is not in any example
- Union_master_GPU in union is not in any example
---------------------------------------

willend and others added 4 commits November 29, 2026 15:16
…ures

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

SANS_Liposomes_Abs used an uninitialised inner radius in INITIALIZE.
Enable both comps in SANSsimple and Test_SANS (mock sphere curve).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same fix as Pol_bender. No change seen in Test_Vertical_Bender.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
willend and others added 9 commits November 29, 2026 17:39
TOF2Q_cyl_monitor: lambda unset for pixel other than 0/1.
Pol_bender_tapering: no propagation by unset time on entry miss.
FermiChopper: initialise c in FC_xzbrent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add acc routine and pass _particle for the RNG, as in Lens.

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

An unspaced "<x" was read as an HTML tag and cut the description short.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mcdoc HTML read <parameters=values> as a tag and dropped it.

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

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

<...> placeholders were swallowed as HTML tags by mcdoc.

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

willend commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

The failling test https://github.com/mccode-dev/McCode/actions/runs/46305431939/job/141480284593?pr=3219 hangs on a quite specific case of a 1-element vector vector = {val} init that mccode-antlr choked on - upstream PR contributed.

Everything else is green and a IMHO constitutes a long-overdue cleanup.

Merge!

@willend
willend merged commit 0717c7b into main Nov 30, 2026
27 of 28 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