Skip to content

Generate Region Plots Directly - #2895

Merged
paulromano merged 5 commits into
openmc-dev:developfrom
pshriwise:region-plot
Apr 12, 2024
Merged

paulromano merged 5 commits into
openmc-dev:developfrom
pshriwise:region-plot

Conversation

@pshriwise

Copy link
Copy Markdown
Contributor

Description

A continuation of #2648, these changes allow regions to be plotted directly without need for a cell definition. A simple region can now be plotted with the following:

import openmc
from matplotlib import pyplot as plt

sphere = openmc.Sphere()
x_plant = openmc.XPlane()
hemisphere = -sphere & +x_plane
hemisphere.plot()
plt.show()

hemisphere

There was a little more nuance here as the color_by, color, legend, and legend_kwargs arguments no longer have meaning at this level of geometry definition, so I've addressed those as best I could for now.

Other

Also cleaned up the openmc.Cell.plot docstring a bit.

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)

@shimwell

shimwell commented Mar 6, 2024

Copy link
Copy Markdown
Member

Nice PR. We might be able to plot everything thing soon 🚀
Region - this PR
Cell - done
Geometry - done
Universe - done
Model - PR #2863

@paulromano paulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@paulromano
paulromano enabled auto-merge (squash) April 11, 2024 13:28
@shimwell

shimwell commented Apr 11, 2024 •

Copy link
Copy Markdown
Member

Looks like that extra assert in the testing picked up an error in the latest CI run.

 >       assert c_after.id + 1 == c_before.id
E       assert (2 + 1) == 1

Comment thread tests/unit_tests/test_region.py Outdated
Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com>
@paulromano
paulromano merged commit 4ba053c into openmc-dev:develop Apr 12, 2024
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
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