Skip to content

Commit f9dca9a

Browse files
GuyStenpaulromano
andauthored
Fixing an incorrect computation of CDF of bremsstrahlung photons (#3396)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent e4f55a5 commit f9dca9a

File tree

5 files changed

+49
-48
lines changed

5 files changed

+49
-48
lines changed

src/material.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,14 +777,15 @@ void Material::init_bremsstrahlung()
777777
// Loop over photon energies
778778
double c = 0.0;
779779
for (int i = 0; i < j; ++i) {
780-
// Integrate the CDF from the PDF using the trapezoidal rule in log-log
781-
// space
780+
// Integrate the CDF from the PDF using the fact that the PDF is linear
781+
// in log-log space
782782
double w_l = std::log(data::ttb_e_grid(i));
783783
double w_r = std::log(data::ttb_e_grid(i + 1));
784784
double x_l = std::log(ttb->pdf(j, i));
785785
double x_r = std::log(ttb->pdf(j, i + 1));
786-
787-
c += 0.5 * (w_r - w_l) * (std::exp(w_l + x_l) + std::exp(w_r + x_r));
786+
double beta = (x_r - x_l) / (w_r - w_l);
787+
double a = beta + 1.0;
788+
c += std::exp(w_l + x_l) / a * std::expm1(a * (w_r - w_l));
788789
ttb->cdf(j, i + 1) = c;
789790
}
790791

tests/regression_tests/photon_production/results_true.dat

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ tally 2:
1616
1.573004E+00
1717
4.296434E-04
1818
1.845934E-07
19-
2.350021E-01
20-
5.522600E-02
19+
2.350047E-01
20+
5.522722E-02
2121
0.000000E+00
2222
0.000000E+00
23-
2.350021E-01
24-
5.522600E-02
23+
2.350047E-01
24+
5.522722E-02
2525
0.000000E+00
2626
0.000000E+00
2727
0.000000E+00
@@ -73,8 +73,8 @@ tally 3:
7373
0.000000E+00
7474
0.000000E+00
7575
0.000000E+00
76-
1.774451E+05
77-
3.148675E+10
76+
1.774484E+05
77+
3.148794E+10
7878
0.000000E+00
7979
0.000000E+00
8080
0.000000E+00
@@ -85,8 +85,8 @@ tally 3:
8585
0.000000E+00
8686
0.000000E+00
8787
0.000000E+00
88-
7.691658E+03
89-
5.916160E+07
88+
7.692488E+03
89+
5.917437E+07
9090
0.000000E+00
9191
0.000000E+00
9292
tally 4:
@@ -122,8 +122,8 @@ tally 4:
122122
0.000000E+00
123123
0.000000E+00
124124
0.000000E+00
125-
1.774451E+05
126-
3.148675E+10
125+
1.774484E+05
126+
3.148794E+10
127127
0.000000E+00
128128
0.000000E+00
129129
0.000000E+00
@@ -134,7 +134,7 @@ tally 4:
134134
0.000000E+00
135135
0.000000E+00
136136
0.000000E+00
137-
7.691658E+03
138-
5.916160E+07
137+
7.692488E+03
138+
5.917437E+07
139139
0.000000E+00
140140
0.000000E+00
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
k-combined:
2-
2.270911E+00 4.568134E-02
2+
2.278476E+00 6.220292E-02
33
tally 1:
4-
2.663476E+00
5-
2.366726E+00
4+
2.664071E+00
5+
2.369250E+00
66
0.000000E+00
77
0.000000E+00
8-
2.663476E+00
9-
2.366726E+00
8+
2.664071E+00
9+
2.369250E+00
1010
0.000000E+00
1111
0.000000E+00
1212
0.000000E+00
@@ -18,52 +18,52 @@ tally 1:
1818
0.000000E+00
1919
0.000000E+00
2020
tally 2:
21-
2.636709E+00
22-
2.318646E+00
23-
4.230052E+08
24-
5.967879E+16
21+
2.640755E+00
22+
2.326201E+00
23+
4.245217E+08
24+
6.012128E+16
2525
0.000000E+00
2626
0.000000E+00
27-
2.636709E+00
28-
2.318646E+00
29-
4.230052E+08
30-
5.967879E+16
27+
2.640755E+00
28+
2.326201E+00
29+
4.245217E+08
30+
6.012128E+16
3131
0.000000E+00
3232
0.000000E+00
3333
0.000000E+00
3434
0.000000E+00
35-
2.455009E+06
36-
2.015314E+12
35+
2.479234E+06
36+
2.052367E+12
3737
0.000000E+00
3838
0.000000E+00
3939
0.000000E+00
4040
0.000000E+00
41-
2.455009E+06
42-
2.015314E+12
41+
2.479234E+06
42+
2.052367E+12
4343
0.000000E+00
4444
0.000000E+00
4545
tally 3:
46-
2.660004E+00
47-
2.358564E+00
48-
4.230052E+08
49-
5.967879E+16
46+
2.657846E+00
47+
2.354717E+00
48+
4.245217E+08
49+
6.012128E+16
5050
0.000000E+00
5151
0.000000E+00
52-
2.660004E+00
53-
2.358564E+00
54-
4.230052E+08
55-
5.967879E+16
52+
2.657846E+00
53+
2.354717E+00
54+
4.245217E+08
55+
6.012128E+16
5656
0.000000E+00
5757
0.000000E+00
5858
0.000000E+00
5959
0.000000E+00
60-
2.455009E+06
61-
2.015314E+12
60+
2.479234E+06
61+
2.052367E+12
6262
0.000000E+00
6363
0.000000E+00
6464
0.000000E+00
6565
0.000000E+00
66-
2.455009E+06
67-
2.015314E+12
66+
2.479234E+06
67+
2.052367E+12
6868
0.000000E+00
6969
0.000000E+00
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tally 1:
2-
2.263938E+02
3-
5.125417E+04
2+
2.263761E+02
3+
5.124615E+04
44
0.000000E+00
55
0.000000E+00
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
952c20fefac374d3b9fd28627fda7d5ae262f8cd7c01a33f0381526204a2287c18e56259a599dc6fdc1b59a2d2866fdfeedea371154c8fa7a69dc5c445b08c2d
1+
a5880ad9262e8aba90801783891ee74618144101401f06fb46e954e851a3c517ab28d5f0d6e1b2b364844f08d363cba35ab23b63fc81012ea8a6a328755d56c4

0 commit comments

Comments
 (0)