Repository navigation
Union particle - #3095
Union particle#3095mads-bertelsen-agentic wants to merge 19 commits into
Conversation
|
GPU (nvc) build of Simplest fix: mark Not verified with an nvc build. |
|
When doing clangformat a problem was found I ran mccode-clangformat on the PR’s changed source files. It formats 41 of 43 files cleanly, but I left IncoherentPhonon_process.comp and Inhomogenous_incoherent_process.comp unchanged because the formatter breaks their one-line dispatch macros. For example, this macro: is reformatted into a macro line ending after the function call, with //break; on the next line. That puts break outside the macro, so the generated switch case can fall through. The same issue occurs in the other component’s dispatch macro. For this pull request the clangformating was reverted on the affected lines. |
|
@mads-bertelsen I have filed #3123 and have started an investigation to avoid breaking # instructions no matter how long. |
|
Running c-lint on Union_demos/demonstration produce what an LLM calls false positives. It's related to the mcdisplay code for union, and it seems there is underlying logic preventing that indices can get out of bounds, but cppcheck doesn't catch that and marks it as an error. Instrument and mcdisplay runs well without any errors / warnings. |
|
@mads-bertelsen sometimes I've tricked the lint'er past these types of things by a simple init e.g. |
|
There seems to something preventing the antlr version from building, but it seems to have to do with some dependency and not this code change |
|
No antlr passed, but a different test had this error: Edit: The root cause seemed to be an ubuntu server being unavailable so install failed, rerunning the job |
|
Thanks for this. Moving the Union callbacks over to Bug
Propagation
Simplicity
Compatibility
Scope: we'll take this one as it is. Going forward, please keep each PR to one well-defined concern (for example the API change, the fixes, and new options or tests separately). That makes review much faster. |
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Call particle helpers directly and restore the standard rectangular targeting macro in both flavours. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Use transport snapshots for temporary changes, retain RNG advancement, and keep diagnostic copies in safe modes. Cover snapshot and callback behavior in the Union particle regression. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Free-form text area
Please describe what your PR is adding in terms of features or bugfixes:
Refactors Union process, surface and logger callbacks to use the particle state directly in both McStas and McXtrace. This reduces duplicated state handling and adds an optional safe_mode to protect particle fields from unintended callback changes.
Along the way, the update fixes particle-frame transformations, RNG forwarding, photon absorption logging and several unnecessary particle copies. It also adds regression coverage under Tests_union.
Compatibility note: Custom Union callbacks must be updated to the particle-based API. RNG forwarding and skipping unused absorption samples can change seeded trajectories.
Declaration of use of AI-tools
opencode session with GPT-6.1 Terra - aim of switching to _particle approach
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)
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 raisedMy contribution includes a new component file
mcdocutility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)mccode-clangformattool to apply the standard McCode component indentation schemecontribcomponent categoryMy contribution includes a new instrument file
mcdocutility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)%Test:line (or a%TestScan:line for a parameter scan) to describe expected behaviourmcrun --c-lint"linter" and followed advice to remove most / all warnings that are raisedexampleshierarchy in a folder in the style ofexamples/ESS/New_stuff/New_stuff.instrexamplefolder, but if general use I have placed it in the globaldatafolder.My work touches / adds to the runtime lib code (.c,.h etc in multiple locations
common/lib/share,mccode/nlib/share,mcstas-comps/shareormcxtrace-comps/sharelibrary and runtime file (.c,.h,.h.in) has aTest_lib_<name>instrument inexamples/libtest/(McStas and/or McXtrace), with a%Test:line where the result can be checked. If it cannot be standalone, say why in the free-form text (e.g. needs a component or external package)