Skip to content

Commit be1cd21

Browse files
committed
relax stochastic testing of interactions + sources
1 parent 8cea842 commit be1cd21

2 files changed

Lines changed: 22 additions & 42 deletions

File tree

test/testInteraction.cpp

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ TEST(NuclearDecay, scandium44) {
139139
// This test can stochastically fail.
140140
NuclearDecay d(true, true);
141141
Candidate c;
142-
c.setCurrentStep(1 * Mpc);
143142
c.current.setId(nucleusId(44, 21));
144143
c.current.setEnergy(1 * EeV);
144+
c.setCurrentStep(100 * Mpc);
145145
double gamma = c.current.getLorentzFactor();
146146
d.process(&c);
147147
// primary
@@ -162,9 +162,9 @@ TEST(NuclearDecay, lithium4) {
162162
// This test can stochastically fail.
163163
NuclearDecay d;
164164
Candidate c;
165-
c.setCurrentStep(1 * kpc);
166165
c.current.setId(nucleusId(4, 3));
167166
c.current.setEnergy(4 * EeV);
167+
c.setCurrentStep(100 * Mpc);
168168
d.process(&c);
169169
// primary
170170
EXPECT_EQ(nucleusId(3, 2), c.current.getId());
@@ -177,12 +177,12 @@ TEST(NuclearDecay, lithium4) {
177177

178178
TEST(NuclearDecay, helium5) {
179179
// Test neturon dripping of He-5 to He-4.
180-
// This test can stochastically fail if no interaction occurs over 1 Mpc.
180+
// This test can stochastically fail.
181181
NuclearDecay d;
182182
Candidate c;
183-
c.setCurrentStep(1 * Mpc);
184183
c.current.setId(nucleusId(5, 2));
185184
c.current.setEnergy(5 * EeV);
185+
c.setCurrentStep(100 * Mpc);
186186
d.process(&c);
187187
// primary
188188
EXPECT_EQ(nucleusId(4, 2), c.current.getId());
@@ -248,14 +248,14 @@ TEST(PhotoDisintegration, allBackgrounds) {
248248
}
249249

250250
TEST(PhotoDisintegration, carbon) {
251-
// Test if a 100 EeV C-12 nucleus photo-disintegrates (at least once) over a distance of 50 Mpc.
252-
// This test can stochastically fail if no interaction occurs over 50 Mpc.
251+
// Test if a 100 EeV C-12 nucleus photo-disintegrates (at least once) over a distance of 1 Gpc.
252+
// This test can stochastically fail.
253253
PhotoDisintegration pd(CMB);
254254
Candidate c;
255255
int id = nucleusId(12, 6);
256256
c.current.setId(id);
257257
c.current.setEnergy(100 * EeV);
258-
c.setCurrentStep(50 * Mpc);
258+
c.setCurrentStep(1000 * Mpc);
259259
pd.process(&c);
260260

261261
EXPECT_TRUE(c.current.getEnergy() < 100 * EeV);
@@ -283,14 +283,14 @@ TEST(PhotoDisintegration, carbon) {
283283
}
284284

285285
TEST(PhotoDisintegration, iron) {
286-
// Test if a 200 EeV Fe-56 nucleus photo-disintegrates (at least once) over a distance of 100 Mpc.
287-
// This test can stochastically fail if no interaction occurs over this distance.
286+
// Test if a 200 EeV Fe-56 nucleus photo-disintegrates (at least once) over a distance of 1 Gpc.
287+
// This test can stochastically fail.
288288
PhotoDisintegration pd(IRB);
289289
Candidate c;
290290
int id = nucleusId(56, 26);
291291
c.current.setId(id);
292292
c.current.setEnergy(200 * EeV);
293-
c.setCurrentStep(100 * Mpc);
293+
c.setCurrentStep(1000 * Mpc);
294294
pd.process(&c);
295295

296296
EXPECT_TRUE(c.current.getEnergy() < 200 * EeV);
@@ -383,12 +383,12 @@ TEST(PhotoPionProduction, allBackgroundsWithEvolution) {
383383

384384
TEST(PhotoPionProduction, proton) {
385385
// Test photo-pion interaction for 100 EeV proton.
386-
// This test can stochastically fail if no interaction occurs over 100 Mpc.
386+
// This test can stochastically fail.
387387
PhotoPionProduction ppp;
388388
Candidate c;
389-
c.setCurrentStep(100 * Mpc);
390389
c.current.setId(nucleusId(1, 1));
391390
c.current.setEnergy(100 * EeV);
391+
c.setCurrentStep(1000 * Mpc);
392392
ppp.process(&c);
393393
EXPECT_TRUE(c.current.getEnergy() / EeV < 100); // energy loss
394394
int id = c.current.getId();
@@ -398,12 +398,12 @@ TEST(PhotoPionProduction, proton) {
398398

399399
TEST(PhotoPionProduction, helium) {
400400
// Test photo-pion interaction for 400 EeV He nucleus.
401-
// This test can stochastically fail if no interaction occurs over 100 Mpc.
401+
// This test can stochastically fail.
402402
PhotoPionProduction ppp;
403403
Candidate c;
404-
c.setCurrentStep(100 * Mpc);
405404
c.current.setId(nucleusId(4, 2));
406405
c.current.setEnergy(400 * EeV);
406+
c.setCurrentStep(1000 * Mpc);
407407
ppp.process(&c);
408408
EXPECT_LT(c.current.getEnergy(), 400 * EeV);
409409
int id = c.current.getId();
@@ -415,10 +415,9 @@ TEST(PhotoPionProduction, thisIsNotNucleonic) {
415415
// Test if noting happens to an electron
416416
PhotoPionProduction ppp;
417417
Candidate c;
418-
c.setCurrentStep(1 * Mpc);
419-
c.setNextStep(std::numeric_limits<double>::max());
420418
c.current.setId(11); // electron
421419
c.current.setEnergy(10 * EeV);
420+
c.setCurrentStep(100 * Mpc);
422421
ppp.process(&c);
423422
EXPECT_EQ(11, c.current.getId());
424423
EXPECT_EQ(10 * EeV, c.current.getEnergy());
@@ -435,33 +434,14 @@ TEST(PhotoPionProduction, limitNextStep) {
435434
EXPECT_LT(c.getNextStep(), std::numeric_limits<double>::max());
436435
}
437436

438-
TEST(PhotoPionProduction, withoutSecondaries) {
439-
// Test photo-pion (SOPHIA) interaction for 100 EeV proton.
440-
// This test can stochastically fail if no interaction occurs over 100 Mpc.
441-
PhotoPionProduction ppp;
442-
Candidate c;
443-
c.setCurrentStep(100 * Mpc);
444-
c.current.setId(nucleusId(1, 1));
445-
c.current.setEnergy(100 * EeV);
446-
ppp.process(&c);
447-
448-
// energy loss
449-
EXPECT_GT(100 * EeV, c.current.getEnergy());
450-
// nucleon number conserved
451-
int id = c.current.getId();
452-
EXPECT_EQ(1, massNumber(id));
453-
// secondaries turned off
454-
EXPECT_EQ(0, c.secondaries.size());
455-
}
456-
457-
TEST(PhotoPionProduction, withSecondaries) {
437+
TEST(PhotoPionProduction, secondaries) {
458438
// Test photo-pion interaction for 100 EeV proton.
459-
// This test can stochastically fail if no interaction occurs over 100 Mpc.
439+
// This test can stochastically fail.
460440
PhotoPionProduction ppp(CMB, true, true, true);
461441
Candidate c;
462442
c.current.setId(nucleusId(1, 1));
463443
c.current.setEnergy(100 * EeV);
464-
c.setCurrentStep(100 * Mpc);
444+
c.setCurrentStep(1000 * Mpc);
465445
ppp.process(&c);
466446
// there should be secondaries
467447
EXPECT_GT(c.secondaries.size(), 1);

test/testSource.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ TEST(SourceDensityGrid, OneAllowedCell) {
119119

120120
// mean should be close to (1, 1, 1) if random positions are uniform in (0, 0, 0) - (2, 2, 2)
121121
mean /= 10000;
122-
EXPECT_NEAR(1, mean.x, 0.1);
123-
EXPECT_NEAR(1, mean.y, 0.1);
124-
EXPECT_NEAR(1, mean.z, 0.1);
122+
EXPECT_NEAR(1, mean.x, 0.2);
123+
EXPECT_NEAR(1, mean.y, 0.2);
124+
EXPECT_NEAR(1, mean.z, 0.2);
125125
}
126126

127127
TEST(SourceDensityGrid1D, withInRange) {
@@ -221,7 +221,7 @@ TEST(SourceGenericComposition, simpleTest) {
221221
ElowCount++;
222222
if ( (e >= 20) && (e <= Emax))
223223
EhighCount++;
224-
224+
225225
}
226226
EXPECT_EQ(n, id1Count + id2Count);
227227
EXPECT_EQ(n, ElowCount + EhighCount);

0 commit comments

Comments
 (0)