Skip to content

Commit

Permalink
Creating a new method instead of a flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Dec 17, 2024
1 parent a36eaf2 commit ed6cb4b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 7 additions & 3 deletions include/openmc/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ class Particle : public ParticleData {
//! \param wgt Weight of the secondary particle
//! \param u Direction of the secondary particle
//! \param E Energy of the secondary particle in [eV]
//! \param accumulate_E Whether to accumulate the energy of the secondary
//! for adjustment to heating tallies
//! \param type Particle type
void create_secondary(double wgt, Direction u, double E, ParticleType type, bool accumulate_E = true);
void create_secondary(double wgt, Direction u, double E, ParticleType type);

//! split a particle
//
//! creates a new particle with weight wgt
//! \param wgt Weight of the new particle
void split(double wgt);

//! initialize from a source site
//
Expand Down
15 changes: 12 additions & 3 deletions src/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void Particle::move_distance(double length)
}

void Particle::create_secondary(
double wgt, Direction u, double E, ParticleType type, bool accumulate_E)
double wgt, Direction u, double E, ParticleType type)
{
// If energy is below cutoff for this particle, don't create secondary
// particle
Expand All @@ -100,9 +100,18 @@ void Particle::create_secondary(
bank.u = u;
bank.E = settings::run_CE ? E : g();
bank.time = time();
bank_second_E() += bank.E;
}

if (accumulate_E)
bank_second_E() += bank.E;
void Particle::split(double wgt) {
secondary_bank().emplace_back();
auto& bank {secondary_bank().back()};
bank.particle = type();
bank.wgt = wgt;
bank.r = r();
bank.u = u();
bank.E = settings::run_CE ? E() : g();
bank.time = time();
}

void Particle::from_source(const SourceSite* src)
Expand Down
2 changes: 1 addition & 1 deletion src/weight_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void apply_weight_windows(Particle& p)
// Create secondaries and divide weight among all particles
int i_split = std::round(n_split);
for (int l = 0; l < i_split - 1; l++) {
p.create_secondary(weight / n_split, p.u(), p.E(), p.type(), false);
p.split(weight / n_split);
}
// remaining weight is applied to current particle
p.wgt() = weight / n_split;
Expand Down

0 comments on commit ed6cb4b

Please sign in to comment.