mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Always checking DAGMC models for additional material definitions.
This commit is contained in:
parent
3e93b814a9
commit
0bd2f9263b
5 changed files with 61 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ void load_dagmc_geometry();
|
|||
int32_t create_dagmc_universe(const std::string& filename);
|
||||
void read_geometry_dagmc();
|
||||
void read_dagmc_universes(pugi::xml_node node);
|
||||
void read_dagmc_uwuw_materials();
|
||||
bool read_uwuw_materials(pugi::xml_document& doc);
|
||||
bool get_uwuw_materials_xml(std::string& s);
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,50 @@ bool read_uwuw_materials(pugi::xml_document& doc) {
|
|||
return found_uwuw_mats;
|
||||
}
|
||||
|
||||
void read_dagmc_uwuw_materials() {
|
||||
std::string filename = settings::path_input + "geometry.xml";
|
||||
if (!file_exists(filename)) {
|
||||
fatal_error(fmt::format("Geometry XML file '{}' does not exist!", filename));
|
||||
}
|
||||
|
||||
pugi::xml_document doc;
|
||||
auto result = doc.load_file(filename.c_str());
|
||||
if (!result) {
|
||||
fatal_error("Error processing geometry.xml file.");
|
||||
}
|
||||
pugi::xml_node root = doc.document_element();
|
||||
// Loop over DAGMC elements
|
||||
for (pugi::xml_node dagmc_node : root.children("dagmc")) {
|
||||
if (!check_for_node(dagmc_node, "filename")) {
|
||||
fatal_error("No filename specified on a DAGMC universe element");
|
||||
}
|
||||
std::string dagmc_filename = get_node_value(dagmc_node, "filename");
|
||||
// Load any existing UWUW materials
|
||||
UWUW uwuw(dagmc_filename.c_str());
|
||||
const auto& mat_lib = uwuw.material_library;
|
||||
if (mat_lib.size() == 0) continue;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "<?xml version=\"1.0\"?>\n";
|
||||
ss << "<materials>\n";
|
||||
for (auto mat : mat_lib) { ss << mat.second.openmc("atom"); }
|
||||
ss << "</materials>";
|
||||
std::string mat_xml_string = ss.str();
|
||||
|
||||
// create a pugi XML document from this string
|
||||
pugi::xml_document doc;
|
||||
auto result = doc.load_string(mat_xml_string.c_str());
|
||||
if (!result) {
|
||||
fatal_error("Error processing XML created using DAGMC UWUW materials.");
|
||||
}
|
||||
pugi::xml_node root = doc.document_element();
|
||||
for (pugi::xml_node material_node : root.children("material")) {
|
||||
model::materials.push_back(std::make_unique<Material>(material_node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool write_uwuw_materials_xml() {
|
||||
std::string s;
|
||||
bool found_uwuw_mats = get_uwuw_materials_xml(s);
|
||||
|
|
|
|||
|
|
@ -1237,6 +1237,10 @@ void read_materials_xml()
|
|||
for (pugi::xml_node material_node : root.children("material")) {
|
||||
model::materials.push_back(make_unique<Material>(material_node));
|
||||
}
|
||||
|
||||
// Search for materials defined on DAGMC models
|
||||
read_dagmc_uwuw_materials();
|
||||
|
||||
model::materials.shrink_to_fit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<geometry>
|
||||
<dagmc filename="dagmc.h5m" id="9" name="" />
|
||||
</geometry>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<materials>
|
||||
</materials>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<settings>
|
||||
<run_mode>eigenvalue</run_mode>
|
||||
<particles>100</particles>
|
||||
|
|
@ -9,7 +16,6 @@
|
|||
<parameters>-4 -4 -4 4 4 4</parameters>
|
||||
</space>
|
||||
</source>
|
||||
<dagmc>true</dagmc>
|
||||
</settings>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<tallies>
|
||||
|
|
|
|||
|
|
@ -27,13 +27,17 @@ class UWUWTest(PyAPITestHarness):
|
|||
|
||||
model.settings.export_to_xml()
|
||||
|
||||
# geometry
|
||||
dag_univ = openmc.DAGMCUniverse("dagmc.h5m")
|
||||
model.geometry = openmc.Geometry(root=dag_univ)
|
||||
|
||||
# tally
|
||||
tally = openmc.Tally()
|
||||
tally.scores = ['total']
|
||||
tally.filters = [openmc.CellFilter(1)]
|
||||
model.tallies = [tally]
|
||||
|
||||
model.tallies.export_to_xml()
|
||||
model.export_to_xml()
|
||||
|
||||
def test_uwuw():
|
||||
harness = UWUWTest('statepoint.5.h5')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue