Merge pull request #2224 from gridley/nick_mg_high_rejection

helpful error message for excessive energy spectrum rejection rate
This commit is contained in:
Paul Romano 2022-09-21 14:40:25 -05:00 committed by GitHub
commit 3fa3d5587e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,14 +201,12 @@ SourceSite IndependentSource::sample(uint64_t* seed) const
if (n_reject >= EXTSRC_REJECT_THRESHOLD &&
static_cast<double>(n_accept) / n_reject <= EXTSRC_REJECT_FRACTION) {
fatal_error("More than 95% of external source sites sampled were "
"rejected. Please check your external source definition.");
"rejected. Please check your external source's spatial "
"definition.");
}
}
}
// Increment number of accepted samples
++n_accept;
// Sample angle
site.u = angle_->sample(seed);
@ -233,11 +231,22 @@ SourceSite IndependentSource::sample(uint64_t* seed) const
// Resample if energy falls outside minimum or maximum particle energy
if (site.E < data::energy_max[p] && site.E > data::energy_min[p])
break;
n_reject++;
if (n_reject >= EXTSRC_REJECT_THRESHOLD &&
static_cast<double>(n_accept) / n_reject <= EXTSRC_REJECT_FRACTION) {
fatal_error("More than 95% of external source sites sampled were "
"rejected. Please check your external source energy spectrum "
"definition.");
}
}
// Sample particle creation time
site.time = time_->sample(seed);
// Increment number of accepted samples
++n_accept;
return site;
}