Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make random number stride user-configurable #2993

Open
paulromano opened this issue May 8, 2024 · 3 comments · May be fixed by #3067
Open

Make random number stride user-configurable #2993

paulromano opened this issue May 8, 2024 · 3 comments · May be fixed by #3067

Comments

@paulromano
Copy link
Contributor

Description

Several papers/reports in the literature have documented that the limited PRNG stride in Monte Carlo codes can negatively impact results. For example, see the paper by Hakim and Fynan as well as the recent technical report by @cjosey. Currently, OpenMC uses a fixed stride of 152,917:

constexpr uint64_t prn_stride {152917LL}; // stride between particles

For some problems (highly scattering media, deep penetration fixed source with variance reduction, subcritical multiplication with k close to 1), the stride in OpenMC would be easily exceeded, which calls into question the reliability of the results. At a minimum, we should allow the stride to be user-configurable so that for these types of problems, one can at least choose a longer stride.

Other Considerations

Since the total period of the PRNG is fixed, picking a longer stride means that the effective period between source particles is reduced. Longer term, for very large problems we probably ought to adopt a PRNG with a longer period to handle problems with lots of source particles.

Compatibility

We can make the stride user-configurable while maintaining the default value, which means there won't be any compatibility issues or changes in test results.

@ahman24
Copy link

ahman24 commented Jun 21, 2024

Hi Paul, I am Arief the first author of the article.

Can I take a go at this?
We have a local branch already implemented this feature and initially planned to submit a PR (feature + theories) after the article is published.

@ethankrammer
Copy link
Contributor

Hi @ahman24, it was great to discuss this with Dr. Fynan at the latest ANS meeting! If you haven't already implemented it, it may also be useful to print a warning to the user if the stride is exceeded.

@ahman24 ahman24 linked a pull request Jul 3, 2024 that will close this issue
5 tasks
@ahman24
Copy link

ahman24 commented Jul 3, 2024

Hi @ethankrammer,

We already had a local branch that implements random number usage counter and throw warning whenever the stride is exceeded, but I am currently on a vacation. For now, we will submit a PR only for user-configurable stride and submit a follow up PR later after my vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants