McStasMcXtrace / McCode

The home of the McStas (neutrons) and McXtrace (x-rays) Monte-Carlo ray-tracing instrument simulation codes.
https://github.com/McStasMcXtrace/McCode/wiki
GNU General Public License v3.0
76 stars 54 forks source link

MCPL_input.comp seemingly does not "repeat" with repeat_count > 1 #1677

Closed willend closed 5 days ago

willend commented 3 weeks ago

Received this bug report from Marcell Wolf (TUM) via email:

we are working on our virtual TOFTOF in McStas. For this we are splitting our instrument in several parts to reduce the simulation times by producing and using virtual sources via MCPL input and output. Until now, we were working with McStas 2.7. for the virtual instrument because of problems with the Component TOFTOF_Monitor which I got from Mads. Now one of my collegue changed the TOFTOF_Monitor that we can use it now also under McStas 3.3 and 3.4. Now we found the problem when we read in the virtual source via MCPL input that it plays no role which value we will hand in for the "repeat_count". Everytime we receive the same amount of simulated neutrons on our detectors (the N-value). When we use the same Instrument file and components with McStas 2.7. the "repeat_count" work and we find and increased value of the simulated neutrons on the detectors. Until now we did not find the problem for the differences between Mcstas 3.3 or McStas 3.4 and McStas 2.7. Do you know where the problem is and how we can solve this problem? Attached you will find

Best regards

-- Dr. Marcell Wolf

The issue is confirmed with an MCPL_input instance of

COMPONENT mcpl_input = MCPL_input(
    filename="VS_6A_14000rpm_ratio5.mcpl",
    repeat_count=repeat)
    AT (0, 0, 0) RELATIVE PREVIOUS

It turns out that the issue is mostly one of missing documentation and/or sanity-checking of input parameters. Adding the relevant "smearing" parameters (values estimated by a quick run of pymcpltool --stats --gui VS_6A_14000rpm_ratio5.mcpl) allows the statistic to be duplicated repeat-fold:

COMPONENT mcpl_input = MCPL_input(E_smear=0.01, pos_smear=0.001, dir_smear=0.001,
    filename="VS_6A_14000rpm_ratio5.mcpl",
    repeat_count=repeat)
    AT (0, 0, 0) RELATIVE PREVIOUS
willend commented 3 weeks ago

Proposed solution: Exit in error if repeat_count > 1 and all smear-parameters put to 0 -> with prompt that user should set these smearing parameters.