Repository navigation
Conversation
…e in diagnostics Rename 7 diagnostic messages (read_hkl_data, INITIALIZE, TRACE, FINALLY) that referred to the parent component Single_crystal, and drop a stray extra hkl_info.sigma_i argument from the 'incoherent elastic scattering only' printf.
- Allocate the 4-channel structure-factor scratch array f_ once on the heap instead of per candidate hkl, and free it after the generation loop (its contents are copied into list[i].f, so a single reused allocation also scales to ~1e6 reflections). - Table_Free(&atoms) after use of the parsed atom table. - Free the reflection list, scratch array and atom table on all early-error returns (alloc failures, anisotropic-mosaic abort, tau_list OOM). - Use a temporary pointer for the list realloc so the original block is not lost on failure.
read_hkl_data now returns 0 on success (including the valid no-atom-file, incoherent-only case) and -1 on all errors (file read, allocation failures, unimplemented anisotropic mosaic). Previously 0 meant fatal and -1 was ambiguous, letting allocation failures silently continue with a NULL reflection list. INITIALIZE check inverted accordingly; a normal zero-reflection result no longer looks like an error.
- Add SM_list_compare and qsort the generated reflection list by |tau| before handing it to TRACE. The Ewald-sphere search breaks early on L[i].tau > tau_max assuming sortedness; without the sort most reflections were unreachable (physics fix). - Sanity-check the unit cell after computing the lattice vectors: zero-length or degenerate (co-planar) vectors previously led to division by zero / inf / NaN in the reciprocal lattice and hkl loops. Aborts with a descriptive error message.
Describe all 28 columns of the atom file (fractional positions, b[fm], gS/gL Lande factors, spin/orbital moment components along a,b,c, and the reserved j0*/j2* form-factor columns), including the b/10 unit convention and the >=14-column requirement for magnetic use. The block lives in the %D description section (next to the sample-shape notes) rather than under the atom_sites parameter in %P, where mcdoc drops multi-line parameter documentation.
Files with 7-13 data columns take the magnetic branch, but Table_Index clamps out-of-range indices to the last column, silently aliasing the missing moment components. Emit an explicit warning naming the file, column count, and expected layout.
and fix some typos
willend
marked this pull request as draft
November 13, 2026 18:18
Contributor
|
Converted to draft since you wrote "WIP and experimental do not merge yet!" |
…le_magnetic_crystal The branch's Single_magnetic_crystal gives PSD4PImon_I=1.19609e-05 at the default mctest settings (ncount 1e6, seed 1000, L0=4), verified over several seeds (1.20e-05..1.25e-05); Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
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
WIP and experimental do not merge yet!
These are some updated to the magnetic single crystal component
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:
This is tested on Ubuntu 26.04 through WSL
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 patches to an existing instrument file
mcdocutility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)mctestutility to test the instrument (please attachmcviewtestreport as screenshot in comments)mcrun --c-lint"linter" and followed advice to remove most / all warnings that are raised