From 3a72bcfb10893bb6911646f3cd5c54a7a12b31c0 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 9 Sep 2019 17:03:11 -0500 Subject: [PATCH] Create [simple] Tabulated1D with x and y vectors Allow the creation of openmc::Tabulated1D objects using x and y vectors. The implementation is simple and does not handle any breakpoints, assuming all y data can be linearly interpolated. --- include/openmc/endf.h | 6 ++++++ src/endf.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/openmc/endf.h b/include/openmc/endf.h index 61e82bec21..90dfc2c3f5 100644 --- a/include/openmc/endf.h +++ b/include/openmc/endf.h @@ -81,6 +81,12 @@ public: //! \param[in] dset Dataset containing tabulated data explicit Tabulated1D(hid_t dset); + //! Construct using x and y data + //! \param[in] x independent variable + //! \param[in] y dependent variable to be interpolated + //! Assumes no breakpoints with linear interpolation + Tabulated1D(std::vector x, std::vector y); + //! Evaluate the tabulated function //! \param[in] x independent variable //! \return Function evaluated at x diff --git a/src/endf.cpp b/src/endf.cpp index f01a643113..5ef0b43025 100644 --- a/src/endf.cpp +++ b/src/endf.cpp @@ -151,6 +151,16 @@ Tabulated1D::Tabulated1D(hid_t dset) n_pairs_ = x_.size(); } +Tabulated1D::Tabulated1D(std::vector x, std::vector y) +{ + x_ = x; + y_ = y; + n_pairs_ = x.size(); + int_.push_back(Interpolation::lin_lin); + nbt_.push_back(x.size()); + n_regions_ = 1; +} + double Tabulated1D::operator()(double x) const { // find which bin the abscissa is in -- if the abscissa is outside the