Esempio n. 1
0
def get_openmoc_region(openmc_region):
    """Return an OpenMOC region corresponding to an OpenMC region.

    Parameters
    ----------
    openmc_region : openmc.Region
        OpenMC region

    Returns
    -------
    openmoc_region : openmoc.Region
        Equivalent OpenMOC region

    """

    cv.check_type('openmc_region', openmc_region, openmc.Region)

    # Recursively instantiate a region of the appropriate type
    if isinstance(openmc_region, openmc.Halfspace):
        surface = openmc_region.surface
        halfspace = -1 if openmc_region.side == '-' else 1
        openmoc_region = \
            openmoc.Halfspace(halfspace, get_openmoc_surface(surface))
    elif isinstance(openmc_region, openmc.Intersection):
        openmoc_region = openmoc.Intersection()
        for openmc_node in openmc_region:
            openmoc_region.addNode(get_openmoc_region(openmc_node))
    elif isinstance(openmc_region, openmc.Union):
        openmoc_region = openmoc.Union()
        for openmc_node in openmc_region:
            openmoc_region.addNode(get_openmoc_region(openmc_node))
    elif isinstance(openmc_region, openmc.Complement):
        openmoc_region = openmoc.Complement()
        openmoc_region.addNode(get_openmoc_region(openmc_region.node))

    return openmoc_region
Esempio n. 2
0
    def test_complement(self):

        complement = openmoc.Complement()
        intersection = openmoc.Intersection()

        # Define surfaces
        p1x = openmoc.XPlane(x=3)
        p2x = openmoc.XPlane(x=-2)
        p1y = openmoc.YPlane(y=1)
        p2y = openmoc.YPlane(y=-0.5)
        p1z = openmoc.ZPlane(z=8)
        p2z = openmoc.ZPlane(z=-4)

        # Define boundary types
        p1x.setBoundaryType(openmoc.VACUUM)
        p2x.setBoundaryType(openmoc.REFLECTIVE)
        p1y.setBoundaryType(openmoc.PERIODIC)
        p2y.setBoundaryType(openmoc.REFLECTIVE)
        p1z.setBoundaryType(openmoc.PERIODIC)
        p2z.setBoundaryType(openmoc.VACUUM)

        # Define halfspaces
        h1x = openmoc.Halfspace(-1, p1x)
        h2x = openmoc.Halfspace(+1, p2x)
        h1y = openmoc.Halfspace(-1, p1y)
        h2y = openmoc.Halfspace(+1, p2y)
        h1z = openmoc.Halfspace(-1, p1z)
        h2z = openmoc.Halfspace(+1, p2z)

        # Add halfspaces
        intersection.addNode(h1x)
        intersection.addNode(h2x)
        intersection.addNode(h1y)
        intersection.addNode(h2y)
        intersection.addNode(h1z)
        intersection.addNode(h2z)
        complement.addNode(intersection)

        # Test getMaxXYZ + MaxXYZboundary
        #FIXME Implement boundary type getter for complement regions
        self.assertEqual(complement.getMaxX(), 3)
        with self.assertRaises(Exception):
            self.assertEqual(complement.getMaxXBoundaryType(), openmoc.VACUUM)
        self.assertEqual(complement.getMaxY(), 1)
        with self.assertRaises(Exception):
            self.assertEqual(complement.getMaxYBoundaryType(),
                             openmoc.PERIODIC)
        self.assertEqual(complement.getMaxZ(), 8)
        with self.assertRaises(Exception):
            self.assertEqual(complement.getMaxZBoundaryType(),
                             openmoc.PERIODIC)

        # Test getMinXYZ + MinXYZboundary
        self.assertEqual(complement.getMinX(), -2)
        with self.assertRaises(Exception):
            self.assertEqual(complement.getMinXBoundaryType(),
                             openmoc.REFLECTIVE)
        self.assertEqual(complement.getMinY(), -0.5)
        with self.assertRaises(Exception):
            self.assertEqual(complement.getMinYBoundaryType(),
                             openmoc.REFLECTIVE)
        self.assertEqual(complement.getMinZ(), -4)
        with self.assertRaises(Exception):
            self.assertEqual(complement.getMinZBoundaryType(), openmoc.VACUUM)
Esempio n. 3
0
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating surfaces...')

boundary = openmoc.RectangularPrism(4., 4.)
boundary.setBoundaryType(openmoc.PERIODIC)

zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.3, name='fuel pin')

###############################################################################
#                            Creating Grid Spacer
###############################################################################

outer_box = openmoc.RectangularPrism(1.00, 1.00)
inner_box = openmoc.RectangularPrism(0.96, 0.96)
inner_complement = openmoc.Complement()
inner_complement.addNode(inner_box)

grid_spacer_region = openmoc.Intersection()
grid_spacer_region.addNode(outer_box)
grid_spacer_region.addNode(inner_complement)

###############################################################################
#                             Creating Cells
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating cells...')

fuel = openmoc.Cell(name='fuel')
fuel.setNumRings(3)
fuel.setNumSectors(8)