Skip to content

Commit

Permalink
add test for avg photon energy
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienDoerner committed Aug 28, 2024
1 parent 826dc24 commit 5246f37
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/testInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,32 @@ TEST(SynchrotronRadiation, energyLoss) {
EXPECT_NEAR(1 * PeV - c.current.getEnergy(), dE, 0.01 * dE);
}

TEST(SynchrotronRadiation, PhotonEnergy) {
double brms = 1 * muG;
SynchrotronRadiation sync(brms, true);
sync.setSecondaryThreshold(0.); // allow all secondaries for testing

double E = 1 * TeV;
Candidate c(11, E);
c.setCurrentStep(10 * pc);
c.setNextStep(10 * pc);

double lf = c.current.getLorentzFactor();
double Rg = E / eplus / c_light / (brms * sqrt(2. / 3) ); // factor 2/3 for avg magnetic field direction.
double Ecrit = 3. / 4 * h_planck / M_PI * c_light * pow(lf, 3) / Rg;

sync.process(&c);
EXPECT_TRUE(c.secondaries.size() > 0); // must have secondaries

// check avg energy of the secondary photons
double Esec = 0;
for (size_t i = 0; i < c.secondaries.size(); i++) {
Esec += c.secondaries[i] -> current.getEnergy();
}
Esec /= c.secondaries.size();

EXPECT_NEAR(Esec, Ecrit, Ecrit);
}

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
Expand Down

0 comments on commit 5246f37

Please sign in to comment.