Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove wgt_absorb data member from Particle #1974

Merged
merged 7 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/openmc/particle_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ class ParticleData {
Position r_last_; //!< previous coordinates
Direction u_last_; //!< previous direction coordinates
double wgt_last_ {1.0}; //!< pre-collision particle weight
double wgt_absorb_ {0.0}; //!< weight absorbed for survival biasing

// What event took place
bool fission_ {false}; //!< did particle cause implicit fission
Expand Down Expand Up @@ -375,8 +374,6 @@ class ParticleData {
const Position& u_last() const { return u_last_; }
double& wgt_last() { return wgt_last_; }
const double& wgt_last() const { return wgt_last_; }
double& wgt_absorb() { return wgt_absorb_; }
const double& wgt_absorb() const { return wgt_absorb_; }

bool& fission() { return fission_; }
TallyEvent& event() { return event_; }
Expand Down
4 changes: 3 additions & 1 deletion include/openmc/physics_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
namespace openmc {

//! \brief Performs the russian roulette operation for a particle
void russian_roulette(Particle& p);
//! \param[in,out] p Particle object
//! \param[in] weight_cutoff Weight below which particles are rouletted
void russian_roulette(Particle& p, double weight_survive);
paulromano marked this conversation as resolved.
Show resolved Hide resolved

} // namespace openmc
#endif // OPENMC_PHYSICS_COMMON_H
2 changes: 1 addition & 1 deletion openmc/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2633,7 +2633,7 @@ def rotate(self, rotation, pivot=(0., 0., 0.), order='xyz', inplace=False,
memo = {}

# If rotated surface not in memo, add it
key = (self.surface, tuple(rotation), tuple(pivot), order, inplace)
key = (self.surface, tuple(np.ravel(rotation)), tuple(pivot), order, inplace)
if key not in memo:
memo[key] = self.surface.rotate(rotation, pivot=pivot, order=order,
inplace=inplace)
Expand Down
17 changes: 7 additions & 10 deletions src/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ void sample_neutron_reaction(Particle& p)

if (p.neutron_xs(i_nuclide).absorption > 0.0) {
absorption(p, i_nuclide);
} else {
p.wgt_absorb() = 0.0;
}
if (!p.alive())
return;
Expand All @@ -153,9 +151,9 @@ void sample_neutron_reaction(Particle& p)

// Play russian roulette if survival biasing is turned on
if (settings::survival_biasing) {
russian_roulette(p);
if (!p.alive())
return;
if (p.wgt() < settings::weight_cutoff) {
russian_roulette(p, settings::weight_survive);
}
}
}

Expand Down Expand Up @@ -626,16 +624,15 @@ void absorption(Particle& p, int i_nuclide)
{
if (settings::survival_biasing) {
// Determine weight absorbed in survival biasing
p.wgt_absorb() = p.wgt() * p.neutron_xs(i_nuclide).absorption /
p.neutron_xs(i_nuclide).total;
double wgt_absorb = p.wgt() * p.neutron_xs(i_nuclide).absorption /
paulromano marked this conversation as resolved.
Show resolved Hide resolved
p.neutron_xs(i_nuclide).total;

// Adjust weight of particle by probability of absorption
p.wgt() -= p.wgt_absorb();
p.wgt_last() = p.wgt();
p.wgt() -= wgt_absorb;

// Score implicit absorption estimate of keff
if (settings::run_mode == RunMode::EIGENVALUE) {
p.keff_tally_absorption() += p.wgt_absorb() *
p.keff_tally_absorption() += wgt_absorb *
p.neutron_xs(i_nuclide).nu_fission /
p.neutron_xs(i_nuclide).absorption;
}
Expand Down
16 changes: 6 additions & 10 deletions src/physics_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ namespace openmc {
// RUSSIAN_ROULETTE
//==============================================================================

void russian_roulette(Particle& p)
void russian_roulette(Particle& p, double weight_survive)
{
if (p.wgt() < settings::weight_cutoff) {
if (prn(p.current_seed()) < p.wgt() / settings::weight_survive) {
p.wgt() = settings::weight_survive;
p.wgt_last() = p.wgt();
} else {
p.wgt() = 0.;
p.wgt_last() = 0.;
p.alive() = false;
}
if (weight_survive * prn(p.current_seed()) < p.wgt()) {
paulromano marked this conversation as resolved.
Show resolved Hide resolved
paulromano marked this conversation as resolved.
Show resolved Hide resolved
p.wgt() = weight_survive;
} else {
p.wgt() = 0.;
p.alive() = false;
}
}

Expand Down
15 changes: 6 additions & 9 deletions src/physics_mg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ void sample_reaction(Particle& p)
// weight of the particle. Otherwise, it checks to see if absorption occurs.
if (p.macro_xs().absorption > 0.) {
absorption(p);
} else {
p.wgt_absorb() = 0.;
}
if (!p.alive())
return;
Expand All @@ -66,9 +64,9 @@ void sample_reaction(Particle& p)

// Play Russian roulette if survival biasing is turned on
if (settings::survival_biasing) {
russian_roulette(p);
if (!p.alive())
return;
if (p.wgt() < settings::weight_cutoff) {
russian_roulette(p, settings::weight_survive);
}
}
}

Expand Down Expand Up @@ -216,15 +214,14 @@ void absorption(Particle& p)
{
if (settings::survival_biasing) {
// Determine weight absorbed in survival biasing
p.wgt_absorb() = p.wgt() * p.macro_xs().absorption / p.macro_xs().total;
double wgt_absorb = p.wgt() * p.macro_xs().absorption / p.macro_xs().total;

// Adjust weight of particle by the probability of absorption
p.wgt() -= p.wgt_absorb();
p.wgt_last() = p.wgt();
p.wgt() -= wgt_absorb;

// Score implicit absorpion estimate of keff
p.keff_tally_absorption() +=
p.wgt_absorb() * p.macro_xs().nu_fission / p.macro_xs().absorption;
wgt_absorb * p.macro_xs().nu_fission / p.macro_xs().absorption;
} else {
if (p.macro_xs().absorption > prn(p.current_seed()) * p.macro_xs().total) {
p.keff_tally_absorption() +=
Expand Down
Loading