Fix Weight Window Infinite Loop Bug (#3457)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
John Tramm 2025-06-23 17:20:36 -05:00 committed by GitHub
parent eaef13b9bc
commit 7c6aaf7204
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -47,7 +47,7 @@ struct SourceSite {
double time {0.0};
double wgt {1.0};
int delayed_group {0};
int surf_id {0};
int surf_id {SURFACE_NONE};
ParticleType particle;
// Extra attributes that don't show up in source written to file

View file

@ -104,6 +104,14 @@ void Particle::split(double wgt)
bank.u = u();
bank.E = settings::run_CE ? E() : g();
bank.time = time();
// Convert signed index to a singed surface ID
if (surface() == SURFACE_NONE) {
bank.surf_id = SURFACE_NONE;
} else {
int surf_id = model::surfaces[surface_index()]->id_;
bank.surf_id = (surface() > 0) ? surf_id : -surf_id;
}
}
void Particle::from_source(const SourceSite* src)
@ -140,6 +148,12 @@ void Particle::from_source(const SourceSite* src)
time() = src->time;
time_last() = src->time;
parent_nuclide() = src->parent_nuclide;
// Convert signed surface ID to signed index
if (src->surf_id != SURFACE_NONE) {
int index_plus_one = model::surface_map[std::abs(src->surf_id)] + 1;
surface() = (src->surf_id > 0) ? index_plus_one : -index_plus_one;
}
}
void Particle::event_calculate_xs()