AttributeError: module 'openmc' has no attribute 'BoundingBox'

Hello! I am trying to use a bounding box to create slabs, but I’m having some issues as it doesn’t seem to be recognized. After going through some documentation, I’m also finding bounding boxes with different names (BoundingBox versus bounding_box). I’ve tried both and they output the same error. I’ve tried accessing the bounding_box attribute, and that seems to work, so I don’t know what the issue is. I’m currently on version 0.13.3, is there any way to get around this problem?

import openmc
sphere = openmc.Sphere(r=5.0)
cell = openmc.Cell(fill=None, region=-sphere)

lower_left, upper_right = cell.region.bounding_box
print(lower_left)
print(upper_right)
box = openmc.bounding_box(lower_left, upper_right)

Output:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 8
      6 print(lower_left)
      7 print(upper_right)
----> 8 box = openmc.bounding_box(lower_left, upper_right)

AttributeError: module 'openmc' has no attribute 'bounding_box'

The .bounding_box is a method you can call on openmc.Cell, openmc.Region or openmc.Geometry objects. It returns a openmc.BoundingBox class object.

The openmc.BoundingBox class object behaves like a python tuple with extra methods. The first tuple entry is the lower left and the second is the upper right. The class has a few extra methods like extend.

I don’t normally use the bounding box to contruct geoemtry, rather to know how big the already constructed geometry is

What I’m essentially trying to do with a bounding box is create a finite rectangular prism. Is that not the correct use for it? Are there any other ways to create finite boxes in OpenMC?

Perhaps this is what you are looking for

https://docs.openmc.org/en/stable/pythonapi/generated/openmc.model.RectangularParallelepiped.html

1 Like

Not sure how I missed this. Thank you so much.