Skip to content

Commit 9daf274

Browse files
correct spectrum cal
1 parent 86d9c03 commit 9daf274

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/kernels/QED_process.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ namespace kernel::QED{
298298
auto rand_gen = random_pool.get_state();
299299

300300
ux1_ph(offset + i) = SIGN(ux1(p)) * ONE;
301-
pld_ph(offset + i, 0) = inverseCDF(CDF(zeta) * Random<real_t>(rand_gen))
301+
pld_ph(offset + i, 0) = inverseCDF(CDF(zeta) * (Random<real_t>(rand_gen) + 1e-12))
302302
* CUBE(pp / gamma_emit) / rho;
303303
i1_ph(offset + i) = i1(p);
304304
dx1_ph(offset + i) = dx1(p);

src/kernels/tests/QED_process.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ auto main(int argc, char* argv[]) -> int {
145145
// photon.set_npart(photon.npart() + n_injected);
146146

147147
size_t num_bins { 100 };
148-
real_t log_min { math::log10(e_min / e_ph) };
149-
real_t log_max { TWO };
150-
auto dx = (log_max - log_min) / num_bins;
148+
real_t min { e_min / e_ph };
149+
real_t max { 20.0 };
150+
auto dx = (max - min) / num_bins;
151151

152152
auto e_bins = Kokkos::View<size_t*>("e_bins", num_bins);
153153
Kokkos::deep_copy(e_bins, 0);
@@ -159,8 +159,8 @@ auto main(int argc, char* argv[]) -> int {
159159
if (tag_ph(p) != ParticleTag::alive) {
160160
return;
161161
}
162-
auto log_e = math::log10(pld_ph(p, 0) / e_ph);
163-
auto bin = static_cast<index_t>((log_e - log_min) / dx);
162+
auto e = pld_ph(p, 0) / e_ph;
163+
auto bin = static_cast<index_t>((e - min) / dx);
164164
auto access = scatter_ebins.access();
165165
if (bin < 0) {
166166
access(0) += 1;
@@ -177,7 +177,7 @@ auto main(int argc, char* argv[]) -> int {
177177

178178
std::vector<real_t> bin_centers(num_bins);
179179
for (size_t i = 0; i < num_bins; ++i) {
180-
bin_centers[i] = math::pow(10.0, log_min + (i + 0.5) * dx);
180+
bin_centers[i] = min + (i + 0.5) * dx;
181181
}
182182

183183
if (n_injected > 0) {
@@ -186,6 +186,7 @@ auto main(int argc, char* argv[]) -> int {
186186
file << bin_centers[i] << " " << ebins_h(i) << std::endl;
187187
}
188188
file.close();
189+
189190
}
190191

191192

0 commit comments

Comments
 (0)