From 39c063830cd87210d089f4e9c928038afe8eedc1 Mon Sep 17 00:00:00 2001 From: Adam G Nelson Date: Fri, 15 Jun 2018 19:46:25 -0400 Subject: [PATCH] minor changes, still not passing the test --- src/math_functions.cpp | 2 +- src/scattdata.cpp | 23 ++++++++++------------- src/scattdata.h | 4 ++-- src/xsdata.cpp | 3 ++- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/math_functions.cpp b/src/math_functions.cpp index 159e0a4e2..31f86ea5f 100644 --- a/src/math_functions.cpp +++ b/src/math_functions.cpp @@ -97,7 +97,7 @@ void calc_pn_c(int n, double x, double pnx[]) { } // Use recursion relation to build the higher orders - for (int l = 1; l < n; l ++) { + for (int l = 1; l < n; l++) { pnx[l + 1] = ((2 * l + 1) * x * pnx[l] - l * pnx[l - 1]) / (l + 1); } } diff --git a/src/scattdata.cpp b/src/scattdata.cpp index dd8ca07e4..6bce75c64 100644 --- a/src/scattdata.cpp +++ b/src/scattdata.cpp @@ -6,8 +6,8 @@ namespace openmc { // ScattData base-class methods //============================================================================== -void ScattData::generic_init(int order, int_1dvec in_gmin, - int_1dvec in_gmax, double_2dvec in_energy, double_2dvec in_mult) +void ScattData::generic_init(int order, int_1dvec& in_gmin, + int_1dvec& in_gmax, double_2dvec& in_energy, double_2dvec& in_mult) { int groups = in_energy.size(); @@ -18,18 +18,17 @@ void ScattData::generic_init(int order, int_1dvec in_gmin, dist.resize(groups); for (int gin = 0; gin < groups; gin++) { - // Make sure the energy is normalized - double norm = std::accumulate(in_energy[gin].begin(), - in_energy[gin].end(), 0.); - - if (norm != 0.) { - for (auto& n : in_energy[gin]) n /= norm; - } - // Store the inputted data energy[gin] = in_energy[gin]; mult[gin] = in_mult[gin]; + // Make sure the energy is normalized + double norm = std::accumulate(energy[gin].begin(), energy[gin].end(), 0.); + + if (norm != 0.) { + for (auto& n : energy[gin]) n /= norm; + } + // Initialize the distribution data dist[gin].resize(in_gmax[gin] - in_gmin[gin] + 1); for (auto& v : dist[gin]) { @@ -131,9 +130,7 @@ void ScattDataLegendre::init(int_1dvec& in_gmin, int_1dvec& in_gmax, int num_groups = in_gmax[gin] - in_gmin[gin] + 1; scattxs[gin] = 0.; for (int i_gout = 0; i_gout < num_groups; i_gout++) { - scattxs[gin] = std::accumulate(matrix[gin][i_gout].begin(), - matrix[gin][i_gout].end(), - scattxs[gin]); + scattxs[gin] += matrix[gin][i_gout][0]; } } diff --git a/src/scattdata.h b/src/scattdata.h index a9a236b2b..456610655 100644 --- a/src/scattdata.h +++ b/src/scattdata.h @@ -39,8 +39,8 @@ class ScattData { double_2dvec& in_mult, double_3dvec& coeffs) = 0; void sample_energy(int gin, int& gout, int& i_gout); double get_xs(const int xstype, int gin, int* gout, double* mu); - void generic_init(int order, int_1dvec in_gmin, int_1dvec in_gmax, - double_2dvec in_energy, double_2dvec in_mult); + void generic_init(int order, int_1dvec& in_gmin, int_1dvec& in_gmax, + double_2dvec& in_energy, double_2dvec& in_mult); virtual void combine(std::vector& those_scatts, double_1dvec& scalars) = 0; virtual int get_order() = 0; diff --git a/src/xsdata.cpp b/src/xsdata.cpp index 62bfdc916..655bf9a89 100644 --- a/src/xsdata.cpp +++ b/src/xsdata.cpp @@ -602,7 +602,7 @@ void XsData::_scatter_from_hdf5(hid_t xsdata_grp, int n_pol, int n_azi, double_4dvec temp_mult = double_4dvec(n_pol, double_3dvec(n_azi, double_2dvec(energy_groups))); if (object_exists(scatt_grp, "multiplicity_matrix")) { - temp_arr.resize(length); + temp_arr.resize(length / order_data); read_nd_vector(scatt_grp, "multiplicity_matrix", temp_arr); // convert the flat temp_arr to a jagged array for passing to scatt data @@ -630,6 +630,7 @@ void XsData::_scatter_from_hdf5(hid_t xsdata_grp, int n_pol, int n_azi, } } } + temp_arr.clear(); close_group(scatt_grp); // Finally, convert the Legendre data to tabular, if needed