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

Ensure particle direction is normalized for plotting / volume calculations #2816

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

paulromano
Copy link
Contributor

Description

When generating a plot or running a volume calculation, OpenMC repeatedly makes calls to exhaustive_find_cell to determine which cell/material contains a given point. For CSG geometries, the direction of the particle isn't actually used when performing the "find cell" operation and so the value that is assigned is currently some arbitrary value: {0.7071, 0.7071, 0.} for plotting and {0.5, 0.5, 0.5} for volume calculations. However, for DAGMC geometries, the direction is used for ray-fire operations to determine which volume contains a given point:

rval = dagmc_ptr_->point_in_volume(vol, pnt, result, dir);

It turns out that MOAB expects the direction being passed to be properly normalized, so the values above cause problems. In particular, if you've compiled OpenMC with DAGMC support and are not using double-down, volume calculations give incorrect results. By ensuring that the arbitrary direction assigned to the particle is normalized before sending to MOAB, the incorrect volume calculation results are fixed.

I also noticed that this fixes some plotting artifacts that are observed when using the plotter. For example, here's a snapshot of a DAGMC geometry without and with the fix from this PR:

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

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

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

Looks like a nice update to me. Thanks @paulromano! I like the way you've approached ensuring normalization of the particle direction here.

@pshriwise pshriwise merged commit 2e4811b into openmc-dev:develop Dec 28, 2023
18 checks passed
@paulromano paulromano deleted the normalize-plot-direction branch January 4, 2024 03:26
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants