From 4b1cd83a54c7a5d894f6c29172559ddbaa8270cc Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 22 Dec 2020 15:04:51 -0600 Subject: [PATCH] Address @pshriwise comments on #1733 --- docs/source/usersguide/cross_sections.rst | 12 ++++++------ src/thermal.cpp | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/docs/source/usersguide/cross_sections.rst b/docs/source/usersguide/cross_sections.rst index 5dac7b0f70..74267c9c08 100644 --- a/docs/source/usersguide/cross_sections.rst +++ b/docs/source/usersguide/cross_sections.rst @@ -31,7 +31,7 @@ Environment Variables When :ref:`scripts_openmc` is run, it will look for several environment variables that indicate where cross sections can be found. While the location of cross sections can also be indicated through the -:attr:`openmc.Materials.cross_section` attribute (or in the :ref:`materials.xml +:attr:`openmc.Materials.cross_sections` attribute (or in the :ref:`materials.xml ` file), if you always use the same set of cross section data, it is often easier to just set an environment variable that will be picked up by default every time OpenMC is run. The following environment variables are used: @@ -76,11 +76,11 @@ Manually Creating a Library from ACE files .. currentmodule:: openmc.data The :mod:`openmc.data` module in the Python API enables users to directly -convert ACE data and create a :ref:`cross_sections.xml ` -file. For those who prefer to use the API directly, the -:class:`openmc.data.IncidentNeutron` and :class:`openmc.data.ThermalScattering` -classes can be used to read ACE data and convert it to HDF5. For -continuous-energy incident neutron data, use the +convert ACE data to OpenMC's HDF5 format and create a corresponding +:ref:`cross_sections.xml ` file. For those who prefer to use +the API directly, the :class:`openmc.data.IncidentNeutron` and +:class:`openmc.data.ThermalScattering` classes can be used to read ACE data and +convert it to HDF5. For continuous-energy incident neutron data, use the :meth:`IncidentNeutron.from_ace` class method to read in an existing ACE file and the :meth:`IncidentNeutron.export_to_hdf5` method to write the data to an HDF5 file. diff --git a/src/thermal.cpp b/src/thermal.cpp index 4bb0487188..4b15614283 100644 --- a/src/thermal.cpp +++ b/src/thermal.cpp @@ -153,13 +153,10 @@ ThermalScattering::calculate_xs(double E, double sqrtkT, int* i_temp, double kT = sqrtkT*sqrtkT; int i = 0; - if (kTs_.size() > 1) { + auto n = kTs_.size(); + if (n > 1) { // Find temperatures that bound the actual temperature - for (i = 0; i < kTs_.size() - 1; ++i) { - if (kTs_[i] <= kT && kT < kTs_[i+1]) { - break; - } - } + while (kTs_[i+1] < kT && i + 1 < n - 1) ++i; if (settings::temperature_method == TemperatureMethod::NEAREST) { // Pick closer of two bounding temperatures