From b648142abbfe2a98ce2a92457064618a70c61615 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 28 Feb 2020 17:52:48 -0600 Subject: [PATCH 001/103] Add a new attribute surf_src on class Surface for source banking --- include/openmc/surface.h | 1 + src/surface.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 1e16c4919..febfed27c 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -88,6 +88,7 @@ public: int id_; //!< Unique ID std::string name_; //!< User-defined name std::shared_ptr bc_ {nullptr}; //!< Boundary condition + bool surf_src_ {false}; //!< Activate source banking for the surface? explicit Surface(pugi::xml_node surf_node); Surface(); diff --git a/src/surface.cpp b/src/surface.cpp index e0f2787b6..1e1307eff 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -143,6 +143,10 @@ Surface::Surface(pugi::xml_node surf_node) } } + if (check_for_node(surf_node, "surf_src")) { + surf_src_ = get_node_value_bool(surf_node, "surf_src"); + } + } bool From a0e02fa2dc4b91ffbc32bad342b19da37ac1b2cb Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 2 Mar 2020 14:30:24 -0600 Subject: [PATCH 002/103] Checking surface crossing with surf_src_ --- src/particle.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/particle.cpp b/src/particle.cpp index 4453701be..c94c46ea3 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -416,6 +416,10 @@ Particle::cross_surface() // Handle any applicable boundary conditions. if (surf->bc_ && settings::run_mode != RunMode::PLOTTING) { surf->bc_->handle_particle(*this, *surf); + + if (surf->surf_src_) { + write_message(" Source banking on surface " + std::to_string(surf->id_)); + } return; } From 2c0c2cfc03377980ca7d70ccd47867dbe919af30 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 2 Mar 2020 17:13:31 -0600 Subject: [PATCH 003/103] Add a new element surface_source for banking and writing surface sources --- include/openmc/settings.h | 1 + src/settings.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 74cbbc132..ed9de630b 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -45,6 +45,7 @@ extern "C" bool run_CE; //!< run with continuous-energy data? extern bool source_latest; //!< write latest source at each batch? extern bool source_separate; //!< write source to separate file? extern bool source_write; //!< write source in HDF5 files? +extern bool surface_source; //!< write surface source file? extern bool survival_biasing; //!< use survival biasing? extern bool temperature_multipole; //!< use multipole data? extern "C" bool trigger_on; //!< tally triggers enabled? diff --git a/src/settings.cpp b/src/settings.cpp index 5a868d445..a4e294abf 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -60,6 +60,7 @@ bool run_CE {true}; bool source_latest {false}; bool source_separate {false}; bool source_write {true}; +bool surface_source {false}; bool survival_biasing {false}; bool temperature_multipole {false}; bool trigger_on {false}; @@ -622,6 +623,11 @@ void read_settings_xml() sourcepoint_batch = statepoint_batch; } + // Check if the user has specified to write surface source. + if (check_for_node(root, "surface_source")) { + surface_source = get_node_value_bool(root, "surface_source"); + } + // If source is not seperate and is to be written out in the statepoint file, // make sure that the sourcepoint batch numbers are contained in the // statepoint list From cfed9cda8e966d0089eb41fa8d5ea04e910379de Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 3 Mar 2020 09:13:22 -0600 Subject: [PATCH 004/103] Bank particles on surface crossing --- src/particle.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/particle.cpp b/src/particle.cpp index c94c46ea3..b3bdede06 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -413,13 +413,21 @@ Particle::cross_surface() write_message(1, " Crossing surface {}", surf->id_); } + if (surf->surf_src_) { + Particle::Bank site; + site.r = this->r(); + site.u = this->u(); + site.E = this->E_; + site.wgt = this->wgt_; + site.delayed_group = this->delayed_group_; + site.particle = this->type_; + // site.parent_id = this->id_; + // site.progeny_id = this->n_progeny_; + } + // Handle any applicable boundary conditions. if (surf->bc_ && settings::run_mode != RunMode::PLOTTING) { surf->bc_->handle_particle(*this, *surf); - - if (surf->surf_src_) { - write_message(" Source banking on surface " + std::to_string(surf->id_)); - } return; } From 209394082e314ae38208a130c9cfeba654d0cae4 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 17 Mar 2020 00:01:08 -0500 Subject: [PATCH 005/103] Add a new bank type surf_src_bank for surface source banking --- include/openmc/bank.h | 2 ++ src/bank.cpp | 3 +++ src/simulation.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/include/openmc/bank.h b/include/openmc/bank.h index 7c74125c3..c20ae6fba 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -18,6 +18,8 @@ namespace simulation { extern std::vector source_bank; +extern std::vector surf_src_bank; + extern SharedArray fission_bank; extern std::vector progeny_per_particle; diff --git a/src/bank.cpp b/src/bank.cpp index 6053937b5..0fe3b7c44 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -17,6 +17,8 @@ namespace simulation { std::vector source_bank; +std::vector surf_src_bank; + // The fission bank is allocated as a SharedArray, rather than a vector, as it will // be shared by all threads in the simulation. It will be allocated to a fixed // maximum capacity in the init_fission_bank() function. Then, Elements will be @@ -37,6 +39,7 @@ std::vector progeny_per_particle; void free_memory_bank() { simulation::source_bank.clear(); + simulation::surf_src_bank.clear(); simulation::fission_bank.clear(); simulation::progeny_per_particle.clear(); } diff --git a/src/simulation.cpp b/src/simulation.cpp index 1e35adeee..845ee5031 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -283,8 +283,11 @@ void allocate_banks() { // Allocate source bank simulation::source_bank.resize(simulation::work_per_rank); + // Allocate fission bank init_fission_bank(3*simulation::work_per_rank); + + simulation::surf_src_bank.resize(simulation::work_per_rank); } void initialize_batch() From 2ebf9d844f77da3e72ddec289fe23b5553690b31 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 17 Mar 2020 00:18:35 -0500 Subject: [PATCH 006/103] Copy/simplify source bank writing functions to make temp surface source bank writing functions --- include/openmc/state_point.h | 2 ++ src/state_point.cpp | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index c50ca355b..ac4a8699e 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -14,6 +14,8 @@ namespace openmc { void load_state_point(); void write_source_point(const char* filename); void write_source_bank(hid_t group_id); +void write_surf_src_point(const char* filename); +void write_surf_src_bank(hid_t group_id); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); void write_tally_results_nr(hid_t file_id); void restart_set_keff(); diff --git a/src/state_point.cpp b/src/state_point.cpp index 66706a676..b5f1ffd55 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -653,6 +653,63 @@ write_source_bank(hid_t group_id) } +void +write_surf_src_point(const char* filename) +{ + std::string filename_; + filename_ = filename; + + hid_t file_id; + file_id = file_open(filename_, 'w', true); + write_attribute(file_id, "filetype", "source"); + + write_surf_src_bank(file_id); + + file_close(file_id); +} + + +void +write_surf_src_bank(hid_t group_id) +{ + hid_t banktype = h5banktype(); + + if (mpi::master) { + // Create dataset big enough to hold all source sites + hsize_t dims[] {static_cast(settings::n_particles)}; + hid_t dspace = H5Screate_simple(1, dims, nullptr); + hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + for (int i = 0; i < mpi::n_procs; ++i) { + // Create memory space + hsize_t count[] {static_cast(simulation::work_index[i+1] - + simulation::work_index[i])}; + hid_t memspace = H5Screate_simple(1, count, nullptr); + + // Select hyperslab for this dataspace + dspace = H5Dget_space(dset); + hsize_t start[] {static_cast(simulation::work_index[i])}; + H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); + + // Write data to hyperslab + H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, + simulation::surf_src_bank.data()); + + H5Sclose(memspace); + H5Sclose(dspace); + } + + // Close all ids + H5Dclose(dset); + + } else { + } + + H5Tclose(banktype); +} + + void read_source_bank(hid_t group_id, std::vector& sites, bool distribute) { hid_t banktype = h5banktype(); From 0c8ce53d94d4f5d9db0bbbcbe275a95fce6b70de Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 17 Mar 2020 00:20:00 -0500 Subject: [PATCH 007/103] Rough banking of surface source into surf_src_bank --- include/openmc/particle.h | 2 ++ src/particle.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/openmc/particle.h b/include/openmc/particle.h index f70faa611..705675e2e 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -159,6 +159,8 @@ public: neutron, photon, electron, positron }; + int64_t icross = 0; + //! Saved ("banked") state of a particle //! NOTE: This structure's MPI type is built in initialize_mpi() of //! initialize.cpp. Any changes made to the struct here must also be diff --git a/src/particle.cpp b/src/particle.cpp index b3bdede06..28d93eee3 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -423,6 +423,8 @@ Particle::cross_surface() site.particle = this->type_; // site.parent_id = this->id_; // site.progeny_id = this->n_progeny_; + simulation::surf_src_bank[Particle::icross] = site; + Particle::icross += 1; } // Handle any applicable boundary conditions. From 30b1c6b2d40c4b72112d33893dd4d41fbd1ce8b6 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 17 Mar 2020 00:22:02 -0500 Subject: [PATCH 008/103] Test-writing surface sources into statepoint file --- src/state_point.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index b5f1ffd55..06c6f674e 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -311,7 +311,8 @@ openmc_statepoint_write(const char* filename, bool* write_source) // Write the source bank if desired if (write_source_) { if (mpi::master || parallel) file_id = file_open(filename_, 'a', true); - write_source_bank(file_id); + // write_source_bank(file_id); + write_surf_src_bank(file_id); if (mpi::master || parallel) file_close(file_id); } From 2e49a1d6def86ece45d87b6a701b452cbe599408 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 17 Mar 2020 00:22:39 -0500 Subject: [PATCH 009/103] Add section to write surface source into a separate file --- src/simulation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/simulation.cpp b/src/simulation.cpp index 845ee5031..537a733bc 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -378,6 +378,12 @@ void finalize_batch() write_source_point(filename.c_str()); } } + + // Write out surface source if requested. + if (settings::surface_source) { + auto filename = settings::path_output + "surface_source.h5"; + write_surf_src_point(filename.c_str()); //!! + } } void initialize_generation() From 45b24ca78eaa145713d8d4fb3e0c42e755817a04 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 1 Apr 2020 17:07:41 -0500 Subject: [PATCH 010/103] Switch to push_back method instead of manual indexing --- include/openmc/particle.h | 2 -- src/particle.cpp | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 705675e2e..f70faa611 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -159,8 +159,6 @@ public: neutron, photon, electron, positron }; - int64_t icross = 0; - //! Saved ("banked") state of a particle //! NOTE: This structure's MPI type is built in initialize_mpi() of //! initialize.cpp. Any changes made to the struct here must also be diff --git a/src/particle.cpp b/src/particle.cpp index 28d93eee3..59e5bfb94 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -423,8 +423,7 @@ Particle::cross_surface() site.particle = this->type_; // site.parent_id = this->id_; // site.progeny_id = this->n_progeny_; - simulation::surf_src_bank[Particle::icross] = site; - Particle::icross += 1; + simulation::surf_src_bank.push_back(site); } // Handle any applicable boundary conditions. From 109dfd20f514089939fa4669a860270638bfdc07 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 1 Apr 2020 17:09:21 -0500 Subject: [PATCH 011/103] Revert statepoint surface source writing --- src/state_point.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 06c6f674e..b5f1ffd55 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -311,8 +311,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) // Write the source bank if desired if (write_source_) { if (mpi::master || parallel) file_id = file_open(filename_, 'a', true); - // write_source_bank(file_id); - write_surf_src_bank(file_id); + write_source_bank(file_id); if (mpi::master || parallel) file_close(file_id); } From c362ba5ef47d8b6daf4fa5fc3654946aba4e223c Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 13 Apr 2020 02:55:05 -0500 Subject: [PATCH 012/103] Write surface source only at the last batch, hard-code number of surfaces for surface_source.h5 sizing --- src/particle.cpp | 2 +- src/simulation.cpp | 2 +- src/state_point.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/particle.cpp b/src/particle.cpp index 59e5bfb94..b2ac429c5 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -413,7 +413,7 @@ Particle::cross_surface() write_message(1, " Crossing surface {}", surf->id_); } - if (surf->surf_src_) { + if (surf->surf_src_ && simulation::current_batch == settings::n_batches) { Particle::Bank site; site.r = this->r(); site.u = this->u(); diff --git a/src/simulation.cpp b/src/simulation.cpp index 537a733bc..986a32708 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -380,7 +380,7 @@ void finalize_batch() } // Write out surface source if requested. - if (settings::surface_source) { + if (settings::surface_source && simulation::current_batch == settings::n_batches) { auto filename = settings::path_output + "surface_source.h5"; write_surf_src_point(filename.c_str()); //!! } diff --git a/src/state_point.cpp b/src/state_point.cpp index b5f1ffd55..d31e45b4b 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -676,15 +676,16 @@ write_surf_src_bank(hid_t group_id) if (mpi::master) { // Create dataset big enough to hold all source sites - hsize_t dims[] {static_cast(settings::n_particles)}; + hsize_t dims[] {static_cast(settings::n_particles)*2}; // 2 being hard-coded number of surfaces. hid_t dspace = H5Screate_simple(1, dims, nullptr); hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); for (int i = 0; i < mpi::n_procs; ++i) { + // Create memory space hsize_t count[] {static_cast(simulation::work_index[i+1] - - simulation::work_index[i])}; + simulation::work_index[i])*2}; // 2 being hard-coded number of surfaces. hid_t memspace = H5Screate_simple(1, count, nullptr); // Select hyperslab for this dataspace From d8490143911df7c7800a100bf1be2b7311802c24 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 14 Apr 2020 02:09:49 -0500 Subject: [PATCH 013/103] Switch surf_src_bank from vector to SharedArray --- include/openmc/bank.h | 4 +++- src/bank.cpp | 7 ++++++- src/particle.cpp | 2 +- src/simulation.cpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/openmc/bank.h b/include/openmc/bank.h index c20ae6fba..b81c176fc 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -18,7 +18,7 @@ namespace simulation { extern std::vector source_bank; -extern std::vector surf_src_bank; +extern SharedArray surf_src_bank; extern SharedArray fission_bank; @@ -34,6 +34,8 @@ void sort_fission_bank(); void free_memory_bank(); +void init_surf_src_bank(int64_t max); + void init_fission_bank(int64_t max); } // namespace openmc diff --git a/src/bank.cpp b/src/bank.cpp index 0fe3b7c44..11b54e930 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -17,7 +17,7 @@ namespace simulation { std::vector source_bank; -std::vector surf_src_bank; +SharedArray surf_src_bank; // The fission bank is allocated as a SharedArray, rather than a vector, as it will // be shared by all threads in the simulation. It will be allocated to a fixed @@ -44,6 +44,11 @@ void free_memory_bank() simulation::progeny_per_particle.clear(); } +void init_surf_src_bank(int64_t max) +{ + simulation::surf_src_bank.reserve(max); +} + void init_fission_bank(int64_t max) { simulation::fission_bank.reserve(max); diff --git a/src/particle.cpp b/src/particle.cpp index b2ac429c5..3a05d11ff 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -423,7 +423,7 @@ Particle::cross_surface() site.particle = this->type_; // site.parent_id = this->id_; // site.progeny_id = this->n_progeny_; - simulation::surf_src_bank.push_back(site); + int64_t idx = simulation::surf_src_bank.thread_safe_append(site); } // Handle any applicable boundary conditions. diff --git a/src/simulation.cpp b/src/simulation.cpp index 986a32708..224e0922b 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -287,7 +287,7 @@ void allocate_banks() // Allocate fission bank init_fission_bank(3*simulation::work_per_rank); - simulation::surf_src_bank.resize(simulation::work_per_rank); + init_surf_src_bank(10*simulation::work_per_rank); // TODO: capacity enough? } void initialize_batch() From feb4af6149bf9ffe343e22e7203d6a077d2a717d Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 4 Jun 2020 23:58:30 -0500 Subject: [PATCH 014/103] Revise bank allocation --- src/simulation.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 224e0922b..ff41c3556 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -79,10 +79,8 @@ int openmc_simulation_init() // Determine how much work each process should do calculate_work(); - // Allocate source and fission banks for eigenvalue simulations - if (settings::run_mode == RunMode::EIGENVALUE) { - allocate_banks(); - } + // Allocate source, fission and surface source banks. + allocate_banks(); // If doing an event-based simulation, intialize the particle buffer // and event queues @@ -281,13 +279,19 @@ std::vector work_index; void allocate_banks() { - // Allocate source bank - simulation::source_bank.resize(simulation::work_per_rank); + if (settings::run_mode == RunMode::EIGENVALUE) { + // Allocate source bank + simulation::source_bank.resize(simulation::work_per_rank); - // Allocate fission bank - init_fission_bank(3*simulation::work_per_rank); + // Allocate fission bank + init_fission_bank(3*simulation::work_per_rank); + } + + if (settings::surface_source) { + // Allocate surface source bank + init_surf_src_bank(10*simulation::work_per_rank); // TODO: capacity enough? + } - init_surf_src_bank(10*simulation::work_per_rank); // TODO: capacity enough? } void initialize_batch() From 5ad6cfc4dc08ea16f383f1da793e45eea0c3193a Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 24 Jun 2020 20:03:43 -0500 Subject: [PATCH 015/103] Switching to arbitrary source bank depending on surface source bank boolean --- include/openmc/state_point.h | 4 ++-- src/simulation.cpp | 6 +++--- src/state_point.cpp | 27 ++++++++++++++++----------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index ac4a8699e..beb67daa7 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,8 +12,8 @@ namespace openmc { void load_state_point(); -void write_source_point(const char* filename); -void write_source_bank(hid_t group_id); +void write_source_point(const char* filename, bool surf_src_bank); +void write_source_bank(hid_t group_id, bool surf_src_bank); void write_surf_src_point(const char* filename); void write_surf_src_bank(hid_t group_id); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); diff --git a/src/simulation.cpp b/src/simulation.cpp index ff41c3556..9a87151fa 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -373,20 +373,20 @@ void finalize_batch() // Write out a separate source point if it's been specified for this batch if (contains(settings::sourcepoint_batch, simulation::current_batch) && settings::source_write && settings::source_separate) { - write_source_point(nullptr); + write_source_point(nullptr, false); } // Write a continously-overwritten source point if requested. if (settings::source_latest) { auto filename = settings::path_output + "source.h5"; - write_source_point(filename.c_str()); + write_source_point(filename.c_str(), false); } } // Write out surface source if requested. if (settings::surface_source && simulation::current_batch == settings::n_batches) { auto filename = settings::path_output + "surface_source.h5"; - write_surf_src_point(filename.c_str()); //!! + write_source_point(filename.c_str(), true); //!! } } diff --git a/src/state_point.cpp b/src/state_point.cpp index d31e45b4b..63baf9c77 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,7 +525,7 @@ hid_t h5banktype() { } void -write_source_point(const char* filename) +write_source_point(const char* filename, bool surf_src_bank) { // When using parallel HDF5, the file is written to collectively by all // processes. With MPI-only, the file is opened and written by the master @@ -555,16 +555,22 @@ write_source_point(const char* filename) } // Get pointer to source bank and write to file - write_source_bank(file_id); + write_source_bank(file_id, surf_src_bank); if (mpi::master || parallel) file_close(file_id); } void -write_source_bank(hid_t group_id) +write_source_bank(hid_t group_id, bool surf_src_bank) { hid_t banktype = h5banktype(); + if (surf_src_bank) { + std::vector src_bank = simulation::source_bank + } else { + SharedArray src_bank = simulation::surf_src_bank + } + #ifdef PHDF5 // Set size of total dataspace for all procs and rank hsize_t dims[] {static_cast(settings::n_particles)}; @@ -585,7 +591,7 @@ write_source_bank(hid_t group_id) H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); // Write data to file in parallel - H5Dwrite(dset, banktype, memspace, dspace, plist, simulation::source_bank.data()); + H5Dwrite(dset, banktype, memspace, dspace, plist, src_bank.data()); // Free resources H5Sclose(dspace); @@ -604,8 +610,8 @@ write_source_bank(hid_t group_id) // Save source bank sites since the souce_bank array is overwritten below #ifdef OPENMC_MPI - std::vector temp_source {simulation::source_bank.begin(), - simulation::source_bank.begin() + simulation::work_per_rank}; + std::vector temp_source {src_bank.begin(), + src_bank.begin() + simulation::work_per_rank}; #endif for (int i = 0; i < mpi::n_procs; ++i) { @@ -617,7 +623,7 @@ write_source_bank(hid_t group_id) #ifdef OPENMC_MPI // Receive source sites from other processes if (i > 0) - MPI_Recv(simulation::source_bank.data(), count[0], mpi::bank, i, i, + MPI_Recv(src_bank.data(), count[0], mpi::bank, i, i, mpi::intracomm, MPI_STATUS_IGNORE); #endif @@ -627,8 +633,7 @@ write_source_bank(hid_t group_id) H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab - H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, - simulation::source_bank.data()); + H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, src_bank.data()); H5Sclose(memspace); H5Sclose(dspace); @@ -639,11 +644,11 @@ write_source_bank(hid_t group_id) #ifdef OPENMC_MPI // Restore state of source bank - std::copy(temp_source.begin(), temp_source.end(), simulation::source_bank.begin()); + std::copy(temp_source.begin(), temp_source.end(), src_bank.begin()); #endif } else { #ifdef OPENMC_MPI - MPI_Send(simulation::source_bank.data(), simulation::work_per_rank, mpi::bank, + MPI_Send(src_bank.data(), simulation::work_per_rank, mpi::bank, 0, mpi::rank, mpi::intracomm); #endif } From 1c155526e9653b82c0be18375bec97868a54b43d Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 24 Jun 2020 20:18:13 -0500 Subject: [PATCH 016/103] Add missing argument --- src/source.cpp | 2 +- src/state_point.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/source.cpp b/src/source.cpp index 87644f054..0efaf52ba 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -342,7 +342,7 @@ void initialize_source() write_message("Writing out initial source...", 5); std::string filename = settings::path_output + "initial_source.h5"; hid_t file_id = file_open(filename, 'w', true); - write_source_bank(file_id); + write_source_bank(file_id, false); file_close(file_id); } } diff --git a/src/state_point.cpp b/src/state_point.cpp index 63baf9c77..0f7b11840 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -311,7 +311,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) // Write the source bank if desired if (write_source_) { if (mpi::master || parallel) file_id = file_open(filename_, 'a', true); - write_source_bank(file_id); + write_source_bank(file_id, false); if (mpi::master || parallel) file_close(file_id); } From d28967c8012a897d1db85aada41111d95ffd6dfc Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 30 Jun 2020 21:48:40 -0500 Subject: [PATCH 017/103] Add surf_num to bank datatype --- include/openmc/particle.h | 1 + src/initialize.cpp | 17 +++++++++-------- src/state_point.cpp | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/openmc/particle.h b/include/openmc/particle.h index f70faa611..797f7b0e5 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -172,6 +172,7 @@ public: double E; double wgt; int delayed_group; + int surf_num; Type particle; int64_t parent_id; int64_t progeny_id; diff --git a/src/initialize.cpp b/src/initialize.cpp index 9581cce0f..4f5f525da 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -102,22 +102,23 @@ void initialize_mpi(MPI_Comm intracomm) // Create bank datatype Particle::Bank b; - MPI_Aint disp[8]; + MPI_Aint disp[9]; MPI_Get_address(&b.r, &disp[0]); MPI_Get_address(&b.u, &disp[1]); MPI_Get_address(&b.E, &disp[2]); MPI_Get_address(&b.wgt, &disp[3]); MPI_Get_address(&b.delayed_group, &disp[4]); - MPI_Get_address(&b.particle, &disp[5]); - MPI_Get_address(&b.parent_id, &disp[6]); - MPI_Get_address(&b.progeny_id, &disp[7]); - for (int i = 7; i >= 0; --i) { + MPI_Get_address(&b.surf_num, &disp[5]); + MPI_Get_address(&b.particle, &disp[6]); + MPI_Get_address(&b.parent_id, &disp[7]); + MPI_Get_address(&b.progeny_id, &disp[8]); + for (int i = 8; i >= 0; --i) { disp[i] -= disp[0]; } - int blocks[] {3, 3, 1, 1, 1, 1, 1, 1}; - MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT, MPI_LONG, MPI_LONG}; - MPI_Type_create_struct(8, blocks, disp, types, &mpi::bank); + int blocks[] {3, 3, 1, 1, 1, 1, 1, 1, 1}; + MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT, MPI_INT, MPI_LONG, MPI_LONG}; + MPI_Type_create_struct(9, blocks, disp, types, &mpi::bank); MPI_Type_commit(&mpi::bank); } #endif // OPENMC_MPI diff --git a/src/state_point.cpp b/src/state_point.cpp index 0f7b11840..ab95109b8 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -518,6 +518,7 @@ hid_t h5banktype() { H5Tinsert(banktype, "E", HOFFSET(Particle::Bank, E), H5T_NATIVE_DOUBLE); H5Tinsert(banktype, "wgt", HOFFSET(Particle::Bank, wgt), H5T_NATIVE_DOUBLE); H5Tinsert(banktype, "delayed_group", HOFFSET(Particle::Bank, delayed_group), H5T_NATIVE_INT); + H5Tinsert(banktype, "surf_num", HOFFSET(Particle::Bank, surf_num), H5T_NATIVE_INT); H5Tinsert(banktype, "particle", HOFFSET(Particle::Bank, particle), H5T_NATIVE_INT); H5Tclose(postype); From d48b7df594f2ae8cd6d2745996222f8701d92f9e Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 30 Jun 2020 22:07:50 -0500 Subject: [PATCH 018/103] Bank surface number if surf src is triggered --- src/particle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/particle.cpp b/src/particle.cpp index 3a05d11ff..b6e936b62 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -420,6 +420,7 @@ Particle::cross_surface() site.E = this->E_; site.wgt = this->wgt_; site.delayed_group = this->delayed_group_; + site.surf_num = surf->id_; site.particle = this->type_; // site.parent_id = this->id_; // site.progeny_id = this->n_progeny_; From abca6e580da06d75cd4663a109a13fd8510929bc Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 6 Jul 2020 13:40:04 -0500 Subject: [PATCH 019/103] Set the maximum number of particles to be banked on surfaces --- include/openmc/settings.h | 1 + src/settings.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/openmc/settings.h b/include/openmc/settings.h index ed9de630b..8db05fdea 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -86,6 +86,7 @@ extern std::vector res_scat_nuclides; //!< Nuclides using res. ups extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set statepoint_batch; //!< Batches when state should be written +extern int max_surf_banks; //!< maximum number of particles to be banked on surfaces extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures extern double temperature_default; //!< Default T in [K] diff --git a/src/settings.cpp b/src/settings.cpp index a4e294abf..6b572e0a6 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -99,6 +99,7 @@ std::vector res_scat_nuclides; RunMode run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; +int max_surf_banks; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; double temperature_default {293.6}; @@ -625,7 +626,15 @@ void read_settings_xml() // Check if the user has specified to write surface source. if (check_for_node(root, "surface_source")) { - surface_source = get_node_value_bool(root, "surface_source"); + surface_source = true; + // Get surface source node + xml_node node_ss = root.child("surface_source"); + + // Get maximum number of particles to be banked per surface. + if (check_for_node(node_ss, "max_surf_banks")) { + max_surf_banks = std::stoi(get_node_value(node_ss, + "max_surf_banks")); + } } // If source is not seperate and is to be written out in the statepoint file, From ccb20b6b95ab33ffc895892f1c477ff55f129d96 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 6 Jul 2020 14:24:43 -0500 Subject: [PATCH 020/103] Assign surf_src_bank into vector of particle bank --- src/state_point.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index ab95109b8..0c39257e9 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -566,10 +566,12 @@ write_source_bank(hid_t group_id, bool surf_src_bank) { hid_t banktype = h5banktype(); + std::vector src_bank = simulation::source_bank; if (surf_src_bank) { - std::vector src_bank = simulation::source_bank - } else { - SharedArray src_bank = simulation::surf_src_bank + src_bank.clear(); + src_bank.assign(simulation::surf_src_bank.data(), + simulation::surf_src_bank.data() + + simulation::surf_src_bank.size()); } #ifdef PHDF5 From 74cae60a58f1f28441d0c1d7077528f13453df81 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 6 Jul 2020 15:39:13 -0500 Subject: [PATCH 021/103] Use max_surf_banks for surface source bank allocation --- include/openmc/bank.h | 2 -- src/bank.cpp | 5 ----- src/simulation.cpp | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/openmc/bank.h b/include/openmc/bank.h index b81c176fc..de73641e7 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -34,8 +34,6 @@ void sort_fission_bank(); void free_memory_bank(); -void init_surf_src_bank(int64_t max); - void init_fission_bank(int64_t max); } // namespace openmc diff --git a/src/bank.cpp b/src/bank.cpp index 11b54e930..fa0146df5 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -44,11 +44,6 @@ void free_memory_bank() simulation::progeny_per_particle.clear(); } -void init_surf_src_bank(int64_t max) -{ - simulation::surf_src_bank.reserve(max); -} - void init_fission_bank(int64_t max) { simulation::fission_bank.reserve(max); diff --git a/src/simulation.cpp b/src/simulation.cpp index 9a87151fa..e8dc30fcc 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -289,7 +289,7 @@ void allocate_banks() if (settings::surface_source) { // Allocate surface source bank - init_surf_src_bank(10*simulation::work_per_rank); // TODO: capacity enough? + simulation::surf_src_bank.reserve(settings::max_surf_banks); } } From 26ccf1a0afd0757a73548a927688203bb1ad6322 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 15 Jul 2020 04:03:07 -0500 Subject: [PATCH 022/103] Switch max_surf_banks to int64_t --- include/openmc/settings.h | 2 +- src/settings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 8db05fdea..c7d14b4e7 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -86,7 +86,7 @@ extern std::vector res_scat_nuclides; //!< Nuclides using res. ups extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set statepoint_batch; //!< Batches when state should be written -extern int max_surf_banks; //!< maximum number of particles to be banked on surfaces +extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures extern double temperature_default; //!< Default T in [K] diff --git a/src/settings.cpp b/src/settings.cpp index 6b572e0a6..11effc922 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -99,7 +99,7 @@ std::vector res_scat_nuclides; RunMode run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; -int max_surf_banks; +int64_t max_surf_banks; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; double temperature_default {293.6}; From b06725b4fbc2e47b0a016e0772c26f5ab88d9ba5 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 15 Jul 2020 04:21:00 -0500 Subject: [PATCH 023/103] Adding surf_src_bank logic for write_source_bank --- src/state_point.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 0c39257e9..77e981e0f 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -566,8 +566,28 @@ write_source_bank(hid_t group_id, bool surf_src_bank) { hid_t banktype = h5banktype(); + int64_t dims_size = settings::n_particles; + int64_t count_size = simulation::work_per_rank; + std::vector wi = simulation::work_index; std::vector src_bank = simulation::source_bank; + if (surf_src_bank) { + + // Taken from calculate_work + int64_t min_work = dims_size / mpi::n_procs; + int64_t remainder = dims_size % mpi::n_procs; + int64_t i_bank = 0; + wi.clear(); + wi.resize(mpi::n_procs + 1); + wi[0] = 0; + for (int i = 0; i < mpi::n_procs; ++i) { + int64_t work_i = i < remainder ? min_work +1 : min_work; + if (mpi::rank == i) count_size = work_i; + i_bank += work_i; + wi[i + 1] = i_bank; + } + + dims_size = settings::max_surf_banks; src_bank.clear(); src_bank.assign(simulation::surf_src_bank.data(), simulation::surf_src_bank.data() @@ -576,17 +596,17 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef PHDF5 // Set size of total dataspace for all procs and rank - hsize_t dims[] {static_cast(settings::n_particles)}; + hsize_t dims[] {static_cast(dims_size)}; hid_t dspace = H5Screate_simple(1, dims, nullptr); hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); // Create another data space but for each proc individually - hsize_t count[] {static_cast(simulation::work_per_rank)}; + hsize_t count[] {static_cast(count_size)}; hid_t memspace = H5Screate_simple(1, count, nullptr); // Select hyperslab for this dataspace - hsize_t start[] {static_cast(simulation::work_index[mpi::rank])}; + hsize_t start[] {static_cast(wi[mpi::rank])}; H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Set up the property list for parallel writing @@ -606,7 +626,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) if (mpi::master) { // Create dataset big enough to hold all source sites - hsize_t dims[] {static_cast(settings::n_particles)}; + hsize_t dims[] {static_cast(dims_size)}; hid_t dspace = H5Screate_simple(1, dims, nullptr); hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -614,13 +634,12 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Save source bank sites since the souce_bank array is overwritten below #ifdef OPENMC_MPI std::vector temp_source {src_bank.begin(), - src_bank.begin() + simulation::work_per_rank}; + src_bank.begin() + count_size}; #endif for (int i = 0; i < mpi::n_procs; ++i) { // Create memory space - hsize_t count[] {static_cast(simulation::work_index[i+1] - - simulation::work_index[i])}; + hsize_t count[] {static_cast(wi[i+1] - wi[i])}; hid_t memspace = H5Screate_simple(1, count, nullptr); #ifdef OPENMC_MPI @@ -632,7 +651,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Select hyperslab for this dataspace dspace = H5Dget_space(dset); - hsize_t start[] {static_cast(simulation::work_index[i])}; + hsize_t start[] {static_cast(wi[i])}; H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab From 5d9655256b408855124c8ef95092298b74bea29b Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 22 Jul 2020 04:54:35 -0500 Subject: [PATCH 024/103] Add new variables and functions to query global surface source bank size and index --- include/openmc/simulation.h | 6 ++++++ src/simulation.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 32e2c6730..8c4f044ce 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -45,6 +45,9 @@ extern const RegularMesh* ufs_mesh; extern std::vector k_generation; extern std::vector work_index; +extern int64_t total_surf_banks; //!< Total number of surface source banks +extern std::vector surf_src_index; + } // namespace simulation //============================================================================== @@ -60,6 +63,9 @@ void calculate_work(); //! Initialize nuclear data before a simulation void initialize_data(); +//! Get the total number of surface source banks and populate surf_src_index +void query_surf_src_size(); + //! Initialize a batch void initialize_batch(); diff --git a/src/simulation.cpp b/src/simulation.cpp index e8dc30fcc..2ff136527 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -270,6 +270,8 @@ const RegularMesh* ufs_mesh {nullptr}; std::vector k_generation; std::vector work_index; +int64_t total_surf_banks; +std::vector surf_src_index; } // namespace simulation @@ -385,6 +387,9 @@ void finalize_batch() // Write out surface source if requested. if (settings::surface_source && simulation::current_batch == settings::n_batches) { + + query_surf_src_size(); + auto filename = settings::path_output + "surface_source.h5"; write_source_point(filename.c_str(), true); //!! } @@ -630,6 +635,27 @@ void initialize_data() data::energy_min[neutron]) / settings::n_log_bins; } +void query_surf_src_size() +{ + int64_t i_bank = 0; + simulation::surf_src_index.resize(mpi::n_procs + 1); + simulation::surf_src_index[0] = 0; + for (int i = 0; i < mpi::n_procs; ++i) { + int64_t work_i = 0; + + // Set number of particles + if (mpi::rank == i) work_i = simulation::surf_src_bank.size(); +#ifdef OPENMC_MPI + MPI_Reduce(&work_i, &simulation::total_surf_banks, 1, MPI_INT, + MPI_SUM, 0, mpi::intracomm); +#endif + + // Set index into source bank for rank i + i_bank += work_i; + simulation::surf_src_index[i + 1] = i_bank; + } +} + #ifdef OPENMC_MPI void broadcast_results() { // Broadcast tally results so that each process has access to results From 35fff1ca6270a03f4ce2501e253ada0665a67cfa Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 22 Jul 2020 04:55:27 -0500 Subject: [PATCH 025/103] Corresonding revisions on write_source_point --- src/state_point.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 77e981e0f..14a61d81d 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -572,22 +572,12 @@ write_source_bank(hid_t group_id, bool surf_src_bank) std::vector src_bank = simulation::source_bank; if (surf_src_bank) { + dims_size = simulation::total_surf_banks; + count_size = simulation::surf_src_bank.size(); - // Taken from calculate_work - int64_t min_work = dims_size / mpi::n_procs; - int64_t remainder = dims_size % mpi::n_procs; - int64_t i_bank = 0; wi.clear(); - wi.resize(mpi::n_procs + 1); - wi[0] = 0; - for (int i = 0; i < mpi::n_procs; ++i) { - int64_t work_i = i < remainder ? min_work +1 : min_work; - if (mpi::rank == i) count_size = work_i; - i_bank += work_i; - wi[i + 1] = i_bank; - } + wi = simulation::surf_src_index; - dims_size = settings::max_surf_banks; src_bank.clear(); src_bank.assign(simulation::surf_src_bank.data(), simulation::surf_src_bank.data() @@ -670,7 +660,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #endif } else { #ifdef OPENMC_MPI - MPI_Send(src_bank.data(), simulation::work_per_rank, mpi::bank, + MPI_Send(src_bank.data(), count_size, mpi::bank, 0, mpi::rank, mpi::intracomm); #endif } From 9fd222f4839628f81bd53dcc76fa56d73eeeb06a Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 28 Jul 2020 13:31:12 -0500 Subject: [PATCH 026/103] Revise query_surf_src_size --- src/simulation.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 2ff136527..a58dcb535 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -270,7 +270,7 @@ const RegularMesh* ufs_mesh {nullptr}; std::vector k_generation; std::vector work_index; -int64_t total_surf_banks; +int64_t total_surf_banks {0}; std::vector surf_src_index; } // namespace simulation @@ -637,23 +637,34 @@ void initialize_data() void query_surf_src_size() { - int64_t i_bank = 0; - simulation::surf_src_index.resize(mpi::n_procs + 1); - simulation::surf_src_index[0] = 0; - for (int i = 0; i < mpi::n_procs; ++i) { - int64_t work_i = 0; + int64_t total; + if (mpi::master) { + simulation::surf_src_index.resize(mpi::n_procs + 1); + simulation::surf_src_index[0] = 0; + } - // Set number of particles - if (mpi::rank == i) work_i = simulation::surf_src_bank.size(); #ifdef OPENMC_MPI - MPI_Reduce(&work_i, &simulation::total_surf_banks, 1, MPI_INT, - MPI_SUM, 0, mpi::intracomm); + std::vector bank_size; + bank_size.resize(mpi::n_procs); + + int64_t size = simulation::surf_src_bank.size(); + MPI_Gather(&size, 1, MPI_INT64_T, + bank_size.data(), 1, MPI_INT64_T, + 0, mpi::intracomm); + + if (mpi::master) { + for (int i = 1; i < mpi::n_procs + 1; ++i) { + simulation::surf_src_index[i] = simulation::surf_src_index[i - 1] + bank_size[i - 1]; + } + total = simulation::surf_src_index[mpi::n_procs]; + } +#else + total = simulation::surf_src_bank.size(); + simulation::surf_src_index[mpi::n_procs] = total; #endif - // Set index into source bank for rank i - i_bank += work_i; - simulation::surf_src_index[i + 1] = i_bank; - } + simulation::total_surf_banks = total; + } #ifdef OPENMC_MPI From 5091418d717fc18e2b5e716c9d62ac614d838459 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 29 Jul 2020 11:33:27 -0500 Subject: [PATCH 027/103] Add a new variable to store maximum bank size --- include/openmc/simulation.h | 1 + src/simulation.cpp | 5 +++++ src/state_point.cpp | 21 ++++++++------------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 8c4f044ce..9422590cf 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -46,6 +46,7 @@ extern std::vector k_generation; extern std::vector work_index; extern int64_t total_surf_banks; //!< Total number of surface source banks +extern int64_t max_bank_size; //!< Maximum bank size for MPI extern std::vector surf_src_index; } // namespace simulation diff --git a/src/simulation.cpp b/src/simulation.cpp index a58dcb535..f56a543bc 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -271,6 +271,7 @@ std::vector k_generation; std::vector work_index; int64_t total_surf_banks {0}; +int64_t max_bank_size {0}; std::vector surf_src_index; } // namespace simulation @@ -557,6 +558,9 @@ void calculate_work() // Number of particles for rank i int64_t work_i = i < remainder ? min_work + 1 : min_work; + // Set maximum bank size + if (mpi::master) simulation::max_bank_size = work_i; + // Set number of particles if (mpi::rank == i) simulation::work_per_rank = work_i; @@ -656,6 +660,7 @@ void query_surf_src_size() for (int i = 1; i < mpi::n_procs + 1; ++i) { simulation::surf_src_index[i] = simulation::surf_src_index[i - 1] + bank_size[i - 1]; } + simulation::max_bank_size = *std::max_element(bank_size.begin(), bank_size.end()); total = simulation::surf_src_index[mpi::n_procs]; } #else diff --git a/src/state_point.cpp b/src/state_point.cpp index 14a61d81d..62058423e 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -580,8 +580,8 @@ write_source_bank(hid_t group_id, bool surf_src_bank) src_bank.clear(); src_bank.assign(simulation::surf_src_bank.data(), - simulation::surf_src_bank.data() - + simulation::surf_src_bank.size()); + simulation::surf_src_bank.data() + + simulation::surf_src_bank.size()); } #ifdef PHDF5 @@ -621,11 +621,10 @@ write_source_bank(hid_t group_id, bool surf_src_bank) hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - // Save source bank sites since the souce_bank array is overwritten below -#ifdef OPENMC_MPI - std::vector temp_source {src_bank.begin(), - src_bank.begin() + count_size}; -#endif + // Set new bank sites to avoid the src_bank being overwritten on MPI_Recv + std::vector src_to_save; + src_to_save.reserve(simulation::max_bank_size); + std::copy(src_bank.begin(), src_bank.end(), src_to_save.begin()); for (int i = 0; i < mpi::n_procs; ++i) { // Create memory space @@ -635,7 +634,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Receive source sites from other processes if (i > 0) - MPI_Recv(src_bank.data(), count[0], mpi::bank, i, i, + MPI_Recv(src_to_save.data(), count[0], mpi::bank, i, i, mpi::intracomm, MPI_STATUS_IGNORE); #endif @@ -645,7 +644,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab - H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, src_bank.data()); + H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, src_to_save.data()); H5Sclose(memspace); H5Sclose(dspace); @@ -654,10 +653,6 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Close all ids H5Dclose(dset); -#ifdef OPENMC_MPI - // Restore state of source bank - std::copy(temp_source.begin(), temp_source.end(), src_bank.begin()); -#endif } else { #ifdef OPENMC_MPI MPI_Send(src_bank.data(), count_size, mpi::bank, From bdcfff0f0c905d044d3ac6d3aa5d7023d70fd1e5 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 29 Jul 2020 12:37:22 -0500 Subject: [PATCH 028/103] Remove temporary functions specific to surface source --- include/openmc/state_point.h | 2 -- src/state_point.cpp | 58 ------------------------------------ 2 files changed, 60 deletions(-) diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index beb67daa7..1d7254af8 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -14,8 +14,6 @@ namespace openmc { void load_state_point(); void write_source_point(const char* filename, bool surf_src_bank); void write_source_bank(hid_t group_id, bool surf_src_bank); -void write_surf_src_point(const char* filename); -void write_surf_src_bank(hid_t group_id); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); void write_tally_results_nr(hid_t file_id); void restart_set_keff(); diff --git a/src/state_point.cpp b/src/state_point.cpp index 62058423e..9740220a8 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -665,64 +665,6 @@ write_source_bank(hid_t group_id, bool surf_src_bank) } -void -write_surf_src_point(const char* filename) -{ - std::string filename_; - filename_ = filename; - - hid_t file_id; - file_id = file_open(filename_, 'w', true); - write_attribute(file_id, "filetype", "source"); - - write_surf_src_bank(file_id); - - file_close(file_id); -} - - -void -write_surf_src_bank(hid_t group_id) -{ - hid_t banktype = h5banktype(); - - if (mpi::master) { - // Create dataset big enough to hold all source sites - hsize_t dims[] {static_cast(settings::n_particles)*2}; // 2 being hard-coded number of surfaces. - hid_t dspace = H5Screate_simple(1, dims, nullptr); - hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for (int i = 0; i < mpi::n_procs; ++i) { - - // Create memory space - hsize_t count[] {static_cast(simulation::work_index[i+1] - - simulation::work_index[i])*2}; // 2 being hard-coded number of surfaces. - hid_t memspace = H5Screate_simple(1, count, nullptr); - - // Select hyperslab for this dataspace - dspace = H5Dget_space(dset); - hsize_t start[] {static_cast(simulation::work_index[i])}; - H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); - - // Write data to hyperslab - H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, - simulation::surf_src_bank.data()); - - H5Sclose(memspace); - H5Sclose(dspace); - } - - // Close all ids - H5Dclose(dset); - - } else { - } - - H5Tclose(banktype); -} - - void read_source_bank(hid_t group_id, std::vector& sites, bool distribute) { hid_t banktype = h5banktype(); From 09863806df4563d5e55bb2fe3374e611cbe0051f Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 29 Jul 2020 16:29:45 -0500 Subject: [PATCH 029/103] Add comments and minor changes --- include/openmc/simulation.h | 8 ++--- src/simulation.cpp | 72 ++++++++++++++++++++----------------- src/state_point.cpp | 4 +++ 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 9422590cf..bd10c96c7 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -46,7 +46,7 @@ extern std::vector k_generation; extern std::vector work_index; extern int64_t total_surf_banks; //!< Total number of surface source banks -extern int64_t max_bank_size; //!< Maximum bank size for MPI +extern int64_t max_bank_size; //!< Maximum bank size from a process extern std::vector surf_src_index; } // namespace simulation @@ -61,12 +61,12 @@ void allocate_banks(); //! Determine number of particles to transport per process void calculate_work(); +//! Determine number of surface source banks per process and their sum +void query_surf_src_size(); + //! Initialize nuclear data before a simulation void initialize_data(); -//! Get the total number of surface source banks and populate surf_src_index -void query_surf_src_size(); - //! Initialize a batch void initialize_batch(); diff --git a/src/simulation.cpp b/src/simulation.cpp index f56a543bc..b71de773b 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -570,6 +570,45 @@ void calculate_work() } } +void query_surf_src_size() +{ + int64_t total; + if (mpi::master) { + simulation::surf_src_index.resize(mpi::n_procs + 1); + simulation::surf_src_index[0] = 0; + } + +#ifdef OPENMC_MPI + std::vector bank_size; + bank_size.resize(mpi::n_procs); + + // Collect the number of surface source banks from all processes + int64_t size = simulation::surf_src_bank.size(); + MPI_Gather(&size, 1, MPI_INT64_T, + bank_size.data(), 1, MPI_INT64_T, + 0, mpi::intracomm); + + if (mpi::master) { + // Populate the surf_src_index with cumulative sum of the number of + // surface source banks per process + for (int i = 1; i < mpi::n_procs + 1; ++i) { + simulation::surf_src_index[i] = \ + simulation::surf_src_index[i - 1] + bank_size[i - 1]; + } + // Set maximum bank size + simulation::max_bank_size = *std::max_element(bank_size.begin(), + bank_size.end()); + total = simulation::surf_src_index[mpi::n_procs]; + } +#else + total = simulation::surf_src_bank.size(); + simulation::surf_src_index[mpi::n_procs] = total; +#endif + // Set total number of surface source banks + simulation::total_surf_banks = total; + +} + void initialize_data() { // Determine minimum/maximum energy for incident neutron/photon data @@ -639,39 +678,6 @@ void initialize_data() data::energy_min[neutron]) / settings::n_log_bins; } -void query_surf_src_size() -{ - int64_t total; - if (mpi::master) { - simulation::surf_src_index.resize(mpi::n_procs + 1); - simulation::surf_src_index[0] = 0; - } - -#ifdef OPENMC_MPI - std::vector bank_size; - bank_size.resize(mpi::n_procs); - - int64_t size = simulation::surf_src_bank.size(); - MPI_Gather(&size, 1, MPI_INT64_T, - bank_size.data(), 1, MPI_INT64_T, - 0, mpi::intracomm); - - if (mpi::master) { - for (int i = 1; i < mpi::n_procs + 1; ++i) { - simulation::surf_src_index[i] = simulation::surf_src_index[i - 1] + bank_size[i - 1]; - } - simulation::max_bank_size = *std::max_element(bank_size.begin(), bank_size.end()); - total = simulation::surf_src_index[mpi::n_procs]; - } -#else - total = simulation::surf_src_bank.size(); - simulation::surf_src_index[mpi::n_procs] = total; -#endif - - simulation::total_surf_banks = total; - -} - #ifdef OPENMC_MPI void broadcast_results() { // Broadcast tally results so that each process has access to results diff --git a/src/state_point.cpp b/src/state_point.cpp index 9740220a8..735601b55 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -566,11 +566,15 @@ write_source_bank(hid_t group_id, bool surf_src_bank) { hid_t banktype = h5banktype(); + // Set total and individual process dataspace sizes for source bank int64_t dims_size = settings::n_particles; int64_t count_size = simulation::work_per_rank; + + // Set vectors for source bank and starting bank index of each process std::vector wi = simulation::work_index; std::vector src_bank = simulation::source_bank; + // Reset dataspace sizes and vectors for surface source bank if (surf_src_bank) { dims_size = simulation::total_surf_banks; count_size = simulation::surf_src_bank.size(); From 10e3e83f9042694a50ad92a14ed42b49772c0d0c Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 29 Jul 2020 17:25:28 -0500 Subject: [PATCH 030/103] Set maximum bank size inside write_source_bank --- src/simulation.cpp | 5 ----- src/state_point.cpp | 17 +++++++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index b71de773b..2fec3efb3 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -389,8 +389,6 @@ void finalize_batch() // Write out surface source if requested. if (settings::surface_source && simulation::current_batch == settings::n_batches) { - query_surf_src_size(); - auto filename = settings::path_output + "surface_source.h5"; write_source_point(filename.c_str(), true); //!! } @@ -558,9 +556,6 @@ void calculate_work() // Number of particles for rank i int64_t work_i = i < remainder ? min_work + 1 : min_work; - // Set maximum bank size - if (mpi::master) simulation::max_bank_size = work_i; - // Set number of particles if (mpi::rank == i) simulation::work_per_rank = work_i; diff --git a/src/state_point.cpp b/src/state_point.cpp index 735601b55..278576ea0 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -570,17 +570,22 @@ write_source_bank(hid_t group_id, bool surf_src_bank) int64_t dims_size = settings::n_particles; int64_t count_size = simulation::work_per_rank; + // Set maximum bank size + simulation::max_bank_size = simulation::work_per_rank; + // Set vectors for source bank and starting bank index of each process - std::vector wi = simulation::work_index; + std::vector bank_index = simulation::work_index; std::vector src_bank = simulation::source_bank; // Reset dataspace sizes and vectors for surface source bank if (surf_src_bank) { + query_surf_src_size(); + dims_size = simulation::total_surf_banks; count_size = simulation::surf_src_bank.size(); - wi.clear(); - wi = simulation::surf_src_index; + bank_index.clear(); + bank_index = simulation::surf_src_index; src_bank.clear(); src_bank.assign(simulation::surf_src_bank.data(), @@ -600,7 +605,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) hid_t memspace = H5Screate_simple(1, count, nullptr); // Select hyperslab for this dataspace - hsize_t start[] {static_cast(wi[mpi::rank])}; + hsize_t start[] {static_cast(bank_index[mpi::rank])}; H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Set up the property list for parallel writing @@ -632,7 +637,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) for (int i = 0; i < mpi::n_procs; ++i) { // Create memory space - hsize_t count[] {static_cast(wi[i+1] - wi[i])}; + hsize_t count[] {static_cast(bank_index[i+1] - bank_index[i])}; hid_t memspace = H5Screate_simple(1, count, nullptr); #ifdef OPENMC_MPI @@ -644,7 +649,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Select hyperslab for this dataspace dspace = H5Dget_space(dset); - hsize_t start[] {static_cast(wi[i])}; + hsize_t start[] {static_cast(bank_index[i])}; H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab From b5f6dacb7dc1dfff7b95d382f7db114a8d3e4d62 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 5 Aug 2020 11:39:22 -0500 Subject: [PATCH 031/103] Add setting parameter for surface source file reading --- include/openmc/settings.h | 1 + src/settings.cpp | 1 + src/source.cpp | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/include/openmc/settings.h b/include/openmc/settings.h index c7d14b4e7..1fc68a6ea 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -46,6 +46,7 @@ extern bool source_latest; //!< write latest source at each batch? extern bool source_separate; //!< write source to separate file? extern bool source_write; //!< write source in HDF5 files? extern bool surface_source; //!< write surface source file? +extern bool surf_src_read; //!< read surface source file? extern bool survival_biasing; //!< use survival biasing? extern bool temperature_multipole; //!< use multipole data? extern "C" bool trigger_on; //!< tally triggers enabled? diff --git a/src/settings.cpp b/src/settings.cpp index 11effc922..516dfaaea 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -61,6 +61,7 @@ bool source_latest {false}; bool source_separate {false}; bool source_write {true}; bool surface_source {false}; +bool surf_src_read {false}; bool survival_biasing {false}; bool temperature_multipole {false}; bool trigger_on {false}; diff --git a/src/source.cpp b/src/source.cpp index 0efaf52ba..cdf2bac2d 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -72,6 +72,26 @@ IndependentSource::IndependentSource(pugi::xml_node node) // Check for external source file if (check_for_node(node, "file")) { + // Copy path of source file + settings::path_source = get_node_value(node, "file", false, true); + + // Check if source file exists + if (!file_exists(settings::path_source)) { + fatal_error(fmt::format("Source file '{}' does not exist.", + settings::path_source)); + } + + // Check if it is a surface source file. + if (check_for_node(node, "surf_src_file")) { + settings::surf_src_read = get_node_value_bool(node, "surf_src_file"); + } + + } else if (check_for_node(node, "library")) { + settings::path_source_library = get_node_value(node, "library", false, true); + if (!file_exists(settings::path_source_library)) { + fatal_error(fmt::format("Source library '{}' does not exist.", + settings::path_source_library)); + } } else { From 03a4c1dc56544cb796b8c38a553ec63321127bd5 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 5 Aug 2020 11:47:54 -0500 Subject: [PATCH 032/103] Initialize source when surface source file is provided --- src/simulation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 2fec3efb3..3bc22f22f 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -114,7 +114,8 @@ int openmc_simulation_init() write_message("Resuming simulation...", 6); } else { // Only initialize primary source bank for eigenvalue simulations - if (settings::run_mode == RunMode::EIGENVALUE) { + // or when a surface source file is provided. + if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) { initialize_source(); } } From 82606011c007b7366a48f964da5d77639affc1cc Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 11 Aug 2020 20:19:43 -0500 Subject: [PATCH 033/103] Properly trigger surface source reading --- src/simulation.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 3bc22f22f..0269cc0cb 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -289,6 +289,9 @@ void allocate_banks() // Allocate fission bank init_fission_bank(3*simulation::work_per_rank); + } else if (settings::surf_src_read) { + // Allocate source bank for reading surface source file. + simulation::source_bank.resize(simulation::work_per_rank); } if (settings::surface_source) { @@ -457,7 +460,10 @@ void finalize_generation() void initialize_history(Particle& p, int64_t index_source) { // set defaults - if (settings::run_mode == RunMode::FIXED_SOURCE) { + if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) { + // set defaults for eigenvalue simulations from primary bank + p.from_source(&simulation::source_bank[index_source - 1]); + } else if (settings::run_mode == RunMode::FIXED_SOURCE) { // initialize random number seed int64_t id = (simulation::total_gen + overall_generation() - 1)*settings::n_particles + simulation::work_index[mpi::rank] + index_source; @@ -465,9 +471,6 @@ void initialize_history(Particle& p, int64_t index_source) // sample from external source distribution or custom library then set auto site = sample_external_source(&seed); p.from_source(&site); - } else if (settings::run_mode == RunMode::EIGENVALUE) { - // set defaults for eigenvalue simulations from primary bank - p.from_source(&simulation::source_bank[index_source - 1]); } p.current_work_ = index_source; From f388ac2e1e121893e990b759ae1837b28810df2b Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 11 Aug 2020 21:13:09 -0500 Subject: [PATCH 034/103] Rename variables for better readability --- include/openmc/settings.h | 4 ++-- src/settings.cpp | 11 +++++------ src/simulation.cpp | 4 ++-- src/source.cpp | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 1fc68a6ea..a606d69af 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -45,7 +45,7 @@ extern "C" bool run_CE; //!< run with continuous-energy data? extern bool source_latest; //!< write latest source at each batch? extern bool source_separate; //!< write source to separate file? extern bool source_write; //!< write source in HDF5 files? -extern bool surface_source; //!< write surface source file? +extern bool surf_src_write; //!< write surface source file? extern bool surf_src_read; //!< read surface source file? extern bool survival_biasing; //!< use survival biasing? extern bool temperature_multipole; //!< use multipole data? @@ -87,7 +87,7 @@ extern std::vector res_scat_nuclides; //!< Nuclides using res. ups extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set statepoint_batch; //!< Batches when state should be written -extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces +extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces per process extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures extern double temperature_default; //!< Default T in [K] diff --git a/src/settings.cpp b/src/settings.cpp index 516dfaaea..503aacfe8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -60,7 +60,7 @@ bool run_CE {true}; bool source_latest {false}; bool source_separate {false}; bool source_write {true}; -bool surface_source {false}; +bool surf_src_write {false}; bool surf_src_read {false}; bool survival_biasing {false}; bool temperature_multipole {false}; @@ -626,15 +626,14 @@ void read_settings_xml() } // Check if the user has specified to write surface source. - if (check_for_node(root, "surface_source")) { - surface_source = true; + if (check_for_node(root, "surf_src_write")) { + surf_src_write = true; // Get surface source node - xml_node node_ss = root.child("surface_source"); + xml_node node_ss = root.child("surf_src_write"); // Get maximum number of particles to be banked per surface. if (check_for_node(node_ss, "max_surf_banks")) { - max_surf_banks = std::stoi(get_node_value(node_ss, - "max_surf_banks")); + max_surf_banks = std::stoi(get_node_value(node_ss, "max_surf_banks")); } } diff --git a/src/simulation.cpp b/src/simulation.cpp index 0269cc0cb..3801a0263 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -294,7 +294,7 @@ void allocate_banks() simulation::source_bank.resize(simulation::work_per_rank); } - if (settings::surface_source) { + if (settings::surf_src_write) { // Allocate surface source bank simulation::surf_src_bank.reserve(settings::max_surf_banks); } @@ -391,7 +391,7 @@ void finalize_batch() } // Write out surface source if requested. - if (settings::surface_source && simulation::current_batch == settings::n_batches) { + if (settings::surf_src_write && simulation::current_batch == settings::n_batches) { auto filename = settings::path_output + "surface_source.h5"; write_source_point(filename.c_str(), true); //!! diff --git a/src/source.cpp b/src/source.cpp index cdf2bac2d..0ecf259a7 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -82,8 +82,8 @@ IndependentSource::IndependentSource(pugi::xml_node node) } // Check if it is a surface source file. - if (check_for_node(node, "surf_src_file")) { - settings::surf_src_read = get_node_value_bool(node, "surf_src_file"); + if (check_for_node(node, "surf_src_read")) { + settings::surf_src_read = get_node_value_bool(node, "surf_src_read"); } } else if (check_for_node(node, "library")) { From 065d65d3a569d8fe1e245e0fa7c1e94a992906f3 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 11 Aug 2020 23:03:47 -0500 Subject: [PATCH 035/103] Cleanup --- src/particle.cpp | 4 ++-- src/simulation.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/particle.cpp b/src/particle.cpp index b6e936b62..26caea2f3 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -422,8 +422,8 @@ Particle::cross_surface() site.delayed_group = this->delayed_group_; site.surf_num = surf->id_; site.particle = this->type_; - // site.parent_id = this->id_; - // site.progeny_id = this->n_progeny_; + site.parent_id = this->id_; + site.progeny_id = this->n_progeny_; int64_t idx = simulation::surf_src_bank.thread_safe_append(site); } diff --git a/src/simulation.cpp b/src/simulation.cpp index 3801a0263..f950fa71c 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -461,7 +461,7 @@ void initialize_history(Particle& p, int64_t index_source) { // set defaults if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) { - // set defaults for eigenvalue simulations from primary bank + // set defaults for eigenvalue simulations and surface source reading from primary bank p.from_source(&simulation::source_bank[index_source - 1]); } else if (settings::run_mode == RunMode::FIXED_SOURCE) { // initialize random number seed From 073f5704b352f374bac044e644f7f0df2177b77a Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 19 Aug 2020 17:36:37 -0500 Subject: [PATCH 036/103] Update src/simulation.cpp Co-authored-by: Paul Romano --- src/simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index f950fa71c..bcb48ab54 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -394,7 +394,7 @@ void finalize_batch() if (settings::surf_src_write && simulation::current_batch == settings::n_batches) { auto filename = settings::path_output + "surface_source.h5"; - write_source_point(filename.c_str(), true); //!! + write_source_point(filename.c_str(), true); } } From dd82da692a96575a385858ab72d927ea9e354bbf Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 19 Aug 2020 17:40:56 -0500 Subject: [PATCH 037/103] Move query_surf_src_size from simulation.cpp to state_point.cpp --- include/openmc/simulation.h | 3 --- include/openmc/state_point.h | 1 + src/simulation.cpp | 39 ------------------------------------ src/state_point.cpp | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index bd10c96c7..7a206284f 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -61,9 +61,6 @@ void allocate_banks(); //! Determine number of particles to transport per process void calculate_work(); -//! Determine number of surface source banks per process and their sum -void query_surf_src_size(); - //! Initialize nuclear data before a simulation void initialize_data(); diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index 1d7254af8..255c7ff1d 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,6 +12,7 @@ namespace openmc { void load_state_point(); +void query_surf_src_size(); void write_source_point(const char* filename, bool surf_src_bank); void write_source_bank(hid_t group_id, bool surf_src_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); diff --git a/src/simulation.cpp b/src/simulation.cpp index bcb48ab54..ae0ad319b 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -569,45 +569,6 @@ void calculate_work() } } -void query_surf_src_size() -{ - int64_t total; - if (mpi::master) { - simulation::surf_src_index.resize(mpi::n_procs + 1); - simulation::surf_src_index[0] = 0; - } - -#ifdef OPENMC_MPI - std::vector bank_size; - bank_size.resize(mpi::n_procs); - - // Collect the number of surface source banks from all processes - int64_t size = simulation::surf_src_bank.size(); - MPI_Gather(&size, 1, MPI_INT64_T, - bank_size.data(), 1, MPI_INT64_T, - 0, mpi::intracomm); - - if (mpi::master) { - // Populate the surf_src_index with cumulative sum of the number of - // surface source banks per process - for (int i = 1; i < mpi::n_procs + 1; ++i) { - simulation::surf_src_index[i] = \ - simulation::surf_src_index[i - 1] + bank_size[i - 1]; - } - // Set maximum bank size - simulation::max_bank_size = *std::max_element(bank_size.begin(), - bank_size.end()); - total = simulation::surf_src_index[mpi::n_procs]; - } -#else - total = simulation::surf_src_bank.size(); - simulation::surf_src_index[mpi::n_procs] = total; -#endif - // Set total number of surface source banks - simulation::total_surf_banks = total; - -} - void initialize_data() { // Determine minimum/maximum energy for incident neutron/photon data diff --git a/src/state_point.cpp b/src/state_point.cpp index 278576ea0..01660831d 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,6 +525,45 @@ hid_t h5banktype() { return banktype; } +void query_surf_src_size() +{ + int64_t total; + if (mpi::master) { + simulation::surf_src_index.resize(mpi::n_procs + 1); + simulation::surf_src_index[0] = 0; + } + +#ifdef OPENMC_MPI + std::vector bank_size; + bank_size.resize(mpi::n_procs); + + // Collect the number of surface source banks from all processes + int64_t size = simulation::surf_src_bank.size(); + MPI_Gather(&size, 1, MPI_INT64_T, + bank_size.data(), 1, MPI_INT64_T, + 0, mpi::intracomm); + + if (mpi::master) { + // Populate the surf_src_index with cumulative sum of the number of + // surface source banks per process + for (int i = 1; i < mpi::n_procs + 1; ++i) { + simulation::surf_src_index[i] = \ + simulation::surf_src_index[i - 1] + bank_size[i - 1]; + } + // Set maximum bank size + simulation::max_bank_size = *std::max_element(bank_size.begin(), + bank_size.end()); + total = simulation::surf_src_index[mpi::n_procs]; + } +#else + total = simulation::surf_src_bank.size(); + simulation::surf_src_index[mpi::n_procs] = total; +#endif + // Set total number of surface source banks + simulation::total_surf_banks = total; + +} + void write_source_point(const char* filename, bool surf_src_bank) { From 3be475836bd014a63893296ca507d543dd6c2525 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 19 Aug 2020 17:52:41 -0500 Subject: [PATCH 038/103] Switch from surf_num to surf_id --- include/openmc/particle.h | 2 +- src/initialize.cpp | 2 +- src/particle.cpp | 2 +- src/state_point.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 797f7b0e5..e8002cedb 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -172,7 +172,7 @@ public: double E; double wgt; int delayed_group; - int surf_num; + int surf_id; Type particle; int64_t parent_id; int64_t progeny_id; diff --git a/src/initialize.cpp b/src/initialize.cpp index 4f5f525da..6594417de 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -108,7 +108,7 @@ void initialize_mpi(MPI_Comm intracomm) MPI_Get_address(&b.E, &disp[2]); MPI_Get_address(&b.wgt, &disp[3]); MPI_Get_address(&b.delayed_group, &disp[4]); - MPI_Get_address(&b.surf_num, &disp[5]); + MPI_Get_address(&b.surf_id, &disp[5]); MPI_Get_address(&b.particle, &disp[6]); MPI_Get_address(&b.parent_id, &disp[7]); MPI_Get_address(&b.progeny_id, &disp[8]); diff --git a/src/particle.cpp b/src/particle.cpp index 26caea2f3..a1829751a 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -420,7 +420,7 @@ Particle::cross_surface() site.E = this->E_; site.wgt = this->wgt_; site.delayed_group = this->delayed_group_; - site.surf_num = surf->id_; + site.surf_id = surf->id_; site.particle = this->type_; site.parent_id = this->id_; site.progeny_id = this->n_progeny_; diff --git a/src/state_point.cpp b/src/state_point.cpp index 01660831d..16e616018 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -518,7 +518,7 @@ hid_t h5banktype() { H5Tinsert(banktype, "E", HOFFSET(Particle::Bank, E), H5T_NATIVE_DOUBLE); H5Tinsert(banktype, "wgt", HOFFSET(Particle::Bank, wgt), H5T_NATIVE_DOUBLE); H5Tinsert(banktype, "delayed_group", HOFFSET(Particle::Bank, delayed_group), H5T_NATIVE_INT); - H5Tinsert(banktype, "surf_num", HOFFSET(Particle::Bank, surf_num), H5T_NATIVE_INT); + H5Tinsert(banktype, "surf_id", HOFFSET(Particle::Bank, surf_id), H5T_NATIVE_INT); H5Tinsert(banktype, "particle", HOFFSET(Particle::Bank, particle), H5T_NATIVE_INT); H5Tclose(postype); From 3ab5568ac702878e4dd1040917a03c5bf40b536e Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 19 Aug 2020 19:28:33 -0500 Subject: [PATCH 039/103] Localize variables total_surf_banks and max_bank_size --- include/openmc/simulation.h | 2 -- include/openmc/state_point.h | 2 +- src/simulation.cpp | 2 -- src/state_point.cpp | 27 +++++++++++++++------------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 7a206284f..63fb6e5fd 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -45,8 +45,6 @@ extern const RegularMesh* ufs_mesh; extern std::vector k_generation; extern std::vector work_index; -extern int64_t total_surf_banks; //!< Total number of surface source banks -extern int64_t max_bank_size; //!< Maximum bank size from a process extern std::vector surf_src_index; } // namespace simulation diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index 255c7ff1d..92c5c0f40 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,7 +12,7 @@ namespace openmc { void load_state_point(); -void query_surf_src_size(); +int* query_surf_src_size(); void write_source_point(const char* filename, bool surf_src_bank); void write_source_bank(hid_t group_id, bool surf_src_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); diff --git a/src/simulation.cpp b/src/simulation.cpp index ae0ad319b..82a6e7bd1 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -271,8 +271,6 @@ const RegularMesh* ufs_mesh {nullptr}; std::vector k_generation; std::vector work_index; -int64_t total_surf_banks {0}; -int64_t max_bank_size {0}; std::vector surf_src_index; } // namespace simulation diff --git a/src/state_point.cpp b/src/state_point.cpp index 16e616018..fe750a456 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,8 +525,11 @@ hid_t h5banktype() { return banktype; } -void query_surf_src_size() +int* query_surf_src_size() { + // total_surf_banks, max_bank_size + static int qsize[2] = {0, 0}; + int64_t total; if (mpi::master) { simulation::surf_src_index.resize(mpi::n_procs + 1); @@ -551,17 +554,16 @@ void query_surf_src_size() simulation::surf_src_index[i - 1] + bank_size[i - 1]; } // Set maximum bank size - simulation::max_bank_size = *std::max_element(bank_size.begin(), - bank_size.end()); - total = simulation::surf_src_index[mpi::n_procs]; + qsize[1] = *std::max_element(bank_size.begin(), bank_size.end()); + qsize[0] = simulation::surf_src_index[mpi::n_procs]; } #else - total = simulation::surf_src_bank.size(); - simulation::surf_src_index[mpi::n_procs] = total; + qsize[0] = simulation::surf_src_bank.size(); + simulation::surf_src_index[mpi::n_procs] = simulation::surf_src_bank.size(); + qsize[1] = simulation::work_per_rank; #endif - // Set total number of surface source banks - simulation::total_surf_banks = total; + return qsize; } void @@ -610,7 +612,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) int64_t count_size = simulation::work_per_rank; // Set maximum bank size - simulation::max_bank_size = simulation::work_per_rank; + int64_t max_bank_size = simulation::work_per_rank; // Set vectors for source bank and starting bank index of each process std::vector bank_index = simulation::work_index; @@ -618,9 +620,9 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Reset dataspace sizes and vectors for surface source bank if (surf_src_bank) { - query_surf_src_size(); + int* qsize = query_surf_src_size(); - dims_size = simulation::total_surf_banks; + dims_size = qsize[0]; count_size = simulation::surf_src_bank.size(); bank_index.clear(); @@ -630,6 +632,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) src_bank.assign(simulation::surf_src_bank.data(), simulation::surf_src_bank.data() + simulation::surf_src_bank.size()); + max_bank_size = qsize[1]; } #ifdef PHDF5 @@ -671,7 +674,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Set new bank sites to avoid the src_bank being overwritten on MPI_Recv std::vector src_to_save; - src_to_save.reserve(simulation::max_bank_size); + src_to_save.reserve(max_bank_size); std::copy(src_bank.begin(), src_bank.end(), src_to_save.begin()); for (int i = 0; i < mpi::n_procs; ++i) { From 3059c75eb10e725560bfb63e8bb51b72dbd0921c Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 10 Sep 2020 01:53:15 -0500 Subject: [PATCH 040/103] Remove superfluous clear op --- src/state_point.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index fe750a456..c4f9ed060 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -625,10 +625,8 @@ write_source_bank(hid_t group_id, bool surf_src_bank) dims_size = qsize[0]; count_size = simulation::surf_src_bank.size(); - bank_index.clear(); bank_index = simulation::surf_src_index; - src_bank.clear(); src_bank.assign(simulation::surf_src_bank.data(), simulation::surf_src_bank.data() + simulation::surf_src_bank.size()); From fd6e516a71968fcf074e62a50756abeedf7a2ac6 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 10 Sep 2020 02:08:21 -0500 Subject: [PATCH 041/103] Use pointer instead of full copy for bank_index --- src/state_point.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index c4f9ed060..c6e4c0066 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -615,7 +615,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) int64_t max_bank_size = simulation::work_per_rank; // Set vectors for source bank and starting bank index of each process - std::vector bank_index = simulation::work_index; + std::vector* bank_index = &simulation::work_index; std::vector src_bank = simulation::source_bank; // Reset dataspace sizes and vectors for surface source bank @@ -625,7 +625,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) dims_size = qsize[0]; count_size = simulation::surf_src_bank.size(); - bank_index = simulation::surf_src_index; + bank_index = &simulation::surf_src_index; src_bank.assign(simulation::surf_src_bank.data(), simulation::surf_src_bank.data() @@ -645,7 +645,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) hid_t memspace = H5Screate_simple(1, count, nullptr); // Select hyperslab for this dataspace - hsize_t start[] {static_cast(bank_index[mpi::rank])}; + hsize_t start[] {static_cast((*bank_index)[mpi::rank])}; H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Set up the property list for parallel writing @@ -677,7 +677,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) for (int i = 0; i < mpi::n_procs; ++i) { // Create memory space - hsize_t count[] {static_cast(bank_index[i+1] - bank_index[i])}; + hsize_t count[] {static_cast((*bank_index)[i+1] - (*bank_index)[i])}; hid_t memspace = H5Screate_simple(1, count, nullptr); #ifdef OPENMC_MPI @@ -689,7 +689,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Select hyperslab for this dataspace dspace = H5Dget_space(dset); - hsize_t start[] {static_cast(bank_index[i])}; + hsize_t start[] {static_cast((*bank_index)[i])}; H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab From 32be23eeda155a67d5b8fcbd4b559a1e56a31dd4 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 23 Sep 2020 00:58:31 -0500 Subject: [PATCH 042/103] Add Python API for settings of surface source writing --- openmc/settings.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/openmc/settings.py b/openmc/settings.py index 4825432a8..6be5f242c 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -143,6 +143,11 @@ class Settings: Options for writing state points. Acceptable keys are: :batches: list of batches at which to write source + surf_src_write : dict + Options for writing surface source points. Acceptable keys are: + + :max_surf_banks: Maximum number of particles to be banked on surfaces + per process (int) survival_biasing : bool Indicate whether survival biasing is to be used tabular_legendre : dict @@ -229,6 +234,8 @@ class Settings: self._statepoint = {} self._sourcepoint = {} + self._surf_src_write = {} + self._no_reduce = None self._verbosity = None @@ -356,6 +363,10 @@ class Settings: def statepoint(self): return self._statepoint + @property + def surf_src_write(self): + return self._surf_src_write + @property def no_reduce(self): return self._no_reduce @@ -567,6 +578,19 @@ class Settings: "statepoint options.".format(key)) self._statepoint = statepoint + @surf_src_write.setter + def surf_src_write(self, surf_src_write): + cv.check_type('surface source writing options', surf_src_write, Mapping) + for key, value in surf_src_write.items(): + cv.check_value('surface source writing key', key, + ('max_surf_banks')) + if key == 'max_surf_banks': + cv.check_type('maximum particle banks on surfaces per process', + value, Iterable, Integral) + cv.check_greater_than('maximum particle banks on surfaces per process', + value, 0) + self._surf_src_write = surf_src_write + @confidence_intervals.setter def confidence_intervals(self, confidence_intervals): cv.check_type('confidence interval', confidence_intervals, bool) @@ -889,6 +913,13 @@ class Settings: subelement = ET.SubElement(element, "overwrite_latest") subelement.text = str(self._sourcepoint['overwrite']).lower() + def _create_surf_src_write_subelement(self, root): + if self._surf_src_write: + element = ET.SubElement(root, "surf_src_write") + if 'max_surf_banks' in self._surf_src_write: + subelement = ET.SubElement(element, "max_surf_banks") + subelement.text = str(self._surf_src_write['max_surf_banks']) + def _create_confidence_intervals(self, root): if self._confidence_intervals is not None: element = ET.SubElement(root, "confidence_intervals") @@ -1151,6 +1182,16 @@ class Settings: value = [int(x) for x in value.split()] self.sourcepoint[key] = value + def _surf_src_write_from_xml_element(self, root): + elem = root.find('surf_src_write') + if elem is not None: + for key in ('max_surf_banks'): + value = get_text(elem, key) + if value is not None: + if key in ('max_surf_banks'): + value = int(value) + self.surf_src_write[key] = value + def _confidence_intervals_from_xml_element(self, root): text = get_text(root, 'confidence_intervals') if text is not None: @@ -1349,6 +1390,7 @@ class Settings: self._create_output_subelement(root_element) self._create_statepoint_subelement(root_element) self._create_sourcepoint_subelement(root_element) + self._create_surf_src_write_subelement(root_element) self._create_confidence_intervals(root_element) self._create_electron_treatment_subelement(root_element) self._create_energy_mode_subelement(root_element) @@ -1422,6 +1464,7 @@ class Settings: settings._output_from_xml_element(root) settings._statepoint_from_xml_element(root) settings._sourcepoint_from_xml_element(root) + settings._surf_src_write_from_xml_element(root) settings._confidence_intervals_from_xml_element(root) settings._electron_treatment_from_xml_element(root) settings._energy_mode_from_xml_element(root) From 1264083f1b03b764d15043cf0f62827530e44e3c Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 7 Oct 2020 11:35:15 -0500 Subject: [PATCH 043/103] Switch source writing surface id designation scheme --- include/openmc/settings.h | 1 + src/settings.cpp | 10 ++++++++++ src/surface.cpp | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/openmc/settings.h b/include/openmc/settings.h index a606d69af..d8f785cc1 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -87,6 +87,7 @@ extern std::vector res_scat_nuclides; //!< Nuclides using res. ups extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set statepoint_batch; //!< Batches when state should be written +extern std::unordered_set src_write_surf_id; //!< Surface ids where sources will be written extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces per process extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures diff --git a/src/settings.cpp b/src/settings.cpp index 503aacfe8..a9276ed73 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -100,6 +100,7 @@ std::vector res_scat_nuclides; RunMode run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; +std::unordered_set src_write_surf_id; int64_t max_surf_banks; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; @@ -631,6 +632,14 @@ void read_settings_xml() // Get surface source node xml_node node_ss = root.child("surf_src_write"); + // Determine surface ids at which crossing particles are to be banked. + if (check_for_node(node_ss, "surf_ids")) { + auto temp = get_node_array(node_ss, "surf_ids"); + for (const auto& b : temp) { + src_write_surf_id.insert(b); + } + } + // Get maximum number of particles to be banked per surface. if (check_for_node(node_ss, "max_surf_banks")) { max_surf_banks = std::stoi(get_node_value(node_ss, "max_surf_banks")); @@ -809,6 +818,7 @@ void read_settings_xml() void free_memory_settings() { settings::statepoint_batch.clear(); settings::sourcepoint_batch.clear(); + settings::src_write_surf_id.clear(); settings::res_scat_nuclides.clear(); } diff --git a/src/surface.cpp b/src/surface.cpp index 1e1307eff..9090d60f3 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -8,6 +8,7 @@ #include #include +#include "openmc/container_util.h" #include "openmc/error.h" #include "openmc/dagmc.h" #include "openmc/hdf5_interface.h" @@ -115,6 +116,9 @@ Surface::Surface(pugi::xml_node surf_node) { if (check_for_node(surf_node, "id")) { id_ = std::stoi(get_node_value(surf_node, "id")); + if (contains(settings::src_write_surf_id, id_)) { + surf_src_ = true; + } } else { fatal_error("Must specify id of surface in geometry XML file."); } @@ -143,10 +147,6 @@ Surface::Surface(pugi::xml_node surf_node) } } - if (check_for_node(surf_node, "surf_src")) { - surf_src_ = get_node_value_bool(surf_node, "surf_src"); - } - } bool From fc7ebd1f75f325eb4115e610b19f42813dd46381 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 7 Oct 2020 12:17:31 -0500 Subject: [PATCH 044/103] Revert to temp source scheme --- src/state_point.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index c6e4c0066..90c49667a 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -670,10 +670,11 @@ write_source_bank(hid_t group_id, bool surf_src_bank) hid_t dset = H5Dcreate(group_id, "source_bank", banktype, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - // Set new bank sites to avoid the src_bank being overwritten on MPI_Recv - std::vector src_to_save; - src_to_save.reserve(max_bank_size); - std::copy(src_bank.begin(), src_bank.end(), src_to_save.begin()); + // Save source bank sites since the array is overwritten below +#ifdef OPENMC_MPI + std::vector temp_source {src_bank.begin(), + src_bank.begin() + count_size}; +#endif for (int i = 0; i < mpi::n_procs; ++i) { // Create memory space @@ -683,7 +684,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Receive source sites from other processes if (i > 0) - MPI_Recv(src_to_save.data(), count[0], mpi::bank, i, i, + MPI_Recv(src_bank.data(), count[0], mpi::bank, i, i, mpi::intracomm, MPI_STATUS_IGNORE); #endif @@ -693,7 +694,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab - H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, src_to_save.data()); + H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, src_bank.data()); H5Sclose(memspace); H5Sclose(dspace); @@ -702,6 +703,10 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Close all ids H5Dclose(dset); +#ifdef OPENMC_MPI + // Restore state of source bank + std::copy(temp_source.begin(), temp_source.end(), src_bank.begin()); +#endif } else { #ifdef OPENMC_MPI MPI_Send(src_bank.data(), count_size, mpi::bank, From 5760023d82fbd2b0adb71fc25c20609a43e82ee6 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 7 Oct 2020 19:15:17 -0500 Subject: [PATCH 045/103] Add surf_ids for surf_src_write to Python API --- openmc/settings.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/openmc/settings.py b/openmc/settings.py index 6be5f242c..1fa16372c 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -146,6 +146,8 @@ class Settings: surf_src_write : dict Options for writing surface source points. Acceptable keys are: + :surf_ids: List of surface ids at which crossing particles are to be + banked (int) :max_surf_banks: Maximum number of particles to be banked on surfaces per process (int) survival_biasing : bool @@ -583,8 +585,14 @@ class Settings: cv.check_type('surface source writing options', surf_src_write, Mapping) for key, value in surf_src_write.items(): cv.check_value('surface source writing key', key, - ('max_surf_banks')) - if key == 'max_surf_banks': + ('surf_ids', 'max_surf_banks')) + if key == 'surf_ids': + cv.check_type('surface ids for source banking', value, + Iterable, Integral) + for surf_id in value: + cv.check_greater_than('surface id for source banking', + surf_id, 0) + elif key == 'max_surf_banks': cv.check_type('maximum particle banks on surfaces per process', value, Iterable, Integral) cv.check_greater_than('maximum particle banks on surfaces per process', @@ -916,6 +924,10 @@ class Settings: def _create_surf_src_write_subelement(self, root): if self._surf_src_write: element = ET.SubElement(root, "surf_src_write") + if 'surf_ids' in self._surf_src_write: + subelement = ET.SubElement(element, "surf_ids") + subelement.text = ' '.join( + str(x) for x in self._surf_src_write['surf_ids']) if 'max_surf_banks' in self._surf_src_write: subelement = ET.SubElement(element, "max_surf_banks") subelement.text = str(self._surf_src_write['max_surf_banks']) @@ -1185,10 +1197,12 @@ class Settings: def _surf_src_write_from_xml_element(self, root): elem = root.find('surf_src_write') if elem is not None: - for key in ('max_surf_banks'): + for key in ('surf_ids', 'max_surf_banks'): value = get_text(elem, key) if value is not None: - if key in ('max_surf_banks'): + if key == 'surf_ids': + value = [int(x) for x in value.split()] + elif key in ('max_surf_banks'): value = int(value) self.surf_src_write[key] = value From c4b39cdb6ce0c358d9a3f7f5a0f27b899ba992bf Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 8 Oct 2020 00:05:46 -0500 Subject: [PATCH 046/103] Fix minor error --- openmc/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/settings.py b/openmc/settings.py index 1fa16372c..2c3aadc9c 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -594,7 +594,7 @@ class Settings: surf_id, 0) elif key == 'max_surf_banks': cv.check_type('maximum particle banks on surfaces per process', - value, Iterable, Integral) + value, Integral) cv.check_greater_than('maximum particle banks on surfaces per process', value, 0) self._surf_src_write = surf_src_write From f2bdae918cb5b4f3bb212f3ef7d01df0ff12f547 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 9 Oct 2020 00:46:15 -0500 Subject: [PATCH 047/103] Change the way surface source reading flag is given --- src/settings.cpp | 19 +++++++++++++++++++ src/source.cpp | 5 ----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index a9276ed73..0c1f3c0fa 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -646,6 +646,25 @@ void read_settings_xml() } } + // Check if the user has specified to read surface source. + if (check_for_node(root, "surf_src_read")) { + surf_src_read = true; + // Get surface source read node + xml_node node_ss = root.child("surf_src_read"); + + settings::path_source = "surface_source.h5"; + // Check if the user has specified different file for surface source reading + if (check_for_node(node_ss, "file")) { + settings::path_source = get_node_value(node_ss, "file", false, true); + } + + // Check if surface source file exists + if (!file_exists(settings::path_source)) { + fatal_error(fmt::format("Source file '{}' does not exist.", + settings::path_source)); + } + } + // If source is not seperate and is to be written out in the statepoint file, // make sure that the sourcepoint batch numbers are contained in the // statepoint list diff --git a/src/source.cpp b/src/source.cpp index 0ecf259a7..97a722acf 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -81,11 +81,6 @@ IndependentSource::IndependentSource(pugi::xml_node node) settings::path_source)); } - // Check if it is a surface source file. - if (check_for_node(node, "surf_src_read")) { - settings::surf_src_read = get_node_value_bool(node, "surf_src_read"); - } - } else if (check_for_node(node, "library")) { settings::path_source_library = get_node_value(node, "library", false, true); if (!file_exists(settings::path_source_library)) { From 5fe1ed2919919e926bc43b98982556b831cf7c9a Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 9 Oct 2020 00:48:49 -0500 Subject: [PATCH 048/103] Minor modifications --- src/settings.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 0c1f3c0fa..2e226cfad 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -626,36 +626,36 @@ void read_settings_xml() sourcepoint_batch = statepoint_batch; } - // Check if the user has specified to write surface source. + // Check if the user has specified to write surface source if (check_for_node(root, "surf_src_write")) { surf_src_write = true; - // Get surface source node - xml_node node_ss = root.child("surf_src_write"); + // Get surface source write node + xml_node node_ssw = root.child("surf_src_write"); - // Determine surface ids at which crossing particles are to be banked. - if (check_for_node(node_ss, "surf_ids")) { - auto temp = get_node_array(node_ss, "surf_ids"); + // Determine surface ids at which crossing particles are to be banked + if (check_for_node(node_ssw, "surf_ids")) { + auto temp = get_node_array(node_ssw, "surf_ids"); for (const auto& b : temp) { src_write_surf_id.insert(b); } } - // Get maximum number of particles to be banked per surface. - if (check_for_node(node_ss, "max_surf_banks")) { - max_surf_banks = std::stoi(get_node_value(node_ss, "max_surf_banks")); + // Get maximum number of particles to be banked per surface + if (check_for_node(node_ssw, "max_surf_banks")) { + max_surf_banks = std::stoi(get_node_value(node_ssw, "max_surf_banks")); } } - // Check if the user has specified to read surface source. + // Check if the user has specified to read surface source if (check_for_node(root, "surf_src_read")) { surf_src_read = true; // Get surface source read node - xml_node node_ss = root.child("surf_src_read"); + xml_node node_ssr = root.child("surf_src_read"); settings::path_source = "surface_source.h5"; // Check if the user has specified different file for surface source reading - if (check_for_node(node_ss, "file")) { - settings::path_source = get_node_value(node_ss, "file", false, true); + if (check_for_node(node_ssr, "file")) { + settings::path_source = get_node_value(node_ssr, "file", false, true); } // Check if surface source file exists From 5e490cf44034ed9a6a5d9a8439a23aa0ec2a562f Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 9 Oct 2020 01:46:50 -0500 Subject: [PATCH 049/103] Rename surface source file specification --- src/settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 2e226cfad..18cf61f49 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -654,8 +654,8 @@ void read_settings_xml() settings::path_source = "surface_source.h5"; // Check if the user has specified different file for surface source reading - if (check_for_node(node_ssr, "file")) { - settings::path_source = get_node_value(node_ssr, "file", false, true); + if (check_for_node(node_ssr, "path")) { + settings::path_source = get_node_value(node_ssr, "path", false, true); } // Check if surface source file exists From 7ecaecb853e7813a4e7365602485cda94d114961 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 9 Oct 2020 02:07:37 -0500 Subject: [PATCH 050/103] Add Python API for settings of surface source reading --- openmc/settings.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/openmc/settings.py b/openmc/settings.py index 2c3aadc9c..a19f0e906 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -143,6 +143,10 @@ class Settings: Options for writing state points. Acceptable keys are: :batches: list of batches at which to write source + surf_src_read : dict + Options for reading surface source points. Acceptable keys are: + + :path: Path to surface source file (str). surf_src_write : dict Options for writing surface source points. Acceptable keys are: @@ -236,6 +240,7 @@ class Settings: self._statepoint = {} self._sourcepoint = {} + self._surf_src_read = {} self._surf_src_write = {} self._no_reduce = None @@ -365,6 +370,10 @@ class Settings: def statepoint(self): return self._statepoint + @property + def surf_src_read(self): + return self._surf_src_read + @property def surf_src_write(self): return self._surf_src_write @@ -580,6 +589,16 @@ class Settings: "statepoint options.".format(key)) self._statepoint = statepoint + @surf_src_read.setter + def surf_src_read(self, surf_src_read): + cv.check_type('surface source writing options', surf_src_read, Mapping) + for key, value in surf_src_read.items(): + cv.check_value('surface source reading key', key, + ('path')) + if key == 'path': + cv.check_type('path to surface source file', value, str) + self._surf_src_read = surf_src_read + @surf_src_write.setter def surf_src_write(self, surf_src_write): cv.check_type('surface source writing options', surf_src_write, Mapping) @@ -921,6 +940,13 @@ class Settings: subelement = ET.SubElement(element, "overwrite_latest") subelement.text = str(self._sourcepoint['overwrite']).lower() + def _create_surf_src_read_subelement(self, root): + if self._surf_src_read: + element = ET.SubElement(root, "surf_src_read") + if 'path' in self._surf_src_read: + subelement = ET.SubElement(element, "path") + subelement.text = self._surf_src_read['path'] + def _create_surf_src_write_subelement(self, root): if self._surf_src_write: element = ET.SubElement(root, "surf_src_write") @@ -1194,6 +1220,13 @@ class Settings: value = [int(x) for x in value.split()] self.sourcepoint[key] = value + def _surf_src_read_from_xml_element(self, root): + elem = root.find('surf_src_read') + if elem is not None: + value = get_text(elem, 'path') + if value is not None: + self.surf_src_read['path'] = value + def _surf_src_write_from_xml_element(self, root): elem = root.find('surf_src_write') if elem is not None: @@ -1404,6 +1437,7 @@ class Settings: self._create_output_subelement(root_element) self._create_statepoint_subelement(root_element) self._create_sourcepoint_subelement(root_element) + self._create_surf_src_read_subelement(root_element) self._create_surf_src_write_subelement(root_element) self._create_confidence_intervals(root_element) self._create_electron_treatment_subelement(root_element) @@ -1478,6 +1512,7 @@ class Settings: settings._output_from_xml_element(root) settings._statepoint_from_xml_element(root) settings._sourcepoint_from_xml_element(root) + settings._surf_src_read_from_xml_element(root) settings._surf_src_write_from_xml_element(root) settings._confidence_intervals_from_xml_element(root) settings._electron_treatment_from_xml_element(root) From cc359100746c8cb59b13ef15c746dc1347fd9958 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 9 Oct 2020 14:46:23 -0500 Subject: [PATCH 051/103] Add missing surf_id on source_bank field --- openmc/lib/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 7be94e03d..6d9a680e3 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -17,6 +17,7 @@ class _Bank(Structure): ('E', c_double), ('wgt', c_double), ('delayed_group', c_int), + ('surf_id', c_int), ('particle', c_int), ('parent_id', c_int64), ('progeny_id', c_int64)] From 770d0e0ca0fb388fc294c3d2b09f95da789cd0a6 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 19 Oct 2020 20:24:51 -0500 Subject: [PATCH 052/103] Add surface source read/write tests on settings unit test --- tests/unit_tests/test_settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit_tests/test_settings.py b/tests/unit_tests/test_settings.py index c3ff72879..2b173834e 100644 --- a/tests/unit_tests/test_settings.py +++ b/tests/unit_tests/test_settings.py @@ -20,6 +20,8 @@ def test_export_to_xml(run_in_tmpdir): s.sourcepoint = {'batches': [50, 150, 500, 1000], 'separate': True, 'write': True, 'overwrite': True} s.statepoint = {'batches': [50, 150, 500, 1000]} + s.surf_src_read = {'path': 'surface_source_1.h5'} + s.surf_src_write = {'surf_ids': [2], 'max_surf_banks': 200} s.confidence_intervals = True s.ptables = True s.seed = 17 @@ -76,6 +78,8 @@ def test_export_to_xml(run_in_tmpdir): assert s.sourcepoint == {'batches': [50, 150, 500, 1000], 'separate': True, 'write': True, 'overwrite': True} assert s.statepoint == {'batches': [50, 150, 500, 1000]} + assert s.surf_src_read == {'path': 'surface_source_1.h5'} + assert s.surf_src_write == {'surf_ids': [2], 'max_surf_banks': 200} assert s.confidence_intervals assert s.ptables assert s.seed == 17 From 842d8f03695185b0fb3c1ecc8773759400113c3d Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 21 Oct 2020 01:32:03 -0500 Subject: [PATCH 053/103] Update RELAX NG compact syntax file --- src/relaxng/settings.rnc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/relaxng/settings.rnc b/src/relaxng/settings.rnc index 94347f864..fa6a04901 100644 --- a/src/relaxng/settings.rnc +++ b/src/relaxng/settings.rnc @@ -139,6 +139,17 @@ element settings { attribute overwrite_latest {xsd:boolean})? }? & + element surf_src_read { + (element path { xsd:string } | attribute path { xsd:string }) + }? & + + element surf_src_write { + (element surf_ids { list { xsd:positiveInteger+ } } | + attribute surf_ids { list { xsd:positiveInteger+ } }) & + (element max_surf_banks { xsd:positiveInteger } | + attribute max_surf_banks { xsd:positiveInteger }) + }? & + element survival_biasing { xsd:boolean }? & element temperature_default { xsd:double }? & From 1722f6641a93b5f5d2b022ab38a51c15cec452a9 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 21 Oct 2020 01:34:54 -0500 Subject: [PATCH 054/103] Update RELAX NG regular XML syntax file generated from trang - except previous uncommited changes --- src/relaxng/settings.rng | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng index ab6dcc328..02869d023 100644 --- a/src/relaxng/settings.rng +++ b/src/relaxng/settings.rng @@ -638,6 +638,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f541090ba549122d6f9b7d20a1cd15c79c2bcf59 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 23 Oct 2020 11:11:25 -0500 Subject: [PATCH 055/103] Update openmc/settings.py Co-authored-by: Katie Mummah --- openmc/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/settings.py b/openmc/settings.py index a19f0e906..20c2e9d26 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -591,7 +591,7 @@ class Settings: @surf_src_read.setter def surf_src_read(self, surf_src_read): - cv.check_type('surface source writing options', surf_src_read, Mapping) + cv.check_type('surface source reading options', surf_src_read, Mapping) for key, value in surf_src_read.items(): cv.check_value('surface source reading key', key, ('path')) From 6fda5f12dc0d484639fa0195d7fcd361eb5abf04 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 23 Oct 2020 11:12:41 -0500 Subject: [PATCH 056/103] Fix indentation --- openmc/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/settings.py b/openmc/settings.py index 20c2e9d26..838af3177 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -151,7 +151,7 @@ class Settings: Options for writing surface source points. Acceptable keys are: :surf_ids: List of surface ids at which crossing particles are to be - banked (int) + banked (int) :max_surf_banks: Maximum number of particles to be banked on surfaces per process (int) survival_biasing : bool From d3f26426d48f95f10bc43cf8ac6d05a97992bd67 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 4 Nov 2020 15:23:14 -0600 Subject: [PATCH 057/103] Add regression test for surface source read/write feature --- .../surface_source/inputs_true_read.dat | 33 +++++ .../surface_source/inputs_true_write.dat | 39 ++++++ .../surface_source/results_true.dat | 3 + .../surface_source/surface_source_true.h5 | Bin 0 -> 98088 bytes tests/regression_tests/surface_source/test.py | 127 ++++++++++++++++++ 5 files changed, 202 insertions(+) create mode 100644 tests/regression_tests/surface_source/inputs_true_read.dat create mode 100644 tests/regression_tests/surface_source/inputs_true_write.dat create mode 100644 tests/regression_tests/surface_source/results_true.dat create mode 100644 tests/regression_tests/surface_source/surface_source_true.h5 create mode 100644 tests/regression_tests/surface_source/test.py diff --git a/tests/regression_tests/surface_source/inputs_true_read.dat b/tests/regression_tests/surface_source/inputs_true_read.dat new file mode 100644 index 000000000..b8827e8e1 --- /dev/null +++ b/tests/regression_tests/surface_source/inputs_true_read.dat @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + fixed source + 1000 + 10 + + surface_source_true.h5 + + + + + + 3 + + + 1 + flux + + diff --git a/tests/regression_tests/surface_source/inputs_true_write.dat b/tests/regression_tests/surface_source/inputs_true_write.dat new file mode 100644 index 000000000..6b28ae114 --- /dev/null +++ b/tests/regression_tests/surface_source/inputs_true_write.dat @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + fixed source + 1000 + 10 + + + 0 0 0 + + + + 1 + 1000 + + + + + + 3 + + + 1 + flux + + diff --git a/tests/regression_tests/surface_source/results_true.dat b/tests/regression_tests/surface_source/results_true.dat new file mode 100644 index 000000000..558217673 --- /dev/null +++ b/tests/regression_tests/surface_source/results_true.dat @@ -0,0 +1,3 @@ +tally 1: +5.000000E+00 +2.500000E+00 diff --git a/tests/regression_tests/surface_source/surface_source_true.h5 b/tests/regression_tests/surface_source/surface_source_true.h5 new file mode 100644 index 0000000000000000000000000000000000000000..c5cd611004cd460592bf1e75580d49c3e84e94b1 GIT binary patch literal 98088 zcmeF4c|4U{`|wRoW+_P$GFD2ZNM#vHQpuDOB2p9o+`MrO>pZB-V=d`!4dw=(`?sczq-Pc<8y*)K{sdKOjurmDd zSh$dZg@OCem%sm+`}L5z&iE(#{qyhNoBew6*KZjZJbwKg#q`$;Mh0evKYqvmi*x_- z3p4)(w107Z-QBwx=v)5w|9<}UYX-{vzg{i;4gUA}|En6%*sbzsQ#tbMum0Vhihi}T z-<5IUoTI(P2~+dqwrBoCzuT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I{>mOryxP9k+ zt{%#7zm4fMFSQ0t7)KJ-g>j&CTa=c=dNILxlf45K;aR$E>ui>h&?=kYI0G zH;~(HW|m16GQhZ$eZJI?gRk#m%Fhj}HRI)H!h=r>Qa--n5l3O{_SBmyz_^@axs30D z&!4@NKbk3Lv*MK`A?M~<~bsv5uemb1NGCgTM5S5Qxe7! z9Pxanl=8FF_uMbFsDnW>smF8e4j9en%(hj(M~?9}A5NaZcj{O7QT|Q*&-rgNt^ilB zc;h*BeGLB7w_^5Q6~XvBmzZZPA3T56Px-mp>@+XiBg8Yzd$=TP5YmcYuljeenPA*L y*05kx7=FLw4dstBm2-x(l;GE Date: Thu, 5 Nov 2020 01:24:10 -0600 Subject: [PATCH 058/103] Minor revisions --- tests/regression_tests/surface_source/test.py | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 11fd9fb70..7b0a8eb26 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -1,7 +1,7 @@ import os import h5py -import numpy as np +import numpy as np import pytest import openmc @@ -13,7 +13,7 @@ def model(request): marker = request.node.get_closest_marker("surf_src_op") surf_src_op = marker.args[0] - model = openmc.model.Model() + openmc_model = openmc.model.Model() # Materials # None @@ -33,44 +33,44 @@ def model(request): cell_4 = openmc.Cell(4, region=+sph_3&-sph_4) root = openmc.Universe(universe_id=1, cells=[cell_1, cell_2, cell_3, cell_4]) - model.geometry = openmc.Geometry(root) + openmc_model.geometry = openmc.Geometry(root) # Settings - model.settings.run_mode = 'fixed source' - model.settings.particles = 1000 - model.settings.batches = 10 + openmc_model.settings.run_mode = 'fixed source' + openmc_model.settings.particles = 1000 + openmc_model.settings.batches = 10 if surf_src_op == 'write': point = openmc.stats.Point((0, 0, 0)) pt_src = openmc.Source(space=point) - model.settings.source = pt_src - - model.settings.surf_src_write = {'surf_ids': [1], - 'max_surf_banks': 1000} + openmc_model.settings.source = pt_src + openmc_model.settings.surf_src_write = {'surf_ids': [1], + 'max_surf_banks': 1000} elif surf_src_op == 'read': - model.settings.surf_src_read = {'path': 'surface_source_true.h5'} + openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'} # Tallies tal = openmc.Tally(1) cell_filter = openmc.CellFilter(cell_3, 1) tal.filters = [cell_filter] tal.scores = ['flux'] - model.tallies.append(tal) + openmc_model.tallies.append(tal) - return model + return openmc_model class SurfaceSourceTestHarness(PyAPITestHarness): - def _test_output_created(self): + """Make sure surface_source.h5 has also been created.""" super()._test_output_created() - # Check 'surface_source.h5' + # Check if 'surface_source.h5' has been created. if self._model.settings.surf_src_write: assert os.path.exists('surface_source.h5'), \ 'Surface source file does not exist.' def _compare_output(self): + """Make sure the current surface_source.h5 agree with the reference.""" if self._model.settings.surf_src_write: with h5py.File("surface_source_true.h5", 'r') as f: src_true = f['source_bank'][()] @@ -79,7 +79,7 @@ class SurfaceSourceTestHarness(PyAPITestHarness): assert np.all(np.sort(src_true) == np.sort(src_test)) def execute_test(self): - """Build input XMLs, run OpenMC, and verify correct results.""" + """Build input XMLs, run OpenMC, check output and results.""" try: self._build_inputs() inputs = self._get_inputs() @@ -95,23 +95,15 @@ class SurfaceSourceTestHarness(PyAPITestHarness): self._cleanup() def _cleanup(self): + """Delete statepoints, tally, and test files.""" super()._cleanup() fs = 'surface_source.h5' if os.path.exists(fs): os.remove(fs) - # - create model geom, mat, (fxd_src) sett - without surf_src_read/write cap - # - add surf_src_write sett - # - run with tally - # - check surf_src.h5 exist - give sample/ref? - # - compare tally result, check - # - restart, add surf_src_read sett - # - run with the same tally - # - compare tally result, check @pytest.mark.surf_src_op('write') def test_surface_source_write(model): - harness = SurfaceSourceTestHarness('statepoint.10.h5', model, 'inputs_true_write.dat') @@ -120,7 +112,6 @@ def test_surface_source_write(model): @pytest.mark.surf_src_op('read') def test_surface_source_read(model): - harness = SurfaceSourceTestHarness('statepoint.10.h5', model, 'inputs_true_read.dat') From e2a95a5addc7fe0d11f29a1a649f31956c5d75e1 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 5 Nov 2020 22:42:22 -0600 Subject: [PATCH 059/103] Update settings specification with surf_src_read/write --- docs/source/io_formats/settings.rst | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 588b58b47..47985938b 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -723,6 +723,42 @@ attributes/sub-elements: *Default*: false +--------------------------- +```` Element +--------------------------- + +The ```` element specifies a surface source file for OpenMC to +read source bank for initializing batches. +This element has the following attributes/sub-elements: + + :path: + Absolute or relative path to a surface source file to read in source bank. + + *Default*: ``surface_source.h5`` in current working directory + +---------------------------- +```` Element +---------------------------- + +The ```` element triggers OpenMC to bank particles crossing +certain surfaces and write out the source bank in a separate file called +``surface_source.h5``. +This element has the following attributes/sub-elements: + + :surf_ids: + A list of integers separated by spaces indicating the unique IDs of surfaces + for which crossing particles will be banked. + + *Default*: None + + :max_surf_banks: + An integer indicating the maximum number of particles to be banked on + specified surfaces per processor. The size of source bank in + ``surface_source.h5`` is limited to this value times the number of + processors. + + *Default*: None + ------------------------------ ```` Element ------------------------------ From 3b946ed607cedde780b42ad653f51cc5d22cede7 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 5 Nov 2020 22:59:28 -0600 Subject: [PATCH 060/103] Update source file format with surf_id --- docs/source/io_formats/source.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/io_formats/source.rst b/docs/source/io_formats/source.rst index 4cd023e12..f6889a3e1 100644 --- a/docs/source/io_formats/source.rst +++ b/docs/source/io_formats/source.rst @@ -16,6 +16,7 @@ is that documented here. - **source_bank** (Compound type) -- Source bank information for each particle. The compound type has fields ``r``, ``u``, ``E``, - ``wgt``, ``delayed_group``, and ``particle``, which represent the - position, direction, energy, weight, delayed group, and particle - type (0=neutron, 1=photon, 2=electron, 3=positron), respectively. + ``wgt``, ``delayed_group``, ``surf_id`` and ``particle``, + which represent the position, direction, energy, weight, + delayed group, surface ID, and particle type (0=neutron, 1=photon, + 2=electron, 3=positron), respectively. From eecb2a850797d7738281b4e8f07b55e5282a3b6c Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 5 Nov 2020 23:39:25 -0600 Subject: [PATCH 061/103] Add a new format file for surface source --- docs/source/io_formats/index.rst | 1 + docs/source/io_formats/surface_source.rst | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 docs/source/io_formats/surface_source.rst diff --git a/docs/source/io_formats/index.rst b/docs/source/io_formats/index.rst index 7ae22c0a3..bc5b0a4a9 100644 --- a/docs/source/io_formats/index.rst +++ b/docs/source/io_formats/index.rst @@ -44,6 +44,7 @@ Output Files statepoint source + surface_source summary depletion_results particle_restart diff --git a/docs/source/io_formats/surface_source.rst b/docs/source/io_formats/surface_source.rst new file mode 100644 index 000000000..5cf25fc60 --- /dev/null +++ b/docs/source/io_formats/surface_source.rst @@ -0,0 +1,21 @@ +.. _io_surface_source: + +========================== +Surface Source File Format +========================== + +When surface source writing is triggered, a separate source file is written with +only the sources on specified surfaces. The format is identical to source file. + +**/** + +:Attributes: - **filetype** (*char[]*) -- String indicating the type of file. + +:Datasets: + + - **source_bank** (Compound type) -- Source bank information for each + particle. The compound type has fields ``r``, ``u``, ``E``, + ``wgt``, ``delayed_group``, ``surf_id`` and ``particle``, + which represent the position, direction, energy, weight, + delayed group, surface ID, and particle type (0=neutron, 1=photon, + 2=electron, 3=positron), respectively. From fb9ee5504ead19ab48491e9b4152a3c4aac2f2b4 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 00:09:15 -0600 Subject: [PATCH 062/103] Switch surf_src_bank in write_source_point to be optional --- include/openmc/state_point.h | 2 +- src/simulation.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index 92c5c0f40..bc493372a 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -13,7 +13,7 @@ namespace openmc { void load_state_point(); int* query_surf_src_size(); -void write_source_point(const char* filename, bool surf_src_bank); +void write_source_point(const char* filename, bool surf_src_bank = false); void write_source_bank(hid_t group_id, bool surf_src_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); void write_tally_results_nr(hid_t file_id); diff --git a/src/simulation.cpp b/src/simulation.cpp index 82a6e7bd1..3f52052d4 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -378,13 +378,13 @@ void finalize_batch() // Write out a separate source point if it's been specified for this batch if (contains(settings::sourcepoint_batch, simulation::current_batch) && settings::source_write && settings::source_separate) { - write_source_point(nullptr, false); + write_source_point(nullptr); } // Write a continously-overwritten source point if requested. if (settings::source_latest) { auto filename = settings::path_output + "source.h5"; - write_source_point(filename.c_str(), false); + write_source_point(filename.c_str()); } } From b0bd1ce011681e11689f923666a15ef0a49a88fa Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 00:28:26 -0600 Subject: [PATCH 063/103] Remove deprecated max_bank_size --- include/openmc/state_point.h | 2 +- src/state_point.cpp | 22 +++++----------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index bc493372a..b724b8ad2 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,7 +12,7 @@ namespace openmc { void load_state_point(); -int* query_surf_src_size(); +int query_surf_src_size(); void write_source_point(const char* filename, bool surf_src_bank = false); void write_source_bank(hid_t group_id, bool surf_src_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); diff --git a/src/state_point.cpp b/src/state_point.cpp index 90c49667a..d26e53610 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,11 +525,8 @@ hid_t h5banktype() { return banktype; } -int* query_surf_src_size() +int query_surf_src_size() { - // total_surf_banks, max_bank_size - static int qsize[2] = {0, 0}; - int64_t total; if (mpi::master) { simulation::surf_src_index.resize(mpi::n_procs + 1); @@ -553,17 +550,14 @@ int* query_surf_src_size() simulation::surf_src_index[i] = \ simulation::surf_src_index[i - 1] + bank_size[i - 1]; } - // Set maximum bank size - qsize[1] = *std::max_element(bank_size.begin(), bank_size.end()); - qsize[0] = simulation::surf_src_index[mpi::n_procs]; + total = simulation::surf_src_index[mpi::n_procs]; } #else - qsize[0] = simulation::surf_src_bank.size(); simulation::surf_src_index[mpi::n_procs] = simulation::surf_src_bank.size(); - qsize[1] = simulation::work_per_rank; + total = simulation::surf_src_bank.size(); #endif - return qsize; + return total; } void @@ -611,18 +605,13 @@ write_source_bank(hid_t group_id, bool surf_src_bank) int64_t dims_size = settings::n_particles; int64_t count_size = simulation::work_per_rank; - // Set maximum bank size - int64_t max_bank_size = simulation::work_per_rank; - // Set vectors for source bank and starting bank index of each process std::vector* bank_index = &simulation::work_index; std::vector src_bank = simulation::source_bank; // Reset dataspace sizes and vectors for surface source bank if (surf_src_bank) { - int* qsize = query_surf_src_size(); - - dims_size = qsize[0]; + dims_size = query_surf_src_size(); count_size = simulation::surf_src_bank.size(); bank_index = &simulation::surf_src_index; @@ -630,7 +619,6 @@ write_source_bank(hid_t group_id, bool surf_src_bank) src_bank.assign(simulation::surf_src_bank.data(), simulation::surf_src_bank.data() + simulation::surf_src_bank.size()); - max_bank_size = qsize[1]; } #ifdef PHDF5 From e2d3ace60112ec3e5dfccca224bfaa8261d46d76 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 00:36:26 -0600 Subject: [PATCH 064/103] Add an __init__.py to the surface source regression test --- tests/regression_tests/surface_source/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/regression_tests/surface_source/__init__.py diff --git a/tests/regression_tests/surface_source/__init__.py b/tests/regression_tests/surface_source/__init__.py new file mode 100644 index 000000000..e69de29bb From 7ff8a94a3d998395f5412bfe0792fa70b10cdb66 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 13:45:13 -0600 Subject: [PATCH 065/103] Switch source bank from full copies to pointers --- src/state_point.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index d26e53610..455ddac49 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -607,7 +607,8 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Set vectors for source bank and starting bank index of each process std::vector* bank_index = &simulation::work_index; - std::vector src_bank = simulation::source_bank; + std::vector* src_bank = &simulation::source_bank; + std::vector surf_src_bank_vector; // Reset dataspace sizes and vectors for surface source bank if (surf_src_bank) { @@ -616,9 +617,11 @@ write_source_bank(hid_t group_id, bool surf_src_bank) bank_index = &simulation::surf_src_index; - src_bank.assign(simulation::surf_src_bank.data(), - simulation::surf_src_bank.data() - + simulation::surf_src_bank.size()); + // Copy data in a SharedArray into a vector. + surf_src_bank_vector.resize(count_size); + surf_src_bank_vector.assign(simulation::surf_src_bank.data(), + simulation::surf_src_bank.data() + count_size); + src_bank = &surf_src_bank_vector; } #ifdef PHDF5 @@ -641,7 +644,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); // Write data to file in parallel - H5Dwrite(dset, banktype, memspace, dspace, plist, src_bank.data()); + H5Dwrite(dset, banktype, memspace, dspace, plist, (*src_bank).data()); // Free resources H5Sclose(dspace); @@ -660,8 +663,8 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Save source bank sites since the array is overwritten below #ifdef OPENMC_MPI - std::vector temp_source {src_bank.begin(), - src_bank.begin() + count_size}; + std::vector temp_source {(*src_bank).begin(), + (*src_bank).begin() + count_size}; #endif for (int i = 0; i < mpi::n_procs; ++i) { @@ -672,7 +675,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Receive source sites from other processes if (i > 0) - MPI_Recv(src_bank.data(), count[0], mpi::bank, i, i, + MPI_Recv((*src_bank).data(), count[0], mpi::bank, i, i, mpi::intracomm, MPI_STATUS_IGNORE); #endif @@ -682,7 +685,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab - H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, src_bank.data()); + H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, (*src_bank).data()); H5Sclose(memspace); H5Sclose(dspace); @@ -693,11 +696,11 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Restore state of source bank - std::copy(temp_source.begin(), temp_source.end(), src_bank.begin()); + std::copy(temp_source.begin(), temp_source.end(), (*src_bank).begin()); #endif } else { #ifdef OPENMC_MPI - MPI_Send(src_bank.data(), count_size, mpi::bank, + MPI_Send((*src_bank).data(), count_size, mpi::bank, 0, mpi::rank, mpi::intracomm); #endif } From 12621cb9938579511452819bcfcab5c2364edebd Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 13:47:42 -0600 Subject: [PATCH 066/103] Minor rewording --- docs/source/io_formats/settings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 47985938b..55ffef527 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -728,7 +728,7 @@ attributes/sub-elements: --------------------------- The ```` element specifies a surface source file for OpenMC to -read source bank for initializing batches. +read source bank for initializing histories. This element has the following attributes/sub-elements: :path: From 8b08da7405903deebf203188fecff3f1ab385cf9 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 16:08:16 -0600 Subject: [PATCH 067/103] Give seed to surface source testing --- .../surface_source/inputs_true_read.dat | 1 + .../surface_source/inputs_true_write.dat | 1 + .../surface_source/surface_source_true.h5 | Bin 98088 -> 98088 bytes tests/regression_tests/surface_source/test.py | 1 + 4 files changed, 3 insertions(+) diff --git a/tests/regression_tests/surface_source/inputs_true_read.dat b/tests/regression_tests/surface_source/inputs_true_read.dat index b8827e8e1..aa181a299 100644 --- a/tests/regression_tests/surface_source/inputs_true_read.dat +++ b/tests/regression_tests/surface_source/inputs_true_read.dat @@ -20,6 +20,7 @@ surface_source_true.h5 + 1 diff --git a/tests/regression_tests/surface_source/inputs_true_write.dat b/tests/regression_tests/surface_source/inputs_true_write.dat index 6b28ae114..07dcf7dd2 100644 --- a/tests/regression_tests/surface_source/inputs_true_write.dat +++ b/tests/regression_tests/surface_source/inputs_true_write.dat @@ -26,6 +26,7 @@ 1 1000 + 1 diff --git a/tests/regression_tests/surface_source/surface_source_true.h5 b/tests/regression_tests/surface_source/surface_source_true.h5 index c5cd611004cd460592bf1e75580d49c3e84e94b1..8aefd8159775d3d56c47865371e02b6e92161425 100644 GIT binary patch delta 11046 zcmYkCb$nLk8;9TXPLS>qqq~~{8{OTEcy`q|zy#rB>lw(tGoN!cg&?Ek2ER#5!x)>tfvh1n+( z!S*o!#EjzGS@hqF5|UdDhbX9YmQ<{2C7nL==yOnIZ~;C=Vjo9;G%6tjpiyVV*wy zCkPXztnRt7D7&GG<Zq;Eys?VsN4VOrL2`G9}DwNT3bo+Fh{EuVqyBJ!e^az z$}AR(hbiR}#R})3V)*VnHNs9$S!{9kug@!mY4h##e^KZq&+r(^S;@+=Fmc+#&Sfj} z?e;%xHVteqXTzhXEky}rl()K7!oQXG46_7UBqNp-ro3RcB}pbWIh?$}5}ZYFGqFKZ zSWw=2sLISJtQ6Z`pkxe~!||jrQNiG9I1*eM4+{+rm^Fu!lEU;CZMh8T6jz-hg5yDy z-dt^*lN4qPE=#(KR-^_+1SbViw!_7e!b}k<=vG`gv@EiE=LAuK!^P?OC0j0!Z^hN* z#T8sEh!QQ-#<@vhj^GNUt7L7|qKM$)L71)8+RWL@mbhX(%JC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2*E)f&8j!Vif>6d^PpH@GrhXF4ko$yh>OR}E&Yrsp+Ap2Xu3(v$C z^Co4|;y+ky742-X^CQLHu4V%Tm96vtWvErGQLS`upwv=p|tvZb-sK+AAj`pTB&wpar#7xbbB z%9h6t5>~(t5mv-n1FeJ|E?YV1C0PTlf*mDW6+2p3joqw)MqtOuRwp|_SOYszSQ9&0 zSPMHv7>S)Gtj!s$f!1NJHPE_PYoPV8vy`pR1Z$uTm@rSaA=VmbBkV%i##n2hO|Xk) zn=*Hauo-ig3Y(K%E^I+|rLZM-m9Q1r)xy@;HNrMz*9zNWt%0_~(l?&}|2gg1%^GM2 zY`kno>_%ZH?&c<8XMRzegimv22I1JIi(odvJzb!e|1!g+1AA zudo+$_X&G*oc+Q+1P%yeSawj@7kgOP4|_z|pWTiM2M{{ftI1l!e;NCS>>8{!d=LAV>{{#-VH`GDxQ@C12t(Na zgzK?Sg&R1-Ghuu%l;j%z#$YJfHT+G%P<$%CGMj^;1lQ`f;M17jig&GkTQC&qn*4Tr z2FvUq@0$Ehd}i~z$h+6VyMv){_bPY~=W)E3weGd>J~HmL@P52|Eqovtiq35_53<(1 z7CyvxaZd+_@$Tv12;My%9L2k*gJXF2bZ|Tvigiy1C-Cm+;3VEX9h_p{lD6+@d@18I z Date: Fri, 6 Nov 2020 18:14:07 -0600 Subject: [PATCH 068/103] Test line-by-line assertion --- tests/regression_tests/surface_source/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 1dbd4abd2..7e65abd4d 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -77,7 +77,8 @@ class SurfaceSourceTestHarness(PyAPITestHarness): src_true = f['source_bank'][()] with h5py.File("surface_source.h5", 'r') as f: src_test = f['source_bank'][()] - assert np.all(np.sort(src_true) == np.sort(src_test)) + for (true_p, test_p) in zip(np.sort(src_true), np.sort(src_test)): + assert true_p == test_p def execute_test(self): """Build input XMLs, run OpenMC, check output and results.""" From ba644ca335a10a97a4345ab110b0b853a3ac3235 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 19:37:57 -0600 Subject: [PATCH 069/103] Try numpy assert_array_equal --- tests/regression_tests/surface_source/test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 7e65abd4d..ce70b9dce 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -77,8 +77,7 @@ class SurfaceSourceTestHarness(PyAPITestHarness): src_true = f['source_bank'][()] with h5py.File("surface_source.h5", 'r') as f: src_test = f['source_bank'][()] - for (true_p, test_p) in zip(np.sort(src_true), np.sort(src_test)): - assert true_p == test_p + np.testing.assert_array_equal(np.sort(src_true), np.sort(src_test)) def execute_test(self): """Build input XMLs, run OpenMC, check output and results.""" From 7ee3e12771e108bcefb4d2cc0f967b22db1e818e Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 6 Nov 2020 23:43:05 -0600 Subject: [PATCH 070/103] Test line-by-line assert_array_equal --- tests/regression_tests/surface_source/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index ce70b9dce..57e193801 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -77,7 +77,8 @@ class SurfaceSourceTestHarness(PyAPITestHarness): src_true = f['source_bank'][()] with h5py.File("surface_source.h5", 'r') as f: src_test = f['source_bank'][()] - np.testing.assert_array_equal(np.sort(src_true), np.sort(src_test)) + for (true_p, test_p) in zip(np.sort(src_true), np.sort(src_test)): + np.testing.assert_array_equal(true_p, test_p) def execute_test(self): """Build input XMLs, run OpenMC, check output and results.""" From aa838872c4a90944550bdb677ca2e3344ddc6363 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 10 Nov 2020 16:08:13 -0600 Subject: [PATCH 071/103] Resolve rebase leftover --- src/source.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/source.cpp b/src/source.cpp index 97a722acf..0efaf52ba 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -72,21 +72,6 @@ IndependentSource::IndependentSource(pugi::xml_node node) // Check for external source file if (check_for_node(node, "file")) { - // Copy path of source file - settings::path_source = get_node_value(node, "file", false, true); - - // Check if source file exists - if (!file_exists(settings::path_source)) { - fatal_error(fmt::format("Source file '{}' does not exist.", - settings::path_source)); - } - - } else if (check_for_node(node, "library")) { - settings::path_source_library = get_node_value(node, "library", false, true); - if (!file_exists(settings::path_source_library)) { - fatal_error(fmt::format("Source library '{}' does not exist.", - settings::path_source_library)); - } } else { From f1216d8b51a78ebf8c7ba7a1ff05423baa940772 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 10 Nov 2020 17:32:26 -0600 Subject: [PATCH 072/103] Fix old surface source reading on settings --- src/settings.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 18cf61f49..d9c2857f8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -652,17 +652,12 @@ void read_settings_xml() // Get surface source read node xml_node node_ssr = root.child("surf_src_read"); - settings::path_source = "surface_source.h5"; + std::string path = "surface_source.h5"; // Check if the user has specified different file for surface source reading if (check_for_node(node_ssr, "path")) { - settings::path_source = get_node_value(node_ssr, "path", false, true); + path = get_node_value(node_ssr, "path", false, true); } - - // Check if surface source file exists - if (!file_exists(settings::path_source)) { - fatal_error(fmt::format("Source file '{}' does not exist.", - settings::path_source)); - } + model::external_sources.push_back(std::make_unique(path)); } // If source is not seperate and is to be written out in the statepoint file, From a9af38a4ddcade1ac255007edb9315330bd469fe Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 11 Nov 2020 01:14:52 -0600 Subject: [PATCH 073/103] Relocate surf_src_read setting check to be compatible with changes on external source logic --- src/settings.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index d9c2857f8..76bad237a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -441,6 +441,20 @@ void read_settings_xml() } } + // Check if the user has specified to read surface source + if (check_for_node(root, "surf_src_read")) { + surf_src_read = true; + // Get surface source read node + xml_node node_ssr = root.child("surf_src_read"); + + std::string path = "surface_source.h5"; + // Check if the user has specified different file for surface source reading + if (check_for_node(node_ssr, "path")) { + path = get_node_value(node_ssr, "path", false, true); + } + model::external_sources.push_back(std::make_unique(path)); + } + // If no source specified, default to isotropic point source at origin with Watt spectrum if (model::external_sources.empty()) { model::external_sources.push_back(std::make_unique( @@ -646,20 +660,6 @@ void read_settings_xml() } } - // Check if the user has specified to read surface source - if (check_for_node(root, "surf_src_read")) { - surf_src_read = true; - // Get surface source read node - xml_node node_ssr = root.child("surf_src_read"); - - std::string path = "surface_source.h5"; - // Check if the user has specified different file for surface source reading - if (check_for_node(node_ssr, "path")) { - path = get_node_value(node_ssr, "path", false, true); - } - model::external_sources.push_back(std::make_unique(path)); - } - // If source is not seperate and is to be written out in the statepoint file, // make sure that the sourcepoint batch numbers are contained in the // statepoint list From 9fa68075c6077f55572b65f1dd35de0d8e46f7d0 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Wed, 11 Nov 2020 17:50:31 -0600 Subject: [PATCH 074/103] Convert dtye from mixed to a float for comparison assertion --- tests/regression_tests/surface_source/test.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 57e193801..01eb9a639 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -75,10 +75,14 @@ class SurfaceSourceTestHarness(PyAPITestHarness): if self._model.settings.surf_src_write: with h5py.File("surface_source_true.h5", 'r') as f: src_true = f['source_bank'][()] + # Convert dtye from mixed to a float for comparison assertion + src_true.dtype = 'float64' with h5py.File("surface_source.h5", 'r') as f: src_test = f['source_bank'][()] - for (true_p, test_p) in zip(np.sort(src_true), np.sort(src_test)): - np.testing.assert_array_equal(true_p, test_p) + # Convert dtye from mixed to a float for comparison assertion + src_test.dtype = 'float64' + np.testing.assert_allclose(np.sort(src_true), np.sort(src_test), + atol=1e-07) def execute_test(self): """Build input XMLs, run OpenMC, check output and results.""" From 58a65222a1b00dc54472a8851657e1ef5deb298f Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 19 Nov 2020 16:03:46 -0600 Subject: [PATCH 075/103] Add missing changes on source.py --- openmc/source.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openmc/source.py b/openmc/source.py index b5b53167c..3d544f3a1 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -257,17 +257,20 @@ class SourceParticle: Weight of the particle delayed_group : int Delayed group particle was created in (neutrons only) + surf_id : int + Surface ID where particle is at, if any. particle : ParticleType Type of the particle """ def __init__(self, r=(0., 0., 0.), u=(0., 0., 1.), E=1.0e6, wgt=1.0, - delayed_group=0, particle=ParticleType.NEUTRON): + delayed_group=0, surf_id=0, particle=ParticleType.NEUTRON): self.r = tuple(r) self.u = tuple(u) self.E = float(E) self.wgt = float(wgt) self.delayed_group = delayed_group + self.surf_id = surf_id self.particle = particle def to_tuple(self): @@ -280,7 +283,7 @@ class SourceParticle: """ return (self.r, self.u, self.E, self.wgt, - self.delayed_group, self.particle.value) + self.delayed_group, self.surf_id, self.particle.value) def write_source_file(source_particles, filename, **kwargs): @@ -304,6 +307,7 @@ def write_source_file(source_particles, filename, **kwargs): ('E', ' Date: Thu, 19 Nov 2020 16:06:29 -0600 Subject: [PATCH 076/103] Add missing changes on statepoint.py --- openmc/statepoint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openmc/statepoint.py b/openmc/statepoint.py index f6177fcc4..6e90bcaf7 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -94,9 +94,9 @@ class StatePoint: Pseudorandom number generator seed source : numpy.ndarray of compound datatype Array of source sites. The compound datatype has fields 'r', 'u', - 'E', 'wgt', 'delayed_group', and 'particle', corresponding to the - position, direction, energy, weight, delayed group, and particle type - of the source site, respectively. + 'E', 'wgt', 'delayed_group', 'surf_id', and 'particle', corresponding to + the position, direction, energy, weight, delayed group, surface ID and + particle type of the source site, respectively. source_present : bool Indicate whether source sites are present sparse : bool From 61ce6e528c21abf84ece0c9a0e59e5e2f6cd5c24 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 19 Nov 2020 16:08:56 -0600 Subject: [PATCH 077/103] Add missing changes on statepoint.rst --- docs/source/io_formats/statepoint.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/io_formats/statepoint.rst b/docs/source/io_formats/statepoint.rst index 3a2ad1600..92b103ef7 100644 --- a/docs/source/io_formats/statepoint.rst +++ b/docs/source/io_formats/statepoint.rst @@ -52,9 +52,10 @@ The current version of the statepoint file format is 17.0. sum-of-squares for each global tally. - **source_bank** (Compound type) -- Source bank information for each particle. The compound type has fields ``r``, ``u``, ``E``, - ``wgt``, ``delayed_group``, and ``particle``, which represent the - position, direction, energy, weight, delayed group, and particle - type (0=neutron, 1=photon, 2=electron, 3=positron), respectively. + ``wgt``, ``delayed_group``, ``surf_id``, and ``particle``, which + represent the position, direction, energy, weight, delayed group, + surface ID, and particle type (0=neutron, 1=photon, 2=electron, + 3=positron), respectively. Only present when `run_mode` is 'eigenvalue'. **/tallies/** From 4e312efdeb84ed7b0e7fc684378b776a99f15d08 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 19 Nov 2020 17:38:18 -0600 Subject: [PATCH 078/103] Set surf_id of fission bank site with default value --- src/physics.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/physics.cpp b/src/physics.cpp index 2636207fb..6e4960513 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -190,6 +190,7 @@ create_fission_sites(Particle& p, int i_nuclide, const Reaction& rx) site.wgt = 1. / weight; site.parent_id = p.id_; site.progeny_id = p.n_progeny_++; + site.surf_id = 0; // Sample delayed group and angle/energy for fission reaction sample_fission_neutron(i_nuclide, rx, p.E_, &site, p.current_seed()); From f40c7aac7ed8b539db347c8766a1555c5c94a839 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Thu, 19 Nov 2020 17:40:33 -0600 Subject: [PATCH 079/103] Set surf_id of IndependentSource with default value --- src/source.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/source.cpp b/src/source.cpp index 0efaf52ba..2bbe7c321 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -225,6 +225,8 @@ Particle::Bank IndependentSource::sample(uint64_t* seed) const // Set delayed group site.delayed_group = 0; + // Set surface ID + site.surf_id = 0; return site; } From 61b6fbb124c842aa9e2f6cecde270be02e4b571c Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 20 Nov 2020 03:57:12 -0600 Subject: [PATCH 080/103] Fix error from missing MPI_Bcast --- src/state_point.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 455ddac49..edb65dfa1 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -528,10 +528,9 @@ hid_t h5banktype() { int query_surf_src_size() { int64_t total; - if (mpi::master) { - simulation::surf_src_index.resize(mpi::n_procs + 1); - simulation::surf_src_index[0] = 0; - } + + simulation::surf_src_index.resize(mpi::n_procs + 1); + simulation::surf_src_index[0] = 0; #ifdef OPENMC_MPI std::vector bank_size; @@ -552,6 +551,9 @@ int query_surf_src_size() } total = simulation::surf_src_index[mpi::n_procs]; } + MPI_Bcast(simulation::surf_src_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm); + MPI_Bcast(&total, 1, MPI_INT64_T, 0, mpi::intracomm); + #else simulation::surf_src_index[mpi::n_procs] = simulation::surf_src_bank.size(); total = simulation::surf_src_bank.size(); From b3f41eebeb220427cdbb58c2b3255f1085c23000 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 11 Dec 2020 03:34:07 -0600 Subject: [PATCH 081/103] Add missing surface source flag on DagMC surface --- src/dagmc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 362f9a6e4..2c20f6f94 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -2,6 +2,7 @@ #include "openmc/cell.h" #include "openmc/constants.h" +#include "openmc/container_util.h" #include "openmc/error.h" #include "openmc/file_utils.h" #include "openmc/geometry.h" @@ -296,6 +297,10 @@ void load_dagmc_geometry() s->id_ = model::DAG->id_by_index(2, s->dag_index_); s->dagmc_ptr_ = model::DAG; + if (contains(settings::src_write_surf_id, s->id_)) { + s->surf_src_ = true; + } + // set BCs std::string bc_value = DMD.get_surface_property("boundary", surf_handle); to_lower(bc_value); From c4be96e74a3b94e5baba261128e9966e37f54512 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:16:48 -0600 Subject: [PATCH 082/103] Update src/settings.cpp Co-authored-by: Paul Romano --- src/settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings.cpp b/src/settings.cpp index 76bad237a..47bf0c4d7 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -451,7 +451,7 @@ void read_settings_xml() // Check if the user has specified different file for surface source reading if (check_for_node(node_ssr, "path")) { path = get_node_value(node_ssr, "path", false, true); - } + } model::external_sources.push_back(std::make_unique(path)); } From 13c336c75dd372934e482b0a4bc45f507ea7daa9 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:17:20 -0600 Subject: [PATCH 083/103] Update src/state_point.cpp Co-authored-by: Paul Romano --- src/state_point.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index edb65dfa1..975f42a6f 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -646,7 +646,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); // Write data to file in parallel - H5Dwrite(dset, banktype, memspace, dspace, plist, (*src_bank).data()); + H5Dwrite(dset, banktype, memspace, dspace, plist, src_bank->data()); // Free resources H5Sclose(dspace); From f1dea9c4f1217e8adfe0857de6a9aa3807ea418b Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:17:36 -0600 Subject: [PATCH 084/103] Update tests/regression_tests/surface_source/test.py Co-authored-by: Paul Romano --- tests/regression_tests/surface_source/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 01eb9a639..68fa4a921 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -1,6 +1,6 @@ import os -import h5py +import h5py import numpy as np import pytest import openmc From edd1a17274f739a037f32a04df6a7b67b49a4a8a Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:17:57 -0600 Subject: [PATCH 085/103] Update src/state_point.cpp Co-authored-by: Paul Romano --- src/state_point.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 975f42a6f..ce6349072 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -665,8 +665,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Save source bank sites since the array is overwritten below #ifdef OPENMC_MPI - std::vector temp_source {(*src_bank).begin(), - (*src_bank).begin() + count_size}; + std::vector temp_source {src_bank->begin(), src_bank->end()}; #endif for (int i = 0; i < mpi::n_procs; ++i) { From 400c20b6fcad6f533296b30f9688b94824f465b1 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:18:12 -0600 Subject: [PATCH 086/103] Update tests/regression_tests/surface_source/test.py Co-authored-by: Paul Romano --- tests/regression_tests/surface_source/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 68fa4a921..765188b34 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -52,8 +52,8 @@ def model(request): openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'} # Tallies - tal = openmc.Tally(1) - cell_filter = openmc.CellFilter(cell_3, 1) + tal = openmc.Tally() + cell_filter = openmc.CellFilter(cell_3) tal.filters = [cell_filter] tal.scores = ['flux'] openmc_model.tallies.append(tal) From 944914fb1f498074da24ce501fc5e0dc717288b3 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:18:34 -0600 Subject: [PATCH 087/103] Update src/state_point.cpp Co-authored-by: Paul Romano --- src/state_point.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index ce6349072..6ef794fff 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -701,7 +701,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #endif } else { #ifdef OPENMC_MPI - MPI_Send((*src_bank).data(), count_size, mpi::bank, + MPI_Send(src_bank->data(), count_size, mpi::bank, 0, mpi::rank, mpi::intracomm); #endif } From a5d2c19a10eb814f16e1840d49d8142121cdf9c6 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:18:52 -0600 Subject: [PATCH 088/103] Update src/state_point.cpp Co-authored-by: Paul Romano --- src/state_point.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 6ef794fff..b34669fd7 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -697,7 +697,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Restore state of source bank - std::copy(temp_source.begin(), temp_source.end(), (*src_bank).begin()); + std::copy(temp_source.begin(), temp_source.end(), src_bank->begin()); #endif } else { #ifdef OPENMC_MPI From 6428bc9bc1a3d224403f863c7f8afddc5c7fcb05 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 4 Jan 2021 14:19:07 -0600 Subject: [PATCH 089/103] Update src/state_point.cpp Co-authored-by: Paul Romano --- src/state_point.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index b34669fd7..e1b94c340 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -676,7 +676,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Receive source sites from other processes if (i > 0) - MPI_Recv((*src_bank).data(), count[0], mpi::bank, i, i, + MPI_Recv(src_bank->data(), count[0], mpi::bank, i, i, mpi::intracomm, MPI_STATUS_IGNORE); #endif From e427dbde50a9192096abf67a6547118978e6c370 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 8 Jan 2021 13:45:00 -0600 Subject: [PATCH 090/103] Reword src to source for consistency --- include/openmc/bank.h | 2 +- include/openmc/settings.h | 6 +- include/openmc/simulation.h | 2 +- include/openmc/state_point.h | 6 +- include/openmc/surface.h | 2 +- openmc/settings.py | 80 +++++++++---------- src/bank.cpp | 4 +- src/dagmc.cpp | 4 +- src/particle.cpp | 4 +- src/relaxng/settings.rnc | 4 +- src/relaxng/settings.rng | 4 +- src/settings.cpp | 22 ++--- src/simulation.cpp | 14 ++-- src/state_point.cpp | 60 +++++++------- src/surface.cpp | 4 +- .../surface_source/inputs_true_read.dat | 4 +- .../surface_source/inputs_true_write.dat | 4 +- tests/regression_tests/surface_source/test.py | 19 ++--- 18 files changed, 123 insertions(+), 122 deletions(-) diff --git a/include/openmc/bank.h b/include/openmc/bank.h index de73641e7..4f6f95c19 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -18,7 +18,7 @@ namespace simulation { extern std::vector source_bank; -extern SharedArray surf_src_bank; +extern SharedArray surf_source_bank; extern SharedArray fission_bank; diff --git a/include/openmc/settings.h b/include/openmc/settings.h index d8f785cc1..109255e9f 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -45,8 +45,8 @@ extern "C" bool run_CE; //!< run with continuous-energy data? extern bool source_latest; //!< write latest source at each batch? extern bool source_separate; //!< write source to separate file? extern bool source_write; //!< write source in HDF5 files? -extern bool surf_src_write; //!< write surface source file? -extern bool surf_src_read; //!< read surface source file? +extern bool surf_source_write; //!< write surface source file? +extern bool surf_source_read; //!< read surface source file? extern bool survival_biasing; //!< use survival biasing? extern bool temperature_multipole; //!< use multipole data? extern "C" bool trigger_on; //!< tally triggers enabled? @@ -87,7 +87,7 @@ extern std::vector res_scat_nuclides; //!< Nuclides using res. ups extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set statepoint_batch; //!< Batches when state should be written -extern std::unordered_set src_write_surf_id; //!< Surface ids where sources will be written +extern std::unordered_set source_write_surf_id; //!< Surface ids where sources will be written extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces per process extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 63fb6e5fd..818d98f52 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -45,7 +45,7 @@ extern const RegularMesh* ufs_mesh; extern std::vector k_generation; extern std::vector work_index; -extern std::vector surf_src_index; +extern std::vector surf_source_index; } // namespace simulation diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index b724b8ad2..92649a337 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,9 +12,9 @@ namespace openmc { void load_state_point(); -int query_surf_src_size(); -void write_source_point(const char* filename, bool surf_src_bank = false); -void write_source_bank(hid_t group_id, bool surf_src_bank); +int query_surf_source_size(); +void write_source_point(const char* filename, bool surf_source_bank = false); +void write_source_bank(hid_t group_id, bool surf_source_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); void write_tally_results_nr(hid_t file_id); void restart_set_keff(); diff --git a/include/openmc/surface.h b/include/openmc/surface.h index febfed27c..2a62d81c8 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -88,7 +88,7 @@ public: int id_; //!< Unique ID std::string name_; //!< User-defined name std::shared_ptr bc_ {nullptr}; //!< Boundary condition - bool surf_src_ {false}; //!< Activate source banking for the surface? + bool surf_source_ {false}; //!< Activate source banking for the surface? explicit Surface(pugi::xml_node surf_node); Surface(); diff --git a/openmc/settings.py b/openmc/settings.py index 838af3177..97a1246f3 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -143,11 +143,11 @@ class Settings: Options for writing state points. Acceptable keys are: :batches: list of batches at which to write source - surf_src_read : dict + surf_source_read : dict Options for reading surface source points. Acceptable keys are: :path: Path to surface source file (str). - surf_src_write : dict + surf_source_write : dict Options for writing surface source points. Acceptable keys are: :surf_ids: List of surface ids at which crossing particles are to be @@ -240,8 +240,8 @@ class Settings: self._statepoint = {} self._sourcepoint = {} - self._surf_src_read = {} - self._surf_src_write = {} + self._surf_source_read = {} + self._surf_source_write = {} self._no_reduce = None @@ -371,12 +371,12 @@ class Settings: return self._statepoint @property - def surf_src_read(self): - return self._surf_src_read + def surf_source_read(self): + return self._surf_source_read @property - def surf_src_write(self): - return self._surf_src_write + def surf_source_write(self): + return self._surf_source_write @property def no_reduce(self): @@ -589,20 +589,20 @@ class Settings: "statepoint options.".format(key)) self._statepoint = statepoint - @surf_src_read.setter - def surf_src_read(self, surf_src_read): - cv.check_type('surface source reading options', surf_src_read, Mapping) - for key, value in surf_src_read.items(): + @surf_source_read.setter + def surf_source_read(self, surf_source_read): + cv.check_type('surface source reading options', surf_source_read, Mapping) + for key, value in surf_source_read.items(): cv.check_value('surface source reading key', key, ('path')) if key == 'path': cv.check_type('path to surface source file', value, str) - self._surf_src_read = surf_src_read + self._surf_source_read = surf_source_read - @surf_src_write.setter - def surf_src_write(self, surf_src_write): - cv.check_type('surface source writing options', surf_src_write, Mapping) - for key, value in surf_src_write.items(): + @surf_source_write.setter + def surf_source_write(self, surf_source_write): + cv.check_type('surface source writing options', surf_source_write, Mapping) + for key, value in surf_source_write.items(): cv.check_value('surface source writing key', key, ('surf_ids', 'max_surf_banks')) if key == 'surf_ids': @@ -616,7 +616,7 @@ class Settings: value, Integral) cv.check_greater_than('maximum particle banks on surfaces per process', value, 0) - self._surf_src_write = surf_src_write + self._surf_source_write = surf_source_write @confidence_intervals.setter def confidence_intervals(self, confidence_intervals): @@ -940,23 +940,23 @@ class Settings: subelement = ET.SubElement(element, "overwrite_latest") subelement.text = str(self._sourcepoint['overwrite']).lower() - def _create_surf_src_read_subelement(self, root): - if self._surf_src_read: - element = ET.SubElement(root, "surf_src_read") - if 'path' in self._surf_src_read: + def _create_surf_source_read_subelement(self, root): + if self._surf_source_read: + element = ET.SubElement(root, "surf_source_read") + if 'path' in self._surf_source_read: subelement = ET.SubElement(element, "path") - subelement.text = self._surf_src_read['path'] + subelement.text = self._surf_source_read['path'] - def _create_surf_src_write_subelement(self, root): - if self._surf_src_write: - element = ET.SubElement(root, "surf_src_write") - if 'surf_ids' in self._surf_src_write: + def _create_surf_source_write_subelement(self, root): + if self._surf_source_write: + element = ET.SubElement(root, "surf_source_write") + if 'surf_ids' in self._surf_source_write: subelement = ET.SubElement(element, "surf_ids") subelement.text = ' '.join( - str(x) for x in self._surf_src_write['surf_ids']) - if 'max_surf_banks' in self._surf_src_write: + str(x) for x in self._surf_source_write['surf_ids']) + if 'max_surf_banks' in self._surf_source_write: subelement = ET.SubElement(element, "max_surf_banks") - subelement.text = str(self._surf_src_write['max_surf_banks']) + subelement.text = str(self._surf_source_write['max_surf_banks']) def _create_confidence_intervals(self, root): if self._confidence_intervals is not None: @@ -1220,15 +1220,15 @@ class Settings: value = [int(x) for x in value.split()] self.sourcepoint[key] = value - def _surf_src_read_from_xml_element(self, root): - elem = root.find('surf_src_read') + def _surf_source_read_from_xml_element(self, root): + elem = root.find('surf_source_read') if elem is not None: value = get_text(elem, 'path') if value is not None: - self.surf_src_read['path'] = value + self.surf_source_read['path'] = value - def _surf_src_write_from_xml_element(self, root): - elem = root.find('surf_src_write') + def _surf_source_write_from_xml_element(self, root): + elem = root.find('surf_source_write') if elem is not None: for key in ('surf_ids', 'max_surf_banks'): value = get_text(elem, key) @@ -1237,7 +1237,7 @@ class Settings: value = [int(x) for x in value.split()] elif key in ('max_surf_banks'): value = int(value) - self.surf_src_write[key] = value + self.surf_source_write[key] = value def _confidence_intervals_from_xml_element(self, root): text = get_text(root, 'confidence_intervals') @@ -1437,8 +1437,8 @@ class Settings: self._create_output_subelement(root_element) self._create_statepoint_subelement(root_element) self._create_sourcepoint_subelement(root_element) - self._create_surf_src_read_subelement(root_element) - self._create_surf_src_write_subelement(root_element) + self._create_surf_source_read_subelement(root_element) + self._create_surf_source_write_subelement(root_element) self._create_confidence_intervals(root_element) self._create_electron_treatment_subelement(root_element) self._create_energy_mode_subelement(root_element) @@ -1512,8 +1512,8 @@ class Settings: settings._output_from_xml_element(root) settings._statepoint_from_xml_element(root) settings._sourcepoint_from_xml_element(root) - settings._surf_src_read_from_xml_element(root) - settings._surf_src_write_from_xml_element(root) + settings._surf_source_read_from_xml_element(root) + settings._surf_source_write_from_xml_element(root) settings._confidence_intervals_from_xml_element(root) settings._electron_treatment_from_xml_element(root) settings._energy_mode_from_xml_element(root) diff --git a/src/bank.cpp b/src/bank.cpp index fa0146df5..958676d6e 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -17,7 +17,7 @@ namespace simulation { std::vector source_bank; -SharedArray surf_src_bank; +SharedArray surf_source_bank; // The fission bank is allocated as a SharedArray, rather than a vector, as it will // be shared by all threads in the simulation. It will be allocated to a fixed @@ -39,7 +39,7 @@ std::vector progeny_per_particle; void free_memory_bank() { simulation::source_bank.clear(); - simulation::surf_src_bank.clear(); + simulation::surf_source_bank.clear(); simulation::fission_bank.clear(); simulation::progeny_per_particle.clear(); } diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 2c20f6f94..58d83f54c 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -297,8 +297,8 @@ void load_dagmc_geometry() s->id_ = model::DAG->id_by_index(2, s->dag_index_); s->dagmc_ptr_ = model::DAG; - if (contains(settings::src_write_surf_id, s->id_)) { - s->surf_src_ = true; + if (contains(settings::source_write_surf_id, s->id_)) { + s->surf_source_ = true; } // set BCs diff --git a/src/particle.cpp b/src/particle.cpp index a1829751a..d03511e67 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -413,7 +413,7 @@ Particle::cross_surface() write_message(1, " Crossing surface {}", surf->id_); } - if (surf->surf_src_ && simulation::current_batch == settings::n_batches) { + if (surf->surf_source_ && simulation::current_batch == settings::n_batches) { Particle::Bank site; site.r = this->r(); site.u = this->u(); @@ -424,7 +424,7 @@ Particle::cross_surface() site.particle = this->type_; site.parent_id = this->id_; site.progeny_id = this->n_progeny_; - int64_t idx = simulation::surf_src_bank.thread_safe_append(site); + int64_t idx = simulation::surf_source_bank.thread_safe_append(site); } // Handle any applicable boundary conditions. diff --git a/src/relaxng/settings.rnc b/src/relaxng/settings.rnc index fa6a04901..fcb1d37d8 100644 --- a/src/relaxng/settings.rnc +++ b/src/relaxng/settings.rnc @@ -139,11 +139,11 @@ element settings { attribute overwrite_latest {xsd:boolean})? }? & - element surf_src_read { + element surf_source_read { (element path { xsd:string } | attribute path { xsd:string }) }? & - element surf_src_write { + element surf_source_write { (element surf_ids { list { xsd:positiveInteger+ } } | attribute surf_ids { list { xsd:positiveInteger+ } }) & (element max_surf_banks { xsd:positiveInteger } | diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng index 02869d023..3817d6e07 100644 --- a/src/relaxng/settings.rng +++ b/src/relaxng/settings.rng @@ -639,7 +639,7 @@ - + @@ -651,7 +651,7 @@ - + diff --git a/src/settings.cpp b/src/settings.cpp index 47bf0c4d7..c03b3bc99 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -60,8 +60,8 @@ bool run_CE {true}; bool source_latest {false}; bool source_separate {false}; bool source_write {true}; -bool surf_src_write {false}; -bool surf_src_read {false}; +bool surf_source_write {false}; +bool surf_source_read {false}; bool survival_biasing {false}; bool temperature_multipole {false}; bool trigger_on {false}; @@ -100,7 +100,7 @@ std::vector res_scat_nuclides; RunMode run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; -std::unordered_set src_write_surf_id; +std::unordered_set source_write_surf_id; int64_t max_surf_banks; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; @@ -442,10 +442,10 @@ void read_settings_xml() } // Check if the user has specified to read surface source - if (check_for_node(root, "surf_src_read")) { - surf_src_read = true; + if (check_for_node(root, "surf_source_read")) { + surf_source_read = true; // Get surface source read node - xml_node node_ssr = root.child("surf_src_read"); + xml_node node_ssr = root.child("surf_source_read"); std::string path = "surface_source.h5"; // Check if the user has specified different file for surface source reading @@ -641,16 +641,16 @@ void read_settings_xml() } // Check if the user has specified to write surface source - if (check_for_node(root, "surf_src_write")) { - surf_src_write = true; + if (check_for_node(root, "surf_source_write")) { + surf_source_write = true; // Get surface source write node - xml_node node_ssw = root.child("surf_src_write"); + xml_node node_ssw = root.child("surf_source_write"); // Determine surface ids at which crossing particles are to be banked if (check_for_node(node_ssw, "surf_ids")) { auto temp = get_node_array(node_ssw, "surf_ids"); for (const auto& b : temp) { - src_write_surf_id.insert(b); + source_write_surf_id.insert(b); } } @@ -832,7 +832,7 @@ void read_settings_xml() void free_memory_settings() { settings::statepoint_batch.clear(); settings::sourcepoint_batch.clear(); - settings::src_write_surf_id.clear(); + settings::source_write_surf_id.clear(); settings::res_scat_nuclides.clear(); } diff --git a/src/simulation.cpp b/src/simulation.cpp index 3f52052d4..ff8b115b3 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -115,7 +115,7 @@ int openmc_simulation_init() } else { // Only initialize primary source bank for eigenvalue simulations // or when a surface source file is provided. - if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) { + if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_source_read) { initialize_source(); } } @@ -271,7 +271,7 @@ const RegularMesh* ufs_mesh {nullptr}; std::vector k_generation; std::vector work_index; -std::vector surf_src_index; +std::vector surf_source_index; } // namespace simulation @@ -287,14 +287,14 @@ void allocate_banks() // Allocate fission bank init_fission_bank(3*simulation::work_per_rank); - } else if (settings::surf_src_read) { + } else if (settings::surf_source_read) { // Allocate source bank for reading surface source file. simulation::source_bank.resize(simulation::work_per_rank); } - if (settings::surf_src_write) { + if (settings::surf_source_write) { // Allocate surface source bank - simulation::surf_src_bank.reserve(settings::max_surf_banks); + simulation::surf_source_bank.reserve(settings::max_surf_banks); } } @@ -389,7 +389,7 @@ void finalize_batch() } // Write out surface source if requested. - if (settings::surf_src_write && simulation::current_batch == settings::n_batches) { + if (settings::surf_source_write && simulation::current_batch == settings::n_batches) { auto filename = settings::path_output + "surface_source.h5"; write_source_point(filename.c_str(), true); @@ -458,7 +458,7 @@ void finalize_generation() void initialize_history(Particle& p, int64_t index_source) { // set defaults - if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_src_read) { + if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_source_read) { // set defaults for eigenvalue simulations and surface source reading from primary bank p.from_source(&simulation::source_bank[index_source - 1]); } else if (settings::run_mode == RunMode::FIXED_SOURCE) { diff --git a/src/state_point.cpp b/src/state_point.cpp index e1b94c340..8ce1e3884 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,45 +525,45 @@ hid_t h5banktype() { return banktype; } -int query_surf_src_size() +int query_surf_source_size() { int64_t total; - simulation::surf_src_index.resize(mpi::n_procs + 1); - simulation::surf_src_index[0] = 0; + simulation::surf_source_index.resize(mpi::n_procs + 1); + simulation::surf_source_index[0] = 0; #ifdef OPENMC_MPI std::vector bank_size; bank_size.resize(mpi::n_procs); // Collect the number of surface source banks from all processes - int64_t size = simulation::surf_src_bank.size(); + int64_t size = simulation::surf_source_bank.size(); MPI_Gather(&size, 1, MPI_INT64_T, bank_size.data(), 1, MPI_INT64_T, 0, mpi::intracomm); if (mpi::master) { - // Populate the surf_src_index with cumulative sum of the number of + // Populate the surf_source_index with cumulative sum of the number of // surface source banks per process for (int i = 1; i < mpi::n_procs + 1; ++i) { - simulation::surf_src_index[i] = \ - simulation::surf_src_index[i - 1] + bank_size[i - 1]; + simulation::surf_source_index[i] = \ + simulation::surf_source_index[i - 1] + bank_size[i - 1]; } - total = simulation::surf_src_index[mpi::n_procs]; + total = simulation::surf_source_index[mpi::n_procs]; } - MPI_Bcast(simulation::surf_src_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm); + MPI_Bcast(simulation::surf_source_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm); MPI_Bcast(&total, 1, MPI_INT64_T, 0, mpi::intracomm); #else - simulation::surf_src_index[mpi::n_procs] = simulation::surf_src_bank.size(); - total = simulation::surf_src_bank.size(); + simulation::surf_source_index[mpi::n_procs] = simulation::surf_source_bank.size(); + total = simulation::surf_source_bank.size(); #endif return total; } void -write_source_point(const char* filename, bool surf_src_bank) +write_source_point(const char* filename, bool surf_source_bank) { // When using parallel HDF5, the file is written to collectively by all // processes. With MPI-only, the file is opened and written by the master @@ -593,13 +593,13 @@ write_source_point(const char* filename, bool surf_src_bank) } // Get pointer to source bank and write to file - write_source_bank(file_id, surf_src_bank); + write_source_bank(file_id, surf_source_bank); if (mpi::master || parallel) file_close(file_id); } void -write_source_bank(hid_t group_id, bool surf_src_bank) +write_source_bank(hid_t group_id, bool surf_source_bank) { hid_t banktype = h5banktype(); @@ -609,21 +609,21 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Set vectors for source bank and starting bank index of each process std::vector* bank_index = &simulation::work_index; - std::vector* src_bank = &simulation::source_bank; - std::vector surf_src_bank_vector; + std::vector* source_bank = &simulation::source_bank; + std::vector surf_source_bank_vector; // Reset dataspace sizes and vectors for surface source bank - if (surf_src_bank) { - dims_size = query_surf_src_size(); - count_size = simulation::surf_src_bank.size(); + if (surf_source_bank) { + dims_size = query_surf_source_size(); + count_size = simulation::surf_source_bank.size(); - bank_index = &simulation::surf_src_index; + bank_index = &simulation::surf_source_index; // Copy data in a SharedArray into a vector. - surf_src_bank_vector.resize(count_size); - surf_src_bank_vector.assign(simulation::surf_src_bank.data(), - simulation::surf_src_bank.data() + count_size); - src_bank = &surf_src_bank_vector; + surf_source_bank_vector.resize(count_size); + surf_source_bank_vector.assign(simulation::surf_source_bank.data(), + simulation::surf_source_bank.data() + count_size); + source_bank = &surf_source_bank_vector; } #ifdef PHDF5 @@ -646,7 +646,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); // Write data to file in parallel - H5Dwrite(dset, banktype, memspace, dspace, plist, src_bank->data()); + H5Dwrite(dset, banktype, memspace, dspace, plist, source_bank->data()); // Free resources H5Sclose(dspace); @@ -665,7 +665,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) // Save source bank sites since the array is overwritten below #ifdef OPENMC_MPI - std::vector temp_source {src_bank->begin(), src_bank->end()}; + std::vector temp_source {source_bank->begin(), source_bank->end()}; #endif for (int i = 0; i < mpi::n_procs; ++i) { @@ -676,7 +676,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Receive source sites from other processes if (i > 0) - MPI_Recv(src_bank->data(), count[0], mpi::bank, i, i, + MPI_Recv(source_bank->data(), count[0], mpi::bank, i, i, mpi::intracomm, MPI_STATUS_IGNORE); #endif @@ -686,7 +686,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank) H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, nullptr, count, nullptr); // Write data to hyperslab - H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, (*src_bank).data()); + H5Dwrite(dset, banktype, memspace, dspace, H5P_DEFAULT, (*source_bank).data()); H5Sclose(memspace); H5Sclose(dspace); @@ -697,11 +697,11 @@ write_source_bank(hid_t group_id, bool surf_src_bank) #ifdef OPENMC_MPI // Restore state of source bank - std::copy(temp_source.begin(), temp_source.end(), src_bank->begin()); + std::copy(temp_source.begin(), temp_source.end(), source_bank->begin()); #endif } else { #ifdef OPENMC_MPI - MPI_Send(src_bank->data(), count_size, mpi::bank, + MPI_Send(source_bank->data(), count_size, mpi::bank, 0, mpi::rank, mpi::intracomm); #endif } diff --git a/src/surface.cpp b/src/surface.cpp index 9090d60f3..81d96d83a 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -116,8 +116,8 @@ Surface::Surface(pugi::xml_node surf_node) { if (check_for_node(surf_node, "id")) { id_ = std::stoi(get_node_value(surf_node, "id")); - if (contains(settings::src_write_surf_id, id_)) { - surf_src_ = true; + if (contains(settings::source_write_surf_id, id_)) { + surf_source_ = true; } } else { fatal_error("Must specify id of surface in geometry XML file."); diff --git a/tests/regression_tests/surface_source/inputs_true_read.dat b/tests/regression_tests/surface_source/inputs_true_read.dat index aa181a299..3a122c737 100644 --- a/tests/regression_tests/surface_source/inputs_true_read.dat +++ b/tests/regression_tests/surface_source/inputs_true_read.dat @@ -17,9 +17,9 @@ fixed source 1000 10 - + surface_source_true.h5 - + 1 diff --git a/tests/regression_tests/surface_source/inputs_true_write.dat b/tests/regression_tests/surface_source/inputs_true_write.dat index 07dcf7dd2..7451bed5f 100644 --- a/tests/regression_tests/surface_source/inputs_true_write.dat +++ b/tests/regression_tests/surface_source/inputs_true_write.dat @@ -22,10 +22,10 @@ 0 0 0 - + 1 1000 - + 1 diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 765188b34..959957b73 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -46,8 +46,8 @@ def model(request): pt_src = openmc.Source(space=point) openmc_model.settings.source = pt_src - openmc_model.settings.surf_src_write = {'surf_ids': [1], - 'max_surf_banks': 1000} + openmc_model.settings.surf_source_write = {'surf_ids': [1], + 'max_surf_banks': 1000} elif surf_src_op == 'read': openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'} @@ -66,22 +66,23 @@ class SurfaceSourceTestHarness(PyAPITestHarness): """Make sure surface_source.h5 has also been created.""" super()._test_output_created() # Check if 'surface_source.h5' has been created. - if self._model.settings.surf_src_write: + if self._model.settings.surf_source_write: assert os.path.exists('surface_source.h5'), \ 'Surface source file does not exist.' def _compare_output(self): """Make sure the current surface_source.h5 agree with the reference.""" - if self._model.settings.surf_src_write: + if self._model.settings.surf_source_write: with h5py.File("surface_source_true.h5", 'r') as f: - src_true = f['source_bank'][()] + source_true = f['source_bank'][()] # Convert dtye from mixed to a float for comparison assertion - src_true.dtype = 'float64' + source_true.dtype = 'float64' with h5py.File("surface_source.h5", 'r') as f: - src_test = f['source_bank'][()] + source_test = f['source_bank'][()] # Convert dtye from mixed to a float for comparison assertion - src_test.dtype = 'float64' - np.testing.assert_allclose(np.sort(src_true), np.sort(src_test), + source_test.dtype = 'float64' + np.testing.assert_allclose(np.sort(source_true), + np.sort(source_test), atol=1e-07) def execute_test(self): From 1e01c9b0d08fa8dac02e062e14ec97c1c395caf7 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Fri, 8 Jan 2021 15:21:37 -0600 Subject: [PATCH 091/103] Move surface source file format description under source file format --- docs/source/io_formats/source.rst | 4 ++++ docs/source/io_formats/surface_source.rst | 21 --------------------- 2 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 docs/source/io_formats/surface_source.rst diff --git a/docs/source/io_formats/source.rst b/docs/source/io_formats/source.rst index f6889a3e1..86ae8a1e5 100644 --- a/docs/source/io_formats/source.rst +++ b/docs/source/io_formats/source.rst @@ -8,6 +8,10 @@ Normally, source data is stored in a state point file. However, it is possible to request that the source be written separately, in which case the format used is that documented here. +When surface source writing is triggered, a source file named +``surface_source.h5`` is written with only the sources on specified surfaces, +following the same format. + **/** :Attributes: - **filetype** (*char[]*) -- String indicating the type of file. diff --git a/docs/source/io_formats/surface_source.rst b/docs/source/io_formats/surface_source.rst deleted file mode 100644 index 5cf25fc60..000000000 --- a/docs/source/io_formats/surface_source.rst +++ /dev/null @@ -1,21 +0,0 @@ -.. _io_surface_source: - -========================== -Surface Source File Format -========================== - -When surface source writing is triggered, a separate source file is written with -only the sources on specified surfaces. The format is identical to source file. - -**/** - -:Attributes: - **filetype** (*char[]*) -- String indicating the type of file. - -:Datasets: - - - **source_bank** (Compound type) -- Source bank information for each - particle. The compound type has fields ``r``, ``u``, ``E``, - ``wgt``, ``delayed_group``, ``surf_id`` and ``particle``, - which represent the position, direction, energy, weight, - delayed group, surface ID, and particle type (0=neutron, 1=photon, - 2=electron, 3=positron), respectively. From 49a55120fda38207f4a8babd5fb4b9042f13c5cb Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 11 Jan 2021 17:04:08 -0600 Subject: [PATCH 092/103] Move surf_source_index out of global scope --- include/openmc/simulation.h | 2 -- include/openmc/state_point.h | 2 +- src/state_point.cpp | 27 ++++++++++++--------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 818d98f52..32e2c6730 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -45,8 +45,6 @@ extern const RegularMesh* ufs_mesh; extern std::vector k_generation; extern std::vector work_index; -extern std::vector surf_source_index; - } // namespace simulation //============================================================================== diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index 92649a337..322b3162a 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,7 +12,7 @@ namespace openmc { void load_state_point(); -int query_surf_source_size(); +std::vector query_surf_source_size(); void write_source_point(const char* filename, bool surf_source_bank = false); void write_source_bank(hid_t group_id, bool surf_source_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); diff --git a/src/state_point.cpp b/src/state_point.cpp index 8ce1e3884..23c2748e4 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,12 +525,11 @@ hid_t h5banktype() { return banktype; } -int query_surf_source_size() +std::vector query_surf_source_size() { - int64_t total; - - simulation::surf_source_index.resize(mpi::n_procs + 1); - simulation::surf_source_index[0] = 0; + std::vector surf_source_index; + surf_source_index.resize(mpi::n_procs + 1); + surf_source_index[0] = 0; #ifdef OPENMC_MPI std::vector bank_size; @@ -546,20 +545,16 @@ int query_surf_source_size() // Populate the surf_source_index with cumulative sum of the number of // surface source banks per process for (int i = 1; i < mpi::n_procs + 1; ++i) { - simulation::surf_source_index[i] = \ - simulation::surf_source_index[i - 1] + bank_size[i - 1]; + surf_source_index[i] = surf_source_index[i - 1] + bank_size[i - 1]; } - total = simulation::surf_source_index[mpi::n_procs]; } - MPI_Bcast(simulation::surf_source_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm); - MPI_Bcast(&total, 1, MPI_INT64_T, 0, mpi::intracomm); + MPI_Bcast(surf_source_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm); #else - simulation::surf_source_index[mpi::n_procs] = simulation::surf_source_bank.size(); - total = simulation::surf_source_bank.size(); + surf_source_index[mpi::n_procs] = simulation::surf_source_bank.size(); #endif - return total; + return surf_source_index; } void @@ -610,14 +605,16 @@ write_source_bank(hid_t group_id, bool surf_source_bank) // Set vectors for source bank and starting bank index of each process std::vector* bank_index = &simulation::work_index; std::vector* source_bank = &simulation::source_bank; + std::vector surf_source_index_vector; std::vector surf_source_bank_vector; // Reset dataspace sizes and vectors for surface source bank if (surf_source_bank) { - dims_size = query_surf_source_size(); + surf_source_index_vector = query_surf_source_size(); + dims_size = surf_source_index_vector[mpi::n_procs]; count_size = simulation::surf_source_bank.size(); - bank_index = &simulation::surf_source_index; + bank_index = &surf_source_index_vector; // Copy data in a SharedArray into a vector. surf_source_bank_vector.resize(count_size); From f6bfacad3b8a2ecc8e64594455979871e43e1591 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 12 Jan 2021 00:32:04 -0600 Subject: [PATCH 093/103] Use MPI_Scan + MPI_Allgather instead of MPI_Gather + MPI_Bcast --- src/state_point.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/state_point.cpp b/src/state_point.cpp index 23c2748e4..f6b38f09b 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -528,30 +528,21 @@ hid_t h5banktype() { std::vector query_surf_source_size() { std::vector surf_source_index; - surf_source_index.resize(mpi::n_procs + 1); - surf_source_index[0] = 0; + surf_source_index.reserve(mpi::n_procs + 1); #ifdef OPENMC_MPI - std::vector bank_size; - bank_size.resize(mpi::n_procs); + surf_source_index.resize(mpi::n_procs); + std::vector bank_size(mpi::n_procs); - // Collect the number of surface source banks from all processes + // Populate the surf_source_index with cumulative sum of the number of + // surface source banks per process int64_t size = simulation::surf_source_bank.size(); - MPI_Gather(&size, 1, MPI_INT64_T, - bank_size.data(), 1, MPI_INT64_T, - 0, mpi::intracomm); - - if (mpi::master) { - // Populate the surf_source_index with cumulative sum of the number of - // surface source banks per process - for (int i = 1; i < mpi::n_procs + 1; ++i) { - surf_source_index[i] = surf_source_index[i - 1] + bank_size[i - 1]; - } - } - MPI_Bcast(surf_source_index.data(), mpi::n_procs + 1, MPI_INT64_T, 0, mpi::intracomm); - + MPI_Scan(&size, bank_size.data(), 1, MPI_INT64_T, MPI_SUM, mpi::intracomm); + MPI_Allgather(bank_size.data(), 1, MPI_INT64_T, surf_source_index.data(), 1, MPI_INT64_T, mpi::intracomm); + surf_source_index.insert(surf_source_index.begin(), 0); #else - surf_source_index[mpi::n_procs] = simulation::surf_source_bank.size(); + surf_source_index.push_back(0); + surf_source_index.push_back(simulation::surf_source_bank.size()); #endif return surf_source_index; From f31a4d2e780ebb9069f0f11aae78f19376352832 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 12 Jan 2021 12:05:52 -0600 Subject: [PATCH 094/103] Surf source size function name change --- include/openmc/state_point.h | 2 +- src/state_point.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index 322b3162a..53f072b85 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -12,7 +12,7 @@ namespace openmc { void load_state_point(); -std::vector query_surf_source_size(); +std::vector calculate_surf_source_size(); void write_source_point(const char* filename, bool surf_source_bank = false); void write_source_bank(hid_t group_id, bool surf_source_bank); void read_source_bank(hid_t group_id, std::vector& sites, bool distribute); diff --git a/src/state_point.cpp b/src/state_point.cpp index f6b38f09b..48d87d403 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -525,7 +525,7 @@ hid_t h5banktype() { return banktype; } -std::vector query_surf_source_size() +std::vector calculate_surf_source_size() { std::vector surf_source_index; surf_source_index.reserve(mpi::n_procs + 1); @@ -601,7 +601,7 @@ write_source_bank(hid_t group_id, bool surf_source_bank) // Reset dataspace sizes and vectors for surface source bank if (surf_source_bank) { - surf_source_index_vector = query_surf_source_size(); + surf_source_index_vector = calculate_surf_source_size(); dims_size = surf_source_index_vector[mpi::n_procs]; count_size = simulation::surf_source_bank.size(); From 7a79f78c77f17fc481922d36eecd8b2d7fd3b759 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 12 Jan 2021 14:23:53 -0600 Subject: [PATCH 095/103] Remove unnecessary population of source bank --- src/simulation.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index ff8b115b3..e004fc805 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -115,7 +115,7 @@ int openmc_simulation_init() } else { // Only initialize primary source bank for eigenvalue simulations // or when a surface source file is provided. - if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_source_read) { + if (settings::run_mode == RunMode::EIGENVALUE) { initialize_source(); } } @@ -287,9 +287,6 @@ void allocate_banks() // Allocate fission bank init_fission_bank(3*simulation::work_per_rank); - } else if (settings::surf_source_read) { - // Allocate source bank for reading surface source file. - simulation::source_bank.resize(simulation::work_per_rank); } if (settings::surf_source_write) { @@ -458,7 +455,7 @@ void finalize_generation() void initialize_history(Particle& p, int64_t index_source) { // set defaults - if (settings::run_mode == RunMode::EIGENVALUE || settings::surf_source_read) { + if (settings::run_mode == RunMode::EIGENVALUE) { // set defaults for eigenvalue simulations and surface source reading from primary bank p.from_source(&simulation::source_bank[index_source - 1]); } else if (settings::run_mode == RunMode::FIXED_SOURCE) { From 41be70ce6a6c9ba82855edb635434f1a6605fa01 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Tue, 12 Jan 2021 15:02:03 -0600 Subject: [PATCH 096/103] Add missing change on unit test --- tests/unit_tests/test_settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/test_settings.py b/tests/unit_tests/test_settings.py index 2b173834e..61278fe74 100644 --- a/tests/unit_tests/test_settings.py +++ b/tests/unit_tests/test_settings.py @@ -20,8 +20,8 @@ def test_export_to_xml(run_in_tmpdir): s.sourcepoint = {'batches': [50, 150, 500, 1000], 'separate': True, 'write': True, 'overwrite': True} s.statepoint = {'batches': [50, 150, 500, 1000]} - s.surf_src_read = {'path': 'surface_source_1.h5'} - s.surf_src_write = {'surf_ids': [2], 'max_surf_banks': 200} + s.surf_source_read = {'path': 'surface_source_1.h5'} + s.surf_source_write = {'surf_ids': [2], 'max_surf_banks': 200} s.confidence_intervals = True s.ptables = True s.seed = 17 @@ -78,8 +78,8 @@ def test_export_to_xml(run_in_tmpdir): assert s.sourcepoint == {'batches': [50, 150, 500, 1000], 'separate': True, 'write': True, 'overwrite': True} assert s.statepoint == {'batches': [50, 150, 500, 1000]} - assert s.surf_src_read == {'path': 'surface_source_1.h5'} - assert s.surf_src_write == {'surf_ids': [2], 'max_surf_banks': 200} + assert s.surf_source_read == {'path': 'surface_source_1.h5'} + assert s.surf_source_write == {'surf_ids': [2], 'max_surf_banks': 200} assert s.confidence_intervals assert s.ptables assert s.seed == 17 From fa97e03d5758535cdbb85a547d9475790ccece3a Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 11:23:05 -0600 Subject: [PATCH 097/103] Apply suggestions from code review - remove deprecated changes Co-authored-by: Paul Romano --- src/simulation.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index e004fc805..02aac5537 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -114,7 +114,6 @@ int openmc_simulation_init() write_message("Resuming simulation...", 6); } else { // Only initialize primary source bank for eigenvalue simulations - // or when a surface source file is provided. if (settings::run_mode == RunMode::EIGENVALUE) { initialize_source(); } @@ -271,7 +270,6 @@ const RegularMesh* ufs_mesh {nullptr}; std::vector k_generation; std::vector work_index; -std::vector surf_source_index; } // namespace simulation @@ -387,7 +385,6 @@ void finalize_batch() // Write out surface source if requested. if (settings::surf_source_write && simulation::current_batch == settings::n_batches) { - auto filename = settings::path_output + "surface_source.h5"; write_source_point(filename.c_str(), true); } @@ -456,7 +453,7 @@ void initialize_history(Particle& p, int64_t index_source) { // set defaults if (settings::run_mode == RunMode::EIGENVALUE) { - // set defaults for eigenvalue simulations and surface source reading from primary bank + // set defaults for eigenvalue simulations from primary bank p.from_source(&simulation::source_bank[index_source - 1]); } else if (settings::run_mode == RunMode::FIXED_SOURCE) { // initialize random number seed From 26c3043726de4739b200ff622785ec9be32c5a1f Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 11:46:07 -0600 Subject: [PATCH 098/103] Rename surf_ids to surface_ids --- docs/source/io_formats/settings.rst | 2 +- openmc/settings.py | 16 ++++++++-------- src/relaxng/settings.rnc | 4 ++-- src/relaxng/settings.rng | 4 ++-- src/settings.cpp | 4 ++-- .../surface_source/inputs_true_write.dat | 2 +- tests/regression_tests/surface_source/test.py | 2 +- tests/unit_tests/test_settings.py | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 55ffef527..82414f308 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -745,7 +745,7 @@ certain surfaces and write out the source bank in a separate file called ``surface_source.h5``. This element has the following attributes/sub-elements: - :surf_ids: + :surface_ids: A list of integers separated by spaces indicating the unique IDs of surfaces for which crossing particles will be banked. diff --git a/openmc/settings.py b/openmc/settings.py index 97a1246f3..e069453b7 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -150,7 +150,7 @@ class Settings: surf_source_write : dict Options for writing surface source points. Acceptable keys are: - :surf_ids: List of surface ids at which crossing particles are to be + :surface_ids: List of surface ids at which crossing particles are to be banked (int) :max_surf_banks: Maximum number of particles to be banked on surfaces per process (int) @@ -604,8 +604,8 @@ class Settings: cv.check_type('surface source writing options', surf_source_write, Mapping) for key, value in surf_source_write.items(): cv.check_value('surface source writing key', key, - ('surf_ids', 'max_surf_banks')) - if key == 'surf_ids': + ('surface_ids', 'max_surf_banks')) + if key == 'surface_ids': cv.check_type('surface ids for source banking', value, Iterable, Integral) for surf_id in value: @@ -950,10 +950,10 @@ class Settings: def _create_surf_source_write_subelement(self, root): if self._surf_source_write: element = ET.SubElement(root, "surf_source_write") - if 'surf_ids' in self._surf_source_write: - subelement = ET.SubElement(element, "surf_ids") + if 'surface_ids' in self._surf_source_write: + subelement = ET.SubElement(element, "surface_ids") subelement.text = ' '.join( - str(x) for x in self._surf_source_write['surf_ids']) + str(x) for x in self._surf_source_write['surface_ids']) if 'max_surf_banks' in self._surf_source_write: subelement = ET.SubElement(element, "max_surf_banks") subelement.text = str(self._surf_source_write['max_surf_banks']) @@ -1230,10 +1230,10 @@ class Settings: def _surf_source_write_from_xml_element(self, root): elem = root.find('surf_source_write') if elem is not None: - for key in ('surf_ids', 'max_surf_banks'): + for key in ('surface_ids', 'max_surf_banks'): value = get_text(elem, key) if value is not None: - if key == 'surf_ids': + if key == 'surface_ids': value = [int(x) for x in value.split()] elif key in ('max_surf_banks'): value = int(value) diff --git a/src/relaxng/settings.rnc b/src/relaxng/settings.rnc index fcb1d37d8..03c420525 100644 --- a/src/relaxng/settings.rnc +++ b/src/relaxng/settings.rnc @@ -144,8 +144,8 @@ element settings { }? & element surf_source_write { - (element surf_ids { list { xsd:positiveInteger+ } } | - attribute surf_ids { list { xsd:positiveInteger+ } }) & + (element surface_ids { list { xsd:positiveInteger+ } } | + attribute surface_ids { list { xsd:positiveInteger+ } }) & (element max_surf_banks { xsd:positiveInteger } | attribute max_surf_banks { xsd:positiveInteger }) }? & diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng index 3817d6e07..7cc9eb153 100644 --- a/src/relaxng/settings.rng +++ b/src/relaxng/settings.rng @@ -654,14 +654,14 @@ - + - + diff --git a/src/settings.cpp b/src/settings.cpp index c03b3bc99..7c7e13b4a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -647,8 +647,8 @@ void read_settings_xml() xml_node node_ssw = root.child("surf_source_write"); // Determine surface ids at which crossing particles are to be banked - if (check_for_node(node_ssw, "surf_ids")) { - auto temp = get_node_array(node_ssw, "surf_ids"); + if (check_for_node(node_ssw, "surface_ids")) { + auto temp = get_node_array(node_ssw, "surface_ids"); for (const auto& b : temp) { source_write_surf_id.insert(b); } diff --git a/tests/regression_tests/surface_source/inputs_true_write.dat b/tests/regression_tests/surface_source/inputs_true_write.dat index 7451bed5f..858ee21c3 100644 --- a/tests/regression_tests/surface_source/inputs_true_write.dat +++ b/tests/regression_tests/surface_source/inputs_true_write.dat @@ -23,7 +23,7 @@ - 1 + 1 1000 1 diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 959957b73..1cf6641d4 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -46,7 +46,7 @@ def model(request): pt_src = openmc.Source(space=point) openmc_model.settings.source = pt_src - openmc_model.settings.surf_source_write = {'surf_ids': [1], + openmc_model.settings.surf_source_write = {'surface_ids': [1], 'max_surf_banks': 1000} elif surf_src_op == 'read': openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'} diff --git a/tests/unit_tests/test_settings.py b/tests/unit_tests/test_settings.py index 61278fe74..0ecdb7125 100644 --- a/tests/unit_tests/test_settings.py +++ b/tests/unit_tests/test_settings.py @@ -21,7 +21,7 @@ def test_export_to_xml(run_in_tmpdir): 'write': True, 'overwrite': True} s.statepoint = {'batches': [50, 150, 500, 1000]} s.surf_source_read = {'path': 'surface_source_1.h5'} - s.surf_source_write = {'surf_ids': [2], 'max_surf_banks': 200} + s.surf_source_write = {'surface_ids': [2], 'max_surf_banks': 200} s.confidence_intervals = True s.ptables = True s.seed = 17 @@ -79,7 +79,7 @@ def test_export_to_xml(run_in_tmpdir): 'write': True, 'overwrite': True} assert s.statepoint == {'batches': [50, 150, 500, 1000]} assert s.surf_source_read == {'path': 'surface_source_1.h5'} - assert s.surf_source_write == {'surf_ids': [2], 'max_surf_banks': 200} + assert s.surf_source_write == {'surface_ids': [2], 'max_surf_banks': 200} assert s.confidence_intervals assert s.ptables assert s.seed == 17 From 5f48ec9eeba4d338c0ec80eaf6ea7f7809ef3587 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 11:49:02 -0600 Subject: [PATCH 099/103] Rename max_surf_banks to max_particles --- docs/source/io_formats/settings.rst | 2 +- include/openmc/settings.h | 2 +- openmc/settings.py | 16 ++++++++-------- src/relaxng/settings.rnc | 4 ++-- src/relaxng/settings.rng | 4 ++-- src/settings.cpp | 6 +++--- src/simulation.cpp | 2 +- .../surface_source/inputs_true_write.dat | 2 +- tests/regression_tests/surface_source/test.py | 2 +- tests/unit_tests/test_settings.py | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 82414f308..53376b04c 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -751,7 +751,7 @@ This element has the following attributes/sub-elements: *Default*: None - :max_surf_banks: + :max_particles: An integer indicating the maximum number of particles to be banked on specified surfaces per processor. The size of source bank in ``surface_source.h5`` is limited to this value times the number of diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 109255e9f..7030803e9 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -88,7 +88,7 @@ extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, e extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set statepoint_batch; //!< Batches when state should be written extern std::unordered_set source_write_surf_id; //!< Surface ids where sources will be written -extern int64_t max_surf_banks; //!< maximum number of particles to be banked on surfaces per process +extern int64_t max_particles; //!< maximum number of particles to be banked on surfaces per process extern TemperatureMethod temperature_method; //!< method for choosing temperatures extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures extern double temperature_default; //!< Default T in [K] diff --git a/openmc/settings.py b/openmc/settings.py index e069453b7..dc6a799f5 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -152,7 +152,7 @@ class Settings: :surface_ids: List of surface ids at which crossing particles are to be banked (int) - :max_surf_banks: Maximum number of particles to be banked on surfaces + :max_particles: Maximum number of particles to be banked on surfaces per process (int) survival_biasing : bool Indicate whether survival biasing is to be used @@ -604,14 +604,14 @@ class Settings: cv.check_type('surface source writing options', surf_source_write, Mapping) for key, value in surf_source_write.items(): cv.check_value('surface source writing key', key, - ('surface_ids', 'max_surf_banks')) + ('surface_ids', 'max_particles')) if key == 'surface_ids': cv.check_type('surface ids for source banking', value, Iterable, Integral) for surf_id in value: cv.check_greater_than('surface id for source banking', surf_id, 0) - elif key == 'max_surf_banks': + elif key == 'max_particles': cv.check_type('maximum particle banks on surfaces per process', value, Integral) cv.check_greater_than('maximum particle banks on surfaces per process', @@ -954,9 +954,9 @@ class Settings: subelement = ET.SubElement(element, "surface_ids") subelement.text = ' '.join( str(x) for x in self._surf_source_write['surface_ids']) - if 'max_surf_banks' in self._surf_source_write: - subelement = ET.SubElement(element, "max_surf_banks") - subelement.text = str(self._surf_source_write['max_surf_banks']) + if 'max_particles' in self._surf_source_write: + subelement = ET.SubElement(element, "max_particles") + subelement.text = str(self._surf_source_write['max_particles']) def _create_confidence_intervals(self, root): if self._confidence_intervals is not None: @@ -1230,12 +1230,12 @@ class Settings: def _surf_source_write_from_xml_element(self, root): elem = root.find('surf_source_write') if elem is not None: - for key in ('surface_ids', 'max_surf_banks'): + for key in ('surface_ids', 'max_particles'): value = get_text(elem, key) if value is not None: if key == 'surface_ids': value = [int(x) for x in value.split()] - elif key in ('max_surf_banks'): + elif key in ('max_particles'): value = int(value) self.surf_source_write[key] = value diff --git a/src/relaxng/settings.rnc b/src/relaxng/settings.rnc index 03c420525..f9877a3f9 100644 --- a/src/relaxng/settings.rnc +++ b/src/relaxng/settings.rnc @@ -146,8 +146,8 @@ element settings { element surf_source_write { (element surface_ids { list { xsd:positiveInteger+ } } | attribute surface_ids { list { xsd:positiveInteger+ } }) & - (element max_surf_banks { xsd:positiveInteger } | - attribute max_surf_banks { xsd:positiveInteger }) + (element max_particles { xsd:positiveInteger } | + attribute max_particles { xsd:positiveInteger }) }? & element survival_biasing { xsd:boolean }? & diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng index 7cc9eb153..07b8a6d1d 100644 --- a/src/relaxng/settings.rng +++ b/src/relaxng/settings.rng @@ -670,10 +670,10 @@ - + - + diff --git a/src/settings.cpp b/src/settings.cpp index 7c7e13b4a..9df3b8c46 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -101,7 +101,7 @@ RunMode run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; std::unordered_set source_write_surf_id; -int64_t max_surf_banks; +int64_t max_particles; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; double temperature_default {293.6}; @@ -655,8 +655,8 @@ void read_settings_xml() } // Get maximum number of particles to be banked per surface - if (check_for_node(node_ssw, "max_surf_banks")) { - max_surf_banks = std::stoi(get_node_value(node_ssw, "max_surf_banks")); + if (check_for_node(node_ssw, "max_particles")) { + max_particles = std::stoi(get_node_value(node_ssw, "max_particles")); } } diff --git a/src/simulation.cpp b/src/simulation.cpp index 02aac5537..303575130 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -289,7 +289,7 @@ void allocate_banks() if (settings::surf_source_write) { // Allocate surface source bank - simulation::surf_source_bank.reserve(settings::max_surf_banks); + simulation::surf_source_bank.reserve(settings::max_particles); } } diff --git a/tests/regression_tests/surface_source/inputs_true_write.dat b/tests/regression_tests/surface_source/inputs_true_write.dat index 858ee21c3..48dde9900 100644 --- a/tests/regression_tests/surface_source/inputs_true_write.dat +++ b/tests/regression_tests/surface_source/inputs_true_write.dat @@ -24,7 +24,7 @@ 1 - 1000 + 1000 1 diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 1cf6641d4..341a58bdf 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -47,7 +47,7 @@ def model(request): openmc_model.settings.source = pt_src openmc_model.settings.surf_source_write = {'surface_ids': [1], - 'max_surf_banks': 1000} + 'max_particles': 1000} elif surf_src_op == 'read': openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'} diff --git a/tests/unit_tests/test_settings.py b/tests/unit_tests/test_settings.py index 0ecdb7125..7a3357d43 100644 --- a/tests/unit_tests/test_settings.py +++ b/tests/unit_tests/test_settings.py @@ -21,7 +21,7 @@ def test_export_to_xml(run_in_tmpdir): 'write': True, 'overwrite': True} s.statepoint = {'batches': [50, 150, 500, 1000]} s.surf_source_read = {'path': 'surface_source_1.h5'} - s.surf_source_write = {'surface_ids': [2], 'max_surf_banks': 200} + s.surf_source_write = {'surface_ids': [2], 'max_particles': 200} s.confidence_intervals = True s.ptables = True s.seed = 17 @@ -79,7 +79,7 @@ def test_export_to_xml(run_in_tmpdir): 'write': True, 'overwrite': True} assert s.statepoint == {'batches': [50, 150, 500, 1000]} assert s.surf_source_read == {'path': 'surface_source_1.h5'} - assert s.surf_source_write == {'surface_ids': [2], 'max_surf_banks': 200} + assert s.surf_source_write == {'surface_ids': [2], 'max_particles': 200} assert s.confidence_intervals assert s.ptables assert s.seed == 17 From 65e182b6f90b43b66f38384a8a6eebc9d7a5a71b Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 13:26:43 -0600 Subject: [PATCH 100/103] Add missing change on variable name --- tests/regression_tests/surface_source/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 341a58bdf..323a06b60 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -49,7 +49,7 @@ def model(request): openmc_model.settings.surf_source_write = {'surface_ids': [1], 'max_particles': 1000} elif surf_src_op == 'read': - openmc_model.settings.surf_src_read = {'path': 'surface_source_true.h5'} + openmc_model.settings.surf_source_read = {'path': 'surface_source_true.h5'} # Tallies tal = openmc.Tally() From aada8cd26a41eb0602c4c1014373a16ec590ddd7 Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 14:34:58 -0600 Subject: [PATCH 101/103] Remove manual ID specification --- tests/regression_tests/surface_source/test.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 323a06b60..3a0c3cff7 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -23,16 +23,15 @@ def model(request): # - Innermost sphere to bank surface sources # - Second shell to tally cell flux # - Outermost sphere as vacuum boundary - sph_1 = openmc.Sphere(r=1.0, surface_id=1) # Surface to bank/write sources. - sph_2 = openmc.Sphere(r=2.0, surface_id=2) - sph_3 = openmc.Sphere(r=2.5, surface_id=3) - sph_4 = openmc.Sphere(r=4.0, surface_id=4, boundary_type='vacuum') - cell_1 = openmc.Cell(1, region=-sph_1) - cell_2 = openmc.Cell(2, region=+sph_1&-sph_2) - cell_3 = openmc.Cell(3, region=+sph_2&-sph_3) # Cell to tally flux. - cell_4 = openmc.Cell(4, region=+sph_3&-sph_4) - root = openmc.Universe(universe_id=1, - cells=[cell_1, cell_2, cell_3, cell_4]) + sph_1 = openmc.Sphere(r=1.0) # Surface to bank/write sources. + sph_2 = openmc.Sphere(r=2.0) + sph_3 = openmc.Sphere(r=2.5) + sph_4 = openmc.Sphere(r=4.0, boundary_type='vacuum') + cell_1 = openmc.Cell(region=-sph_1) + cell_2 = openmc.Cell(region=+sph_1&-sph_2) + cell_3 = openmc.Cell(region=+sph_2&-sph_3) # Cell to tally flux. + cell_4 = openmc.Cell(region=+sph_3&-sph_4) + root = openmc.Universe(cells=[cell_1, cell_2, cell_3, cell_4]) openmc_model.geometry = openmc.Geometry(root) # Settings From 797a91e6837d2b93b7f62287ccee77f5bc7afa9d Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 14:35:30 -0600 Subject: [PATCH 102/103] Rename marker/variable name --- tests/regression_tests/surface_source/test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 3a0c3cff7..4c6527783 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -10,8 +10,8 @@ from tests.testing_harness import PyAPITestHarness @pytest.fixture def model(request): - marker = request.node.get_closest_marker("surf_src_op") - surf_src_op = marker.args[0] + marker = request.node.get_closest_marker("surf_source_op") + surf_source_op = marker.args[0] openmc_model = openmc.model.Model() @@ -40,14 +40,14 @@ def model(request): openmc_model.settings.batches = 10 openmc_model.settings.seed = 1 - if surf_src_op == 'write': + if surf_source_op == 'write': point = openmc.stats.Point((0, 0, 0)) pt_src = openmc.Source(space=point) openmc_model.settings.source = pt_src openmc_model.settings.surf_source_write = {'surface_ids': [1], 'max_particles': 1000} - elif surf_src_op == 'read': + elif surf_source_op == 'read': openmc_model.settings.surf_source_read = {'path': 'surface_source_true.h5'} # Tallies @@ -108,7 +108,7 @@ class SurfaceSourceTestHarness(PyAPITestHarness): os.remove(fs) -@pytest.mark.surf_src_op('write') +@pytest.mark.surf_source_op('write') def test_surface_source_write(model): harness = SurfaceSourceTestHarness('statepoint.10.h5', model, @@ -116,7 +116,7 @@ def test_surface_source_write(model): harness.main() -@pytest.mark.surf_src_op('read') +@pytest.mark.surf_source_op('read') def test_surface_source_read(model): harness = SurfaceSourceTestHarness('statepoint.10.h5', model, From c689203874b915e36386738cf61d689759eb6fdb Mon Sep 17 00:00:00 2001 From: YoungHui Park Date: Mon, 18 Jan 2021 14:35:54 -0600 Subject: [PATCH 103/103] Add openmc.reset_auto_ids() to reset ID numbers --- tests/regression_tests/surface_source/test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 4c6527783..492ef192e 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -10,6 +10,7 @@ from tests.testing_harness import PyAPITestHarness @pytest.fixture def model(request): + openmc.reset_auto_ids() marker = request.node.get_closest_marker("surf_source_op") surf_source_op = marker.args[0]