From 7ef73f048d146a8de20892fdc6eb0f6d9ae18c64 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 13 Nov 2020 13:28:32 -0600 Subject: [PATCH] Remove special treatment of mu for fission --- include/openmc/secondary_uncorrelated.h | 2 -- src/physics.cpp | 19 +++++++------------ src/reaction.cpp | 19 ------------------- src/secondary_uncorrelated.cpp | 7 +------ 4 files changed, 8 insertions(+), 39 deletions(-) diff --git a/include/openmc/secondary_uncorrelated.h b/include/openmc/secondary_uncorrelated.h index 79b8b5031..673a299dc 100644 --- a/include/openmc/secondary_uncorrelated.h +++ b/include/openmc/secondary_uncorrelated.h @@ -35,11 +35,9 @@ public: // Accessors AngleDistribution& angle() { return angle_; } - bool& fission() { return fission_; } private: AngleDistribution angle_; //!< Angle distribution std::unique_ptr energy_; //!< Energy distribution - bool fission_ {false}; //!< Whether distribution is use for fission }; } // namespace openmc diff --git a/src/physics.cpp b/src/physics.cpp index 7a8be4ee0..3b1e05a0f 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -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) diff --git a/src/reaction.cpp b/src/reaction.cpp index 3e4d3b981..303bd3393 100644 --- a/src/reaction.cpp +++ b/src/reaction.cpp @@ -63,25 +63,6 @@ Reaction::Reaction(hid_t group, const std::vector& 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(d.get()); - if (d_) d_->fission() = true; - } - } - } - } - // <<<<<<<<<<<<<<<<<<<<<<<<<<<< REMOVE THIS <<<<<<<<<<<<<<<<<<<<<<<<< } double diff --git a/src/secondary_uncorrelated.cpp b/src/secondary_uncorrelated.cpp index a1aa8ca0b..9b3eb9d3d 100644 --- a/src/secondary_uncorrelated.cpp +++ b/src/secondary_uncorrelated.cpp @@ -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