Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom photon fields #218

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ef5a968
add option custom_photon_field
MHoerbe Dec 12, 2017
13a9a87
reset original content
MHoerbe Dec 12, 2017
d265cf5
Merge branch 'master' of https://github.com/CRPropa/CRPropa3
MHoerbe Aug 24, 2018
ddd20a6
Merge branch 'master' of https://github.com/CRPropa/CRPropa3
MHoerbe Dec 18, 2018
99fbb85
- adapt input and output parameters of the new SOPHIA code
MHoerbe Jan 1, 2019
cb44195
- remove unused parts of the code
MHoerbe Jan 1, 2019
6376344
implement ScalarGrid4d
MHoerbe Jan 1, 2019
47ef026
- implement custom photon field
MHoerbe Jan 1, 2019
e550ef4
implement ScalarGrid4d
MHoerbe Jan 1, 2019
30e88b5
- implement ScalarGrid4d
MHoerbe Jan 1, 2019
bb59f33
implement custom photon fields
MHoerbe Jan 1, 2019
04e1fc7
add higher time units {day, year, kyr, Myr, Gyr}
MHoerbe Jan 1, 2019
5623604
- implement custom photon fields
MHoerbe Jan 1, 2019
b93bf1b
- implement custom photon field
MHoerbe Jan 1, 2019
1509133
- implement custom photon fields
MHoerbe Jan 1, 2019
5d2b326
implement ScalarGrid4d
MHoerbe Jan 1, 2019
c25fad8
- implement custom photon fields
MHoerbe Jan 1, 2019
73f8162
update input parameters for PhotoPionProduction
MHoerbe Jan 1, 2019
ad714f1
unite changes by Julien Doerner with ScalarGrid4d
MHoerbe Jan 1, 2019
c2830f1
update test for spacing taking vector3d
MHoerbe Jan 1, 2019
ba18e5d
update test for spacing = vector3d
MHoerbe Jan 1, 2019
c309eb8
update test for spacing = vector3d
MHoerbe Jan 1, 2019
e57ef30
unite changes by Julien Doerner with ScalarGrid4d
MHoerbe Jan 1, 2019
3b7d6f6
update spacing to be vector3d
MHoerbe Jan 1, 2019
7b401ba
update ScalarGrid4d constructor to take spacing that is vector3d
MHoerbe Jan 1, 2019
5ebe39a
re-implement geometry and time-dependence
MHoerbe Jan 1, 2019
e476615
update constructor of ScalarGrid 4d setOrigin to take vector3d instea…
MHoerbe Jan 1, 2019
09babd0
correct for in-middle-of-box interpolation convention in CRPropa in e…
MHoerbe Jan 1, 2019
55c7f47
replace broken file
MHoerbe Jan 3, 2019
b544331
correct for component in kmin/max
MHoerbe Jan 3, 2019
795465e
consider potentially inequal spacing
MHoerbe Jan 3, 2019
71c6404
remove obsolete comments
MHoerbe Jan 3, 2019
981ac7e
replace grid spacing: double -> Vector3d
MHoerbe Jan 8, 2019
6647d23
replace grid spacing type: double -> Vector3d
MHoerbe Jan 8, 2019
bca745f
replace grid spacing data type: double -> Vector3d
MHoerbe Jan 8, 2019
4c6a17a
remove grid origin offset and put corresponding info in wiki page
MHoerbe Jan 9, 2019
094048d
add file to generate tabulated files for interaction modules from a p…
MHoerbe Jan 10, 2019
88dffdd
add file to convert photon field data of IRB models from the CRPropa-…
MHoerbe Jan 10, 2019
ca11bf0
add example picture of photon field for the Wiki page. May be but els…
MHoerbe Jan 10, 2019
5fddeee
improve learning effect of example photon field
MHoerbe Jan 10, 2019
a165971
fix typo
MHoerbe Jan 11, 2019
2efa624
add photon field test
MHoerbe Mar 6, 2019
d9867d2
update CMakeLists with photon field test and boris push
MHoerbe Mar 6, 2019
3579cf2
update photon background
MHoerbe Mar 6, 2019
0babab7
add borish push
MHoerbe Mar 6, 2019
b12b65d
include borish push
MHoerbe Mar 6, 2019
53f8ee9
update photon field naming convention
MHoerbe Mar 6, 2019
07b1bfd
include borish push
MHoerbe Mar 6, 2019
2354a7e
fix bug in secondaries' treatment #225
MHoerbe Mar 22, 2019
72d8141
add HadronicInteraction
MHoerbe Apr 14, 2019
f729dea
add space- & time-dependence to Hadronic Interaction
MHoerbe Apr 14, 2019
c4df65c
fix classifier bug
MHoerbe Apr 14, 2019
3cf60c7
add constructor for various input parameters
MHoerbe Apr 15, 2019
49789cf
fix indent
MHoerbe Apr 15, 2019
fee99c0
implement density interpolation dependent on variability
MHoerbe Apr 15, 2019
790c8bf
improve initialization of empty grids
MHoerbe Apr 15, 2019
ddda3aa
disable print to console
MHoerbe May 10, 2019
fa33d56
account for faulty sophiaevents
MHoerbe May 10, 2019
22b0a28
prevent production of photons with infinite energy
MHoerbe May 10, 2019
d06c29e
meet style criteria
MHoerbe May 13, 2019
9573b23
implement warning when nucleon with E <= 0 is created
MHoerbe May 27, 2019
72ffdf0
deactivate faulty candidates with E <= 0
MHoerbe May 27, 2019
3e74ce0
update warning message
MHoerbe May 27, 2019
9230f52
- add tag in TextPutput
MHoerbe May 27, 2019
b072679
delete file
MHoerbe May 27, 2019
1abd01c
implement overload of PhotoPionProduction for easy grid use
MHoerbe May 29, 2019
ce54caa
fix description string
MHoerbe Jun 10, 2019
fdbca27
update tag option
MHoerbe Jun 13, 2019
e7e8996
overload function for non-gridded initializations
MHoerbe Jun 13, 2019
dfea6b0
update EMPairProduction signature
MHoerbe Jun 13, 2019
ebd10d5
overload function for non-gridded initialization
MHoerbe Jun 13, 2019
54d04e0
improve sampling routine
MHoerbe Jun 13, 2019
cb453fd
update signatures
MHoerbe Jun 13, 2019
2a1eed7
ovoerload functions for improved handling
MHoerbe Jun 13, 2019
7bdf7ab
update signatures
MHoerbe Jun 13, 2019
43b568e
overload functions for better handling
MHoerbe Jun 13, 2019
5b757cc
cast time to const
MHoerbe Jun 13, 2019
1ae5001
overload functions for better handling
MHoerbe Jun 14, 2019
68d9dab
add tag function to synchrotron radiation
MHoerbe Jun 17, 2019
4a2d3c5
reduce scope of interpolation to save resources
MHoerbe Jun 20, 2019
2cd0044
update docstrings
MHoerbe Jun 20, 2019
7fbddfe
fix interpolation choice bug
MHoerbe Jul 15, 2019
9eb46f7
fix bug where s could have been larger than s_max (hard coded!) by in…
MHoerbe Jul 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,13 @@ OPTION(DOWNLOAD_DATA "Download CRProap Data files" ON)
if(DOWNLOAD_DATA)
message("-- Downloading data file from crpropa.desy.de ~ 50 MB")
file(DOWNLOAD
https://www.desy.de/~crpropa/data/interaction_data/data.tar.gz-CHECKSUM
# https://www.desy.de/~crpropa/data/interaction_data/data.tar.gz-CHECKSUM
https://github.com/Froehliche-Kernschmelze/CRPropa3-data/raw/implement_custom_photon_field/data.tar.gz-CHECKSUM
${CMAKE_BINARY_DIR}/data.tar.gz-CHECKSUM)
file(STRINGS ${CMAKE_BINARY_DIR}/data.tar.gz-CHECKSUM DATA_CHECKSUM LIMIT_COUNT 1 LENGTH_MINIMUM 32 LENGTH_MAXIMUM 32)
file(DOWNLOAD
https://www.desy.de/~crpropa/data/interaction_data/data.tar.gz
# https://www.desy.de/~crpropa/data/interaction_data/data.tar.gz
https://github.com/Froehliche-Kernschmelze/CRPropa3-data/raw/implement_custom_photon_field/data.tar.gz
${CMAKE_BINARY_DIR}/data.tar.gz
EXPECTED_MD5 "${DATA_CHECKSUM}")
message("-- Extracting data file")
Expand Down Expand Up @@ -352,6 +354,7 @@ add_library(crpropa SHARED
src/module/EMTripletPairProduction.cpp
src/module/ElasticScattering.cpp
src/module/ElectronPairProduction.cpp
src/module/HadronicInteraction.cpp
src/module/HDF5Output.cpp
src/module/NuclearDecay.cpp
src/module/Observer.cpp
Expand All @@ -363,7 +366,8 @@ add_library(crpropa SHARED
src/module/PhotonEleCa.cpp
src/module/PhotonOutput1D.cpp
src/module/PropagationCK.cpp
src/module/Redshift.cpp
src/module/PropagationBP.cpp
src/module/Redshift.cpp
src/module/RestrictToRegion.cpp
src/module/SimplePropagation.cpp
src/module/SynchrotronRadiation.cpp
Expand Down Expand Up @@ -498,6 +502,10 @@ if(ENABLE_TESTING)
target_link_libraries(testAdvectionField crpropa gtest gtest_main pthread ${COVERAGE_LIBS})
add_test(testAdvectionField testAdvectionField)

add_executable(testPhotonField test/testPhotonField.cpp)
target_link_libraries(testPhotonField crpropa gtest gtest_main pthread ${COVERAGE_LIBS})
add_test(testPhotonField testPhotonField)

add_executable(testDensity test/testDensity.cpp)
target_link_libraries(testDensity crpropa gtest gtest_main pthread ${COVERAGE_LIBS})
add_test(testDensity testDensity)
Expand Down
175 changes: 175 additions & 0 deletions helperFiles/convert_photonField.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
"""
purpose: convert IRB photon field data from external sources to
a unified format for CRPropa to read. The 7 photon fields that can be converted
by this script are:
IRB_Kneiske04, IRB_Stecker05, IRB_Finke10, IRB_Dominguez11,
IRB_Gilmore12, IRB_Stecker16_upper, IRB_Stecker16_lower
usage: this file should be placed in the CRPropa-data/ folder
output: .txt files named by their field name
Written by Mario Hörbe ([email protected])
"""

import numpy as np
import pandas as pd
import os

eV = 1.60217657e-19 # [J]
c0 = 299792458 # [m/s]
h = 6.62606957e-34 # [m^2 kg / s]


def IRB_Stecker05(fileDir):
name = 'IRB_Stecker05'
info = '# cosmic infrared and optical background radiation model of Stecker at al. 2005'
redshift = np.linspace(0, 5, 26)
filePath = fileDir + "EBL_Stecker_2005/data2.txt"
d = np.genfromtxt(filePath, unpack=True)
eps = 10**d[0] # [eV]
n = 10**d[1:] # [1/cm^3]
n /= eps # [1/eVcm^3]
n = pd.DataFrame(n)
photonField = []
energy = []
for col in n.columns:
energy.append(eps[col])
photonField.append(n[col].values)
createField(name, info, energy, redshift, photonField)


def IRB_Gilmore12(fileDir):
name = "IRB_Gilmore12"
info = "# These tables contain the data for the background flux and associated optical depths of gamma rays for the WMAP5+Fixed ('fixed') and Evolving Dust ('fiducial') models presented in Gilmore, Somerville, Primack, and Dominguez (2012), ArXiv:1104.0671v2"
filePath = fileDir + "EBL_Gilmore_2012/eblflux_fiducial.dat"
redshift = [0.0,0.015,0.025,0.044,0.05,0.2,0.4,0.5,0.6,0.8,1.0,1.25,1.5,2.0,2.5,3.0,4.0,5.0,6.0,7.0]
d = np.genfromtxt(filePath, unpack=True)
wavelength = d[0] # angstrom
eps = 12.39842e3 / wavelength # [eV]
photonField = []
energy = []
d = pd.DataFrame(d)
for i in range(len(eps)):
fieldSlice = np.array(list(d[i])[1:]) * 4*np.pi /(100*c0) *1e-10 *6.2415091e11 # eV/cm^3
fieldSlice /= eps[i]**2 # 1/eVcm^3
photonField.append(fieldSlice / eV) # /eV?!
energy.append(eps[i])
# invert, because lambda is antiprop to energy
photonField = [x for x in reversed(photonField)]
energy = [e for e in reversed(energy)]
createField(name, info, energy, redshift, photonField)


def IRB_Finke10(fileDir):
name = "IRB_Finke10"
redshift = np.round(np.linspace(0,4.99,500), 2)
info = "# Extragalactic background light model from Finke et al. 2010, DOI:10.1088/0004-637X/712/1/238, Files obtained from http://www.phy.ohiou.edu/~finke/EBL/"
fileDir = fileDir + "EBL_Finke_2010/"
fileList = os.listdir(fileDir)
d = pd.DataFrame()
col = 0
for file in sorted(fileList):
if "README.txt" not in file:
data = np.genfromtxt(fileDir + file, unpack=True)
# eps = data[0]
eps = data[0] # [eV]
data = pd.DataFrame(data[1],columns=[col/100])
col += 1
d = pd.concat([d,data], axis=1, join_axes=[data.index])
photonField = []
energy = []
for i,e in enumerate(eps):
dens = np.array(list(d.iloc[i])) * 6.2415091e11 / eps[i]**2 # [1/eVcm^3]
photonField.append(dens)
energy.append(eps[i])
createField(name, info, energy, redshift, photonField)


def IRB_Dominguez11(fileDir):
name = "IRB_Dominguez11"
info = "# EBL intensities for the paper >Extragalactic background light inferred from AEGIS galaxy-SED-type fractions<, A. Dominguez et al., 2011, MNRAS, 410, 2556"
redshift = np.array([0,0.01,0.03,0.05,0.1,0.2,0.3,0.4,0.5,0.6,0.8,1.0,1.25,1.5,2.0,2.5,3.0,3.9])
filePath = fileDir + "EBL_Dominguez_2011/ebl_dominguez11.out"
d = np.genfromtxt(filePath, unpack=False)
eps = [1.239842/fieldSlice[0]*eV for fieldSlice in d] # [eV] | 1.238842 = h*c/1µ eV
# nW->W : J->eV : 1/m³->1/cm³ : 1/sm²sr->1/m³
n = np.array([fieldSlice[1:] *1e-9 *eV /1e6 /eps[i]**2 * (4*np.pi/c0) for i,fieldSlice in enumerate(d)]) # [1/eVcm^3]
energy = []
for i,x in enumerate(n):
energy.append(eps[i]/eV)
photonField = [x for x in reversed(n)]
energy = [e for e in reversed(energy)]
createField(name, info, energy, redshift, photonField)


def IRB_Stecker16_lower(fileDir):
name = "IRB_Stecker16_lower"
info = "# Extragalactic background light model from Stecker et al. 2016, DOI:10.3847/0004-637X/827/1/6 <An Empirical Determination of the Intergalactic Background Light from UV to FIR Wavelengths Using FIR Deep Galaxy Surveys and the Gamma-ray Opacity of the Universe>"
redshift = np.linspace(0, 5, 501)
filePath = fileDir + "EBL_Stecker_2016/comoving_enerdens_lo.csv"
d = np.genfromtxt(filePath, delimiter=',')
eps = 10**np.arange(-2.84, 1.14001, 0.01) # [eV]
nu = eps * eV / h # [Hz]
photonField = []
energy = []
for i,dens in enumerate(d):
d[i] = d[i] * 6.2415091e11 * nu[i] / eps[i]**2 # 1/eVcm^3
photonField.append(d[i])
energy.append(eps[i])
createField(name, info, energy, redshift, photonField)


def IRB_Stecker16_upper(fileDir):
name = "IRB_Stecker16_upper"
info = "# Extragalactic background light model from Stecker et al. 2016, DOI:10.3847/0004-637X/827/1/6 <An Empirical Determination of the Intergalactic Background Light from UV to FIR Wavelengths Using FIR Deep Galaxy Surveys and the Gamma-ray Opacity of the Universe>"
redshift = np.linspace(0, 5, 501)
filePath = fileDir + "EBL_Stecker_2016/comoving_enerdens_up.csv"
d = np.genfromtxt(filePath, delimiter=',')
eps = 10**np.arange(-2.84, 1.14001, 0.01) # [eV]
nu = eps * eV / h # [Hz]
photonField = []
energy = []
for i,dens in enumerate(d):
d[i] = d[i] * 6.2415091e11 * nu[i] / eps[i]**2 # 1/eVcm^3
photonField.append(d[i])
energy.append(eps[i])
createField(name, info, energy, redshift, photonField)


def IRB_Kneiske04(fileDir):
name = "IRB_Kneiske04"
info = "# IRO spectrum from Tanja Kneiske et al. obtained from O. E. Kalashev (http://hecr.inr.ac.ru/)"
redshift = np.linspace(0,5,51)
filePath = fileDir + "EBL_Kneiske_2004/all_z"
d = np.genfromtxt(filePath)
photonField = []
energy = []
for i,fieldSlice in enumerate(d):
for j,entry in enumerate(fieldSlice):
if j != 0:
d[i][j] /= 1e6 # 1/eVm^3 -> 1/eVcm^3
photonField.append(fieldSlice[1:])
energy.append(fieldSlice[0])
createField(name, info, energy, redshift, photonField)


def createField(name, info, energy, redshift, photonField):
with open(name+".txt", 'w') as f:
f.write(info+"\n")
f.write("# energy / eV:\n")
np.savetxt(f, [energy], fmt="%1.6e", delimiter=" ")
f.write("# redshift:\n")
np.savetxt(f, [redshift], fmt="%1.2f", delimiter=" ")
f.write("# photon field density / 1/eVcm^3:\n")
np.savetxt(f, photonField, fmt="%1.6e", delimiter=" ")
print("done: " + name)


if __name__ == "__main__":

fileDir = "/tables/"
IRB_Kneiske04(fileDir)
IRB_Stecker05(fileDir)
IRB_Finke10(fileDir)
IRB_Dominguez11(fileDir)
IRB_Gilmore12(fileDir)
IRB_Stecker16_upper(fileDir)
IRB_Stecker16_lower(fileDir)
Loading