Example #1
0
    def test_recursionPin(self):
        """Ensure pin the center assem has axial coordinates consistent with a pin in an off-center assembly."""
        core = MockArmiObject()
        assem = MockArmiObject(core)
        block = MockArmiObject(assem)

        # 2-D grid
        coreGrid = grids.CartesianGrid.fromRectangle(1.0, 1.0, armiObject=core)
        # 1-D z-mesh
        assemblyGrid = grids.Grid(bounds=(None, None, numpy.arange(5)),
                                  armiObject=assem)
        # pins sit in this 2-D grid.
        blockGrid = grids.CartesianGrid.fromRectangle(0.1,
                                                      0.1,
                                                      armiObject=block)

        coreLoc = grids.CoordinateLocation(0.0, 0.0, 0.0, None)
        core.spatialLocator = coreLoc
        assemblyLoc = grids.IndexLocation(0, 0, 0, coreGrid)
        assem.spatialLocator = assemblyLoc
        blockLoc = grids.IndexLocation(0, 0, 3, assemblyGrid)
        block.spatialLocator = blockLoc
        pinIndexLoc = grids.IndexLocation(1, 5, 0, blockGrid)

        assert_allclose(pinIndexLoc.getCompleteIndices(), (1, 5, 0))
Example #2
0
    def test_locationPackingOldVersion(self):
        # pylint: disable=protected-access
        version = 3

        loc1 = grids.IndexLocation(1, 2, 3, None)
        loc2 = grids.CoordinateLocation(4.0, 5.0, 6.0, None)
        loc3 = grids.MultiIndexLocation(None)
        loc3.append(grids.IndexLocation(7, 8, 9, None))
        loc3.append(grids.IndexLocation(10, 11, 12, None))

        locs = [loc1, loc2, loc3]
        tp, data = database3._packLocations(locs, minorVersion=version)

        self.assertEqual(tp[0], "I")
        self.assertEqual(tp[1], "C")
        self.assertEqual(tp[2], "M:2")

        unpackedData = database3._unpackLocations(tp,
                                                  data,
                                                  minorVersion=version)

        self.assertEqual(unpackedData[0], (1, 2, 3))
        self.assertEqual(unpackedData[1], (4.0, 5.0, 6.0))
        self.assertEqual(unpackedData[2][0], (7, 8, 9))
        self.assertEqual(unpackedData[2][1], (10, 11, 12))
Example #3
0
    def test_recursion(self):
        """
        Make sure things work as expected with a chain of locators/grids/locators.

        This makes a Cartesian-like reactor out of unit cubes. The origin
        is in the center of the central cube radially and the bottom axially due
        to the different way steps and bounds are set up.
        """

        core = MockArmiObject()
        assem = MockArmiObject(core)
        block = MockArmiObject(assem)

        # build meshes just like how they're used on a regular system.
        coreGrid = grids.CartesianGrid.fromRectangle(
            1.0, 1.0, armiObject=core
        )  # 2-D grid
        # 1-D z-mesh
        assemblyGrid = grids.Grid(
            bounds=(None, None, numpy.arange(5)), armiObject=assem
        )
        # pins sit in this 2-D grid.
        blockGrid = grids.CartesianGrid.fromRectangle(0.1, 0.1, armiObject=block)

        coreLoc = grids.CoordinateLocation(0.0, 0.0, 0.0, None)
        core.spatialLocator = coreLoc

        assemblyLoc = grids.IndexLocation(2, 3, 0, coreGrid)
        assem.spatialLocator = assemblyLoc

        blockLoc = grids.IndexLocation(0, 0, 3, assemblyGrid)
        block.spatialLocator = blockLoc

        pinIndexLoc = grids.IndexLocation(1, 5, 0, blockGrid)
        pinFree = grids.CoordinateLocation(1.0, 2.0, 3.0, blockGrid)

        assert_allclose(blockLoc.getCompleteIndices(), numpy.array((2, 3, 3)))
        assert_allclose(blockLoc.getGlobalCoordinates(), (2.0, 3.0, 3.5))
        assert_allclose(blockLoc.getGlobalCellBase(), (1.5, 2.5, 3))
        assert_allclose(blockLoc.getGlobalCellTop(), (2.5, 3.5, 4))

        # check coordinates of pins in block
        assert_allclose(
            pinFree.getGlobalCoordinates(), (2.0 + 1.0, 3.0 + 2.0, 3.5 + 3.0)
        )  # epic
        assert_allclose(
            pinIndexLoc.getGlobalCoordinates(), (2.0 + 0.1, 3.0 + 0.5, 3.5)
        )  # wow

        # pin indices should not combine with the parent indices.
        assert_allclose(pinIndexLoc.getCompleteIndices(), (1, 5, 0))
Example #4
0
 def test_blockName(self):
     block = blocks.HexBlock("blockName")
     block.spatialLocator = grids.IndexLocation(0, 0, 7, None)
     self.assertEqual(
         self.history._getBlockHistoryFileName(block),  # pylint:disable=protected-access
         "{}-blockName7-bHist.txt".format(self.history.cs.caseTitle),
     )
Example #5
0
    def test_locationPacking(self):
        # pylint: disable=protected-access
        loc1 = grids.IndexLocation(1, 2, 3, None)
        loc2 = grids.CoordinateLocation(4.0, 5.0, 6.0, None)
        loc3 = grids.MultiIndexLocation(None)
        loc3.append(grids.IndexLocation(7, 8, 9, None))
        loc3.append(grids.IndexLocation(10, 11, 12, None))

        locs = [loc1, loc2, loc3]
        tp, data = database3._packLocations(locs)

        self.assertEqual(tp[0], database3.LOC_INDEX)
        self.assertEqual(tp[1], database3.LOC_COORD)
        self.assertEqual(tp[2], database3.LOC_MULTI + "2")

        unpackedData = database3._unpackLocations(tp, data)

        self.assertEqual(unpackedData[0], (1, 2, 3))
        self.assertEqual(unpackedData[1], (4.0, 5.0, 6.0))
        self.assertEqual(unpackedData[2], [(7, 8, 9), (10, 11, 12)])
Example #6
0
    def test_locationPacking(self):
        # pylint: disable=protected-access
        loc1 = grids.IndexLocation(1, 2, 3, None)
        loc2 = grids.CoordinateLocation(4.0, 5.0, 6.0, None)
        loc3 = grids.MultiIndexLocation(None)
        loc3.append(grids.IndexLocation(7, 8, 9, None))
        loc3.append(grids.IndexLocation(10, 11, 12, None))

        tp, data = database._packLocation(loc1)
        self.assertEqual(tp, database.LOC_INDEX)
        unpacked = database._unpackLocation([tp], data)
        self.assertEqual(unpacked[0], (1, 2, 3))

        tp, data = database._packLocation(loc2)
        self.assertEqual(tp, database.LOC_COORD)
        unpacked = database._unpackLocation([tp], data)
        self.assertEqual(unpacked[0], (4.0, 5.0, 6.0))

        tp, data = database._packLocation(loc3)
        self.assertEqual(tp, database.LOC_MULTI + "2")
        unpacked = database._unpackLocation([tp], data)
        self.assertEqual(unpacked[0], (7, 8, 9))
Example #7
0
 def test_add(self):
     loc1 = grids.IndexLocation(1, 2, 0, None)
     loc2 = grids.IndexLocation(2, 2, 0, None)
     self.assertEqual(loc1 + loc2, grids.IndexLocation(3, 4, 0, None))