Skip to content

mcrun: allow multiscan -M with list -L - #2618

Open
willend wants to merge 2 commits into
mainfrom
mcrun-allow-multiscan-with-list
Open

mcrun: allow multiscan -M with list -L#2618
willend wants to merge 2 commits into
mainfrom
mcrun-allow-multiscan-with-list

Conversation

@willend

@willend willend commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Free-form text area

Please describe what your PR is adding in terms of features or bugfixes:

  • Allow multidimensional scans with independent number of samples pr. parameter axis
  • Allow multidimensional scans from -L parameter lists
  • In case of non-numeric parameter list input (e.g. sample filenames), ensure an output that mcplot can handle (generate indices to go in e.g. mccode.dat)

Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Furter, please describe how / where and for what the tools were used:

Claude, via prompts:

Initial prompt:


New task relating to the mcrun tool:

mcrun can currently:

  • perform linear (or co-linear) parameter scans via -N[number] and param1=a,b (param2=c,d)
  • perform list-based parameter scans via -L and param1=a,b,c,d (param2=e,f,g,h)

The linear method can become multi-dimensional if -M is given (with the assumption that -N provides the same 'resolution' / number of samplings along all parameter dimensions)

Please:

In -M mode, allow different number of samplings along differnt dimensions (I am thinking via a 'list' -N=a,b,c,d
Allow to combine -M with -L which is not currently possible


Secondary prompt:


For a scan of this type which is now allowed
mcrun PSI_DMC.instr -L lambda=2,3 filename=Na2Ca3Al2F14.laz,YBaCuO.lau,Fe.laz,Cu.laz -M -d lambda_filename

(i.e. including parameters provided via list that are not numerical) the resulting scan-dataset (i.e. the mccode.sim/mccode.dat generated from mcrun) is not plottable (example attached).

I also attach mccode.dat and mccode.sim that is plottable, generated via

mcrun PSI_DMC.instr -L lambda=2,3 SPLITS=1,10,25,58 -M -d lambda_splits

Can you implement 'index-variable(s)' generated from non-numeric lists to go into the plotting output so that the generated mccode.dat/mccode.sim for such a scan is now plottable?

(a constraint is that the formal format of mccode.dat stays the same)



Development OS / boundary conditions

Please describe what OS you developed and tested your additions on, and if any special dependencies are required:


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 contains something else

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

@willend

willend commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

@jorobledo could you have a look at / review this small development? I guess it will come in handy for PaNRAID!

Once this is done there is a follow-up review task for you @farhi over at #2619 (builds on this PR - the commits from this one is available in that stack also.)

@jorobledo

Copy link
Copy Markdown
Contributor

I tested it, and it's looking cool! ran something like

mcrun FZJ_SANS_KWS2_AnySample.instr --format=NeXus -L sample=1,2,3 Dlen=5,10,16,20 -M -c

Seems very useful. What would be the option to merge two nexus files in one? Say you run two scans, each one creates a nexus, and then want to create a dataset from the two? Similar to your append, but more like a concatenate.

Other question, ca you set some kind of linspace or does it have to be the list of values separated by commas?

@willend

willend commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

I guess we can add an option to allow appending to an existing dataset, will see about that later.

-N now takes both a single value and a list of bins (between usual par=a,b) so yes linspace

-L is list mode par=a,d,f,z

Both can be combined with -M to become multi-dimensional.

@jorobledo

Copy link
Copy Markdown
Contributor

Yes, but the linear spacing is the same for all vars of the type var1=a,b var2=c,d . Maybe you want 10 points for var1 and 20 points for var2. Sometimes you also want logarithmic spacing (base 10 for example). These options would make it fully versatile for dataset generation. I guess at this point it's easier of course through python and just allow to concatenate nexus files conveniently.

@willend

willend commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Different number of points for par1 and par2 is there in the linear case with

-N2,10 par1=a,b par2=c,d -M

Log mode - can be done via lists and -M for now

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.

2 participants