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

Error in setting up turbulent field #323

Closed PrantikS closed 3 years ago

PrantikS commented 3 years ago

from crpropa import *

set up random turbulent field

vgrid = Grid3f(Vector3d(0), 512, 30 kpc) initTurbulence(vgrid, 8 nG, 60 kpc, 800 kpc, -11. / 3, 42) Bfield = MagneticFieldGrid(vgrid)

When I am running this, I am getting the following error:

vgrid = Grid3f(Vector3d(0), 512, 30 * kpc) NameError: name 'Grid3f' is not defined

Can you help me out to resolve this issue?

adundovi commented 3 years ago

Hi @PrantikS, please download the latest version of CRPropa as the example that you tried is based on it.

PrantikS commented 3 years ago

Thanks, the latest version solved this issue. However, the latest version is showing the following error for the module, sim.add(PhotoPionProduction(CMB)) :

sim.add(PhotoPionProduction(CMB)) File "/home/prantik/.virtualenvs/crpropa/lib/python2.7/site-packages/crpropa/crpropa.py", line 7564, in init _crpropa.PhotoPionProduction_swiginit(self, _crpropa.new_PhotoPionProduction(photonField, photons, neutrinos, electrons, antiNucleons, limit, haveRedshiftDependence)) TypeError: Wrong number or type of arguments for overloaded function 'new_PhotoPionProduction'. Possible C/C++ prototypes are: crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >,bool,bool,bool,bool,double,bool) crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >,bool,bool,bool,bool,double) crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >,bool,bool,bool,bool) crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >,bool,bool,bool) crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >,bool,bool) crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >,bool) crpropa::PhotoPionProduction::PhotoPionProduction(crpropa::ref_ptr< crpropa::PhotonField >)

Is there any error installation error or something else?

adundovi commented 3 years ago

Use CMB() instead of CMB. Photon fields are now classes, not an enumerator. We have changed this recently (it is written in the changelog). I'll fix this in example notebooks soon.

PrantikS commented 3 years ago

Thanks a lot