Exemplo n.º 1
0

eV = 1.60217657e-19
gamma = logspace(6, 14, 201)  # tabulated UHECR Lorentz-factors


# cross sections for A < 12 (various sources)
ddir1 = 'tables/PD_external/'
isotopes1 = genfromtxt(ddir1 + 'isotopes.txt')
x = genfromtxt(ddir1+'eps.txt') * eV * 1e6  # [J]
n = len(x)
d1sum = genfromtxt(ddir1+'xs_sum.txt',
    dtype=[('Z',int), ('N',int), ('xs','%if8'%n)])
d1exc = genfromtxt(ddir1+'xs_excl.txt',
    dtype=[('Z',int), ('N',int), ('ch',int), ('xs','%if8'%n)])
eps1 = iR.romb_pad_logspaced(x, 513)  # padding
xs1sum = array([iR.romb_pad_zero(x, 513) for x in d1sum['xs']])*1e-31
xs1exc = array([iR.romb_pad_zero(x, 513) for x in d1exc['xs']])*1e-31


# cross sections for A >= 12 (TALYS)
ddir2 = 'tables/PD_Talys1.6_Khan/'
# ddir2 = 'tables/PD_Talys1.6_Geant4/'
isotopes2 = genfromtxt(ddir2 + 'isotopes.txt')
x = genfromtxt(ddir2+'eps.txt') * eV * 1e6  # [J]
n = len(x)
d2sum = genfromtxt(ddir2+'xs_sum.txt',
    dtype=[('Z',int), ('N',int), ('xs','%if8'%n)])
d2exc = genfromtxt(ddir2+'xs_thin.txt',
    dtype=[('Z',int), ('N',int), ('ch',int), ('xs','%if8'%n)])
eps2 = iR.romb_pad_logspaced(x, 513)  # padding
Exemplo n.º 2
0
# load cross section data from TALYS
ddir = 'tables/PD_Talys1.8_Khan/'
eps = np.genfromtxt(ddir + 'eps_elastic.txt'
                    ) * eV * 1e6  # nuclear rest frame photon energies [J]
data = np.genfromtxt(ddir + 'xs_elastic.txt',
                     dtype=[('Z', int), ('N', int), ('xs', '%if8' % len(eps))])

# only consider TALYS cross sections for A >= 12
idx = (data['Z'] + data['N']) >= 12
data = data[idx]

# factor out the principal scaling given by the TRK formula: sigma_int ~ Z*N/A
data['xs'] /= (data['Z'] * data['N'] / (data['Z'] + data['N']))[:, np.newaxis]

# pad cross sections to next larger 2^n + 1 tabulation points for Romberg integration
eps = iR.romb_pad_logspaced(eps, 513)
xs = np.array([iR.romb_pad_zero(x, 513) for x in data['xs']]) * 1e-31

