Skip to content

Commit

Permalink
Merge 32bd1e5 into 97ba5ee
Browse files Browse the repository at this point in the history
  • Loading branch information
ntouran committed Jun 22, 2022
2 parents 97ba5ee + 32bd1e5 commit e71dbe5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 39 deletions.
65 changes: 26 additions & 39 deletions armi/reactor/blocks.py
Expand Up @@ -269,7 +269,7 @@ def getSmearDensity(self, cold=True):
# Compute component areas
cladID = numpy.mean([clad.getDimension("id", cold=cold) for clad in clads])
innerCladdingArea = (
math.pi * (cladID ** 2) / 4.0 * self.getNumComponents(Flags.FUEL)
math.pi * (cladID**2) / 4.0 * self.getNumComponents(Flags.FUEL)
)
fuelComponentArea = 0.0
unmovableComponentArea = 0.0
Expand Down Expand Up @@ -1921,20 +1921,16 @@ def getSymmetryFactor(self):
# seeing the first one is the easiest way to detect them.
# Check it last in the and statement so we don't waste time doing it.
upperEdgeLoc = self.r.core.spatialGrid[-1, 2, 0]
if (
symmetryLine
in [
grids.BOUNDARY_0_DEGREES,
grids.BOUNDARY_120_DEGREES,
]
and bool(self.r.core.childrenByLocator.get(upperEdgeLoc))
):
if symmetryLine in [
grids.BOUNDARY_0_DEGREES,
grids.BOUNDARY_120_DEGREES,
] and bool(self.r.core.childrenByLocator.get(upperEdgeLoc)):
return 2.0
return 1.0

def getPinCoordinates(self):
"""
Compute the centroid coordinates of any pins in this block.
Compute the local centroid coordinates of any pins in this block.
Returns
-------
Expand All @@ -1944,40 +1940,27 @@ def getPinCoordinates(self):
Notes
-----
This assumes hexagonal pin lattice and needs to be upgraded once more generic geometry
options are needed.
A block with fully-defined pins could just use their individual spatialLocators in a
block-level 2-D grid. However most cases do not have this to minimize overhead and maximize
speed. Thus we want to just come up with a uniform mesh of pins if they're not explicitly
placed in the grid.
options are needed. Only works if pins have clad.
"""
return self._getPinCoordinatesHex()

def _getPinCoordinatesHex(self):
coordinates = []
numPins = self.getNumPins()
numPinRings = hexagon.numRingsToHoldNumCells(numPins)
pinPitch = self.getPinPitch()
if pinPitch is None:
return []
# pin lattice is rotated 30 degrees from assembly lattice
grid = grids.HexGrid.fromPitch(pinPitch, numPinRings, self, pointedEndUp=True)
for ring in range(numPinRings):
for pos in range(grid.getPositionsInRing(ring + 1)):
i, j = grid.getIndicesFromRingAndPos(ring + 1, pos + 1)
xyz = grid[i, j, 0].getLocalCoordinates()
coordinates.append(xyz)
return coordinates
coords = []
for clad in self.getChildrenWithFlags(Flags.CLAD):
if isinstance(clad.spatialLocator, grids.MultiIndexLocation):
coords.extend(
[locator.getLocalCoordinates() for locator in clad.spatialLocator]
)
else:
coords.append(locator.getLocalCoordinates())
return coords

def autoCreateSpatialGrids(self):
"""
Given a block without a spatialGrid, create a spatialGrid and give its children
the corresponding spatialLocators (if it is a simple block).
In this case, a simple block would
be one that has either multiplicity of components equal to 1 or N but no other multiplicities. Also, this should only happen when N fits exactly into a given number of hex rings.
Otherwise, do not create a grid for this block.
In this case, a simple block would be one that has either multiplicity of
components equal to 1 or N but no other multiplicities. Also, this should only
happen when N fits exactly into a given number of hex rings. Otherwise, do not
create a grid for this block.
Notes
-----
Expand All @@ -2002,10 +1985,14 @@ def autoCreateSpatialGrids(self):
)
)

spatialLocators = grids.MultiIndexLocation(grid=self.spatialGrid)
ringNumber = hexagon.numRingsToHoldNumCells(self.getNumPins())
# For the below to work, there must not be multiple wire or multiple clad types.
grid = grids.HexGrid.fromPitch(self.getPinPitch(cold=True), numRings=0)
# note that it's the pointed end of the cell hexes that are up (but the
# macro shape of the pins forms a hex with a flat top fitting in the assembly)
grid = grids.HexGrid.fromPitch(
self.getPinPitch(cold=True), numRings=0, pointedEndUp=True
)
spatialLocators = grids.MultiIndexLocation(grid=self.spatialGrid)
numLocations = 0
for ring in range(ringNumber):
numLocations = numLocations + hexagon.numPositionsInRing(ring + 1)
Expand Down
2 changes: 2 additions & 0 deletions armi/reactor/tests/test_blocks.py
Expand Up @@ -1615,6 +1615,7 @@ def setUp(self):
self.HexBlock.add(
components.DerivedShape("coolant", "Sodium", Tinput=273.0, Thot=273.0)
)
self.HexBlock.autoCreateSpatialGrids()
r = tests.getEmptyHexReactor()
a = makeTestAssembly(1, 1)
a.add(self.HexBlock)
Expand Down Expand Up @@ -1833,6 +1834,7 @@ def test_gridNotCreatedMultipleMultiplicities(self):
# add a wire only some places in the block, so grid should not be created.
wire = components.Helix("wire", "HT9", **wireDims)
self.HexBlock.add(wire)
self.HexBlock.spatialGrid = None # clear existing
with self.assertRaises(ValueError):
self.HexBlock.autoCreateSpatialGrids()

Expand Down

0 comments on commit e71dbe5

Please sign in to comment.