-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathssc+eic.py
138 lines (120 loc) · 3.04 KB
/
ssc+eic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import astropy.units as u
import numpy as np
from astropy.constants import c
import matplotlib
matplotlib.rcParams['text.usetex'] = True
import matplotlib.pyplot as plt
import naima
from naima.models import (
ExponentialCutoffBrokenPowerLaw,
InverseCompton,
Synchrotron,
)
# Blob parameters
B = 1.e-3 * u.Gauss # magnetic field
R = 1.e18 * u.cm # radius
Gamma = 20. # bulk Lorentz factor
theta = 5*u.degree # viewing angle
delta = 1. / (Gamma * ( 1 - np.sqrt(1-Gamma**-2) * np.cos(theta) ))
# BLR parameters
T = 80 * u.K
w = 1 * u.eV * u.cm**-3
# electron distributions
# Model: ExponentialCutoffBrokenPowerLaw
# parameters for comoving frame
amplitude = 1.e35 / u.eV
e_0 = 1 * u.TeV # normalization energy
e_break = 10 * u.GeV
alpha_1 = 2.
alpha_2 = 3.
e_cutoff = 1 * u.TeV
beta = 1. # exponential cutoff rapidity
Emin = 1 * u.GeV
Emax = 10 * u.TeV
comoving = ExponentialCutoffBrokenPowerLaw(
amplitude = amplitude,
e_0 = e_0,
e_break = e_break,
alpha_1 = alpha_1,
alpha_2 = alpha_2,
e_cutoff = e_cutoff,
beta = beta,
)
lab = ExponentialCutoffBrokenPowerLaw(
amplitude = amplitude * delta ** 3,
e_0 = e_0 * delta,
e_break = e_break * delta,
alpha_1 = alpha_1,
alpha_2 = alpha_2,
e_cutoff = e_cutoff * delta,
beta = beta ,
)
# blob emission
SYN = Synchrotron(comoving, B=B, Eemax=Emax, Eemin=Emin)
# Compute photon density spectrum from synchrotron emission
Esy = np.logspace( np.log10(((Emin/u.TeV)**2*(B/u.Gauss)).cgs.value ) + 3 , np.log10(((e_cutoff/u.TeV)**2*(B/u.Gauss)).cgs.value) + 5, 300) * u.eV
Lsy = SYN.flux(Esy, distance=0 * u.cm) # use distance 0 to get luminosity
phn_sy = Lsy * 2.25 / (4 * np.pi * R ** 2 * c)
SSC = InverseCompton(
comoving,
seed_photon_fields=[
["SSC", Esy, phn_sy],
],
Eemax=Emax,
Eemin=Emin,
)
EIC = InverseCompton(
lab,
seed_photon_fields = [
"CMB",
["BLR", T, w],
],
Eemax = Emax * delta,
Eemin = Emin * delta,
)
# Use matplotlib to plot the spectra
figure, ax = plt.subplots()
# Plot the computed model emission
energy = np.logspace(-3, 13, 100) * u.eV
SYN_plot = SYN.sed(energy / delta, distance = 0 * u.cm) * delta**2
SSC_plot = SSC.sed(energy / delta, distance = 0 * u.cm) * delta**2
EIC_plot = EIC.sed(energy, distance = 0 * u.cm)
ylim_max = max(SYN_plot.max().value,SSC_plot.max().value,EIC_plot.max().value)
ax.set_ylim(ylim_max/1.e10, ylim_max*5)
for i, seed, ls in zip(
range(2), ["CMB", "BLR"], ["--", "-."]
):
ax.loglog(
energy,
EIC.sed(energy, distance=0 * u.cm, seed=seed),
lw=1,
c=naima.plot.color_cycle[i + 1],
label=seed,
ls=ls,
)
ax.loglog(
energy,
SYN_plot,
lw=2,
c="g",
label="SYN",
)
ax.loglog(
energy,
SSC_plot,
lw=2,
c="b",
label="SSC",
)
ax.loglog(
energy,
EIC_plot,
lw=2,
c="r",
label="EIC",
)
ax.legend(loc="lower right", frameon=False)
ax.set_xlabel(r'\textbf{E, eV}')
ax.set_ylabel(r'\boldmath $ \nu L_\nu, \rm\, erg/s$')
figure.tight_layout()
figure.savefig("SSC+EIC.png")