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

allowing varible offsets for polygon.offset #3120

Merged

Conversation

shimwell
Copy link
Member

Description

This PR allows the polygon offset distance to be an iterable of values for a non constant offset. I hear this is useful for stellerators :-)

varible_offset_poly

Checklist

  • I have performed a self-review of my own code
  • 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)

example script

import openmc
import numpy as np
import matplotlib.pyplot as plt

star = np.array(
    [
        [1.0, 2.0],
        [0.70610737, 1.4045085],
        [0.04894348, 1.30901699],
        [0.52447174, 0.8454915],
        [0.41221475, 0.19098301],
        [1.0, 0.5],
        [1.58778525, 0.19098301],
        [1.47552826, 0.8454915],
        [1.95105652, 1.30901699],
        [1.29389263, 1.4045085],
        [1.0, 2.0],
    ]
)

surf_poly = openmc.model.Polygon(star, basis="rz")
surf_poly2 = surf_poly.offset(
    [
        0.5,
        0.1,
        0.1,
        0.1,
        0.1,
        1.0,
        0.1,
        0.1,
        0.1,
        0.1,
    ]
)

region_poly = -surf_poly
region_poly2 = -surf_poly2 & +surf_poly

cell_poly = openmc.Cell(region=region_poly)
cell_poly2 = openmc.Cell(region=region_poly2)

my_geometry = openmc.Geometry([cell_poly, cell_poly2])
my_geometry.plot(basis="yz", width=(8, 8), color_by="cell")

plt.show()

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

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

Thanks @shimwell!

@paulromano paulromano enabled auto-merge (squash) November 8, 2024 21:53
@paulromano paulromano merged commit 9983ee1 into openmc-dev:develop Nov 8, 2024
15 checks passed
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.

2 participants