tudo-astroparticlephysics / PROPOSAL

Monte Carlo Simulation propagating charged Leptons through Media as C++ Library
GNU Lesser General Public License v3.0
35 stars 21 forks source link

make interactions problem for specific energy cuts #375

Open pascalgutjahr opened 1 year ago

pascalgutjahr commented 1 year ago

The function collection.interaction = pp.make_interaction(cross, True) seems to be an infinite loop for v_cut = 0.01. In my case, v_cut = 0.05 worked totally fine. This was also tested for three different energy cuts.

I have tested this with the following script example:

import proposal as pp
import numpy as np

e_cut = 500
v_cut = 0.01 # 0.05 
cont_rand = True

args = {
        "particle_def": pp.particle.MuMinusDef(),
        "target": pp.medium.Ice(),
        "interpolate": True,
        "cuts": pp.EnergyCutSettings(e_cut, v_cut, cont_rand)
        }

cross = pp.crosssection.make_std_crosssection(**args)
collection = pp.PropagationUtilityCollection()
collection.interaction = pp.make_interaction(cross, True)
Jean1995 commented 1 year ago

Very weird... I can confirm this issue. But I can easily create the table from C++, and I can even read the created table from python...

Jean1995 commented 1 year ago

It looks likes this happens because PROPOSAL tries to print out too many logging warnings at once (due to dNdx becoming negative at specific points), which somehow breaks python...

I've never seen such a problem before. The "quick fix" solution would be to just suppress these messages by using

pp.logging.set_loglevel(pp.logging.loglevel.off).

You may also just put this command before you invoke make_interaction, and directly restore the default by calling

pp.logging.set_loglevel(pp.logging.loglevel.warn) afterwards.