nrc-cnrc / EGSnrc

Toolkit for Monte Carlo simulation of ionizing radiation — Trousse d'outils logiciels pour la simulation Monte Carlo du rayonnement ionisant
http://nrc-cnrc.github.io/EGSnrc
GNU Affero General Public License v3.0
243 stars 146 forks source link

In BEAMnrc phsp files are not overwritten properly when re-rerunning #1014

Open rtownson opened 1 year ago

rtownson commented 1 year ago

Describe the bug When you run the same simulation repeatedly, the new particles are just added to the end of the existing phase-space, and the header is updated to correspond only to the new particles that were added. This results in an invalid phase-space, where the header doesn't correspond to the full size of the file. New simulations of the same input file should really overwrite the existing phsp, not append, or there should be an option to append and the header updated appropriately.

EGSnrc version Tested on v2023 but this has been a bug for a very long time.

crcrewso commented 1 year ago

I've wondered about this for a long time. Either manually prepping the folder before any run or moving the previous result files into a 'prev run' folder. Do you have an idea about the behaviour that EGSnrc should have?

ftessier commented 1 year ago

One option is to prevent running (with an appropriate error message) if there is already a phase space file of the same name present in the folder. The current behaviour (appending) could be allowed when the restart option is selected.

blakewalters commented 3 months ago

@rtownson: I never knew this was an issue! There should be a relatively easy fix to ensure that a BEAMnrc overwrites its previous phase space, unless, of course, it's a restart. I'll take a look.

blakewalters commented 3 months ago

@rtownson: I'm not able to reproduce this issue. Are you referring to cases where the no. of particles scored in the 2nd run, Nscore_2, is less than that scored in the first run, Nscore_1, in which case, data for the first Nscore_2 particles is overwritten with the phase space data from the 2nd run (and the header is rewritten to reflect data scored for the 2nd run), but the size of the phase space file remains what it was for the Nscore_1 particles from the first run (i.e., Nscore_1*28+28 instead of Nscore_2*28+28)?