[mcstas-users] Multiple sources - potential bug

Петр Коник 104pet104 at gmail.com
Sat Mar 21 20:07:46 CET 2026


Hi Peter,

Thanks for very quick reply and confirmation. Yeah, I figured out this is an unavoidable case, just never took a chance to think about that!

Best,
PK

> On 2026. Mar 21., at 20:04, Peter Kjær Willendrup <pkwi at dtu.dk> wrote:
> 
> Hi Peter,
> 
> 
>> On 21 Mar 2026, at 16.10, Петр Коник via mcstas-users <mcstas-users at mcstas.org> wrote:
>> 
>> Wanted to report (maybe not so) strange behavior with calculating beam intensities when several sources are used. The way I do it is to put EXTEND to the very first origin arm, where I flip a coin to choose which of two sources to use (e.g. for bi-spectral extraction) with WHEN condition.
>> 
>> The problem is that it looks like while each source now generates only half of the total number of trajectories, they still use the full number of them to estimate the flux “carried” by each of them. My solution is to artificially double the flux of the sources (given I generate 50/50 trajectories on each of two sources).
>> 
>> Don’t know if it’s intended behavior or not.
> 
> 
> This is in fact to be expected, but admittedly not written down explicitly anywhere (I think). The Source-components each normalise the later produced particle weights with respect to the --ncount ( mcget_ncount() ) at INITIALIZE time, whereas the EXTEND rand01() and the WHEN condition both happen at TRACE time. At INITIALIZE time there is (currently) no way of telling the sources that they are “not alone”.
>  
> This in fact the same for any set of  classical McStas components - each of them work under the assumption that they will see “all” of the neutrons. So if you e.g. to combine Single_crystal and Phonon_simple for an elastic-inelastic sample, the same type of weight-renormalisation must be made. 
> 
> Best,
> Peter
> 
> 
> Peter Kjær Willendrup
> Forskningsingeniør, Specialkonsulent
> 
> DTU Physics
> 
> <image001.gif>
> 
> 
> Technical University of Denmark
> 
> 
> <image002.gif>
> 
> 
> Department of Physics
> Fysikvej
> Building 307
> DK-2800 Kongens Lyngby
> 
> Main office at 
> ESS DMSC
> Building 305
> DK-2800 Kongens Lyngby
> 
> Direct +45 2125 4612
> Mobil +45 2125 4612
> Fax +45 4593 2399
> pkwi at fysik.dtu.dk
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20260321/b04c12f3/attachment.htm>


More information about the mcstas-users mailing list