simplified interface for creating fission sites

This commit is contained in:
John Tramm 2020-01-13 20:03:18 +00:00
parent b41f3aadb4
commit 58e3d3a275
4 changed files with 30 additions and 21 deletions

View file

@ -48,8 +48,7 @@ int sample_nuclide(Particle* p);
//! Determine the average total, prompt, and delayed neutrons produced from
//! fission and creates appropriate bank sites.
void create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
std::vector<Particle::Bank>& bank, bool use_fission_bank);
void create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx);
int sample_element(Particle* p);

View file

@ -36,7 +36,7 @@ scatter(Particle* p);
//! \param bank The particle bank to populate
//! \param use_fission_bank Indicates if shared global fission bank should be used
void
create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fission_bank);
create_fission_sites(Particle* p);
//! \brief Handles an absorption event
//! \param p Particle to operate on

View file

@ -95,17 +95,13 @@ void sample_neutron_reaction(Particle* p)
if (nuc->fissionable_) {
Reaction* rx = sample_fission(i_nuclide, p);
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
//create_fission_sites(p, i_nuclide, rx, simulation::fission_bank);
create_fission_sites(p, i_nuclide, rx, simulation::fission_bank, true);
create_fission_sites(p, i_nuclide, rx);
} else if (settings::run_mode == RUN_MODE_FIXEDSOURCE &&
settings::create_fission_neutrons) {
//create_fission_sites(p, i_nuclide, rx, simulation::secondary_bank);
//create_fission_sites(p, i_nuclide, rx, p->secondary_bank_);
create_fission_sites(p, i_nuclide, rx, p->secondary_bank_, false);
create_fission_sites(p, i_nuclide, rx);
// Make sure particle population doesn't grow out of control for
// subcritical multiplication problems.
//if (simulation::secondary_bank.size() >= 10000) {
if (p->secondary_bank_.size() >= 10000) {
fatal_error("The secondary particle bank appears to be growing without "
"bound. You are likely running a subcritical multiplication problem "
@ -150,8 +146,7 @@ void sample_neutron_reaction(Particle* p)
}
void
create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
std::vector<Particle::Bank>& bank, bool use_fission_bank)
create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx)
{
// If uniform fission source weighting is turned on, we increase or decrease
// the expected number of fission sites produced
@ -179,6 +174,12 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
p->fission_ = true;
int skipped = 0;
// Determine whether to place fission sites into the shared fission bank
// or the secondary particle bank.
bool use_fission_bank = false;
if (settings::run_mode == RUN_MODE_EIGENVALUE)
use_fission_bank = true;
for (int i = 0; i < nu; ++i) {
Particle::Bank * site;
if(use_fission_bank)
@ -188,9 +189,10 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
idx = simulation::shared_fission_bank_length++;
if( idx >= simulation::shared_fission_bank_max )
{
warning("The shared fission bank is full. Additional fission sites created in this generation will not be banked.");
#pragma omp atomic
simulation::shared_fission_bank_length--;
warning("The shared fission bank is full. Additional fission sites created "
"in this generation will not be banked.");
#pragma omp atomic write
simulation::shared_fission_bank_length = simulation::shared_fission_bank_max;
skipped++;
break;
}
@ -199,6 +201,7 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
else
{
// Create new bank site and get reference to last element
auto& bank = p->secondary_bank_;
bank.emplace_back();
site = &bank.back();
}

View file

@ -48,11 +48,10 @@ sample_reaction(Particle* p)
if (model::materials[p->material_]->fissionable_) {
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
create_fission_sites(p, simulation::fission_bank, true);
create_fission_sites(p);
} else if ((settings::run_mode == RUN_MODE_FIXEDSOURCE) &&
(settings::create_fission_neutrons)) {
//create_fission_sites(p, simulation::secondary_bank);
create_fission_sites(p, p->secondary_bank_, false);
create_fission_sites(p);
}
}
@ -92,7 +91,7 @@ scatter(Particle* p)
}
void
create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fission_bank)
create_fission_sites(Particle* p)
{
// If uniform fission source weighting is turned on, we increase or decrease
// the expected number of fission sites produced
@ -122,6 +121,12 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fi
p->fission_ = true;
int skipped = 0;
// Determine whether to place fission sites into the shared fission bank
// or the secondary particle bank.
bool use_fission_bank = false;
if (settings::run_mode == RUN_MODE_EIGENVALUE)
use_fission_bank = true;
for (int i = 0; i < nu; ++i) {
Particle::Bank * site;
@ -132,9 +137,10 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fi
idx = simulation::shared_fission_bank_length++;
if( idx >= simulation::shared_fission_bank_max )
{
warning("The shared fission bank is full. Additional fission sites created in this generation will not be banked.");
#pragma omp atomic
simulation::shared_fission_bank_length--;
warning("The shared fission bank is full. Additional fission sites created "
"in this generation will not be banked.");
#pragma omp atomic write
simulation::shared_fission_bank_length = simulation::shared_fission_bank_max;
skipped++;
break;
}
@ -143,6 +149,7 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fi
else
{
// Create new bank site and get reference to last element
auto& bank = p->secondary_bank_;
bank.emplace_back();
site = &bank.back();
}