Implement user-configurable random number stride (#3067)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
ahman24 2025-03-05 08:26:38 +09:00 committed by GitHub
parent e2557bbe22
commit 239f7fed5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 153 additions and 3 deletions

View file

@ -71,6 +71,7 @@ int openmc_get_nuclide_index(const char name[], int* index);
int openmc_add_unstructured_mesh(
const char filename[], const char library[], int* id);
int64_t openmc_get_seed();
uint64_t openmc_get_stride();
int openmc_get_tally_index(int32_t id, int32_t* index);
void openmc_get_tally_next_id(int32_t* id);
int openmc_global_tallies(double** ptr);
@ -137,6 +138,7 @@ int openmc_reset_timers();
int openmc_run();
int openmc_sample_external_source(size_t n, uint64_t* seed, void* sites);
void openmc_set_seed(int64_t new_seed);
void openmc_set_stride(uint64_t new_stride);
int openmc_set_n_batches(
int32_t n_batches, bool set_max_batches, bool add_statepoint_batch);
int openmc_simulation_finalize();

View file

@ -15,6 +15,7 @@ constexpr int STREAM_SOURCE {1};
constexpr int STREAM_URR_PTABLE {2};
constexpr int STREAM_VOLUME {3};
constexpr int64_t DEFAULT_SEED {1};
constexpr uint64_t DEFAULT_STRIDE {152917ULL};
//==============================================================================
//! Generate a pseudo-random number using a linear congruential generator.
@ -98,5 +99,18 @@ extern "C" int64_t openmc_get_seed();
extern "C" void openmc_set_seed(int64_t new_seed);
//==============================================================================
//! Get OpenMC's stride.
//==============================================================================
extern "C" uint64_t openmc_get_stride();
//==============================================================================
//! Set OpenMC's stride.
//! @param new_stride Stride.
//==============================================================================
extern "C" void openmc_set_stride(uint64_t new_stride);
} // namespace openmc
#endif // OPENMC_RANDOM_LCG_H