Remove special treatment of mu for fission

This commit is contained in:
Paul Romano 2020-11-13 13:28:32 -06:00
parent 4399645859
commit 7ef73f048d
4 changed files with 8 additions and 39 deletions

View file

@ -35,11 +35,9 @@ public:
// Accessors
AngleDistribution& angle() { return angle_; }
bool& fission() { return fission_; }
private:
AngleDistribution angle_; //!< Angle distribution
std::unique_ptr<EnergyDistribution> energy_; //!< Energy distribution
bool fission_ {false}; //!< Whether distribution is use for fission
};
} // namespace openmc

View file

@ -1009,24 +1009,13 @@ sample_cxs_target_velocity(double awr, double E, Direction u, double kT, uint64_
void sample_fission_neutron(int i_nuclide, const Reaction& rx, double E_in, Particle::Bank* site, uint64_t* seed)
{
// Sample cosine of angle -- fission neutrons are always emitted
// isotropically. Sometimes in ACE data, fission reactions actually have
// an angular distribution listed, but for those that do, it's simply just
// a uniform distribution in mu
double mu = 2.0 * prn(seed) - 1.0;
// Sample azimuthal angle uniformly in [0,2*pi)
double phi = 2.0*PI*prn(seed);
site->u.x = mu;
site->u.y = std::sqrt(1.0 - mu*mu) * std::cos(phi);
site->u.z = std::sqrt(1.0 - mu*mu) * std::sin(phi);
// Determine total nu, delayed nu, and delayed neutron fraction
const auto& nuc {data::nuclides[i_nuclide]};
double nu_t = nuc->nu(E_in, Nuclide::EmissionMode::total);
double nu_d = nuc->nu(E_in, Nuclide::EmissionMode::delayed);
double beta = nu_d / nu_t;
double mu;
if (prn(seed) < beta) {
// ====================================================================
// DELAYED NEUTRON SAMPLED
@ -1096,6 +1085,12 @@ void sample_fission_neutron(int i_nuclide, const Reaction& rx, double E_in, Part
}
}
}
// Sample azimuthal angle uniformly in [0, 2*pi) and assign angle
double phi = 2.0*PI*prn(seed);
site->u.x = mu;
site->u.y = std::sqrt(1.0 - mu*mu) * std::cos(phi);
site->u.z = std::sqrt(1.0 - mu*mu) * std::sin(phi);
}
void inelastic_scatter(const Nuclide& nuc, const Reaction& rx, Particle& p)

View file

@ -63,25 +63,6 @@ Reaction::Reaction(hid_t group, const std::vector<int>& temperatures)
close_group(pgroup);
}
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<< REMOVE THIS <<<<<<<<<<<<<<<<<<<<<<<<<
// Before the secondary distribution refactor, when the angle/energy
// distribution was uncorrelated, no angle was actually sampled. With
// the refactor, an angle is always sampled for an uncorrelated
// distribution even when no angle distribution exists in the ACE file
// (isotropic is assumed). To preserve the RNG stream, we explicitly
// mark fission reactions so that we avoid the angle sampling.
if (is_fission(mt_)) {
for (auto& p : products_) {
if (p.particle_ == Particle::Type::neutron) {
for (auto& d : p.distribution_) {
auto d_ = dynamic_cast<UncorrelatedAngleEnergy*>(d.get());
if (d_) d_->fission() = true;
}
}
}
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<< REMOVE THIS <<<<<<<<<<<<<<<<<<<<<<<<<
}
double

View file

@ -55,12 +55,7 @@ UncorrelatedAngleEnergy::sample(double E_in, double& E_out, double& mu,
uint64_t* seed) const
{
// Sample cosine of scattering angle
if (fission_) {
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< REMOVE THIS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// For fission, the angle is not used, so just assign a dummy value
mu = 1.0;
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< REMOVE THIS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
} else if (!angle_.empty()) {
if (!angle_.empty()) {
mu = angle_.sample(E_in, seed);
} else {
// no angle distribution given => assume isotropic for all energies