예제 #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))
예제 #2
0
파일: test_grids.py 프로젝트: ntouran/armi
    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))
예제 #3
0
    def testBasicPosition(self):
        """
        Ensure a basic Cartesian grid works as expected.

        The default stepped grid defines zero at the center of the (0,0,0)th cell.
        Its centroid is 0., 0., 0). This convention is nicely compatible with 120-degree hex grid.

        Full core Cartesian meshes will want to be shifted to bottom left of 0th cell.
        """
        grid = grids.Grid(unitSteps=((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)))
        assert_allclose(grid.getCoordinates((1, 1, 1)), (1, 1, 1))
        assert_allclose(grid.getCoordinates((0, 0, 0)), (0.0, 0.0, 0.0))
        assert_allclose(grid.getCoordinates((0, 0, -1)), (0, 0, -1))
        assert_allclose(grid.getCoordinates((1, 0, 0)), (1, 0, 0))
예제 #4
0
    def test_recursionPin(self):
        """Ensure pin the center assem has axial coordinates consistent with a pin in an off-center assembly."""
        reactorGrid = grids.cartesianGridFromRectangle(1.0, 1.0)  # 2-D grid
        assemblyGrid = grids.Grid(bounds=(None, None, numpy.arange(5)))  # 1-D z-mesh
        blockGrid = grids.cartesianGridFromRectangle(
            0.1, 0.1
        )  # pins sit in this 2-D grid.

        reactorLoc = grids.CoordinateLocation(0.0, 0.0, 0.0, None)
        assemblyLoc = MockLocator(0, 0, 0, reactorGrid)
        blockLoc = MockLocator(0, 0, 3, assemblyGrid)
        pinIndexLoc = MockLocator(1, 5, 0, blockGrid)

        pinIndexLoc._parent = blockLoc
        blockLoc._parent = assemblyLoc
        assemblyLoc._parent = reactorLoc

        assert_allclose(pinIndexLoc.getCompleteIndices(), (1, 5, 0))
예제 #5
0
 def test_getIndexBounds(self):
     grid = grids.Grid(bounds=([0, 1, 2, 3, 4], [0, 10, 20, 50], [0, 20, 60, 90]))
     boundsIJK = grid.getIndexBounds()
     self.assertEqual(boundsIJK, ((0, 5), (0, 4), (0, 4)))
예제 #6
0
 def testPositionsMixedDefinition(self):
     grid = grids.Grid(
         unitSteps=((1.0, 0.0), (0.0, 1.0)), bounds=(None, None, [0, 20, 60, 90])
     )
     assert_allclose(grid.getCoordinates((1, 1, 1)), (1, 1, 40.0))
예제 #7
0
 def testBase(self):
     grid = grids.Grid(bounds=([0, 1, 2, 3, 4], [0, 10, 20, 50], [0, 20, 60, 90]))
     assert_allclose(grid.getCellBase((1, 1, 1)), (1.0, 10.0, 20.0))
예제 #8
0
 def testPositions(self):
     grid = grids.Grid(bounds=([0, 1, 2, 3, 4], [0, 10, 20, 50], [0, 20, 60, 90]))
     assert_allclose(grid.getCoordinates((1, 1, 1)), (1.5, 15.0, 40.0))
예제 #9
0
 def testLabel(self):
     grid = grids.Grid(unitSteps=((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)))
     self.assertEqual(grid.getLabel((1, 1, 2)), "A1001C")
예제 #10
0
 def testNeighbors(self):
     grid = grids.Grid(unitSteps=((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)))
     neighbs = grid.getNeighboringCellIndices(0, 0, 0)
     self.assertEqual(len(neighbs), 4)
예제 #11
0
Learn more about :py:mod:`grids <armi.reactor.grids>`.
"""
import itertools
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

from armi.reactor import grids

import armi

armi.configure()

fig = plt.figure()
zCoords = [1, 4, 8]
cartesian_grid = grids.Grid(
    unitSteps=((1, 0), (0, 1)),
    bounds=(None, None, zCoords),
    offset=(10, 5, 5),
)
xyz = []

# the grid is infinite in i and j so we will just plot the first 10 items
for i, j, k in itertools.product(range(10), range(10),
                                 range(len(zCoords) - 1)):
    xyz.append(cartesian_grid[i, j, k].getGlobalCoordinates())
ax = fig.add_subplot(1, 1, 1, projection="3d")
x, y, z = zip(*xyz)
ax.scatter(x, y, z)
plt.show()