CRPropa / CRPropa3

CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
https://crpropa.desy.de
GNU General Public License v3.0
65 stars 66 forks source link

Error in 4D propagation simulation with PhotoPionProduction module #414

Closed GDMarco closed 1 year ago

GDMarco commented 1 year ago

Describe the bug By running a simple CRPropa (version 3.2-37-g5364e8af) 4D simulation of propagating nuclei, an error related to the PhotoPionProduction module arises. Explicitly "error: no photon found in sampleEps, please make sure that photon field provides photons for the interaction by adapting the energy range of the tabulated photon field."

Is the bug related to the physics in CRPropa? No

To Reproduce One can simply run the example in the CRPropa documentation: https://crpropa.github.io/CRPropa3/pages/example_notebooks/sim4D/sim4D.v4.html . It is about the 4D propagation of protons.

Expected behavior It is expected the simulation of the 10000 protons' propagation. However, the error stops the code very soon.

System (please complete the following information):

Additional context If one rules out the processes related to the PhotoPionProduction modules (e.g. with the CMB and EBL) in the 4D propagation, the aforementioned example works. If one keeps the PhotoPionProduction modules and rules out the ones related to the Redshift (e.g. FutureRedshift(), ObserverRedshiftWindow(), SourceRedshiftEvolution(), etc.), the simulation succeeds. The example works if we consider the propagation of electrons or gamma-rays. It seems to be a conflict between the new release of the PhotoPionProduction module with the Redshift components.

lukasmerten commented 1 year ago

I can confirm this bug with the current master branch. I will take a closer look as soon as possible.

The problem seems to be connected to the concurrent use of FutureRedshift() and PhotoPionProduction(). Commenting either of the two modules makes the script run as expected.

Using Redshift() instead works. So it might be connected to allowing for negative redshift values (in FutureRedshift).

JulienDoerner commented 1 year ago

I also had a look and can confirm the bug.

The problem is independent of the PhotoPionProduction but is in the behaviour of the photon field IRB_Kneiske04 for negative redshifts. It seems that the photon density is set to 0 in this case, which lead to no possibility of sampling a photon from this distribution as the probability at each photon energy is 0.

In this plot I have taken the redshift scaling from the data table (blue solid) and from the photon field instance (orange, dashed). Both seems to be okay. But the photon density for a photon of $\epsilon = 0.1$ eV drops to 0 for $z< 0$.

redshift_scaling_density

GDMarco commented 1 year ago

Thanks for having a glance at that!

I also tried to use different EBL models (Gilmore, Dominguez, Franceschini etc.), however the error rises the same.