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
69 stars 68 forks source link

ParticleMapsContainer crashes the kernel #462

Closed VeronikaVasickova closed 8 months ago

VeronikaVasickova commented 8 months ago

Describe the bug I created an instance of a ParticleMapsContainer. This object can be initialised and particles can be added into it. But calling any of its properties of methods crashes (such as getParticleIds, or when a lens is created, applyLens; see my minimal example below).

If I run the code exactly as in this example: https://crpropa.github.io/CRPropa3/pages/example_notebooks/galactic_lensing/lensing_cr.v4.html, this also crashes. That suggests the example is outdated.

The bug is not related to the physics in CRPropa.

To Reproduce

from crpropa import *

M = ParticleMapsContainer()

particleId = nucleusId(1,1) energy = 10 * EeV galCenter = Vector3d(-1,0,0) momentumVector = Vector3d(-1,0,0)

M.addParticle(particleId, energy, momentumVector)

M.getParticleIds()

Expected behaviour I expect this method to return particle IDs.

System (please complete the following information):

Additional context Other methods that I found also crash: M.getEnergies(particleId,), M.getMap(particleId, energy), or, after creating or downloading a lens from the link above, M.applyLens(lens) .

lukasmerten commented 8 months ago

Hey @VeronikaVasickova Thanks for reporting the issue. This is related to #448, #397 and other issues. The notebook is not outdated but is not working with current python versions. You could downgrade python to something earlier than 3.6, which might solve the issue. @rafaelab and others are working to solve that problem, which seems to fixed in this PR draft #457 for MacOS. However, a fix for Linux is not yet ready. Until then I can only suggest to work without the ParticleCollector or work with a pure c++ program, without using the python wrapping.

VeronikaVasickova commented 8 months ago

Hello Lukas, thank you very much for your answer and sorry for the delayed response. This helped a lot! Best, Veronika