diff --git a/include/openmc/wmp.h b/include/openmc/wmp.h index 97377242a3..2378f89da2 100644 --- a/include/openmc/wmp.h +++ b/include/openmc/wmp.h @@ -70,6 +70,10 @@ public: xt::xtensor windows_; //!< Indices of pole at start/end of window xt::xtensor curvefit_; //!< Fitting function (reaction, coeff index, window index) xt::xtensor broaden_poly_; //!< Whether to broaden curvefit + + // Constant data + static constexpr int MAX_POLY_COEFFICIENTS = + 11; //!< Max order of polynomial fit plus one }; //======================================================================== diff --git a/src/wmp.cpp b/src/wmp.cpp index 60393e9ba7..708cf923f3 100644 --- a/src/wmp.cpp +++ b/src/wmp.cpp @@ -56,6 +56,13 @@ WindowedMultipole::WindowedMultipole(hid_t group) "array shape in WMP library for " + name_ + "."); } fit_order_ = curvefit_.shape()[1] - 1; + + // Check the code is compiling to work with sufficiently high fit order + if (fit_order_ + 1 > MAX_POLY_COEFFICIENTS) { + fatal_error(fmt::format( + "Need to compile with WindowedMultipole::MAX_POLY_COEFFICIENTS = {}", + fit_order_ + 1)); + } } std::tuple @@ -87,7 +94,7 @@ WindowedMultipole::evaluate(double E, double sqrtkT) if (sqrtkT > 0.0 && broaden_poly_(i_window)) { // Broaden the curvefit. double dopp = sqrt_awr_ / sqrtkT; - std::vector broadened_polynomials(fit_order_ + 1); + std::array broadened_polynomials; broaden_wmp_polynomials(E, dopp, fit_order_ + 1, broadened_polynomials.data()); for (int i_poly = 0; i_poly < fit_order_ + 1; ++i_poly) { sig_s += curvefit_(i_window, i_poly, FIT_S) * broadened_polynomials[i_poly];