How to kill the secondaries processes totally

I’ve set up an example of carbon ion point source irradiating water, aiming to eliminate the processes of secondary particles with Z=1 to 5 using usrmed.f . My approach involved considering three key components: heavy fragments defined in include/fheavy.inc , the rest of the secondaries in include/genstk.inc , and the residual nucleus (if any) in include/resnuc.inc .https://fluka-forum.web.cern.ch/t/scoring-the-information-of-all-the-secondaries-from-inelastic-nuclear-interactions/2569/3 I attempted to “kill” these particles’ processes by setting the WEE =ZERZER using usrmed.f, and then scoring the dose to verify.
When setting the particle count to 10,000, secondary particles of H, He, Li, and B were successfully eliminated with no residual dose, but Be particles still remained. However, when the particle count was increased to 100,000, the dose contributions from all secondary particles were non-zero, indicating that the processes for all secondary particles were not successfully killed.The magnitude of the summed dose is in the order of 10^-10.
I have uploaded example files for Be and H and seek guidance on what might be going wrong.
usrmed_Be.f (3.3 KB)
usrmed_H.f (4.0 KB)
KILL_Be.inp (1.3 KB)
KILL_H.inp (1.3 KB)

Dear Richard,

Thank you for reaching out on the FLUKA forum.
Please allow me a few days to inspect your inquiry and come back to you with a reply.
Best regards,

Tommaso

Dear Tommaso
Thank you for your prompt response. I appreciate your attention to my inquiry
Looking forward to hearing from you soon.

Best regards

Dear Richard,

sorry for the late reply. I took some time to consider your question and engaged in useful discussions with colleagues. Below, you will find my proposal and some accompanying considerations.

FLUKA offers a card, THRESHOLd, with which it is possible to set thresholds for elastic and inelastic hadron reactions. By specifying a sufficiently high threshold, you could hence suppress the secondaries. This approach is surely powerful and immediate, but also crude.
Moreover, the approach may not align with your objectives, because the carbon beam would not be depleted in a natural way, with all the consequences that you can image. Nevertheless, it’s valuable to mention this option for the benefit of users.

FLUKA also includes the mdstk.f user routine (manual). This routine is called without the need of any specific card and is definitely suitable for suppressing the secondaries; in fact, it is designed for the management of the stack of secondaries. An older post discusses this topic and could provide you with some useful insights. Also there, the approach involved looping through the stacks and applying particle filtering.

mdstck.f is called after a nuclear interaction in which at least one secondary particle has been produced, before any biasing is applied, to decide which secondary will be loaded in the main stack for further transport (quoting the manual). This is why, generally speaking, this solution is definitely interesting. It is worth noting that acting on secondaries has an impact on energy conservation.

Regarding your implementation, despite the use of usrmed.f might be non-standard, I would say that much of the logic is there. A robust implementation of if/else conditions can filter out the particles that you want to exclude. You are also looking for negative numbers in generalised particles as in this post.

I would suggest to give mdstck.f a try.

If you want to explore the usrmed.f implementation further, my only idea would be to look also for heavy residuals (I was inspired by this example of the Fluka course, slide 22, last lines of code). My guess is that a contribution might come from this, but further testing would be needed.

I hope that this can be a good starting point for your simulation.
Best regards,

Tommaso