-
Notifications
You must be signed in to change notification settings - Fork 1
/
grplinst.cc
239 lines (208 loc) · 6.63 KB
/
grplinst.cc
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include "grplinst.h"
PlasmaInstability::PlasmaInstability(double nIGM, double temperature, double lumBeam, char model) : crpropa::Module() {
setIGMDensity(nIGM);
setTemperature(temperature);
setBeamLuminosity(lumBeam);
setModel(model);
initTables();
setDescription("PlasmaInstability");
}
void PlasmaInstability::initTables() {
// Initiate tables for Miniati and Elyv model
// double d_[] = {-0.05, 0.14, 0.35, 0.59, 0.79, 0.96, 1.17, 1.40, 1.57, 1.77, 1.99, 2.20, 2.41, 2.60, 2.80, 3.00};
// double w_[] = { 3.28, 3.46, 3.14, 3.08, 3.05, 3.00, 2.84, 2.56, 2.40, 2.55, 2.36, 2.08, 1.73, 1.55, 1.05, 0.75};
// std::vector<double> D (d_, d_ + sizeof(d_) / sizeof(double));
// std::vector<double> W (w_, w_ + sizeof(w_) / sizeof(double));
std::vector<double> D = {-0.05, 0.14, 0.35, 0.59, 0.79, 0.96, 1.17, 1.40, 1.57, 1.77, 1.99, 2.20, 2.41, 2.60, 2.80, 3.00};
std::vector<double> W = { 3.28, 3.46, 3.14, 3.08, 3.05, 3.00, 2.84, 2.56, 2.40, 2.55, 2.36, 2.08, 1.73, 1.55, 1.05, 0.75};
_d = D;
_w = W;
}
void PlasmaInstability::setIGMDensity(double rho) {
// Defines the density of the IGM at z=0, in units of m^-3.
densityIGM = rho;
}
void PlasmaInstability::setBeamLuminosity(double rho) {
// Sets the beam luminosity in units of Watts.
luminosityBeam = rho;
}
void PlasmaInstability::setTemperature(double t) {
// Defines the temperature of the IGM at z=0.
temperatureIGM = t;
}
void PlasmaInstability::setModel(char model) {
// Select the model of plasma instability.
// Models available:
// A: Broderick, Chang, Pfrommer. Astrophys. J. 752 (2012) 22. arXiv:1106.5494
// B: Miniati & Elyiv. Astrophys. J. 770 (2013) 54. arXiv:1208.1761
// C: Schlickeiser, Ibscher, Supsar. Astrophys. J. 758 (2012) 102.
// D: Sironi, Giannios. Astrophys. J. 787 (2014) 49. arXiv:1312.4538
// E: Vafin, Rafighi, Pohl, Niemiec. Astrophys. J. 857 (2018) 43. arXiv:1803.02990
plasmaInstabilityModel = model;
}
double PlasmaInstability::getIGMDensity() const {
return densityIGM;
}
double PlasmaInstability::getBeamLuminosity() const {
return luminosityBeam;
}
double PlasmaInstability::getTemperature() const {
return temperatureIGM;
}
char PlasmaInstability::getModel() const {
return plasmaInstabilityModel;
}
void PlasmaInstability::process(crpropa::Candidate *candidate) const {
int id = candidate->current.getId();
// only works for electrons and positrons
if (fabs(id) != 11)
return;
double dx = candidate->getCurrentStep();
double z = candidate->getRedshift();
double E = candidate->current.getEnergy();
double dEdx = coolingPower(E, z);
if (dEdx < 0)
dEdx = 0;
double Enew = E - dEdx * dx;
candidate->current.setEnergy(Enew);
candidate->limitNextStep(0.1 * E / dEdx);
}
double PlasmaInstability::coolingPower(double E, double z) const {
double dEdx = 0;
switch(plasmaInstabilityModel) {
case 'a':
case 'A':
dEdx = coolingPowerA(E, z);
break;
case 'b':
case 'B':
dEdx = coolingPowerB(E, z);
break;
case 'c':
case 'C':
dEdx = coolingPowerC(E, z);
break;
case 'd':
case 'D':
dEdx = coolingPowerD(E, z);
break;
case 'e':
case 'E':
dEdx = coolingPowerE(E, z);
break;
default:
dEdx = 0;
}
return dEdx;
}
double PlasmaInstability::coolingPowerA(double E, double z) const {
E /= (1 + z);
double eta = 1.;
double Ethr = 8.7e-6 * pow(1 + z, -13. / 6) * pow(luminosityBeam / 1e38, -1. / 3) * pow(densityIGM / 0.1, 1. / 3);
double a0, a1, a2, a3, a4;
if (E < Ethr) {
a0 = 7.7e-26;
a1 = 8;
a2 = 3;
a3 = 1;
a4 = -1. / 2;
} else {
a0 = 2.3e-22;
a1 = 11. / 3;
a2 = 1;
a3 = 1. / 3;
a4 = 1. / 6;
}
return a0 * eta * pow(E / crpropa::TeV, a2) * pow(luminosityBeam / 1e38, a3) * pow(densityIGM / 0.1, a4);
}
double PlasmaInstability::coolingPowerB(double E, double z) const {
E /= (1 + z);
double d0 = log10(crpropa::redshift2LightTravelDistance(z) / crpropa::Mpc); // co-moving?
double w = pow(10, crpropa::interpolate(d0, _d, _w));
return 1.4e-29 * pow(1 + z, 2) * pow(E / crpropa::TeV, 2) / w;
}
double PlasmaInstability::coolingPowerC(double E, double z) const {
E /= (1 + z);
double eta = 1.;
double Ethr = 7.9e-8 * pow(1 + z, -9. / 4) / sqrt(luminosityBeam / 1e38) * pow(densityIGM / 0.1, 0.5) * pow(temperatureIGM / 1e4, 1.);
double F = 1. + 1.25 * log(temperatureIGM / 1e4) - 0.25 * log(densityIGM / 0.1) + 0.5 * log(1 + z);
double a0, a1, a2, a3, a4, b;
if (E < Ethr) {
a0 = 4.7e-30;
a1 = -5;
a2 = -1;
a3 = 1. / 3.;
a4 = 5. / 6.;
b = pow(temperatureIGM / 1e4, 2);
} else {
a0 = 1.4e-23;
a1 = 11. / 3;
a2 = 1;
a3 = 1. / 3.;
a4 = 1. / 6.;
b = 1. / F;
}
return a0 * eta * pow(1 + z, a1) * pow(E / crpropa::TeV, a2) * pow(luminosityBeam / 1e38, a3) * pow(densityIGM / 0.1, a4) * b;
}
double PlasmaInstability::coolingPowerD(double E, double z) const {
E /= (1 + z);
double eta = 1.; // for now fixed; should add a function to play with it.
double Ethr = 6.9e-6 * pow(1 + z, -13. / 16) * pow(luminosityBeam / 1e38, -1. / 3) / sqrt(densityIGM / 0.1);
double a0, a1, a2, a3, a4, b;
if (E < Ethr) {
a0 = 3.9e-25;
a1 = 8.;
a2 = 3.;
a3 = 1.;
a4 = -0.5;
} else {
a0 = 1.2e-22;
a1 = 11. / 3;
a2 = 1.;
a3 = 1. / 3;
a4 = 1. / 6;
}
return a0 * eta * pow(1 + z, a1) * pow(E / crpropa::TeV, a2) * pow(luminosityBeam / 1e38, a3) * pow(densityIGM / 0.1, a4);
}
double PlasmaInstability::coolingPowerE(double E, double z) const {
E /= (1 + z);
return 2.7e-20 * pow(0.5 + z / 2., 19. / 6) * E * pow(E / crpropa::TeV, -1.) * pow(luminosityBeam / 1e38, 1. / 3) * pow(densityIGM / 0.1, -1. / 3) * (temperatureIGM / 1e4);
}
std::string PlasmaInstability::getModelReference() const {
std::stringstream s;
switch(plasmaInstabilityModel) {
case 'a':
case 'A':
s << "Broderick, Chang, Pfrommer. Astrophys. J. 752 (2012) 22. arXiv:1106.5494";
break;
case 'b':
case 'B':
s << "Miniati & Elyiv. Astrophys. J. 770 (2013) 54. arXiv:1208.1761";
break;
case 'c':
case 'C':
s << "Schlickeiser, Ibscher, Supsar. Astrophys. J. 758 (2012) 102.";
break;
case 'd':
case 'D':
s << "Sironi, Giannios. Astrophys. J. 787 (2014) 49. arXiv:1312.4538";
break;
case 'e':
case 'E':
s << "Vafin, Rafighi, Pohl, Niemiec. Astrophys. J. 857 (2018) 43. arXiv:1803.02990";
break;
default:
break;
// throw std::invalid_argument("Unknown plasma instability model \n.");
}
return s.str();
}
std::string PlasmaInstability::getDescription() const {
std::stringstream s;
s << "PlasmaInstability";
s << " density IGM: " << getIGMDensity() << " / m^3\n";
s << " temperature: " << getTemperature() << " K\n";
s << " beam luminosity: " << getBeamLuminosity() << " J/s\n";
s << " model: " << getModel() << " (" << getModelReference() << ")\n";
return s.str();
}