From faa70b168f61867e1d102bc57a8c8d504a572905 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 10 Jan 2019 15:53:45 -0600 Subject: [PATCH] Remove weight correction method for resonance scattering, rename ARES -> RVS --- docs/source/io_formats/settings.rst | 12 ++++---- examples/jupyter/nuclear-data.ipynb | 2 +- include/openmc/constants.h | 9 +++--- include/openmc/physics.h | 2 +- include/openmc/settings.h | 23 +++++++------- openmc/settings.py | 18 +++++------ src/finalize.cpp | 2 +- src/physics.cpp | 30 ++++++------------- src/plot.cpp | 8 ----- src/settings.cpp | 11 +++---- .../resonance_scattering/inputs_true.dat | 2 +- .../resonance_scattering/test.py | 2 +- tests/unit_tests/test_settings.py | 2 +- 13 files changed, 51 insertions(+), 72 deletions(-) diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 178c44080..13a53fb0b 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -321,14 +321,14 @@ or sub-elements: :method: - Which resonance elastic scattering method is to be applied: "ares" - (accelerated resonance elastic scattering), "dbrc" (Doppler broadening - rejection correction), or "wcm" (weight correction method). Descriptions of - each of these methods are documented here_. + Which resonance elastic scattering method is to be applied: "rvs" (relative + velocity sampling), "dbrc" (Doppler broadening rejection correction), or + "wcm" (weight correction method). Descriptions of each of these methods are + documented here_. - .. _here: http://dx.doi.org/10.1016/j.anucene.2014.01.017 + .. _here: http://dx.doi.org/10.1016/j.anucene.2017.12.044 - *Default*: "ares" + *Default*: "rvs" :energy_min: The energy in eV above which the resonance elastic scattering method should diff --git a/examples/jupyter/nuclear-data.ipynb b/examples/jupyter/nuclear-data.ipynb index aace5e9d2..09da5a2d0 100644 --- a/examples/jupyter/nuclear-data.ipynb +++ b/examples/jupyter/nuclear-data.ipynb @@ -1203,7 +1203,7 @@ "source": [ "## Heavy-nuclide resonance scattering\n", "\n", - "OpenMC has two methods for accounting for resonance upscattering in heavy nuclides, DBRC and ARES. These methods rely on 0 K elastic scattering data being present. If you have an existing ACE/HDF5 dataset and you need to add 0 K elastic scattering data to it, this can be done using the `IncidentNeutron.add_elastic_0K_from_endf()` method. Let's do this with our original `gd157` object that we instantiated from an ACE file." + "OpenMC has two methods for accounting for resonance upscattering in heavy nuclides, DBRC and RVS. These methods rely on 0 K elastic scattering data being present. If you have an existing ACE/HDF5 dataset and you need to add 0 K elastic scattering data to it, this can be done using the `IncidentNeutron.add_elastic_0K_from_endf()` method. Let's do this with our original `gd157` object that we instantiated from an ACE file." ] }, { diff --git a/include/openmc/constants.h b/include/openmc/constants.h index 5b0fd8ec4..d29abcdcf 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -269,10 +269,11 @@ constexpr int PARTIAL_FISSION_MAX {4}; // Resonance elastic scattering methods // TODO: Convert to enum -constexpr int RES_SCAT_ARES {1}; -constexpr int RES_SCAT_DBRC {2}; -constexpr int RES_SCAT_WCM {3}; -constexpr int RES_SCAT_CXS {4}; +enum class ResScatMethod { + rvs, // Relative velocity sampling + dbrc, // Doppler broadening rejection correction + cxs // Constant cross section +}; // Electron treatments // TODO: Convert to enum diff --git a/include/openmc/physics.h b/include/openmc/physics.h index 1b5fb9023..a51ed91b8 100644 --- a/include/openmc/physics.h +++ b/include/openmc/physics.h @@ -64,7 +64,7 @@ void sab_scatter(int i_nuclide, int i_sab, double* E, //! samples the target velocity. The constant cross section free gas model is //! the default method. Methods for correctly accounting for the energy //! dependence of cross sections in treating resonance elastic scattering such -//! as the DBRC, WCM, and a new, accelerated scheme are also implemented here. +//! as the DBRC and a new, accelerated scheme are also implemented here. Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, Direction v_neut, double xs_eff, double kT, double* wgt); diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 06cc1ab90..bfd3d056f 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -12,6 +12,8 @@ #include "pugixml.hpp" +#include "openmc/constants.h" + namespace openmc { //============================================================================== @@ -33,7 +35,7 @@ extern "C" bool output_tallies; //!< write tallies.out? extern "C" bool particle_restart_run; //!< particle restart run? extern "C" bool photon_transport; //!< photon transport turned on? extern "C" bool reduce_tallies; //!< reduce tallies at end of batch? -extern "C" bool res_scat_on; //!< use resonance upscattering method? +extern bool res_scat_on; //!< use resonance upscattering method? extern "C" bool restart_run; //!< restart run? extern "C" bool run_CE; //!< run with continuous-energy data? extern "C" bool source_latest; //!< write latest source at each batch? @@ -43,8 +45,8 @@ extern "C" bool survival_biasing; //!< use survival biasing? extern "C" bool temperature_multipole; //!< use multipole data? extern "C" bool trigger_on; //!< tally triggers enabled? extern "C" bool trigger_predict; //!< predict batches for triggers? -extern "C" bool ufs_on; //!< uniform fission site method on? -extern "C" bool urr_ptables_on; //!< use unresolved resonance prob. tables? +extern bool ufs_on; //!< uniform fission site method on? +extern bool urr_ptables_on; //!< use unresolved resonance prob. tables? extern "C" bool write_all_tracks; //!< write track files for every particle? extern "C" bool write_initial_source; //!< write out initial source file? extern "C" bool dagmc; //!< indicator of DAGMC geometry @@ -58,9 +60,8 @@ extern std::string path_source; extern std::string path_sourcepoint; //!< path to a source file extern std::string path_statepoint; //!< path to a statepoint file -extern "C" int32_t index_entropy_mesh; //!< Index of entropy mesh in global mesh array -extern "C" int32_t index_ufs_mesh; //!< Index of UFS mesh in global mesh array -extern "C" int32_t index_cmfd_mesh; //!< Index of CMFD mesh in global mesh array +extern int32_t index_entropy_mesh; //!< Index of entropy mesh in global mesh array +extern int32_t index_ufs_mesh; //!< Index of UFS mesh in global mesh array extern "C" int32_t n_batches; //!< number of (inactive+active) batches extern "C" int32_t n_inactive; //!< number of inactive batches @@ -73,9 +74,9 @@ extern "C" int legendre_to_tabular_points; //!< number of points to convert Lege extern "C" int max_order; //!< Maximum Legendre order for multigroup data extern "C" int n_log_bins; //!< number of bins for logarithmic energy grid extern "C" int n_max_batches; //!< Maximum number of batches -extern "C" int res_scat_method; //!< resonance upscattering method -extern "C" double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering -extern "C" double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering +extern ResScatMethod res_scat_method; //!< resonance upscattering method +extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering +extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering extern std::vector res_scat_nuclides; //!< Nuclides using res. upscattering treatment extern "C" int run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written @@ -90,8 +91,8 @@ extern "C" int64_t trace_particle; //!< Particle ID to enable trace on extern std::vector> track_identifiers; //!< Particle numbers for writing tracks extern "C" int trigger_batch_interval; //!< Batch interval for triggers extern "C" int verbosity; //!< How verbose to make output -extern "C" double weight_cutoff; //!< Weight cutoff for Russian roulette -extern "C" double weight_survive; //!< Survival weight after Russian roulette +extern double weight_cutoff; //!< Weight cutoff for Russian roulette +extern double weight_survive; //!< Survival weight after Russian roulette } // namespace settings //! Read settings from XML file diff --git a/openmc/settings.py b/openmc/settings.py index 1d97250ed..ab91aa5a6 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -11,7 +11,7 @@ import openmc.checkvalue as cv from openmc import VolumeCalculation, Source, Mesh _RUN_MODES = ['eigenvalue', 'fixed source', 'plot', 'volume', 'particle restart'] -_RES_SCAT_METHODS = ['dbrc', 'wcm', 'ares'] +_RES_SCAT_METHODS = ['dbrc', 'rvs'] class Settings(object): @@ -82,14 +82,14 @@ class Settings(object): Settings for resonance elastic scattering. Accepted keys are 'enable' (bool), 'method' (str), 'energy_min' (float), 'energy_max' (float), and 'nuclides' (list). The 'method' can be set to 'dbrc' (Doppler broadening - rejection correction), 'wcm' (weight correction method), and 'ares' - (accelerated resonance elastic scattering). If not specified, 'ares' is - the default method. The 'energy_min' and 'energy_max' values indicate - the minimum and maximum energies above and below which the resonance - elastic scattering method is to be applied. The 'nuclides' list - indicates what nuclides the method should be applied to. In its absence, - the method will be applied to all nuclides with 0 K elastic scattering - data present. + rejection correction), 'wcm' (weight correction method), and 'rvs' + (relative velocity sampling). If not specified, 'rvs' is the default + method. The 'energy_min' and 'energy_max' values indicate the minimum + and maximum energies above and below which the resonance elastic + scattering method is to be applied. The 'nuclides' list indicates what + nuclides the method should be applied to. In its absence, the method + will be applied to all nuclides with 0 K elastic scattering data + present. run_mode : {'eigenvalue', 'fixed source', 'plot', 'volume', 'particle restart'} The type of calculation to perform (default is 'eigenvalue') seed : int diff --git a/src/finalize.cpp b/src/finalize.cpp index 84b68e82e..2a9f5923e 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -47,7 +47,7 @@ int openmc_finalize() settings::photon_transport = false; settings::reduce_tallies = true; settings::res_scat_on = false; - settings::res_scat_method = RES_SCAT_ARES; + settings::res_scat_method = ResScatMethod::rvs; settings::res_scat_energy_min = 0.01; settings::res_scat_energy_max = 1000.0; settings::restart_run = false; diff --git a/src/physics.cpp b/src/physics.cpp index 4a303c3ce..8aec309e8 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -799,7 +799,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, Direction v_neut, double xs_eff, double kT, double* wgt) { // check if nuclide is a resonant scatterer - int sampling_method; + ResScatMethod sampling_method; if (nuc->resonant_) { // sampling method to use @@ -811,7 +811,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, // lower resonance scattering energy bound (should be no resonances below) } else if (E < settings::res_scat_energy_min) { - sampling_method = RES_SCAT_CXS; + sampling_method = ResScatMethod::cxs; } // otherwise, use free gas model @@ -819,31 +819,19 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, if (E >= FREE_GAS_THRESHOLD * kT && nuc->awr_ > 1.0) { return {}; } else { - sampling_method = RES_SCAT_CXS; + sampling_method = ResScatMethod::cxs; } } // use appropriate target velocity sampling method switch (sampling_method) { - case RES_SCAT_CXS: + case ResScatMethod::cxs: // sample target velocity with the constant cross section (cxs) approx. return sample_cxs_target_velocity(nuc->awr_, E, u, kT); - case RES_SCAT_WCM: { - // sample target velocity with the constant cross section (cxs) approx. - Direction v_target = sample_cxs_target_velocity(nuc->awr_, E, u, kT); - - // adjust weight as prescribed by the weight correction method (wcm) - Direction v_rel = v_neut - v_target; - double E_rel = v_rel.dot(v_rel); - double xs_0K = nuc->elastic_xs_0K(E_rel); - *wgt *= xs_0K / xs_eff; - return v_target; - } - - case RES_SCAT_DBRC: - case RES_SCAT_ARES: { + case ResScatMethod::dbrc: + case ResScatMethod::rvs: { double E_red = std::sqrt(nuc->awr_ * E / kT); double E_low = std::pow(std::max(0.0, E_red - 4.0), 2) * kT / nuc->awr_; double E_up = (E_red + 4.0)*(E_red + 4.0) * kT / nuc->awr_; @@ -877,7 +865,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, return sample_cxs_target_velocity(nuc->awr_, E, u, kT); } - if (sampling_method == RES_SCAT_DBRC) { + if (sampling_method == ResScatMethod::dbrc) { // interpolate xs since we're not exactly at the energy indices double xs_low = nuc->elastic_0K_[i_E_low]; double m = (nuc->elastic_0K_[i_E_low + 1] - xs_low) @@ -910,7 +898,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, if (prn() < R) return v_target; } - } else if (sampling_method == RES_SCAT_ARES) { + } else if (sampling_method == ResScatMethod::rvs) { // interpolate xs CDF since we're not exactly at the energy indices // cdf value at lower bound attainable energy double m = (nuc->xs_cdf_[i_E_low] - nuc->xs_cdf_[i_E_low - 1]) @@ -952,7 +940,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, } } } - } // case RES_SCAT_ARES, RES_SCAT_DBRC + } // case RVS, DBRC } // switch (sampling_method) } diff --git a/src/plot.cpp b/src/plot.cpp index 70dcd11b5..be217083c 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -495,14 +495,6 @@ Plot::set_meshlines(pugi::xml_node plot_node) } else { index_meshlines_mesh_ = settings::index_ufs_mesh; } - } else if ("cmfd" == meshtype) { - if (!settings::cmfd_run) { - std::stringstream err_msg; - err_msg << "Need CMFD run to plot CMFD mesh for meshlines on plot " << id_; - fatal_error(err_msg); - } else { - index_meshlines_mesh_ = settings::index_cmfd_mesh; - } } else if ("entropy" == meshtype) { if (settings::index_entropy_mesh < 0) { std::stringstream err_msg; diff --git a/src/settings.cpp b/src/settings.cpp index 3cfbd4286..dbbe9c6da 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -74,7 +74,6 @@ std::string path_statepoint; int32_t index_entropy_mesh {-1}; int32_t index_ufs_mesh {-1}; -int32_t index_cmfd_mesh {-1}; int32_t n_batches; int32_t n_inactive {0}; @@ -87,7 +86,7 @@ int legendre_to_tabular_points {C_NONE}; int max_order {0}; int n_log_bins {8000}; int n_max_batches; -int res_scat_method {RES_SCAT_ARES}; +ResScatMethod res_scat_method {ResScatMethod::rvs}; double res_scat_energy_min {0.01}; double res_scat_energy_max {1000.0}; std::vector res_scat_nuclides; @@ -703,12 +702,10 @@ void read_settings_xml() // Determine what method is used if (check_for_node(node_res_scat, "method")) { auto temp = get_node_value(node_res_scat, "method", true, true); - if (temp == "ares") { - res_scat_method = RES_SCAT_ARES; + if (temp == "rvs") { + res_scat_method = ResScatMethod::rvs; } else if (temp == "dbrc") { - res_scat_method = RES_SCAT_DBRC; - } else if (temp == "wcm") { - res_scat_method = RES_SCAT_WCM; + res_scat_method = ResScatMethod::dbrc; } else { fatal_error("Unrecognized resonance elastic scattering method: " + temp + "."); diff --git a/tests/regression_tests/resonance_scattering/inputs_true.dat b/tests/regression_tests/resonance_scattering/inputs_true.dat index 2301ccf76..57a5e1a4b 100644 --- a/tests/regression_tests/resonance_scattering/inputs_true.dat +++ b/tests/regression_tests/resonance_scattering/inputs_true.dat @@ -26,7 +26,7 @@ true - ares + rvs 1.0 210.0 U238 U235 Pu239 diff --git a/tests/regression_tests/resonance_scattering/test.py b/tests/regression_tests/resonance_scattering/test.py index 15e9d6894..c83005ff2 100644 --- a/tests/regression_tests/resonance_scattering/test.py +++ b/tests/regression_tests/resonance_scattering/test.py @@ -28,7 +28,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): 'enable': True, 'energy_min': 1.0, 'energy_max': 210.0, - 'method': 'ares', + 'method': 'rvs', 'nuclides': ['U238', 'U235', 'Pu239'] } diff --git a/tests/unit_tests/test_settings.py b/tests/unit_tests/test_settings.py index a78f074c9..697eb095f 100644 --- a/tests/unit_tests/test_settings.py +++ b/tests/unit_tests/test_settings.py @@ -40,7 +40,7 @@ def test_export_to_xml(run_in_tmpdir): s.trace = (10, 1, 20) s.track = [1, 1, 1, 2, 1, 1] s.ufs_mesh = mesh - s.resonance_scattering = {'enable': True, 'method': 'ares', + s.resonance_scattering = {'enable': True, 'method': 'rvs', 'energy_min': 1.0, 'energy_max': 1000.0, 'nuclides': ['U235', 'U238', 'Pu239']} s.volume_calculations = openmc.VolumeCalculation(