EGSnrc icon indicating copy to clipboard operation
EGSnrc copied to clipboard

Biased sampling of phase space source (C++) in parallel runs with ncase > no. of particles in phase space file

Open blakewalters opened this issue 2 months ago • 0 comments

Describe the bug Currently in parallel runs where ncase (total no. of histories) > Nphsp (no. of particles in phase space source), any "chunk" of the run for which the final history of the chunk > Nphsp generates a warning indicating that a suitable chunk of the phase space source cannot be found (confusing labelled an "illegal attempt to set a simulation chunk") then proceeds to use the last chunk of the phase space source that was successfully accessed (Note: usually close to, but not necessarily including, the end of the phase space data). Thus, there is the potential for sampling this last successfully accessed chunk of the phase space source over and over again.

To Reproduce

  1. Generate a small phase space file containing Nparticle particles
  2. Use it as a source in a simple egs++ simulation with ncase = 3*Nparticle
  3. Run a single parallel job using command line arguments -P 4 -f 1 -j 1
  4. Look in the _w1.egslog file and see the appearance of many "illegal attempt to set simulation chunk" warnings each followed by a message indicating that the same chunk of the phase space file (same first and last particle no.'s) is about to be reused.

Expected behavior Just like ncase is divided into (npar * nchunk) chunks, we need to divide Nparticle into (npar * nchunk) segments. Each chunk of the parallel run will then have its own designated segment of the phase space source outside of which it will not sample. This will ensure that we don't attempt to sample past the end of the phase space data and that as much of the phase space data as possible is sampled. This is similar to how we deal with parallel runs with phase space sources in the .mortran codes.

Operating system All applicable

EGSnrc version Develop branch

Additional context Add any other context about the problem here.

blakewalters avatar Apr 12 '24 18:04 blakewalters