-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlasmaInstability.cpp
66 lines (52 loc) · 1.84 KB
/
PlasmaInstability.cpp
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
#include "crpropa/module/PlasmaInstability.h"
PlasmaInstability::PlasmaInstability(double a, double Energyscale,
double Lengthscale)
: crpropa::Module() {
setPlasmaIndex(a);
setPlasmaEnergyScale(Energyscale);
setPlasmaLengthScale(Lengthscale);
setDescription("PlasmaInstability");
}
void PlasmaInstability::setPlasmaIndex(double alpha) {
index = alpha;
}
void PlasmaInstability::setPlasmaEnergyScale(double Escale) {
tildeE = Escale;
}
void PlasmaInstability::setPlasmaLengthScale(double lambdascale) {
lambda = lambdascale;
}
double PlasmaInstability::getPlasmaIndex() const {
return index;
}
double PlasmaInstability::getPlasmaEnergyScale() const {
return tildeE;
}
double PlasmaInstability::getPlasmaLengthScale() const {
return lambda;
}
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;
E /= (1 + z);
return (tildeE / lambda) * pow( E / tildeE, 1-index);
}
std::string PlasmaInstability::getDescription() const {
std::stringstream s;
s << "PlasmaInstability";
return s.str();
}