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

how to compute the spectra of secondary gamma-rays? #25

Closed Qyun closed 9 years ago

Qyun commented 9 years ago

how to set the crpropa simulation to get secondary gamma-rays?

DavidWalz commented 9 years ago

As this is undocumented so far, we should provide an example of a photon simulation.

TobiasWinchen commented 9 years ago

Dear Qyun,

please find below an example script that creates photon output:

#!/usr/bin/env python
from crpropa import *   

m = ModuleList()    
m.add(SimplePropagation(0, 10 * Mpc))   

m.add(ElectronPairProduction(CMB, True))    
m.add(PhotoPionProduction(CMB, True))   
m.add(MinimumEnergy(1 * EeV))   
m.add(Observer1D()) 
m.add(PhotonOutput1D("photon_output.txt"))  
m.add(EventOutput1D("proton_output.txt"))   

# source setup  
source = Source()   
source.add(SourceParticleType(nucleusId(1, 1))) 
source.add(SourcePowerLawSpectrum(10 * EeV, 100 * EeV, -2)) 
source.add(SourceUniform1D(3 * Mpc, 100.00001 * Mpc))   

# run simulation    
m.setShowProgress(True) 
m.run(source, 10000, True)  

To propagate the photons you can use EleCa or Dint

crpropa.DintPropagation("photon_output.txt", "spectrumDINT.txt")
crpropa.EleCaPropagation("photon_output.txt", "photonsEleCa.dat")

Please note that the interface to the photon propagation is currently under development and might change in the future.

Cheers,

Tobias

Qyun commented 9 years ago

Dear Tobias, Sorry for replying to you so late.m.add(PhotonOutput1D("photon_output.txt")) m.add(EventOutput1D("proton_output.txt")) "photon_output.txt" which contain electron & positron as input file to compute the same Physical process―electromagnetic cascade by crpropa.DintPropagation("photon_output.txt", "spectrumDINT.txt")crpropa.EleCaPropagation("photon_output.txt", "photonsEleCa.dat")Why the photon we get in the two output file "spectrumDINT.txt"&"photonsEleCa.dat" don't consist with each other?And I found the file "proton_output.txt" contains both proton,electron and positron,but state message of the electron and positron didn't consist with the the electron and positron within the "photonsEleCa.dat" file, and the number of electron & positron in "photonsEleCa.dat" is much less than the ones in "spectrumDINT.txt" With kind regards!Qingyun Date: Sat, 23 May 2015 00:25:07 -0700 From: notifications@github.com To: CRPropa3@noreply.github.com CC: yangqingyun@outlook.com Subject: Re: [CRPropa3] how to compute the spectra of secondary gamma-rays? (#25)

Dear Qyun,

please find below an example script that creates photon output:

!/usr/bin/env python

from crpropa import *

m = ModuleList()
m.add(SimplePropagation(0, 10 * Mpc))

m.add(ElectronPairProduction(CMB, True))
m.add(PhotoPionProduction(CMB, True))
m.add(MinimumEnergy(1 * EeV))
m.add(Observer1D()) m.add(PhotonOutput1D("photon_output.txt"))
m.add(EventOutput1D("proton_output.txt"))

source setup

source = Source()
source.add(SourceParticleType(nucleusId(1, 1))) source.add(SourcePowerLawSpectrum(10 * EeV, 100 * EeV, -2)) source.add(SourceUniform1D(3 * Mpc, 100.00001 * Mpc))

run simulation

m.setShowProgress(True) m.run(source, 10000, True)

To propagate the photons you can use EleCa or Dint

crpropa.DintPropagation("photon_output.txt", "spectrumDINT.txt") crpropa.EleCaPropagation("photon_output.txt", "photonsEleCa.dat")

Please note that the interface to the photon propagation is currently under development and might change in the future.

Cheers,

Tobias

― Reply to this email directly or view it on GitHub.

TobiasWinchen commented 9 years ago

We now have an example to demonstrate the EM secondaries: http://nbviewer.ipython.org/github/CRPropa/CRPropa3-notebooks/blob/master/secondaries/photons.ipynb