diff --git a/examples/python/basic/build-xml.py b/examples/python/basic/build-xml.py index fb850f3ad..865740e13 100644 --- a/examples/python/basic/build-xml.py +++ b/examples/python/basic/build-xml.py @@ -1,5 +1,5 @@ import openmc - +from openmc.region import Intersection ############################################################################### # Simulation Input File Parameters @@ -55,11 +55,10 @@ cell3 = openmc.Cell(cell_id=101, name='cell 3') cell4 = openmc.Cell(cell_id=2, name='cell 4') # Register Surfaces with Cells -cell1.add_surface(surface=surf2, halfspace=-1) -cell2.add_surface(surface=surf1, halfspace=-1) -cell3.add_surface(surface=surf1, halfspace=+1) -cell4.add_surface(surface=surf2, halfspace=+1) -cell4.add_surface(surface=surf3, halfspace=-1) +cell1.region = surf2.negative +cell2.region = surf1.negative +cell3.region = surf1.positive +cell4.region = Intersection(surf2.positive, surf3.negative) # Register Materials with Cells cell2.fill = fuel diff --git a/examples/python/lattice/hexagonal/build-xml.py b/examples/python/lattice/hexagonal/build-xml.py index 5cf8eed06..b042e830a 100644 --- a/examples/python/lattice/hexagonal/build-xml.py +++ b/examples/python/lattice/hexagonal/build-xml.py @@ -1,4 +1,5 @@ import openmc +from openmc.region import Intersection ############################################################################### @@ -68,14 +69,12 @@ cell5 = openmc.Cell(cell_id=600, name='cell 5') cell6 = openmc.Cell(cell_id=601, name='cell 6') # Register Surfaces with Cells -cell1.add_surface(left, halfspace=+1) -cell1.add_surface(right, halfspace=-1) -cell1.add_surface(bottom, halfspace=+1) -cell1.add_surface(top, halfspace=-1) -cell2.add_surface(fuel_surf, halfspace=-1) -cell3.add_surface(fuel_surf, halfspace=+1) -cell5.add_surface(fuel_surf, halfspace=-1) -cell6.add_surface(fuel_surf, halfspace=+1) +cell1.region = Intersection(left.positive, right.negative, + bottom.positive, top.negative) +cell2.region = fuel_surf.negative +cell3.region = fuel_surf.positive +cell5.region = fuel_surf.negative +cell6.region = fuel_surf.positive # Register Materials with Cells cell2.fill = fuel diff --git a/examples/python/lattice/nested/build-xml.py b/examples/python/lattice/nested/build-xml.py index 24b5554c0..f4bc7d1ac 100644 --- a/examples/python/lattice/nested/build-xml.py +++ b/examples/python/lattice/nested/build-xml.py @@ -1,4 +1,5 @@ import openmc +from openmc.region import Intersection ############################################################################### @@ -67,20 +68,16 @@ cell7 = openmc.Cell(cell_id=301, name='cell 7') cell8 = openmc.Cell(cell_id=302, name='cell 8') # Register Surfaces with Cells -cell1.add_surface(left, halfspace=+1) -cell1.add_surface(right, halfspace=-1) -cell1.add_surface(bottom, halfspace=+1) -cell1.add_surface(top, halfspace=-1) -cell2.add_surface(left, halfspace=+1) -cell2.add_surface(right, halfspace=-1) -cell2.add_surface(bottom, halfspace=+1) -cell2.add_surface(top, halfspace=-1) -cell3.add_surface(fuel1, halfspace=-1) -cell4.add_surface(fuel1, halfspace=+1) -cell5.add_surface(fuel2, halfspace=-1) -cell6.add_surface(fuel2, halfspace=+1) -cell7.add_surface(fuel3, halfspace=-1) -cell8.add_surface(fuel3, halfspace=+1) +cell1.region = Intersection(left.positive, right.negative, + bottom.positive, top.negative) +cell2.region = Intersection(left.positive, right.negative, + bottom.positive, top.negative) +cell3.region = fuel1.negative +cell4.region = fuel1.positive +cell5.region = fuel2.negative +cell6.region = fuel2.positive +cell7.region = fuel3.negative +cell8.region = fuel3.positive # Register Materials with Cells cell3.fill = fuel diff --git a/examples/python/lattice/simple/build-xml.py b/examples/python/lattice/simple/build-xml.py index 57e1f1729..155cfa1cb 100644 --- a/examples/python/lattice/simple/build-xml.py +++ b/examples/python/lattice/simple/build-xml.py @@ -1,5 +1,5 @@ import openmc - +from openmc.region import Intersection ############################################################################### # Simulation Input File Parameters @@ -65,17 +65,15 @@ cell5 = openmc.Cell(cell_id=202, name='cell 5') cell6 = openmc.Cell(cell_id=301, name='cell 6') cell7 = openmc.Cell(cell_id=302, name='cell 7') -# Register Surfaces with Cells -cell1.add_surface(left, halfspace=+1) -cell1.add_surface(right, halfspace=-1) -cell1.add_surface(bottom, halfspace=+1) -cell1.add_surface(top, halfspace=-1) -cell2.add_surface(fuel1, halfspace=-1) -cell3.add_surface(fuel1, halfspace=+1) -cell4.add_surface(fuel2, halfspace=-1) -cell5.add_surface(fuel2, halfspace=+1) -cell6.add_surface(fuel3, halfspace=-1) -cell7.add_surface(fuel3, halfspace=+1) +# Register Regions with Cells +cell1.region = Intersection(left.positive, right.negative, + bottom.positive, top.negative) +cell2.region = fuel1.negative +cell3.region = fuel1.positive +cell4.region = fuel2.negative +cell5.region = fuel2.positive +cell6.region = fuel3.negative +cell7.region = fuel3.positive # Register Materials with Cells cell2.fill = fuel diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index fc9663b90..d37024db3 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -1,5 +1,5 @@ import openmc - +from openmc.region import Intersection ############################################################################### # Simulation Input File Parameters @@ -133,16 +133,11 @@ clad = openmc.Cell(cell_id=3, name='cell 3') water = openmc.Cell(cell_id=4, name='cell 4') # Register Surfaces with Cells -fuel.add_surface(fuel_or, halfspace=-1) -gap.add_surface(fuel_or, halfspace=+1) -gap.add_surface(clad_ir, halfspace=-1) -clad.add_surface(clad_ir, halfspace=+1) -clad.add_surface(clad_or, halfspace=-1) -water.add_surface(clad_or, halfspace=+1) -water.add_surface(left, halfspace=+1) -water.add_surface(right, halfspace=-1) -water.add_surface(bottom, halfspace=+1) -water.add_surface(top, halfspace=-1) +fuel.region = fuel_or.negative +gap.region = Intersection(fuel_or.positive, clad_ir.negative) +clad.region = Intersection(clad_ir.positive, clad_or.negative) +water.region = Intersection(clad_or.positive, left.positive, right.negative, + bottom.positive, top.negative) # Register Materials with Cells fuel.fill = uo2 diff --git a/examples/python/reflective/build-xml.py b/examples/python/reflective/build-xml.py index 9a182903e..5a3e861e6 100644 --- a/examples/python/reflective/build-xml.py +++ b/examples/python/reflective/build-xml.py @@ -1,5 +1,5 @@ import openmc - +from openmc.region import Intersection ############################################################################### # Simulation Input File Parameters @@ -52,13 +52,10 @@ surf6.boundary_type = 'reflective' # Instantiate Cell cell = openmc.Cell(cell_id=1, name='cell 1') -# Register Surfaces with Cell -cell.add_surface(surface=surf1, halfspace=+1) -cell.add_surface(surface=surf2, halfspace=-1) -cell.add_surface(surface=surf3, halfspace=+1) -cell.add_surface(surface=surf4, halfspace=-1) -cell.add_surface(surface=surf5, halfspace=+1) -cell.add_surface(surface=surf6, halfspace=-1) +# Register Region with Cell +cell.region = Intersection(surf1.positive, surf2.negative, + surf3.positive, surf4.negative, + surf5.positive, surf6.negative) # Register Material with Cell cell.fill = fuel diff --git a/openmc/universe.py b/openmc/universe.py index 79cb90fd0..e9a693bc4 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -327,8 +327,8 @@ class Cell(object): self._fill.create_xml_subelement(xml_element) if self.region is not None: - # Set the surfaces attribute with the region specification - element.set("surfaces", str(self.region)) + # Set the region attribute with the region specification + element.set("region", str(self.region)) # Only surfaces that appear in a region are added to the geometry # file, so the appropriate check is performed here. First we create