From cc6822f171e9963f91a6adeb7d3fabcbbe363f46 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 7 Oct 2019 00:11:51 -0500 Subject: [PATCH 01/13] Pulling in C++ side changes for counter caching. --- include/openmc/geometry_aux.h | 70 +++++++++++++++++++ src/finalize.cpp | 4 ++ src/geometry_aux.cpp | 126 +++++++++++++++++++++++++++++++--- 3 files changed, 189 insertions(+), 11 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index ffcdcf885..557d82193 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -7,8 +7,78 @@ #include #include #include +#include namespace openmc { + struct CellCountStorage { + private: + CellCountStorage() {} + CellCountStorage(CellCountStorage& c) {} + CellCountStorage(const CellCountStorage& c) {} + + static CellCountStorage* instance_; + + std::map> counts; + + public: + + static CellCountStorage* instance() { + if (instance_ == nullptr) + instance_ = new CellCountStorage; + + return instance_; + } + + + + void clear(); + + void set_cell_count_for_univ(int32_t univ, int32_t cell, int count); + + void increment_count_for_univ(int32_t univ, int32_t cell); + + bool has_count(int32_t univ, int32_t cell); + + bool has_count(int32_t univ); + + void absorb_b_into_a(int32_t a, int32_t b); + + auto get_count(int32_t univ); + }; + + struct LevelCountStorage { + private: + LevelCountStorage() {} + LevelCountStorage(LevelCountStorage& c) {} + LevelCountStorage(const LevelCountStorage& c) {} + + static LevelCountStorage* instance_; + + std::map counts; + + public: + + static LevelCountStorage* instance() { + if (instance_ == nullptr) + instance_ = new LevelCountStorage; + + return instance_; + } + + void clear(); + + void set_cell_count_for_univ(int32_t univ, int count); + + void increment_count_for_univ(int32_t univ); + + bool has_count(int32_t univ); + + void absorb_b_into_a(int32_t a, int32_t b); + + void set_count(int32_t univ, int count); + + int get_count(int32_t univ); + }; void read_geometry_xml(); diff --git a/src/finalize.cpp b/src/finalize.cpp index 3de20d6d0..f2cbc973c 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -135,6 +135,10 @@ int openmc_finalize() int openmc_reset() { + + CellCountStorage::instance()->clear(); + LevelCountStorage::instance()->clear(); + for (auto& t : model::tallies) { t->reset(); } diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index d195a9de3..662b6790d 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -60,6 +60,91 @@ void read_geometry_xml() model::root_universe = find_root_universe(); } +void CellCountStorage::clear() { + if (instance_ != nullptr) { + delete instance_; + instance_ = nullptr; + } +} + +void CellCountStorage::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { + counts[univ][cell] = count; +} + + void CellCountStorage::increment_count_for_univ(int32_t univ, int32_t cell) { + if (has_count(univ,cell)) { + counts[univ][cell] += 1; + } else { + counts[univ][cell] = 1; + } + } + +bool CellCountStorage::has_count(int32_t univ, int32_t cell) { + return counts.count(univ) && counts[univ].count(cell); +} + +bool CellCountStorage::has_count(int32_t univ) { + return counts.count(univ); +} + +void CellCountStorage::absorb_b_into_a(int32_t a, int32_t b) { + std::map b_map = counts[b]; + + for (auto it : b_map) { + if (has_count(a, it.first)) { + counts[a][it.first] += it.second; + } else { + counts[a][it.first] = it.second; + } + } +} + +auto CellCountStorage::get_count(int32_t univ) { + return counts[univ]; +} + +void LevelCountStorage::clear() { + if (instance_ != nullptr) { + delete instance_; + instance_ = nullptr; + } +} + +void LevelCountStorage::set_cell_count_for_univ(int32_t univ, int count) { + counts[univ] = count; +} + +void LevelCountStorage::increment_count_for_univ(int32_t univ) { + if (has_count(univ)) { + counts[univ] += 1; + } else { + counts[univ] = 1; + } +} + +bool LevelCountStorage::has_count(int32_t univ) { + return counts.count(univ); +} + +void LevelCountStorage::absorb_b_into_a(int32_t a, int32_t b) { + if (has_count(a)) { + counts[a] += counts[b]; + } else { + counts[a] = counts[b]; + } +} + +void LevelCountStorage::set_count(int32_t univ, int count) { + counts[univ] = count; +} + +int LevelCountStorage::get_count(int32_t univ) { + return counts[univ]; +} + +CellCountStorage* CellCountStorage::instance_ = nullptr; +LevelCountStorage* LevelCountStorage::instance_ = nullptr; + //============================================================================== void @@ -395,19 +480,31 @@ prepare_distribcell() void count_cell_instances(int32_t univ_indx) { - for (int32_t cell_indx : model::universes[univ_indx]->cells_) { - Cell& c = *model::cells[cell_indx]; - ++c.n_instances_; + CellCountStorage* counter = CellCountStorage::instance(); - if (c.type_ == FILL_UNIVERSE) { - // This cell contains another universe. Recurse into that universe. - count_cell_instances(c.fill_); + if (counter->has_count(univ_indx)) { + std::map univ_counts = counter->get_count(univ_indx); + for(auto it : univ_counts) { + Cell& c = *model::cells[it.first]; + c.n_instances_ += it.second; + } + } else { + for (int32_t cell_indx : model::universes[univ_indx]->cells_) { + Cell& c = *model::cells[cell_indx]; + ++c.n_instances_; + counter->increment_count_for_univ(univ_indx, cell_indx); - } else if (c.type_ == FILL_LATTICE) { - // This cell contains a lattice. Recurse into the lattice universes. - Lattice& lat = *model::lattices[c.fill_]; - for (auto it = lat.begin(); it != lat.end(); ++it) { - count_cell_instances(*it); + if (c.type_ == FILL_UNIVERSE) { + // This cell contains another universe. Recurse into that universe. + count_cell_instances(c.fill_); + counter->absorb_b_into_a(univ_indx, c.fill_); + } else if (c.type_ == FILL_LATTICE) { + // This cell contains a lattice. Recurse into the lattice universes. + Lattice& lat = *model::lattices[c.fill_]; + for (auto it = lat.begin(); it != lat.end(); ++it) { + count_cell_instances(*it); + counter->absorb_b_into_a(univ_indx, *it); + } } } } @@ -529,6 +626,12 @@ distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset) int maximum_levels(int32_t univ) { + LevelCountStorage* counter = LevelCountStorage::instance(); + + if (counter->has_count(univ)) { + return counter->get_count(univ); + } + int levels_below {0}; for (int32_t cell_indx : model::universes[univ]->cells_) { @@ -546,6 +649,7 @@ maximum_levels(int32_t univ) } ++levels_below; + counter->set_count(univ, levels_below); return levels_below; } From 4860bd5ed207bbe1584b0ca29d97022c902c8fff Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 6 Nov 2019 09:31:56 -0600 Subject: [PATCH 02/13] Updating name of Universer counter class. --- include/openmc/geometry_aux.h | 14 +++++++------- src/finalize.cpp | 2 +- src/geometry_aux.cpp | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 557d82193..14e119282 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -10,21 +10,21 @@ #include namespace openmc { - struct CellCountStorage { + struct UniverseCellCounter { private: - CellCountStorage() {} - CellCountStorage(CellCountStorage& c) {} - CellCountStorage(const CellCountStorage& c) {} + UniverseCellCounter() {} + UniverseCellCounter(UniverseCellCounter& c) {} + UniverseCellCounter(const UniverseCellCounter& c) {} - static CellCountStorage* instance_; + static UniverseCellCounter* instance_; std::map> counts; public: - static CellCountStorage* instance() { + static UniverseCellCounter* instance() { if (instance_ == nullptr) - instance_ = new CellCountStorage; + instance_ = new UniverseCellCounter; return instance_; } diff --git a/src/finalize.cpp b/src/finalize.cpp index f2cbc973c..3b8530b21 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -136,7 +136,7 @@ int openmc_finalize() int openmc_reset() { - CellCountStorage::instance()->clear(); + UniverseCellCounter::instance()->clear(); LevelCountStorage::instance()->clear(); for (auto& t : model::tallies) { diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 662b6790d..42fb33284 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -60,18 +60,18 @@ void read_geometry_xml() model::root_universe = find_root_universe(); } -void CellCountStorage::clear() { +void UniverseCellCounter::clear() { if (instance_ != nullptr) { delete instance_; instance_ = nullptr; } } -void CellCountStorage::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { +void UniverseCellCounter::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { counts[univ][cell] = count; } - void CellCountStorage::increment_count_for_univ(int32_t univ, int32_t cell) { + void UniverseCellCounter::increment_count_for_univ(int32_t univ, int32_t cell) { if (has_count(univ,cell)) { counts[univ][cell] += 1; } else { @@ -79,15 +79,15 @@ void CellCountStorage::set_cell_count_for_univ(int32_t univ, int32_t cell, int c } } -bool CellCountStorage::has_count(int32_t univ, int32_t cell) { +bool UniverseCellCounter::has_count(int32_t univ, int32_t cell) { return counts.count(univ) && counts[univ].count(cell); } -bool CellCountStorage::has_count(int32_t univ) { +bool UniverseCellCounter::has_count(int32_t univ) { return counts.count(univ); } -void CellCountStorage::absorb_b_into_a(int32_t a, int32_t b) { +void UniverseCellCounter::absorb_b_into_a(int32_t a, int32_t b) { std::map b_map = counts[b]; for (auto it : b_map) { @@ -99,7 +99,7 @@ void CellCountStorage::absorb_b_into_a(int32_t a, int32_t b) { } } -auto CellCountStorage::get_count(int32_t univ) { +auto UniverseCellCounter::get_count(int32_t univ) { return counts[univ]; } @@ -142,7 +142,7 @@ int LevelCountStorage::get_count(int32_t univ) { return counts[univ]; } -CellCountStorage* CellCountStorage::instance_ = nullptr; +UniverseCellCounter* UniverseCellCounter::instance_ = nullptr; LevelCountStorage* LevelCountStorage::instance_ = nullptr; //============================================================================== @@ -480,7 +480,7 @@ prepare_distribcell() void count_cell_instances(int32_t univ_indx) { - CellCountStorage* counter = CellCountStorage::instance(); + UniverseCellCounter* counter = UniverseCellCounter::instance(); if (counter->has_count(univ_indx)) { std::map univ_counts = counter->get_count(univ_indx); From c20e942f1ccb7deb6edd6c63d31d3575f735b484 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 6 Nov 2019 09:36:41 -0600 Subject: [PATCH 03/13] Update name of universe level counter. --- include/openmc/geometry_aux.h | 14 +++++++------- src/finalize.cpp | 2 +- src/geometry_aux.cpp | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 14e119282..0e694e982 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -46,21 +46,21 @@ namespace openmc { auto get_count(int32_t univ); }; - struct LevelCountStorage { + struct UniverseLevelCounter { private: - LevelCountStorage() {} - LevelCountStorage(LevelCountStorage& c) {} - LevelCountStorage(const LevelCountStorage& c) {} + UniverseLevelCounter() {} + UniverseLevelCounter(UniverseLevelCounter& c) {} + UniverseLevelCounter(const UniverseLevelCounter& c) {} - static LevelCountStorage* instance_; + static UniverseLevelCounter* instance_; std::map counts; public: - static LevelCountStorage* instance() { + static UniverseLevelCounter* instance() { if (instance_ == nullptr) - instance_ = new LevelCountStorage; + instance_ = new UniverseLevelCounter; return instance_; } diff --git a/src/finalize.cpp b/src/finalize.cpp index 3b8530b21..534382382 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -137,7 +137,7 @@ int openmc_reset() { UniverseCellCounter::instance()->clear(); - LevelCountStorage::instance()->clear(); + UniverseLevelCounter::instance()->clear(); for (auto& t : model::tallies) { t->reset(); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 42fb33284..3a98d02b6 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -103,18 +103,18 @@ auto UniverseCellCounter::get_count(int32_t univ) { return counts[univ]; } -void LevelCountStorage::clear() { +void UniverseLevelCounter::clear() { if (instance_ != nullptr) { delete instance_; instance_ = nullptr; } } -void LevelCountStorage::set_cell_count_for_univ(int32_t univ, int count) { +void UniverseLevelCounter::set_cell_count_for_univ(int32_t univ, int count) { counts[univ] = count; } -void LevelCountStorage::increment_count_for_univ(int32_t univ) { +void UniverseLevelCounter::increment_count_for_univ(int32_t univ) { if (has_count(univ)) { counts[univ] += 1; } else { @@ -122,11 +122,11 @@ void LevelCountStorage::increment_count_for_univ(int32_t univ) { } } -bool LevelCountStorage::has_count(int32_t univ) { +bool UniverseLevelCounter::has_count(int32_t univ) { return counts.count(univ); } -void LevelCountStorage::absorb_b_into_a(int32_t a, int32_t b) { +void UniverseLevelCounter::absorb_b_into_a(int32_t a, int32_t b) { if (has_count(a)) { counts[a] += counts[b]; } else { @@ -134,16 +134,16 @@ void LevelCountStorage::absorb_b_into_a(int32_t a, int32_t b) { } } -void LevelCountStorage::set_count(int32_t univ, int count) { +void UniverseLevelCounter::set_count(int32_t univ, int count) { counts[univ] = count; } -int LevelCountStorage::get_count(int32_t univ) { +int UniverseLevelCounter::get_count(int32_t univ) { return counts[univ]; } UniverseCellCounter* UniverseCellCounter::instance_ = nullptr; -LevelCountStorage* LevelCountStorage::instance_ = nullptr; +UniverseLevelCounter* UniverseLevelCounter::instance_ = nullptr; //============================================================================== @@ -626,7 +626,7 @@ distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset) int maximum_levels(int32_t univ) { - LevelCountStorage* counter = LevelCountStorage::instance(); + UniverseLevelCounter* counter = UniverseLevelCounter::instance(); if (counter->has_count(univ)) { return counter->get_count(univ); From d37c416308bb6ec13e5857ef8d3eb28ce47a1e9f Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 6 Nov 2019 15:28:06 -0600 Subject: [PATCH 04/13] Updating attribute name and placing below methods. --- include/openmc/geometry_aux.h | 15 +-- src/geometry_aux.cpp | 170 +++++++++++++++++----------------- 2 files changed, 94 insertions(+), 91 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 0e694e982..bf09aacec 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -18,10 +18,9 @@ namespace openmc { static UniverseCellCounter* instance_; - std::map> counts; - public: + // Methods static UniverseCellCounter* instance() { if (instance_ == nullptr) instance_ = new UniverseCellCounter; @@ -29,8 +28,6 @@ namespace openmc { return instance_; } - - void clear(); void set_cell_count_for_univ(int32_t univ, int32_t cell, int count); @@ -44,6 +41,9 @@ namespace openmc { void absorb_b_into_a(int32_t a, int32_t b); auto get_count(int32_t univ); + + // Members + std::map> counts_; }; struct UniverseLevelCounter { @@ -54,10 +54,10 @@ namespace openmc { static UniverseLevelCounter* instance_; - std::map counts; - public: + //Methods + static UniverseLevelCounter* instance() { if (instance_ == nullptr) instance_ = new UniverseLevelCounter; @@ -78,6 +78,9 @@ namespace openmc { void set_count(int32_t univ, int count); int get_count(int32_t univ); + + // Members + std::map counts_; }; void read_geometry_xml(); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 3a98d02b6..436528927 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -23,6 +23,91 @@ namespace openmc { +void UniverseCellCounter::clear() { + if (instance_ != nullptr) { + delete instance_; + instance_ = nullptr; + } +} + +void UniverseCellCounter::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { + counts_[univ][cell] = count; +} + + void UniverseCellCounter::increment_count_for_univ(int32_t univ, int32_t cell) { + if (has_count(univ,cell)) { + counts_[univ][cell] += 1; + } else { + counts_[univ][cell] = 1; + } + } + +bool UniverseCellCounter::has_count(int32_t univ, int32_t cell) { + return counts_.count(univ) && counts_[univ].count(cell); +} + +bool UniverseCellCounter::has_count(int32_t univ) { + return counts_.count(univ); +} + +void UniverseCellCounter::absorb_b_into_a(int32_t a, int32_t b) { + std::map b_map = counts_[b]; + + for (auto it : b_map) { + if (has_count(a, it.first)) { + counts_[a][it.first] += it.second; + } else { + counts_[a][it.first] = it.second; + } + } +} + +auto UniverseCellCounter::get_count(int32_t univ) { + return counts_[univ]; +} + +void UniverseLevelCounter::clear() { + if (instance_ != nullptr) { + delete instance_; + instance_ = nullptr; + } +} + +void UniverseLevelCounter::set_cell_count_for_univ(int32_t univ, int count) { + counts_[univ] = count; +} + +void UniverseLevelCounter::increment_count_for_univ(int32_t univ) { + if (has_count(univ)) { + counts_[univ] += 1; + } else { + counts_[univ] = 1; + } +} + +bool UniverseLevelCounter::has_count(int32_t univ) { + return counts_.count(univ); +} + +void UniverseLevelCounter::absorb_b_into_a(int32_t a, int32_t b) { + if (has_count(a)) { + counts_[a] += counts_[b]; + } else { + counts_[a] = counts_[b]; + } +} + +void UniverseLevelCounter::set_count(int32_t univ, int count) { + counts_[univ] = count; +} + +int UniverseLevelCounter::get_count(int32_t univ) { + return counts_[univ]; +} + +UniverseCellCounter* UniverseCellCounter::instance_ = nullptr; +UniverseLevelCounter* UniverseLevelCounter::instance_ = nullptr; + void read_geometry_xml() { #ifdef DAGMC @@ -60,91 +145,6 @@ void read_geometry_xml() model::root_universe = find_root_universe(); } -void UniverseCellCounter::clear() { - if (instance_ != nullptr) { - delete instance_; - instance_ = nullptr; - } -} - -void UniverseCellCounter::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { - counts[univ][cell] = count; -} - - void UniverseCellCounter::increment_count_for_univ(int32_t univ, int32_t cell) { - if (has_count(univ,cell)) { - counts[univ][cell] += 1; - } else { - counts[univ][cell] = 1; - } - } - -bool UniverseCellCounter::has_count(int32_t univ, int32_t cell) { - return counts.count(univ) && counts[univ].count(cell); -} - -bool UniverseCellCounter::has_count(int32_t univ) { - return counts.count(univ); -} - -void UniverseCellCounter::absorb_b_into_a(int32_t a, int32_t b) { - std::map b_map = counts[b]; - - for (auto it : b_map) { - if (has_count(a, it.first)) { - counts[a][it.first] += it.second; - } else { - counts[a][it.first] = it.second; - } - } -} - -auto UniverseCellCounter::get_count(int32_t univ) { - return counts[univ]; -} - -void UniverseLevelCounter::clear() { - if (instance_ != nullptr) { - delete instance_; - instance_ = nullptr; - } -} - -void UniverseLevelCounter::set_cell_count_for_univ(int32_t univ, int count) { - counts[univ] = count; -} - -void UniverseLevelCounter::increment_count_for_univ(int32_t univ) { - if (has_count(univ)) { - counts[univ] += 1; - } else { - counts[univ] = 1; - } -} - -bool UniverseLevelCounter::has_count(int32_t univ) { - return counts.count(univ); -} - -void UniverseLevelCounter::absorb_b_into_a(int32_t a, int32_t b) { - if (has_count(a)) { - counts[a] += counts[b]; - } else { - counts[a] = counts[b]; - } -} - -void UniverseLevelCounter::set_count(int32_t univ, int count) { - counts[univ] = count; -} - -int UniverseLevelCounter::get_count(int32_t univ) { - return counts[univ]; -} - -UniverseCellCounter* UniverseCellCounter::instance_ = nullptr; -UniverseLevelCounter* UniverseLevelCounter::instance_ = nullptr; - //============================================================================== void From 053434b99daf246f954155d9568a00eaf5764e8d Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 6 Nov 2019 15:32:00 -0600 Subject: [PATCH 05/13] Simplifying clears and absorption methods. --- src/geometry_aux.cpp | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 436528927..3ee0648f9 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -24,23 +24,16 @@ namespace openmc { void UniverseCellCounter::clear() { - if (instance_ != nullptr) { - delete instance_; - instance_ = nullptr; - } + instance_->counts_.clear(); } void UniverseCellCounter::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { counts_[univ][cell] = count; } - void UniverseCellCounter::increment_count_for_univ(int32_t univ, int32_t cell) { - if (has_count(univ,cell)) { - counts_[univ][cell] += 1; - } else { - counts_[univ][cell] = 1; - } - } +void UniverseCellCounter::increment_count_for_univ(int32_t univ, int32_t cell) { + counts_[univ][cell] += 1; +} bool UniverseCellCounter::has_count(int32_t univ, int32_t cell) { return counts_.count(univ) && counts_[univ].count(cell); @@ -52,14 +45,7 @@ bool UniverseCellCounter::has_count(int32_t univ) { void UniverseCellCounter::absorb_b_into_a(int32_t a, int32_t b) { std::map b_map = counts_[b]; - - for (auto it : b_map) { - if (has_count(a, it.first)) { - counts_[a][it.first] += it.second; - } else { - counts_[a][it.first] = it.second; - } - } + for (auto it : b_map) { counts_[a][it.first] += it.second; } } auto UniverseCellCounter::get_count(int32_t univ) { @@ -67,10 +53,7 @@ auto UniverseCellCounter::get_count(int32_t univ) { } void UniverseLevelCounter::clear() { - if (instance_ != nullptr) { - delete instance_; - instance_ = nullptr; - } + instance_->counts_.clear(); } void UniverseLevelCounter::set_cell_count_for_univ(int32_t univ, int count) { @@ -78,11 +61,7 @@ void UniverseLevelCounter::set_cell_count_for_univ(int32_t univ, int count) { } void UniverseLevelCounter::increment_count_for_univ(int32_t univ) { - if (has_count(univ)) { counts_[univ] += 1; - } else { - counts_[univ] = 1; - } } bool UniverseLevelCounter::has_count(int32_t univ) { @@ -90,11 +69,7 @@ bool UniverseLevelCounter::has_count(int32_t univ) { } void UniverseLevelCounter::absorb_b_into_a(int32_t a, int32_t b) { - if (has_count(a)) { counts_[a] += counts_[b]; - } else { - counts_[a] = counts_[b]; - } } void UniverseLevelCounter::set_count(int32_t univ, int count) { From a685e4768c3e36f89d6c0967729962b2c9e2ea8f Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 6 Nov 2019 16:03:51 -0600 Subject: [PATCH 06/13] Removing class defs in favor of STL types. --- include/openmc/geometry_aux.h | 72 +--------------------------- src/finalize.cpp | 4 +- src/geometry_aux.cpp | 88 +++++++++-------------------------- 3 files changed, 26 insertions(+), 138 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index bf09aacec..04c377400 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -10,78 +10,10 @@ #include namespace openmc { - struct UniverseCellCounter { - private: - UniverseCellCounter() {} - UniverseCellCounter(UniverseCellCounter& c) {} - UniverseCellCounter(const UniverseCellCounter& c) {} - static UniverseCellCounter* instance_; + extern std::map> universe_cell_counts; + extern std::map universe_level_counts; - public: - - // Methods - static UniverseCellCounter* instance() { - if (instance_ == nullptr) - instance_ = new UniverseCellCounter; - - return instance_; - } - - void clear(); - - void set_cell_count_for_univ(int32_t univ, int32_t cell, int count); - - void increment_count_for_univ(int32_t univ, int32_t cell); - - bool has_count(int32_t univ, int32_t cell); - - bool has_count(int32_t univ); - - void absorb_b_into_a(int32_t a, int32_t b); - - auto get_count(int32_t univ); - - // Members - std::map> counts_; - }; - - struct UniverseLevelCounter { - private: - UniverseLevelCounter() {} - UniverseLevelCounter(UniverseLevelCounter& c) {} - UniverseLevelCounter(const UniverseLevelCounter& c) {} - - static UniverseLevelCounter* instance_; - - public: - - //Methods - - static UniverseLevelCounter* instance() { - if (instance_ == nullptr) - instance_ = new UniverseLevelCounter; - - return instance_; - } - - void clear(); - - void set_cell_count_for_univ(int32_t univ, int count); - - void increment_count_for_univ(int32_t univ); - - bool has_count(int32_t univ); - - void absorb_b_into_a(int32_t a, int32_t b); - - void set_count(int32_t univ, int count); - - int get_count(int32_t univ); - - // Members - std::map counts_; - }; void read_geometry_xml(); diff --git a/src/finalize.cpp b/src/finalize.cpp index 534382382..6012dfd0b 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -136,8 +136,8 @@ int openmc_finalize() int openmc_reset() { - UniverseCellCounter::instance()->clear(); - UniverseLevelCounter::instance()->clear(); + universe_cell_counts.clear(); + universe_level_counts.clear(); for (auto& t : model::tallies) { t->reset(); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 3ee0648f9..0d95ccbcc 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -23,66 +23,24 @@ namespace openmc { -void UniverseCellCounter::clear() { - instance_->counts_.clear(); +std::map> universe_cell_counts; +std::map universe_level_counts; + + +void update_universe_cell_count(int32_t a, int32_t b) { + auto& universe_a_counts = universe_cell_counts[a]; + const auto& universe_b_counts = universe_cell_counts[b]; + for (auto it : universe_b_counts) { + universe_a_counts[it.first] += it.second; + } } -void UniverseCellCounter::set_cell_count_for_univ(int32_t univ, int32_t cell, int count) { - counts_[univ][cell] = count; +void update_universe_level_count(int32_t a, int32_t b) { + auto& universe_a_count = universe_level_counts[a]; + const auto& universe_b_count = universe_level_counts[b]; + universe_a_count += universe_b_count; } -void UniverseCellCounter::increment_count_for_univ(int32_t univ, int32_t cell) { - counts_[univ][cell] += 1; -} - -bool UniverseCellCounter::has_count(int32_t univ, int32_t cell) { - return counts_.count(univ) && counts_[univ].count(cell); -} - -bool UniverseCellCounter::has_count(int32_t univ) { - return counts_.count(univ); -} - -void UniverseCellCounter::absorb_b_into_a(int32_t a, int32_t b) { - std::map b_map = counts_[b]; - for (auto it : b_map) { counts_[a][it.first] += it.second; } -} - -auto UniverseCellCounter::get_count(int32_t univ) { - return counts_[univ]; -} - -void UniverseLevelCounter::clear() { - instance_->counts_.clear(); -} - -void UniverseLevelCounter::set_cell_count_for_univ(int32_t univ, int count) { - counts_[univ] = count; -} - -void UniverseLevelCounter::increment_count_for_univ(int32_t univ) { - counts_[univ] += 1; -} - -bool UniverseLevelCounter::has_count(int32_t univ) { - return counts_.count(univ); -} - -void UniverseLevelCounter::absorb_b_into_a(int32_t a, int32_t b) { - counts_[a] += counts_[b]; -} - -void UniverseLevelCounter::set_count(int32_t univ, int count) { - counts_[univ] = count; -} - -int UniverseLevelCounter::get_count(int32_t univ) { - return counts_[univ]; -} - -UniverseCellCounter* UniverseCellCounter::instance_ = nullptr; -UniverseLevelCounter* UniverseLevelCounter::instance_ = nullptr; - void read_geometry_xml() { #ifdef DAGMC @@ -455,10 +413,9 @@ prepare_distribcell() void count_cell_instances(int32_t univ_indx) { - UniverseCellCounter* counter = UniverseCellCounter::instance(); - if (counter->has_count(univ_indx)) { - std::map univ_counts = counter->get_count(univ_indx); + if (universe_cell_counts.count(univ_indx)) { + std::map univ_counts = universe_cell_counts[univ_indx]; for(auto it : univ_counts) { Cell& c = *model::cells[it.first]; c.n_instances_ += it.second; @@ -467,18 +424,18 @@ count_cell_instances(int32_t univ_indx) for (int32_t cell_indx : model::universes[univ_indx]->cells_) { Cell& c = *model::cells[cell_indx]; ++c.n_instances_; - counter->increment_count_for_univ(univ_indx, cell_indx); + universe_cell_counts[univ_indx][cell_indx] += 1; if (c.type_ == FILL_UNIVERSE) { // This cell contains another universe. Recurse into that universe. count_cell_instances(c.fill_); - counter->absorb_b_into_a(univ_indx, c.fill_); + update_universe_cell_count(univ_indx, c.fill_); } else if (c.type_ == FILL_LATTICE) { // This cell contains a lattice. Recurse into the lattice universes. Lattice& lat = *model::lattices[c.fill_]; for (auto it = lat.begin(); it != lat.end(); ++it) { count_cell_instances(*it); - counter->absorb_b_into_a(univ_indx, *it); + update_universe_cell_count(univ_indx, *it); } } } @@ -601,10 +558,9 @@ distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset) int maximum_levels(int32_t univ) { - UniverseLevelCounter* counter = UniverseLevelCounter::instance(); - if (counter->has_count(univ)) { - return counter->get_count(univ); + if (universe_level_counts.count(univ)) { + return universe_level_counts[univ]; } int levels_below {0}; @@ -624,7 +580,7 @@ maximum_levels(int32_t univ) } ++levels_below; - counter->set_count(univ, levels_below); + universe_level_counts[univ] = levels_below; return levels_below; } From 031047ee80a8952d7e5bad8e7ee0db3c122c700e Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 6 Nov 2019 16:07:28 -0600 Subject: [PATCH 07/13] Moving counters into the model namespace. --- include/openmc/geometry_aux.h | 3 ++- src/finalize.cpp | 4 ++-- src/geometry_aux.cpp | 27 ++++++++++++++------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 04c377400..677dcf180 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -11,9 +11,10 @@ namespace openmc { +namespace model { extern std::map> universe_cell_counts; extern std::map universe_level_counts; - +} // namespace model void read_geometry_xml(); diff --git a/src/finalize.cpp b/src/finalize.cpp index 6012dfd0b..16ff0fbcc 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -136,8 +136,8 @@ int openmc_finalize() int openmc_reset() { - universe_cell_counts.clear(); - universe_level_counts.clear(); + model::universe_cell_counts.clear(); + model::universe_level_counts.clear(); for (auto& t : model::tallies) { t->reset(); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 0d95ccbcc..229b46b8c 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -23,21 +23,22 @@ namespace openmc { -std::map> universe_cell_counts; -std::map universe_level_counts; - +namespace model { + std::map> universe_cell_counts; + std::map universe_level_counts; +} // namespace model void update_universe_cell_count(int32_t a, int32_t b) { - auto& universe_a_counts = universe_cell_counts[a]; - const auto& universe_b_counts = universe_cell_counts[b]; + auto& universe_a_counts = model::universe_cell_counts[a]; + const auto& universe_b_counts = model::universe_cell_counts[b]; for (auto it : universe_b_counts) { universe_a_counts[it.first] += it.second; } } void update_universe_level_count(int32_t a, int32_t b) { - auto& universe_a_count = universe_level_counts[a]; - const auto& universe_b_count = universe_level_counts[b]; + auto& universe_a_count = model::universe_level_counts[a]; + const auto& universe_b_count = model::universe_level_counts[b]; universe_a_count += universe_b_count; } @@ -414,8 +415,8 @@ void count_cell_instances(int32_t univ_indx) { - if (universe_cell_counts.count(univ_indx)) { - std::map univ_counts = universe_cell_counts[univ_indx]; + if (model::universe_cell_counts.count(univ_indx)) { + std::map univ_counts = model::universe_cell_counts[univ_indx]; for(auto it : univ_counts) { Cell& c = *model::cells[it.first]; c.n_instances_ += it.second; @@ -424,7 +425,7 @@ count_cell_instances(int32_t univ_indx) for (int32_t cell_indx : model::universes[univ_indx]->cells_) { Cell& c = *model::cells[cell_indx]; ++c.n_instances_; - universe_cell_counts[univ_indx][cell_indx] += 1; + model::universe_cell_counts[univ_indx][cell_indx] += 1; if (c.type_ == FILL_UNIVERSE) { // This cell contains another universe. Recurse into that universe. @@ -559,8 +560,8 @@ int maximum_levels(int32_t univ) { - if (universe_level_counts.count(univ)) { - return universe_level_counts[univ]; + if (model::universe_level_counts.count(univ)) { + return model::universe_level_counts[univ]; } int levels_below {0}; @@ -580,7 +581,7 @@ maximum_levels(int32_t univ) } ++levels_below; - universe_level_counts[univ] = levels_below; + model::universe_level_counts[univ] = levels_below; return levels_below; } From 4394582657f5d95dd9112b44bb053c60528c4351 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 8 Nov 2019 14:43:35 -0600 Subject: [PATCH 08/13] Addressing PR comments from @paulromano. --- include/openmc/geometry_aux.h | 6 +++--- src/geometry_aux.cpp | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 677dcf180..800baef26 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -7,13 +7,13 @@ #include #include #include -#include +#include namespace openmc { namespace model { - extern std::map> universe_cell_counts; - extern std::map universe_level_counts; + extern std::unordered_map> universe_cell_counts; + extern std::unordered_map universe_level_counts; } // namespace model void read_geometry_xml(); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 229b46b8c..5ebee4aca 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -24,24 +24,20 @@ namespace openmc { namespace model { - std::map> universe_cell_counts; - std::map universe_level_counts; + std::unordered_map> universe_cell_counts; + std::unordered_map universe_level_counts; } // namespace model + +// adds the cell counts of universe b to universe a void update_universe_cell_count(int32_t a, int32_t b) { auto& universe_a_counts = model::universe_cell_counts[a]; const auto& universe_b_counts = model::universe_cell_counts[b]; - for (auto it : universe_b_counts) { + for (const auto& it : universe_b_counts) { universe_a_counts[it.first] += it.second; } } -void update_universe_level_count(int32_t a, int32_t b) { - auto& universe_a_count = model::universe_level_counts[a]; - const auto& universe_b_count = model::universe_level_counts[b]; - universe_a_count += universe_b_count; -} - void read_geometry_xml() { #ifdef DAGMC @@ -415,11 +411,10 @@ void count_cell_instances(int32_t univ_indx) { - if (model::universe_cell_counts.count(univ_indx)) { - std::map univ_counts = model::universe_cell_counts[univ_indx]; - for(auto it : univ_counts) { - Cell& c = *model::cells[it.first]; - c.n_instances_ += it.second; + const auto univ_counts = model::universe_cell_counts.find(univ_indx); + if (univ_counts != model::universe_cell_counts.end()) { + for (const auto& it : univ_counts->second) { + model::cells[it.first]->n_instances_ += it.second; } } else { for (int32_t cell_indx : model::universes[univ_indx]->cells_) { @@ -560,8 +555,9 @@ int maximum_levels(int32_t univ) { - if (model::universe_level_counts.count(univ)) { - return model::universe_level_counts[univ]; + const auto level_count = model::universe_level_counts.find(univ); + if (level_count != model::universe_level_counts.end()) { + return level_count->second; } int levels_below {0}; From f2a59994d68a90ba7e7f714d0a781e8a4881bd5c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 6 Nov 2019 21:50:25 -0500 Subject: [PATCH 09/13] Show colored diffs on test results when there are failures --- setup.py | 2 +- tests/testing_harness.py | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index aff7834d7..99db83148 100755 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ kwargs = { 'pandas', 'lxml', 'uncertainties' ], 'extras_require': { - 'test': ['pytest', 'pytest-cov'], + 'test': ['pytest', 'pytest-cov', 'colorama'], 'vtk': ['vtk'], }, } diff --git a/tests/testing_harness.py b/tests/testing_harness.py index 0d3c4bec0..2266189c0 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -10,9 +10,25 @@ import sys import numpy as np import openmc from openmc.examples import pwr_core +from colorama import Fore, init from tests.regression_tests import config +init() + + +def colorize(diff): + """Produce colored diff for test results""" + for line in diff: + if line.startswith('+'): + yield Fore.RED + line + Fore.RESET + elif line.startswith('-'): + yield Fore.GREEN + line + Fore.RESET + elif line.startswith('^'): + yield Fore.BLUE + line + Fore.RESET + else: + yield line + class TestHarness(object): """General class for running OpenMC regression tests.""" @@ -108,11 +124,17 @@ class TestHarness(object): shutil.copyfile('results_test.dat', 'results_true.dat') def _compare_results(self): - """Make sure the current results agree with the _true standard.""" + """Make sure the current results agree with the reference.""" compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: + expected = open('results_true.dat').readlines() + actual = open('results_test.dat').readlines() + diff = unified_diff(expected, actual, 'results_true.dat', + 'results_test.dat') + print('Result differences:') + print(''.join(colorize(diff))) os.rename('results_test.dat', 'results_error.dat') - assert compare, 'Results do not agree.' + assert compare, 'Results do not agree' def _cleanup(self): """Delete statepoints, tally, and test files.""" @@ -325,11 +347,13 @@ class PyAPITestHarness(TestHarness): """Make sure the current inputs agree with the _true standard.""" compare = filecmp.cmp('inputs_test.dat', 'inputs_true.dat') if not compare: + expected = open('inputs_true.dat', 'r').readlines() + actual = open('inputs_error.dat', 'r').readlines() + diff = unified_diff(expected, actual, 'inputs_true.dat', + 'inputs_error.dat') + print('Input differences:') + print(''.join(colorize(diff))) os.rename('inputs_test.dat', 'inputs_error.dat') - for line in unified_diff(open('inputs_true.dat', 'r').readlines(), - open('inputs_error.dat', 'r').readlines(), - 'inputs_true.dat', 'inputs_error.dat'): - print(line, end='') assert compare, 'Input files are broken.' def _cleanup(self): From 8a449666bc36a57cb99c3847a1df9333986c8a6d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 6 Nov 2019 21:52:49 -0500 Subject: [PATCH 10/13] Don't hash mg_tallies test results --- .../mg_tallies/results_true.dat | 1325 ++++++++++++++++- tests/regression_tests/mg_tallies/test.py | 6 +- 2 files changed, 1327 insertions(+), 4 deletions(-) diff --git a/tests/regression_tests/mg_tallies/results_true.dat b/tests/regression_tests/mg_tallies/results_true.dat index 50ec653e2..8743a290f 100644 --- a/tests/regression_tests/mg_tallies/results_true.dat +++ b/tests/regression_tests/mg_tallies/results_true.dat @@ -1 +1,1324 @@ -508cd056f2d9409a536e487512df34c683720ea45b9100316efb31c19927890c4cacd92f38817d74fcf491bbe4bdb78a0215a798d5a078e0575e3fd94cedf0bd \ No newline at end of file +k-combined: +9.934975E-01 2.679669E-02 +tally 1: +2.542000E+00 +1.343070E+00 +1.260000E-01 +3.298000E-03 +4.838111E-02 +4.857369E-04 +1.202865E-01 +3.119670E-03 +6.000347E-07 +8.163458E-14 +1.202865E-01 +3.119670E-03 +0.000000E+00 +0.000000E+00 +9.676221E+06 +1.942948E+13 +2.542000E+00 +1.343070E+00 +0.000000E+00 +0.000000E+00 +7.404202E+00 +1.141803E+01 +1.949000E+00 +8.324030E-01 +9.000000E-02 +1.762000E-03 +3.793334E-02 +3.031575E-04 +1.081691E-01 +2.457437E-03 +5.571912E-07 +6.439495E-14 +1.071378E-01 +2.411702E-03 +1.031308E-03 +1.063597E-06 +7.586669E+06 +1.212630E+13 +1.949000E+00 +8.324030E-01 +8.760860E-04 +7.675267E-07 +5.650158E+00 +7.016308E+00 +1.039000E+00 +2.447670E-01 +4.200000E-02 +4.120000E-04 +1.685968E-02 +6.389070E-05 +4.929366E-02 +5.628729E-04 +2.018053E-07 +1.119308E-14 +4.823620E-02 +5.371538E-04 +1.057461E-03 +1.118225E-06 +3.371936E+06 +2.555628E+12 +1.039000E+00 +2.447670E-01 +8.983029E-04 +8.069481E-07 +3.038326E+00 +2.108568E+00 +5.930000E-01 +7.205300E-02 +2.300000E-02 +1.110000E-04 +1.056715E-02 +2.338156E-05 +2.528379E-02 +1.491420E-04 +1.384831E-07 +6.031333E-15 +2.528379E-02 +1.491420E-04 +0.000000E+00 +0.000000E+00 +2.113430E+06 +9.352624E+11 +5.930000E-01 +7.205300E-02 +0.000000E+00 +0.000000E+00 +1.727671E+00 +6.138025E-01 +3.501000E+00 +2.515635E+00 +1.600000E-01 +5.250000E-03 +5.998847E-02 +7.320149E-04 +1.529867E-01 +4.932068E-03 +7.476127E-07 +1.267077E-13 +1.529867E-01 +4.932068E-03 +0.000000E+00 +0.000000E+00 +1.199769E+07 +2.928060E+13 +3.501000E+00 +2.515635E+00 +0.000000E+00 +0.000000E+00 +1.021925E+01 +2.143166E+01 +4.454000E+00 +4.082446E+00 +1.920000E-01 +7.726000E-03 +8.044824E-02 +1.327101E-03 +2.231973E-01 +1.024637E-02 +1.236154E-06 +3.183460E-13 +2.211081E-01 +1.008915E-02 +2.089232E-03 +2.182800E-06 +1.608965E+07 +5.308405E+13 +4.454000E+00 +4.082446E+00 +2.942322E-03 +8.657261E-06 +1.292241E+01 +3.441496E+01 +4.210000E+00 +3.829106E+00 +1.750000E-01 +6.549000E-03 +7.464456E-02 +1.228199E-03 +1.787859E-01 +7.634408E-03 +1.144154E-06 +3.572375E-13 +1.777141E-01 +7.525287E-03 +1.071750E-03 +1.148648E-06 +1.492891E+07 +4.912798E+13 +4.210000E+00 +3.829106E+00 +9.104408E-04 +8.289024E-07 +1.222119E+01 +3.220371E+01 +1.364000E+00 +3.933640E-01 +8.200000E-02 +1.378000E-03 +3.158206E-02 +2.047576E-04 +5.983520E-02 +7.581471E-04 +3.272437E-07 +2.772035E-14 +5.983520E-02 +7.581471E-04 +0.000000E+00 +0.000000E+00 +6.316412E+06 +8.190302E+12 +1.364000E+00 +3.933640E-01 +0.000000E+00 +0.000000E+00 +3.971532E+00 +3.348259E+00 +1.363000E+00 +4.205090E-01 +7.000000E-02 +1.130000E-03 +2.590153E-02 +1.476101E-04 +5.594611E-02 +6.902009E-04 +2.690262E-07 +1.501020E-14 +5.594611E-02 +6.902009E-04 +0.000000E+00 +0.000000E+00 +5.180306E+06 +5.904403E+12 +1.363000E+00 +4.205090E-01 +0.000000E+00 +0.000000E+00 +3.984609E+00 +3.608477E+00 +1.246000E+00 +3.852900E-01 +5.300000E-02 +6.650000E-04 +1.954836E-02 +9.404628E-05 +4.771133E-02 +6.866474E-04 +1.814542E-07 +1.125942E-14 +4.771133E-02 +6.866474E-04 +0.000000E+00 +0.000000E+00 +3.909672E+06 +3.761851E+12 +1.246000E+00 +3.852900E-01 +0.000000E+00 +0.000000E+00 +3.660351E+00 +3.335482E+00 +tally 2: +2.599889E+00 +1.402744E+00 +1.167830E-01 +2.830760E-03 +4.644159E-02 +4.578546E-04 +1.161040E-01 +2.861591E-03 +6.110737E-07 +8.591437E-14 +1.153679E-01 +2.825421E-03 +7.360997E-04 +1.150235E-07 +9.288319E+06 +1.831418E+13 +2.589000E+00 +1.391365E+00 +3.449004E-04 +2.525229E-08 +7.573543E+00 +1.191287E+01 +1.935337E+00 +8.143708E-01 +9.059861E-02 +1.758063E-03 +3.784648E-02 +3.023430E-04 +9.461621E-02 +1.889644E-03 +5.353929E-07 +5.956643E-14 +9.401634E-02 +1.865759E-03 +5.998671E-04 +7.595546E-08 +7.569296E+06 +1.209372E+13 +1.989000E+00 +8.632630E-01 +2.810685E-04 +1.667528E-08 +5.615484E+00 +6.866983E+00 +1.015076E+00 +2.265305E-01 +4.209446E-02 +3.711488E-04 +1.500394E-02 +4.824763E-05 +3.750984E-02 +3.015477E-04 +1.616914E-07 +8.025617E-15 +3.727203E-02 +2.977362E-04 +2.378125E-04 +1.212091E-08 +3.000787E+06 +1.929905E+12 +1.051000E+00 +2.509110E-01 +1.114274E-04 +2.661027E-09 +2.978146E+00 +1.962310E+00 +6.199894E-01 +7.878811E-02 +2.804937E-02 +1.607308E-04 +1.125386E-02 +2.891349E-05 +2.813466E-02 +1.807093E-04 +1.501221E-07 +7.165022E-15 +2.795628E-02 +1.784252E-04 +1.783738E-04 +7.263729E-09 +2.250773E+06 +1.156540E+12 +6.190000E-01 +7.822300E-02 +8.357728E-05 +1.594681E-09 +1.804831E+00 +6.709321E-01 +3.398516E+00 +2.363683E+00 +1.505108E-01 +4.655588E-03 +5.879057E-02 +7.289809E-04 +1.469764E-01 +4.556130E-03 +7.516677E-07 +1.300615E-13 +1.460446E-01 +4.498542E-03 +9.318311E-04 +1.831366E-07 +1.175811E+07 +2.915923E+13 +3.542000E+00 +2.572512E+00 +4.366106E-04 +4.020586E-08 +9.912955E+00 +2.011678E+01 +4.395956E+00 +3.964331E+00 +2.146513E-01 +9.286938E-03 +9.388516E-02 +1.784380E-03 +2.347129E-01 +1.115237E-02 +1.410768E-06 +4.182007E-13 +2.332248E-01 +1.101141E-02 +1.488081E-03 +4.482769E-07 +1.877703E+07 +7.137519E+13 +4.497000E+00 +4.157935E+00 +6.972420E-04 +9.841483E-08 +1.270142E+01 +3.319405E+01 +4.157899E+00 +3.751197E+00 +1.897379E-01 +8.038105E-03 +7.692709E-02 +1.413632E-03 +1.923177E-01 +8.835202E-03 +1.042521E-06 +3.025447E-13 +1.910984E-01 +8.723527E-03 +1.219295E-03 +3.551367E-07 +1.538542E+07 +5.654529E+13 +4.268000E+00 +3.930780E+00 +5.713023E-04 +7.796680E-08 +1.209407E+01 +3.169559E+01 +1.357524E+00 +3.878228E-01 +5.983682E-02 +7.460748E-04 +2.322979E-02 +1.144334E-04 +5.807447E-02 +7.152085E-04 +2.940107E-07 +2.024706E-14 +5.770628E-02 +7.061684E-04 +3.681924E-04 +2.874827E-08 +4.645957E+06 +4.577335E+12 +1.390000E+00 +4.083140E-01 +1.725170E-04 +6.311403E-09 +3.961412E+00 +3.308776E+00 +1.376941E+00 +4.321098E-01 +6.198249E-02 +8.400785E-04 +2.471448E-02 +1.321749E-04 +6.178621E-02 +8.260929E-04 +3.265418E-07 +2.485223E-14 +6.139448E-02 +8.156513E-04 +3.917248E-04 +3.320534E-08 +4.942896E+06 +5.286995E+12 +1.395000E+00 +4.400290E-01 +1.835431E-04 +7.289909E-09 +4.010262E+00 +3.684656E+00 +1.267762E+00 +4.052744E-01 +5.233659E-02 +6.929809E-04 +1.852753E-02 +9.379170E-05 +4.631882E-02 +5.861981E-04 +1.967460E-07 +1.534801E-14 +4.602516E-02 +5.787887E-04 +2.936615E-04 +2.356261E-08 +3.705506E+06 +3.751668E+12 +1.284000E+00 +4.070420E-01 +1.375955E-04 +5.172942E-09 +3.720938E+00 +3.496554E+00 +tally 3: +1.131330E+02 +2.561428E+03 +4.988000E+00 +4.976048E+00 +1.993967E+00 +7.956428E-01 +5.135468E+00 +5.291611E+00 +2.697394E-05 +1.462336E-10 +5.101779E+00 +5.222461E+00 +3.368875E-02 +2.575850E-04 +3.987934E+08 +3.182571E+16 +1.131330E+02 +2.561428E+03 +2.987487E-02 +1.870547E-04 +3.294536E+02 +2.172280E+04 +1.081450E+02 +2.340681E+03 +1.081450E+02 +2.340681E+03 +tally 4: +1.131330E+02 +2.561428E+03 +5.099217E+00 +5.202791E+00 +2.036481E+00 +8.305328E-01 +5.091203E+00 +5.190830E+00 +4.963770E-05 +4.951715E-10 +5.058925E+00 +5.125219E+00 +3.227825E-02 +2.086488E-04 +4.072963E+08 +3.322131E+16 +1.131330E+02 +2.561428E+03 +1.512401E-02 +4.580681E-05 +3.294536E+02 +2.172280E+04 +tally 5: +1.126689E+02 +2.540742E+03 +5.072428E+00 +5.150411E+00 +2.022883E+00 +8.201638E-01 +5.057207E+00 +5.126024E+00 +2.673439E-05 +1.438788E-10 +5.025144E+00 +5.061232E+00 +3.206271E-02 +2.060439E-04 +4.045765E+08 +3.280655E+16 +1.133620E+02 +2.571755E+03 +1.502302E-02 +4.523492E-05 +3.281376E+02 +2.155147E+04 +tally 6: +1.081450E+02 +2.340681E+03 +1.081450E+02 +2.340681E+03 +5.135468E+00 +5.291611E+00 +tally 7: +6.429000E+00 +8.307829E+00 +1.410000E+00 +3.992220E-01 +1.119414E+00 +2.516273E-01 +2.887237E+00 +1.682974E+00 +2.674702E-05 +1.437976E-10 +2.870392E+00 +1.663680E+00 +1.684448E-02 +5.768606E-05 +2.238828E+08 +1.006509E+16 +6.429000E+00 +8.307829E+00 +1.451639E-02 +4.943007E-05 +1.176869E+01 +2.783921E+01 +5.019000E+00 +5.067025E+00 +5.019000E+00 +5.067025E+00 +1.067040E+02 +2.278956E+03 +3.578000E+00 +2.562210E+00 +8.745532E-01 +1.530758E-01 +2.248231E+00 +1.013550E+00 +2.269178E-07 +1.030651E-14 +2.231387E+00 +9.980240E-01 +1.684427E-02 +8.005737E-05 +1.749106E+08 +6.123032E+15 +1.067040E+02 +2.278956E+03 +1.535848E-02 +6.943495E-05 +3.176849E+02 +2.020075E+04 +1.031260E+02 +2.128783E+03 +1.031260E+02 +2.128783E+03 +tally 8: +6.429000E+00 +8.307829E+00 +1.437899E+00 +4.155824E-01 +1.141563E+00 +2.619392E-01 +2.853907E+00 +1.637120E+00 +4.896211E-05 +4.818601E-10 +2.835814E+00 +1.616427E+00 +1.809378E-02 +6.580509E-05 +2.283126E+08 +1.047757E+16 +6.429000E+00 +8.307829E+00 +8.477865E-03 +1.444687E-05 +1.176869E+01 +2.783921E+01 +1.067040E+02 +2.278956E+03 +3.661318E+00 +2.683178E+00 +8.949183E-01 +1.603029E-01 +2.237296E+00 +1.001893E+00 +6.755918E-07 +9.135730E-14 +2.223111E+00 +9.892292E-01 +1.418446E-02 +4.027174E-05 +1.789837E+08 +6.412115E+15 +1.067040E+02 +2.278956E+03 +6.646148E-03 +8.841267E-06 +3.176849E+02 +2.020075E+04 +tally 9: +6.371628E+00 +8.173477E+00 +1.425067E+00 +4.088618E-01 +1.131376E+00 +2.577032E-01 +2.828439E+00 +1.610645E+00 +2.650833E-05 +1.414721E-10 +2.810507E+00 +1.590286E+00 +1.793232E-02 +6.474091E-05 +2.262751E+08 +1.030813E+16 +6.432000E+00 +8.315518E+00 +8.402208E-03 +1.421324E-05 +1.166367E+01 +2.738901E+01 +1.062973E+02 +2.261709E+03 +3.647362E+00 +2.662872E+00 +8.915070E-01 +1.590897E-01 +2.228767E+00 +9.943106E-01 +2.260528E-07 +1.022851E-14 +2.214637E+00 +9.817427E-01 +1.413039E-02 +3.996696E-05 +1.783014E+08 +6.363588E+15 +1.069300E+02 +2.288574E+03 +6.620813E-03 +8.774357E-06 +3.164739E+02 +2.004788E+04 +tally 10: +5.019000E+00 +5.067025E+00 +5.019000E+00 +5.067025E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.887237E+00 +1.682974E+00 +1.410000E+00 +3.992220E-01 +1.410000E+00 +3.992220E-01 +0.000000E+00 +0.000000E+00 +1.017160E+02 +2.071035E+03 +1.017160E+02 +2.071035E+03 +2.248231E+00 +1.013550E+00 +tally 11: +2.542000E+00 +1.343070E+00 +1.260000E-01 +3.298000E-03 +4.838111E-02 +4.857369E-04 +1.202865E-01 +3.119670E-03 +6.000347E-07 +8.163458E-14 +1.202865E-01 +3.119670E-03 +0.000000E+00 +0.000000E+00 +9.676221E+06 +1.942948E+13 +2.542000E+00 +1.343070E+00 +0.000000E+00 +0.000000E+00 +1.949000E+00 +8.324030E-01 +9.000000E-02 +1.762000E-03 +3.793334E-02 +3.031575E-04 +1.081691E-01 +2.457437E-03 +5.571912E-07 +6.439495E-14 +1.071378E-01 +2.411702E-03 +1.031308E-03 +1.063597E-06 +7.586669E+06 +1.212630E+13 +1.949000E+00 +8.324030E-01 +8.760860E-04 +7.675267E-07 +1.039000E+00 +2.447670E-01 +4.200000E-02 +4.120000E-04 +1.685968E-02 +6.389070E-05 +4.929366E-02 +5.628729E-04 +2.018053E-07 +1.119308E-14 +4.823620E-02 +5.371538E-04 +1.057461E-03 +1.118225E-06 +3.371936E+06 +2.555628E+12 +1.039000E+00 +2.447670E-01 +8.983029E-04 +8.069481E-07 +5.930000E-01 +7.205300E-02 +2.300000E-02 +1.110000E-04 +1.056715E-02 +2.338156E-05 +2.528379E-02 +1.491420E-04 +1.384831E-07 +6.031333E-15 +2.528379E-02 +1.491420E-04 +0.000000E+00 +0.000000E+00 +2.113430E+06 +9.352624E+11 +5.930000E-01 +7.205300E-02 +0.000000E+00 +0.000000E+00 +3.501000E+00 +2.515635E+00 +1.600000E-01 +5.250000E-03 +5.998847E-02 +7.320149E-04 +1.529867E-01 +4.932068E-03 +7.476127E-07 +1.267077E-13 +1.529867E-01 +4.932068E-03 +0.000000E+00 +0.000000E+00 +1.199769E+07 +2.928060E+13 +3.501000E+00 +2.515635E+00 +0.000000E+00 +0.000000E+00 +4.454000E+00 +4.082446E+00 +1.920000E-01 +7.726000E-03 +8.044824E-02 +1.327101E-03 +2.231973E-01 +1.024637E-02 +1.236154E-06 +3.183460E-13 +2.211081E-01 +1.008915E-02 +2.089232E-03 +2.182800E-06 +1.608965E+07 +5.308405E+13 +4.454000E+00 +4.082446E+00 +2.942322E-03 +8.657261E-06 +4.210000E+00 +3.829106E+00 +1.750000E-01 +6.549000E-03 +7.464456E-02 +1.228199E-03 +1.787859E-01 +7.634408E-03 +1.144154E-06 +3.572375E-13 +1.777141E-01 +7.525287E-03 +1.071750E-03 +1.148648E-06 +1.492891E+07 +4.912798E+13 +4.210000E+00 +3.829106E+00 +9.104408E-04 +8.289024E-07 +1.364000E+00 +3.933640E-01 +8.200000E-02 +1.378000E-03 +3.158206E-02 +2.047576E-04 +5.983520E-02 +7.581471E-04 +3.272437E-07 +2.772035E-14 +5.983520E-02 +7.581471E-04 +0.000000E+00 +0.000000E+00 +6.316412E+06 +8.190302E+12 +1.364000E+00 +3.933640E-01 +0.000000E+00 +0.000000E+00 +1.363000E+00 +4.205090E-01 +7.000000E-02 +1.130000E-03 +2.590153E-02 +1.476101E-04 +5.594611E-02 +6.902009E-04 +2.690262E-07 +1.501020E-14 +5.594611E-02 +6.902009E-04 +0.000000E+00 +0.000000E+00 +5.180306E+06 +5.904403E+12 +1.363000E+00 +4.205090E-01 +0.000000E+00 +0.000000E+00 +1.246000E+00 +3.852900E-01 +5.300000E-02 +6.650000E-04 +1.954836E-02 +9.404628E-05 +4.771133E-02 +6.866474E-04 +1.814542E-07 +1.125942E-14 +4.771133E-02 +6.866474E-04 +0.000000E+00 +0.000000E+00 +3.909672E+06 +3.761851E+12 +1.246000E+00 +3.852900E-01 +0.000000E+00 +0.000000E+00 +tally 12: +2.599889E+00 +1.402744E+00 +1.167830E-01 +2.830760E-03 +4.644159E-02 +4.578546E-04 +1.161040E-01 +2.861591E-03 +6.110737E-07 +8.591437E-14 +1.153679E-01 +2.825421E-03 +7.360997E-04 +1.150235E-07 +9.288319E+06 +1.831418E+13 +2.589000E+00 +1.391365E+00 +3.449004E-04 +2.525229E-08 +1.935337E+00 +8.143708E-01 +9.059861E-02 +1.758063E-03 +3.784648E-02 +3.023430E-04 +9.461621E-02 +1.889644E-03 +5.353929E-07 +5.956643E-14 +9.401634E-02 +1.865759E-03 +5.998671E-04 +7.595546E-08 +7.569296E+06 +1.209372E+13 +1.989000E+00 +8.632630E-01 +2.810685E-04 +1.667528E-08 +1.015076E+00 +2.265305E-01 +4.209446E-02 +3.711488E-04 +1.500394E-02 +4.824763E-05 +3.750984E-02 +3.015477E-04 +1.616914E-07 +8.025617E-15 +3.727203E-02 +2.977362E-04 +2.378125E-04 +1.212091E-08 +3.000787E+06 +1.929905E+12 +1.051000E+00 +2.509110E-01 +1.114274E-04 +2.661027E-09 +6.199894E-01 +7.878811E-02 +2.804937E-02 +1.607308E-04 +1.125386E-02 +2.891349E-05 +2.813466E-02 +1.807093E-04 +1.501221E-07 +7.165022E-15 +2.795628E-02 +1.784252E-04 +1.783738E-04 +7.263729E-09 +2.250773E+06 +1.156540E+12 +6.190000E-01 +7.822300E-02 +8.357728E-05 +1.594681E-09 +3.398516E+00 +2.363683E+00 +1.505108E-01 +4.655588E-03 +5.879057E-02 +7.289809E-04 +1.469764E-01 +4.556130E-03 +7.516677E-07 +1.300615E-13 +1.460446E-01 +4.498542E-03 +9.318311E-04 +1.831366E-07 +1.175811E+07 +2.915923E+13 +3.542000E+00 +2.572512E+00 +4.366106E-04 +4.020586E-08 +4.395956E+00 +3.964331E+00 +2.146513E-01 +9.286938E-03 +9.388516E-02 +1.784380E-03 +2.347129E-01 +1.115237E-02 +1.410768E-06 +4.182007E-13 +2.332248E-01 +1.101141E-02 +1.488081E-03 +4.482769E-07 +1.877703E+07 +7.137519E+13 +4.497000E+00 +4.157935E+00 +6.972420E-04 +9.841483E-08 +4.157899E+00 +3.751197E+00 +1.897379E-01 +8.038105E-03 +7.692709E-02 +1.413632E-03 +1.923177E-01 +8.835202E-03 +1.042521E-06 +3.025447E-13 +1.910984E-01 +8.723527E-03 +1.219295E-03 +3.551367E-07 +1.538542E+07 +5.654529E+13 +4.268000E+00 +3.930780E+00 +5.713023E-04 +7.796680E-08 +1.357524E+00 +3.878228E-01 +5.983682E-02 +7.460748E-04 +2.322979E-02 +1.144334E-04 +5.807447E-02 +7.152085E-04 +2.940107E-07 +2.024706E-14 +5.770628E-02 +7.061684E-04 +3.681924E-04 +2.874827E-08 +4.645957E+06 +4.577335E+12 +1.390000E+00 +4.083140E-01 +1.725170E-04 +6.311403E-09 +1.376941E+00 +4.321098E-01 +6.198249E-02 +8.400785E-04 +2.471448E-02 +1.321749E-04 +6.178621E-02 +8.260929E-04 +3.265418E-07 +2.485223E-14 +6.139448E-02 +8.156513E-04 +3.917248E-04 +3.320534E-08 +4.942896E+06 +5.286995E+12 +1.395000E+00 +4.400290E-01 +1.835431E-04 +7.289909E-09 +1.267762E+00 +4.052744E-01 +5.233659E-02 +6.929809E-04 +1.852753E-02 +9.379170E-05 +4.631882E-02 +5.861981E-04 +1.967460E-07 +1.534801E-14 +4.602516E-02 +5.787887E-04 +2.936615E-04 +2.356261E-08 +3.705506E+06 +3.751668E+12 +1.284000E+00 +4.070420E-01 +1.375955E-04 +5.172942E-09 +tally 13: +1.131330E+02 +2.561428E+03 +4.988000E+00 +4.976048E+00 +1.993967E+00 +7.956428E-01 +5.135468E+00 +5.291611E+00 +2.697394E-05 +1.462336E-10 +5.101779E+00 +5.222461E+00 +3.368875E-02 +2.575850E-04 +3.987934E+08 +3.182571E+16 +1.131330E+02 +2.561428E+03 +2.987487E-02 +1.870547E-04 +1.081450E+02 +2.340681E+03 +1.081450E+02 +2.340681E+03 +tally 14: +1.131330E+02 +2.561428E+03 +5.099217E+00 +5.202791E+00 +2.036481E+00 +8.305328E-01 +5.091203E+00 +5.190830E+00 +4.963770E-05 +4.951715E-10 +5.058925E+00 +5.125219E+00 +3.227825E-02 +2.086488E-04 +4.072963E+08 +3.322131E+16 +1.131330E+02 +2.561428E+03 +1.512401E-02 +4.580681E-05 +tally 15: +1.126689E+02 +2.540742E+03 +5.072428E+00 +5.150411E+00 +2.022883E+00 +8.201638E-01 +5.057207E+00 +5.126024E+00 +2.673439E-05 +1.438788E-10 +5.025144E+00 +5.061232E+00 +3.206271E-02 +2.060439E-04 +4.045765E+08 +3.280655E+16 +1.133620E+02 +2.571755E+03 +1.502302E-02 +4.523492E-05 +tally 16: +1.081450E+02 +2.340681E+03 +1.081450E+02 +2.340681E+03 +5.135468E+00 +5.291611E+00 +tally 17: +6.429000E+00 +8.307829E+00 +1.410000E+00 +3.992220E-01 +1.119414E+00 +2.516273E-01 +2.887237E+00 +1.682974E+00 +2.674702E-05 +1.437976E-10 +2.870392E+00 +1.663680E+00 +1.684448E-02 +5.768606E-05 +2.238828E+08 +1.006509E+16 +6.429000E+00 +8.307829E+00 +1.451639E-02 +4.943007E-05 +5.019000E+00 +5.067025E+00 +5.019000E+00 +5.067025E+00 +1.067040E+02 +2.278956E+03 +3.578000E+00 +2.562210E+00 +8.745532E-01 +1.530758E-01 +2.248231E+00 +1.013550E+00 +2.269178E-07 +1.030651E-14 +2.231387E+00 +9.980240E-01 +1.684427E-02 +8.005737E-05 +1.749106E+08 +6.123032E+15 +1.067040E+02 +2.278956E+03 +1.535848E-02 +6.943495E-05 +1.031260E+02 +2.128783E+03 +1.031260E+02 +2.128783E+03 +tally 18: +6.429000E+00 +8.307829E+00 +1.437899E+00 +4.155824E-01 +1.141563E+00 +2.619392E-01 +2.853907E+00 +1.637120E+00 +4.896211E-05 +4.818601E-10 +2.835814E+00 +1.616427E+00 +1.809378E-02 +6.580509E-05 +2.283126E+08 +1.047757E+16 +6.429000E+00 +8.307829E+00 +8.477865E-03 +1.444687E-05 +1.067040E+02 +2.278956E+03 +3.661318E+00 +2.683178E+00 +8.949183E-01 +1.603029E-01 +2.237296E+00 +1.001893E+00 +6.755918E-07 +9.135730E-14 +2.223111E+00 +9.892292E-01 +1.418446E-02 +4.027174E-05 +1.789837E+08 +6.412115E+15 +1.067040E+02 +2.278956E+03 +6.646148E-03 +8.841267E-06 +tally 19: +6.371628E+00 +8.173477E+00 +1.425067E+00 +4.088618E-01 +1.131376E+00 +2.577032E-01 +2.828439E+00 +1.610645E+00 +2.650833E-05 +1.414721E-10 +2.810507E+00 +1.590286E+00 +1.793232E-02 +6.474091E-05 +2.262751E+08 +1.030813E+16 +6.432000E+00 +8.315518E+00 +8.402208E-03 +1.421324E-05 +1.062973E+02 +2.261709E+03 +3.647362E+00 +2.662872E+00 +8.915070E-01 +1.590897E-01 +2.228767E+00 +9.943106E-01 +2.260528E-07 +1.022851E-14 +2.214637E+00 +9.817427E-01 +1.413039E-02 +3.996696E-05 +1.783014E+08 +6.363588E+15 +1.069300E+02 +2.288574E+03 +6.620813E-03 +8.774357E-06 +tally 20: +5.019000E+00 +5.067025E+00 +5.019000E+00 +5.067025E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.887237E+00 +1.682974E+00 +1.410000E+00 +3.992220E-01 +1.410000E+00 +3.992220E-01 +0.000000E+00 +0.000000E+00 +1.017160E+02 +2.071035E+03 +1.017160E+02 +2.071035E+03 +2.248231E+00 +1.013550E+00 diff --git a/tests/regression_tests/mg_tallies/test.py b/tests/regression_tests/mg_tallies/test.py index e1c19e6b7..f4e9693f6 100644 --- a/tests/regression_tests/mg_tallies/test.py +++ b/tests/regression_tests/mg_tallies/test.py @@ -5,7 +5,7 @@ import numpy as np import openmc from openmc.examples import slab_mg -from tests.testing_harness import HashedPyAPITestHarness +from tests.testing_harness import PyAPITestHarness def create_library(): @@ -49,7 +49,7 @@ def create_library(): mg_cross_sections_file.export_to_hdf5('2g.h5') -class MGXSTestHarness(HashedPyAPITestHarness): +class MGXSTestHarness(PyAPITestHarness): def _cleanup(self): super()._cleanup() f = '2g.h5' @@ -144,5 +144,5 @@ def test_mg_tallies(): t.nuclides = nuclides model.tallies.append(t) - harness = HashedPyAPITestHarness('statepoint.10.h5', model) + harness = MGXSTestHarness('statepoint.10.h5', model) harness.main() From 9409f0ff8f550133b608a9375da142456e7ccab4 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 7 Nov 2019 10:47:54 -0600 Subject: [PATCH 11/13] Fix delayed group indexing errors --- src/mgxs.cpp | 20 +++++++------------- src/tallies/tally_scoring.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/mgxs.cpp b/src/mgxs.cpp index 1fca66308..05ce05ac0 100644 --- a/src/mgxs.cpp +++ b/src/mgxs.cpp @@ -548,8 +548,7 @@ Mgxs::sample_fission_energy(int gin, int& dg, int& gout) double nu_fission = xs_t->nu_fission(cache[tid].a, gin); // Find the probability of having a prompt neutron - double prob_prompt = - xs_t->prompt_nu_fission(cache[tid].a, gin); + double prob_prompt = xs_t->prompt_nu_fission(cache[tid].a, gin); // sample random numbers double xi_pd = prn() * nu_fission; @@ -564,8 +563,7 @@ Mgxs::sample_fission_energy(int gin, int& dg, int& gout) // sample the outgoing energy group gout = 0; - double prob_gout = - xs_t->chi_prompt(cache[tid].a, gin, gout); + double prob_gout = xs_t->chi_prompt(cache[tid].a, gin, gout); while (prob_gout < xi_gout) { gout++; prob_gout += xs_t->chi_prompt(cache[tid].a, gin, gout); @@ -575,11 +573,9 @@ Mgxs::sample_fission_energy(int gin, int& dg, int& gout) // the neutron is delayed // get the delayed group - dg = 0; - while (xi_pd >= prob_prompt) { - dg++; - prob_prompt += - xs_t->delayed_nu_fission(cache[tid].a, dg, gin); + for (dg = 0; dg < num_delayed_groups; ++dg) { + prob_prompt += xs_t->delayed_nu_fission(cache[tid].a, dg, gin); + if (xi_pd < prob_prompt) break; } // adjust dg in case of round-off error @@ -587,12 +583,10 @@ Mgxs::sample_fission_energy(int gin, int& dg, int& gout) // sample the outgoing energy group gout = 0; - double prob_gout = - xs_t->chi_delayed(cache[tid].a, dg, gin, gout); + double prob_gout = xs_t->chi_delayed(cache[tid].a, dg, gin, gout); while (prob_gout < xi_gout) { gout++; - prob_gout += - xs_t->chi_delayed(cache[tid].a, dg, gin, gout); + prob_gout += xs_t->chi_delayed(cache[tid].a, dg, gin, gout); } } } diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index 37310070f..7ef05837c 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -1720,7 +1720,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, model::tally_filters[i_dg_filt].get())}; // Tally each delayed group bin individually for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { - auto d = filt.groups()[d_bin]; + auto d = filt.groups()[d_bin] - 1; score = p->wgt_absorb_ * flux; if (i_nuclide >= 0) { score *= @@ -1802,7 +1802,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, model::tally_filters[i_dg_filt].get())}; // Tally each delayed group bin individually for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { - auto d = filt.groups()[d_bin]; + auto d = filt.groups()[d_bin] - 1; if (i_nuclide >= 0) { score = flux * atom_density * get_nuclide_xs(i_nuclide, MG_GET_XS_DELAYED_NU_FISSION, @@ -1842,7 +1842,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, model::tally_filters[i_dg_filt].get())}; // Tally each delayed group bin individually for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { - auto d = filt.groups()[d_bin]; + auto d = filt.groups()[d_bin] - 1; score = p->wgt_absorb_ * flux; if (i_nuclide >= 0) { score *= @@ -1902,8 +1902,8 @@ score_general_mg(const Particle* p, int i_tally, int start_index, for (auto i = 0; i < p->n_bank_; ++i) { auto i_bank = simulation::fission_bank.size() - p->n_bank_ + i; const auto& bank = simulation::fission_bank[i_bank]; - auto g = bank.delayed_group; - if (g != 0) { + auto g = bank.delayed_group - 1; + if (g != -1) { if (i_nuclide >= 0) { score += simulation::keff * atom_density * bank.wgt * flux * get_nuclide_xs(i_nuclide, MG_GET_XS_DECAY_RATE, p_g, @@ -1923,7 +1923,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, // Find the corresponding filter bin and then score for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { auto d = filt.groups()[d_bin]; - if (d == g) + if (d == g + 1) score_fission_delayed_dg(i_tally, d_bin, score, score_index); } @@ -1941,7 +1941,7 @@ score_general_mg(const Particle* p, int i_tally, int start_index, model::tally_filters[i_dg_filt].get())}; // Tally each delayed group bin individually for (auto d_bin = 0; d_bin < filt.n_bins(); ++d_bin) { - auto d = filt.groups()[d_bin]; + auto d = filt.groups()[d_bin] - 1; if (i_nuclide >= 0) { score += atom_density * flux * get_nuclide_xs(i_nuclide, MG_GET_XS_DECAY_RATE, From dd7094d682533b79be7f557c9faff532890dc07d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 7 Nov 2019 10:50:18 -0600 Subject: [PATCH 12/13] Update mg_tallies test result --- .../mg_tallies/results_true.dat | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/regression_tests/mg_tallies/results_true.dat b/tests/regression_tests/mg_tallies/results_true.dat index 8743a290f..26a062fac 100644 --- a/tests/regression_tests/mg_tallies/results_true.dat +++ b/tests/regression_tests/mg_tallies/results_true.dat @@ -41,8 +41,8 @@ tally 1: 1.212630E+13 1.949000E+00 8.324030E-01 -8.760860E-04 -7.675267E-07 +3.122595E-04 +9.750600E-08 5.650158E+00 7.016308E+00 1.039000E+00 @@ -63,8 +63,8 @@ tally 1: 2.555628E+12 1.039000E+00 2.447670E-01 -8.983029E-04 -8.069481E-07 +3.201782E-04 +1.025141E-07 3.038326E+00 2.108568E+00 5.930000E-01 @@ -129,8 +129,8 @@ tally 1: 5.308405E+13 4.454000E+00 4.082446E+00 -2.942322E-03 -8.657261E-06 +3.894344E-03 +9.877407E-06 1.292241E+01 3.441496E+01 4.210000E+00 @@ -151,8 +151,8 @@ tally 1: 4.912798E+13 4.210000E+00 3.829106E+00 -9.104408E-04 -8.289024E-07 +3.245044E-04 +1.053031E-07 1.222119E+01 3.220371E+01 1.364000E+00 @@ -461,8 +461,8 @@ tally 3: 3.182571E+16 1.131330E+02 2.561428E+03 -2.987487E-02 -1.870547E-04 +1.464422E-02 +8.408713E-05 3.294536E+02 2.172280E+04 1.081450E+02 @@ -541,8 +541,8 @@ tally 7: 1.006509E+16 6.429000E+00 8.307829E+00 -1.451639E-02 -4.943007E-05 +3.761262E-03 +3.156399E-06 1.176869E+01 2.783921E+01 5.019000E+00 @@ -567,8 +567,8 @@ tally 7: 6.123032E+15 1.067040E+02 2.278956E+03 -1.535848E-02 -6.943495E-05 +1.088296E-02 +6.231251E-05 3.176849E+02 2.020075E+04 1.031260E+02 @@ -729,8 +729,8 @@ tally 11: 1.212630E+13 1.949000E+00 8.324030E-01 -8.760860E-04 -7.675267E-07 +3.122595E-04 +9.750600E-08 1.039000E+00 2.447670E-01 4.200000E-02 @@ -749,8 +749,8 @@ tally 11: 2.555628E+12 1.039000E+00 2.447670E-01 -8.983029E-04 -8.069481E-07 +3.201782E-04 +1.025141E-07 5.930000E-01 7.205300E-02 2.300000E-02 @@ -809,8 +809,8 @@ tally 11: 5.308405E+13 4.454000E+00 4.082446E+00 -2.942322E-03 -8.657261E-06 +3.894344E-03 +9.877407E-06 4.210000E+00 3.829106E+00 1.750000E-01 @@ -829,8 +829,8 @@ tally 11: 4.912798E+13 4.210000E+00 3.829106E+00 -9.104408E-04 -8.289024E-07 +3.245044E-04 +1.053031E-07 1.364000E+00 3.933640E-01 8.200000E-02 @@ -1111,8 +1111,8 @@ tally 13: 3.182571E+16 1.131330E+02 2.561428E+03 -2.987487E-02 -1.870547E-04 +1.464422E-02 +8.408713E-05 1.081450E+02 2.340681E+03 1.081450E+02 @@ -1185,8 +1185,8 @@ tally 17: 1.006509E+16 6.429000E+00 8.307829E+00 -1.451639E-02 -4.943007E-05 +3.761262E-03 +3.156399E-06 5.019000E+00 5.067025E+00 5.019000E+00 @@ -1209,8 +1209,8 @@ tally 17: 6.123032E+15 1.067040E+02 2.278956E+03 -1.535848E-02 -6.943495E-05 +1.088296E-02 +6.231251E-05 1.031260E+02 2.128783E+03 1.031260E+02 From 005b126f96d8a8339c523ed3968e4e726bcbe852 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Fri, 8 Nov 2019 18:05:32 -0500 Subject: [PATCH 13/13] can write track files in restart mode now --- src/particle_restart.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/particle_restart.cpp b/src/particle_restart.cpp index b2017bbeb..1a75d6b47 100644 --- a/src/particle_restart.cpp +++ b/src/particle_restart.cpp @@ -79,6 +79,9 @@ void run_particle_restart() int previous_run_mode; read_particle_restart(p, previous_run_mode); + // write track if that was requested on command line + if (settings::write_all_tracks) p.write_track_ = true; + // Set all tallies to 0 for now (just tracking errors) model::tallies.clear();