mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Implement new fixed source bank model for custom library source. Additional non-member functions in source.cpp with function pointer saved in model namespace allow custom library to be opened, sampled as needed in initialize_history and closed.
This commit is contained in:
parent
0ae1077a39
commit
907459d02f
3 changed files with 65 additions and 30 deletions
|
|
@ -112,6 +112,12 @@ int openmc_simulation_init()
|
|||
}
|
||||
}
|
||||
|
||||
// If fixed source and using custom source library then need to load
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE &&
|
||||
!settings::path_source_library.empty()) {
|
||||
load_custom_source_library();
|
||||
}
|
||||
|
||||
// Display header
|
||||
if (mpi::master) {
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE) {
|
||||
|
|
@ -158,6 +164,12 @@ int openmc_simulation_finalize()
|
|||
t->active_ = false;
|
||||
}
|
||||
|
||||
// If fixed source and using custom source library then need to close
|
||||
if (settings::run_mode == RunMode::FIXED_SOURCE &&
|
||||
!settings::path_source_library.empty()) {
|
||||
close_custom_source_library();
|
||||
}
|
||||
|
||||
// Stop timers and show timing statistics
|
||||
simulation::time_finalize.stop();
|
||||
simulation::time_total.stop();
|
||||
|
|
@ -444,8 +456,13 @@ void initialize_history(Particle* p, int64_t index_source)
|
|||
int64_t id = (simulation::total_gen + overall_generation() - 1)*settings::n_particles +
|
||||
simulation::work_index[mpi::rank] + index_source;
|
||||
uint64_t seed = init_seed(id, STREAM_SOURCE);
|
||||
// sample external source distribution then set
|
||||
Particle::Bank site = sample_external_source(&seed);
|
||||
// sample from external source distribution or custom library then set
|
||||
Particle::Bank site;
|
||||
if (!settings::path_source_library.empty()) {
|
||||
site = sample_custom_source_library(&seed);
|
||||
} else {
|
||||
site = sample_external_source(&seed);
|
||||
}
|
||||
p->from_source(&site);
|
||||
} else if (settings::run_mode == RunMode::EIGENVALUE) {
|
||||
// set defaults for eigenvalue simulations from primary bank
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue