Merge pull request #1746 from paulromano/wmp-performance-opt

Performance optimizations for windowed multipole
This commit is contained in:
Gavin Ridley 2021-01-20 12:59:30 -05:00 committed by GitHub
commit c262407af5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 122 additions and 111 deletions

View file

@ -203,19 +203,6 @@ extern "C" double normal_variate(double mean, double std_dev, uint64_t* seed);
extern "C" double muir_spectrum(double e0, double m_rat, double kt,
uint64_t* seed);
//==============================================================================
//! Doppler broadens the windowed multipole curvefit.
//!
//! The curvefit is a polynomial of the form a/E + b/sqrt(E) + c + d sqrt(E)...
//!
//! \param E The energy to evaluate the broadening at
//! \param dopp sqrt(atomic weight ratio / kT) with kT given in eV
//! \param n The number of components to the polynomial
//! \param factors The output leading coefficient
//==============================================================================
extern "C" void broaden_wmp_polynomials(double E, double dopp, int n, double factors[]);
//==============================================================================
//! Constructs a natural cubic spline.
//!

View file

@ -35,6 +35,13 @@ constexpr std::array<int, 2> WMP_VERSION {1, 1};
class WindowedMultipole {
public:
// Types
struct WindowInfo {
int index_start; // Index of starting pole
int index_end; // Index of ending pole
bool broaden_poly; // Whether to broaden polynomial curvefit
};
// Constructors, destructors
WindowedMultipole(hid_t group);
@ -46,7 +53,7 @@ public:
//! \param E Incident neutron energy in [eV]
//! \param sqrtkT Square root of temperature times Boltzmann constant
//! \return Tuple of elastic scattering, absorption, and fission cross sections in [b]
std::tuple<double, double, double> evaluate(double E, double sqrtkT);
std::tuple<double, double, double> evaluate(double E, double sqrtkT) const;
//! \brief Evaluates the windowed multipole equations for the derivative of
//! cross sections in the resolved resonance regions with respect to
@ -56,20 +63,19 @@ public:
//! \param sqrtkT Square root of temperature times Boltzmann constant
//! \return Tuple of derivatives of elastic scattering, absorption, and
//! fission cross sections in [b/K]
std::tuple<double, double, double> evaluate_deriv(double E, double sqrtkT);
std::tuple<double, double, double> evaluate_deriv(double E, double sqrtkT) const;
// Data members
std::string name_; //!< Name of nuclide
bool fissionable_; //!< Is the nuclide fissionable?
xt::xtensor<std::complex<double>, 2> data_; //!< Poles and residues
double sqrt_awr_; //!< Square root of atomic weight ratio
double E_min_; //!< Minimum energy in [eV]
double E_max_; //!< Maximum energy in [eV]
double spacing_; //!< Spacing in sqrt(E) space
double sqrt_awr_; //!< Square root of atomic weight ratio
double inv_spacing_; //!< 1 / spacing in sqrt(E) space
int fit_order_; //!< Order of the fit
xt::xtensor<int, 2> windows_; //!< Indices of pole at start/end of window
xt::xtensor<double, 3> curvefit_; //!< Fitting function (reaction, coeff index, window index)
xt::xtensor<bool, 1> broaden_poly_; //!< Whether to broaden curvefit
bool fissionable_; //!< Is the nuclide fissionable?
std::vector<WindowInfo> window_info_; // Information about a window
xt::xtensor<double, 3> curvefit_; // Curve fit coefficients (window, poly order, reaction)
xt::xtensor<std::complex<double>, 2> data_; //!< Poles and residues
// Constant data
static constexpr int MAX_POLY_COEFFICIENTS =
@ -91,6 +97,20 @@ void check_wmp_version(hid_t file);
//! \param[in] i_nuclide Index in global nuclides array
void read_multipole_data(int i_nuclide);
//==============================================================================
//! Doppler broadens the windowed multipole curvefit.
//!
//! The curvefit is a polynomial of the form a/E + b/sqrt(E) + c + d sqrt(E)...
//!
//! \param E The energy to evaluate the broadening at
//! \param dopp sqrt(atomic weight ratio / kT) with kT given in eV
//! \param n The number of components to the polynomial
//! \param factors The output leading coefficient
//==============================================================================
extern "C" void broaden_wmp_polynomials(double E, double dopp, int n, double factors[]);
} // namespace openmc
#endif // OPENMC_WMP_H