Repository navigation
Fix MPI polarization monitor statistics - #3057
Draft
mads-bertelsen-agentic wants to merge 6 commits into
Draft
mads-bertelsen-agentic wants to merge 6 commits into
mads-bertelsen-agentic wants to merge 6 commits into
Conversation
mads-bertelsen-agentic
marked this pull request as draft
November 6, 2026 13:17
Contributor
|
Good to have as an early blueprint, I think we need a centralised solution, so
yes maybe something like that. At least I would not like addition of this MPI-mangling stuff across the board "per monitor". Longer / more complete review / thoughts later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Free-form text area
Lukas Beddrich from the BIFROST team informed me of some odd findings on the polarization monitors when using mpi. The simulations and issues were discovered by Ewout Voorrips. I had an LLM look at a simple fix, and so the below is a suggestion that seems to fix the issue, but it requires components to be aware of MPI merging. That seems to be necessary because the current DETECTOR_ macros make assumptions about errors based on the recorded number being an intensity rather than a polarization, which have different properties.
Maybe instead we should have appropriate DETECTOR_ macros that handle polarization specific issues?
LLM explanation of the issue and fix:
Fix MPI polarization monitor statistics
Fix MPI aggregation and uncertainty calculations in
Pol_monitorandPSD_Pol_monitor.Previously,
PSD_Pol_monitornormalized polarization before passing data tothe generic detector output path, which performed a second MPI reduction.
This caused a fully polarized beam to report polarization equal to the number
of MPI nodes.
The monitors now:
Testing
Tested on macOS using the
mcstas-dev-agentenvironment:Test_pol_idealinstrument, serial and with two MPI ranks.clangandmpicc, including warning builds.The fixed MPI regression reports polarization 1 per PSD pixel with
near-zero uncertainty, instead of polarization equal to the MPI node count.
Declaration of use of AI-tools
Development OS / boundary conditions
Please describe what OS you developed and tested your additions on, and if any special dependencies are required:
OS X 14.6.1 (23G93) in UTM virtual machine
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