for field in fields:
    print(field.name)

    # calculate the interaction rate, averaged over all isotopes
    rate = np.mean([iR.calc_rate_eps(eps, x, gamma, field) for x in xs],
                   axis=0)
    fname = folder + '/rate_%s.txt' % field.name.split('_')[0]
    try:
        git_hash = gh.get_git_revision_hash()
        header = (
            "Average interaction rate for elastic scattering of %s photons off nuclei\n"
            % field.info + "Produced with crpropa-data version: " + git_hash +
            "\n" +

# Load cross section data from TALYS
ddir = 'tables/PD_Talys1.8_Khan/'
eps  = genfromtxt(ddir+'eps_elastic.txt') * eV * 1e6  # nuclear rest frame photon energies [J]
data = genfromtxt(ddir+'xs_elastic.txt', dtype=[('Z',int), ('N',int), ('xs','%if8'%len(eps))])

# Only consider TALYS cross sections for A >= 12
idx = (data['Z'] + data['N']) >= 12
data = data[idx]

# Factor out the principal scaling given by the TRK formula: sigma_int ~ Z*N/A
data['xs'] /= ( data['Z'] * data['N'] / (data['Z'] + data['N']) )[:,newaxis]

# Pad cross sections to next larger 2^n + 1 tabulation points for Romberg integration
eps = iR.romb_pad_logspaced(eps, 513)
xs  = array([iR.romb_pad_zero(x, 513) for x in data['xs']]) * 1e-31


for field in [photonField.CMB(), photonField.EBL_Gilmore12()]:
    print (field.name)

    # Calculate the interaction rate, averaged over all isotopes
    rate = mean([iR.calc_rate_eps(eps, x, gamma, field) for x in xs], axis=0)

    savetxt('data/ElasticScattering_%s.txt' % field.name.split('_')[0],
        rate, fmt='%g',
        header='Average interaction rate for elastic scattering of %s photons off nuclei\nScale with Z*N/A for nuclei\n1/lambda [1/Mpc] for log10(gamma) = 6-14 in 201 steps' % field.info)

    # Calculate CDF for background photon energies, averaged over all isotopes
    CDF = zeros((len(gamma), len(eps)))
import photonField
import interactionRate


eV = 1.60217657e-19
gamma = logspace(6, 14, 201)  # tabulated UHECR Lorentz-factors


# Load cross sections for A < 12
ddir1 = 'tables/PD_external/'
isotopes1 = genfromtxt(ddir1 + 'isotopes.txt')
eps = genfromtxt(ddir1 + 'eps.txt')
d1sum = genfromtxt(ddir1 + 'xs_sum.txt', dtype=[('Z',int), ('N',int), ('xs','%if8'%len(eps))])
d1exc = genfromtxt(ddir1 + 'xs_excl.txt', dtype=[('Z',int), ('N',int), ('ch',int), ('xs','%if8'%len(eps))])
# Pad cross sections to next larger 2^n + 1 tabulation points for Romberg integration and convert to SI units
eps1 = interactionRate.romb_pad_logspaced(eps, 513) * eV * 1e6
xs1sum = array([interactionRate.romb_pad_zero(x, 513) for x in d1sum['xs']]) * 1e-31
xs1exc = array([interactionRate.romb_pad_zero(x, 513) for x in d1exc['xs']]) * 1e-31


# Load cross sections for A >= 12 (TALYS)
ddir2 = 'tables/PD_Talys1.8_Khan/'
isotopes2 = genfromtxt(ddir2 + 'isotopes.txt')
eps = genfromtxt(ddir2+'eps.txt')
d2sum = genfromtxt(ddir2+'xs_pd_sum.txt', dtype=[('Z',int), ('N',int), ('xs','%if8'%len(eps))])
d2exc = genfromtxt(ddir2+'xs_pd_thin.txt', dtype=[('Z',int), ('N',int), ('ch',int), ('xs','%if8'%len(eps))])
# Only consider cross sections for A > 12
d2sum = d2sum[(d2sum['Z'] + d2sum['N']) >= 12]
d2exc = d2exc[(d2exc['Z'] + d2exc['N']) >= 12]
# Pad cross sections to next larger 2^n + 1 tabulation points for Romberg integration and convert to SI units
eps2 = interactionRate.romb_pad_logspaced(eps, 513) * eV * 1e6
Exemplo n.º 5
0
gamma = np.logspace(6, 14, 201)  # tabulated UHECR Lorentz-factors

# ----------------------------------------------------
# Load cross sections for A < 12
# ----------------------------------------------------
ddir1 = 'tables/PD_external/'
isotopes1 = np.genfromtxt(ddir1 + 'isotopes.txt')
eps = np.genfromtxt(ddir1 + 'eps.txt')
d1sum = np.genfromtxt(ddir1 + 'xs_sum.txt',
                      dtype=[('Z', int), ('N', int),
                             ('xs', '%if8' % len(eps))])
d1exc = np.genfromtxt(ddir1 + 'xs_excl.txt',
                      dtype=[('Z', int), ('N', int), ('ch', int),
                             ('xs', '%if8' % len(eps))])
# Pad cross sections to next larger 2^n + 1 tabulation points for Romberg integration and convert to SI units
eps1 = interactionRate.romb_pad_logspaced(eps, 513) * eV * 1e6
xs1sum = np.array([interactionRate.romb_pad_zero(x, 513)
                   for x in d1sum['xs']]) * 1e-31
xs1exc = np.array([interactionRate.romb_pad_zero(x, 513)
                   for x in d1exc['xs']]) * 1e-31

# ----------------------------------------------------
# Load cross sections for A >= 12 (TALYS)
# ----------------------------------------------------
ddir2 = 'tables/PD_Talys1.8_Khan/'
isotopes2 = np.genfromtxt(ddir2 + 'isotopes.txt')
eps = np.genfromtxt(ddir2 + 'eps.txt')
d2sum = np.genfromtxt(ddir2 + 'xs_pd_sum.txt',
                      dtype=[('Z', int), ('N', int),
                             ('xs', '%if8' % len(eps))])
d2exc = np.genfromtxt(ddir2 + 'xs_pd_thin.txt',