mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Random Ray Misc Memory Error Fixes (#3405)
Co-authored-by: Hunter Belanger <hunter.belanger@gmail.com>
This commit is contained in:
parent
ba834be5c2
commit
f615441f06
3 changed files with 23 additions and 12 deletions
|
|
@ -206,9 +206,11 @@ void FlatSourceDomain::set_flux_to_flux_plus_source(
|
|||
int material = source_regions_.material(sr);
|
||||
if (material == MATERIAL_VOID) {
|
||||
source_regions_.scalar_flux_new(sr, g) /= volume;
|
||||
source_regions_.scalar_flux_new(sr, g) +=
|
||||
0.5f * source_regions_.external_source(sr, g) *
|
||||
source_regions_.volume_sq(sr);
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
source_regions_.scalar_flux_new(sr, g) +=
|
||||
0.5f * source_regions_.external_source(sr, g) *
|
||||
source_regions_.volume_sq(sr);
|
||||
}
|
||||
} else {
|
||||
double sigma_t = sigma_t_[source_regions_.material(sr) * negroups_ + g];
|
||||
source_regions_.scalar_flux_new(sr, g) /= (sigma_t * volume);
|
||||
|
|
|
|||
|
|
@ -518,8 +518,10 @@ void RandomRay::attenuate_flux_flat_source_void(
|
|||
}
|
||||
|
||||
// Add source to incoming angular flux, assuming void region
|
||||
for (int g = 0; g < negroups_; g++) {
|
||||
angular_flux_[g] += srh.external_source(g) * distance;
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
for (int g = 0; g < negroups_; g++) {
|
||||
angular_flux_[g] += srh.external_source(g) * distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -688,7 +690,10 @@ void RandomRay::attenuate_flux_linear_source_void(
|
|||
// transport through a void region is greatly simplified. Here we
|
||||
// compute the updated flux moments.
|
||||
for (int g = 0; g < negroups_; g++) {
|
||||
float spatial_source = srh.external_source(g);
|
||||
float spatial_source = 0.f;
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
spatial_source = srh.external_source(g);
|
||||
}
|
||||
float new_delta_psi = (angular_flux_[g] - spatial_source) * distance;
|
||||
float h1 = 0.5f;
|
||||
h1 = h1 * angular_flux_[g];
|
||||
|
|
@ -750,8 +755,10 @@ void RandomRay::attenuate_flux_linear_source_void(
|
|||
}
|
||||
|
||||
// Add source to incoming angular flux, assuming void region
|
||||
for (int g = 0; g < negroups_; g++) {
|
||||
angular_flux_[g] += srh.external_source(g) * distance;
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
for (int g = 0; g < negroups_; g++) {
|
||||
angular_flux_[g] += srh.external_source(g) * distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -782,9 +789,7 @@ void RandomRay::initialize_ray(uint64_t ray_id, FlatSourceDomain* domain)
|
|||
fatal_error("Unknown sample method for random ray transport.");
|
||||
}
|
||||
|
||||
site.E = lower_bound_index(
|
||||
data::mg.rev_energy_bins_.begin(), data::mg.rev_energy_bins_.end(), site.E);
|
||||
site.E = negroups_ - site.E - 1.;
|
||||
site.E = 0.0;
|
||||
this->from_source(&site);
|
||||
|
||||
// Locate ray
|
||||
|
|
|
|||
|
|
@ -217,7 +217,11 @@ SourceRegionHandle SourceRegionContainer::get_source_region_handle(int64_t sr)
|
|||
handle.scalar_flux_old_ = &scalar_flux_old(sr, 0);
|
||||
handle.scalar_flux_new_ = &scalar_flux_new(sr, 0);
|
||||
handle.source_ = &source(sr, 0);
|
||||
handle.external_source_ = &external_source(sr, 0);
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
handle.external_source_ = &external_source(sr, 0);
|
||||
} else {
|
||||
handle.external_source_ = nullptr;
|
||||
}
|
||||
handle.scalar_flux_final_ = &scalar_flux_final(sr, 0);
|
||||
handle.tally_task_ = &tally_task(sr, 0);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue