mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Added multigroup support for shared fission bank. Should be relatively easy to support for GPU.
This commit is contained in:
parent
e59a70ebb7
commit
747971dffe
4 changed files with 45 additions and 19 deletions
|
|
@ -34,8 +34,9 @@ scatter(Particle* p);
|
|||
//! from fission and creates the appropriate bank sites.
|
||||
//! \param p Particle to operate on
|
||||
//! \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);
|
||||
create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fission_bank);
|
||||
|
||||
//! \brief Handles an absorption event
|
||||
//! \param p Particle to operate on
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ sample_reaction(Particle* p)
|
|||
|
||||
if (model::materials[p->material_]->fissionable_) {
|
||||
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
|
||||
create_fission_sites(p, simulation::fission_bank);
|
||||
create_fission_sites(p, simulation::fission_bank, true);
|
||||
} 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_);
|
||||
create_fission_sites(p, p->secondary_bank_, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ scatter(Particle* p)
|
|||
}
|
||||
|
||||
void
|
||||
create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank)
|
||||
create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank, bool use_fission_bank)
|
||||
{
|
||||
// If uniform fission source weighting is turned on, we increase or decrease
|
||||
// the expected number of fission sites produced
|
||||
|
|
@ -111,6 +111,8 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank)
|
|||
// Begin banking the source neutrons
|
||||
// First, if our bank is full then don't continue
|
||||
if (nu == 0) return;
|
||||
|
||||
assert( nu < 15 );
|
||||
|
||||
// Initialize the counter of delayed neutrons encountered for each delayed
|
||||
// group.
|
||||
|
|
@ -119,13 +121,30 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank)
|
|||
p->fission_ = true;
|
||||
for (int i = 0; i < nu; ++i) {
|
||||
// Create new bank site and get reference to last element
|
||||
bank.emplace_back();
|
||||
auto& site {bank.back()};
|
||||
//bank.emplace_back();
|
||||
//auto& site {bank.back()};
|
||||
|
||||
Particle::Bank * site;
|
||||
if(use_fission_bank)
|
||||
{
|
||||
// Create new bank site and get reference to last element
|
||||
int idx;
|
||||
#pragma omp atomic capture
|
||||
idx = shared_fission_bank_length++;
|
||||
site = shared_fission_bank + idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create new bank site and get reference to last element
|
||||
bank.emplace_back();
|
||||
site = &bank.back();
|
||||
}
|
||||
|
||||
// Bank source neutrons by copying the particle data
|
||||
site.r = p->r();
|
||||
site.particle = Particle::Type::neutron;
|
||||
site.wgt = 1. / weight;
|
||||
site->r = p->r();
|
||||
site->particle = Particle::Type::neutron;
|
||||
site->wgt = 1. / weight;
|
||||
site->parent_id = p->id_;
|
||||
|
||||
// Sample the cosine of the angle, assuming fission neutrons are emitted
|
||||
// isotropically
|
||||
|
|
@ -133,9 +152,9 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank)
|
|||
|
||||
// Sample the azimuthal angle uniformly in [0, 2.pi)
|
||||
double phi = 2. * PI * prn(p->current_seed() );
|
||||
site.u.x = mu;
|
||||
site.u.y = std::sqrt(1. - mu * mu) * std::cos(phi);
|
||||
site.u.z = std::sqrt(1. - mu * mu) * std::sin(phi);
|
||||
site->u.x = mu;
|
||||
site->u.y = std::sqrt(1. - mu * mu) * std::cos(phi);
|
||||
site->u.z = std::sqrt(1. - mu * mu) * std::sin(phi);
|
||||
|
||||
// Sample secondary energy distribution for the fission reaction
|
||||
int dg;
|
||||
|
|
@ -143,10 +162,10 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank)
|
|||
data::mg.macro_xs_[p->material_].sample_fission_energy(p->g_, dg, gout,
|
||||
p->current_seed());
|
||||
// Store the energy and delayed groups on the fission bank
|
||||
site.E = gout;
|
||||
site->E = gout;
|
||||
// We add 1 to the delayed_group bc in MG, -1 is prompt, but in the rest
|
||||
// of the code, 0 is prompt.
|
||||
site.delayed_group = dg + 1;
|
||||
site->delayed_group = dg + 1;
|
||||
|
||||
// Set the delayed group on the particle as well
|
||||
p->delayed_group_ = dg + 1;
|
||||
|
|
@ -155,6 +174,14 @@ create_fission_sites(Particle* p, std::vector<Particle::Bank>& bank)
|
|||
if (p->delayed_group_ > 0) {
|
||||
nu_d[dg]++;
|
||||
}
|
||||
|
||||
// Write fission particles to nuBank
|
||||
if(use_fission_bank)
|
||||
{
|
||||
p->nu_bank_[nu-1-i].wgt = site->wgt;
|
||||
p->nu_bank_[nu-1-i].E = site->E;
|
||||
p->nu_bank_[nu-1-i].delayed_group = site->delayed_group;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the total weight banked for analog fission tallies
|
||||
|
|
|
|||
|
|
@ -579,9 +579,9 @@ int openmc_next_batch(int* status)
|
|||
// Start timer for transport
|
||||
simulation::time_transport.start();
|
||||
|
||||
/*
|
||||
// ====================================================================
|
||||
// LOOP OVER PARTICLES
|
||||
/*
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i_work = 1; i_work <= simulation::work_per_rank; ++i_work) {
|
||||
// grab source particle from bank
|
||||
|
|
@ -913,11 +913,9 @@ void initialize_history(Particle* p, int64_t index_source)
|
|||
|
||||
// set particle trace
|
||||
p->trace_ = false;
|
||||
/*
|
||||
if (simulation::current_batch == settings::trace_batch &&
|
||||
simulation::current_gen == settings::trace_gen &&
|
||||
p->id_ == settings::trace_particle) p->trace_ = true;
|
||||
*/
|
||||
|
||||
// Set particle track.
|
||||
p->write_track_ = false;
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ class MGXSTestHarness(PyAPITestHarness):
|
|||
os.remove(f)
|
||||
|
||||
|
||||
import pytest
|
||||
@pytest.mark.skip(reason="MG not planned for GPU support.")
|
||||
#import pytest
|
||||
#@pytest.mark.skip(reason="MG not planned for GPU support.")
|
||||
def test_mg_basic():
|
||||
create_library()
|
||||
mat_names = ['base leg', 'base tab', 'base hist', 'base matrix',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue