Make sure fission neutron energy is resampled if > max energy

Also fix two other bugs, one where openmc.capi.find_material crashes if a
material is void, and one where OpenMC doesn't compile if omp.h is missing (can
happen on macOS).
This commit is contained in:
Paul Romano 2018-12-05 08:35:08 -06:00
parent aaffe35056
commit cef713b91e
3 changed files with 7 additions and 3 deletions

View file

@ -121,7 +121,7 @@ def find_material(xyz):
_dll.openmc_find_cell((c_double*3)(*xyz), index, instance)
mats = openmc.capi.Cell(index=index.value).fill
if isinstance(mats, openmc.capi.Material):
if isinstance(mats, (openmc.capi.Material, type(None))):
return mats
else:
return mats[instance.value]

View file

@ -1057,7 +1057,8 @@ void sample_fission_neutron(int i_nuclide, const Reaction* rx, double E_in, Bank
rx->products_[group].sample(E_in, site->E, mu);
// resample if energy is greater than maximum neutron energy
constexpr int neutron = static_cast<int>(ParticleType::neutron);
// TODO: off-by-one
constexpr int neutron = static_cast<int>(ParticleType::neutron) - 1;
if (site->E < data::energy_max[neutron]) break;
// check for large number of resamples
@ -1082,7 +1083,8 @@ void sample_fission_neutron(int i_nuclide, const Reaction* rx, double E_in, Bank
rx->products_[0].sample(E_in, site->E, mu);
// resample if energy is greater than maximum neutron energy
constexpr int neutron = static_cast<int>(ParticleType::neutron);
// TODO: off-by-one
constexpr int neutron = static_cast<int>(ParticleType::neutron) - 1;
if (site->E < data::energy_max[neutron]) break;
// check for large number of resamples

View file

@ -5,7 +5,9 @@
#include <sstream>
#include <string>
#ifdef _OPENMP
#include <omp.h>
#endif
#include "openmc/capi.h"
#include "openmc/constants.h"