Convert Reaction type

This commit is contained in:
Paul Romano 2018-07-11 07:01:54 -05:00
parent 7ded07f9cf
commit d4775552e0
3 changed files with 78 additions and 0 deletions

View file

@ -412,6 +412,7 @@ add_library(libopenmc SHARED
src/position.cpp
src/pugixml/pugixml_c.cpp
src/random_lcg.cpp
src/reaction.cpp
src/reaction_product.cpp
src/secondary_correlated.cpp
src/secondary_kalbach.cpp

48
src/reaction.cpp Normal file
View file

@ -0,0 +1,48 @@
#include "reaction.h"
#include <string>
#include <utility> // for move
#include "hdf5_interface.h"
namespace openmc {
Reaction::Reaction(hid_t group, const std::vector<int>& temperatures)
{
read_attribute(group, "Q_value", q_value_);
read_attribute(group, "mt", mt_);
int cm;
read_attribute(group, "center_of_mass", cm);
scatter_in_cm_ = (cm == 1);
// Read cross section and threshold_idx data
for (auto t : temperatures) {
// Get group corresponding to temperature
std::string temp_str {std::to_string(t) + "K"};
hid_t temp_group = open_group(group, temp_str.c_str());
hid_t dset = open_dataset(temp_group, "xs");
// Get threshold index
TemperatureXS xs;
read_attribute(dset, "threshold_idx", xs.threshold);
// Read cross section values
read_dataset(dset, xs.value);
close_dataset(dset);
close_group(temp_group);
// create new entry in xs vector
xs_.push_back(std::move(xs));
}
// Read products
for (const auto& name : group_names(group)) {
if (name.rfind("product_", 0) == 0) {
hid_t pgroup = open_group(group, name.c_str());
products_.emplace_back(pgroup);
close_group(pgroup);
}
}
}
}

29
src/reaction.h Normal file
View file

@ -0,0 +1,29 @@
#ifndef OPENMC_REACTION_H
#define OPENMC_REACTION_H
#include <vector>
#include "hdf5.h"
#include "reaction_product.h"
namespace openmc {
class Reaction {
public:
explicit Reaction(hid_t group, const std::vector<int>& temperatures);
struct TemperatureXS {
int threshold;
std::vector<double> value;
};
int mt_; //!< ENDF MT value
double q_value_; //!< Reaction Q value in [eV]
bool scatter_in_cm_; //!< scattering system in center-of-mass?
std::vector<TemperatureXS> xs_;
std::vector<ReactionProduct> products_;
};
}
#endif // OPENMC_REACTION_H