hummingbird
Solving the self-adjoint angular flux transport equation using spectral elements on Cartesian geometry
Loading...
Searching...
No Matches
material_bank.cc
Go to the documentation of this file.
2
3namespace hummingbird {
4void from_json(const json& j, Material& material) {
5 material.scattering_xs = j.at("scattering_xs").get<double>();
6 material.total_xs = j.at("total_xs").get<double>();
7 material.fission_xs = j.at("fission_xs").get<double>();
8 material.nu = j.at("nu").get<double>();
9}
10
11MaterialBank::MaterialBank(const json& input_file_json) {
12 Build(input_file_json);
14}
15
16void MaterialBank::Build(const json& input_file_json) {
17 int id = 0;
18 for (const auto& [name, material_json] :
19 input_file_json.at("materials").items()) {
20 Material material = material_json.get<Material>();
21
22 id_object_map_.emplace(id, std::move(material));
23 name_id_map_.emplace(name, id);
24 id++;
25 }
26}
27
29 std::vector<Material> materials;
30 materials.reserve(id_object_map_.size());
31 for (const auto& [id, material] : id_object_map_)
32 materials.push_back(material);
33
34 for (const auto& material : materials) {
35 if (material.total_xs < (material.scattering_xs + material.fission_xs))
36 throw std::runtime_error(
37 "Sum of scattering and fission cross sections is greater than the "
38 "total cross section. Please check over material data in input "
39 "file.");
40 if (material.total_xs < 0)
41 throw std::runtime_error(
42 "Negative total cross section passed in material. Please check over "
43 "material data in input file.");
44 if (material.scattering_xs < 0)
45 throw std::runtime_error(
46 "Negative scattering cross section passed in material. Please check "
47 "over material data in input file.");
48 if (material.fission_xs < 0)
49 throw std::runtime_error(
50 "Negative fission cross section passed in material. Please check "
51 "over material data in input file.");
52 if (material.nu < 0)
53 throw std::runtime_error(
54 "Negative fission multiplication (nu) passed in material. Please "
55 "check over material data in input file.");
56 }
57}
58
59} // namespace hummingbird
std::unordered_map< std::string, int > name_id_map_
Definition bank_base.h:56
std::unordered_map< int, Material > id_object_map_
Definition bank_base.h:53
void CheckMaterials()
Check that all materials in id_object_map_ have physically valid cross sections.
MaterialBank(const json &json_input)
Construct a new Material Bank object. Material structs are built using the json input.
void Build(const json &json_input)
Builds the material structs and assigns them to the id_material_map_ and name_id_map_ members.
void from_json(const json &j, Material &material)
Get the Material information from the json input.
Defines a monoenergetic, constant-properties material.
Definition material.h:13
double scattering_xs
Isotropic scattering macroscopic cross section in 1/cm.
Definition material.h:18
double nu
Average number of neutrons produced per fission event.
Definition material.h:24
double total_xs
Total macroscopic cross section in 1/cm.
Definition material.h:15
double fission_xs
Fission macroscopic cross section in 1/cm.
Definition material.h:21