Skip to content

Conversation

@paulromano
Copy link
Contributor

Description

This PR extends the Normal distribution class to support optional truncation bounds. Normal distributions are sometimes used for source sampling, but their infinite support makes them problematic for biased sampling. OpenMC currently does not let you use a normal distribution as a bias for another distribution with finite support because of the mismatched domains. Truncation allows the normal distribution to be restricted to match the support of the target distribution. A truncated normal is simply specified by passing one or both of the lower and upper arguments. Without these arguments, the untruncated behavior is preserved.

Thanks to @akoen for inspiration!

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Copy link
Contributor

@j-fletcher j-fletcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! It all seems to be working; there's only one quirk I found which is that booleans can be provided as the upper/lower bounds, which are counted as valid alternatives to 0.0 or 1.0 in the support of the distribution, but upon exporting to C++ via XML causes the distribution to silently become un-truncated. I don't think we have to worry too much about it though.

Copy link
Contributor

@GuySten GuySten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@GuySten GuySten merged commit 8198e60 into openmc-dev:develop Feb 12, 2026
17 checks passed
@paulromano paulromano deleted the truncated-normal branch February 12, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants