Skip to content

Commit

Permalink
Merge 06b4612 into 108e321
Browse files Browse the repository at this point in the history
  • Loading branch information
onufer committed Apr 23, 2020
2 parents 108e321 + 06b4612 commit 5e7b7f1
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 63 deletions.
56 changes: 13 additions & 43 deletions armi/reactor/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,6 @@ def add(self, c):
if self.p.percentBuByPin is None or len(self.p.percentBuByPin) < mult:
# this may be a little wasteful, but we can fix it later...
self.p.percentBuByPin = [0.0] * mult

self._updatePitchComponent(c)

def addComponent(self, c):
Expand Down Expand Up @@ -1846,20 +1845,16 @@ def getPitch(self, returnComp=False):
setPitch : sets pitch
"""
c, p = self._pitchDefiningComponent
c, _p = self._pitchDefiningComponent

# Admittedly awkward here, but allows for a clean comparison when adding components to the
# block as opposed to initializing _pitchDefiningComponent to (None, None)
if c is None:
p = None
else:
# ask component for dimensions, since they could have changed
p = c.getDimension("op")
raise ValueError("{} has no valid pitch defining component".format(self))

if returnComp:
return p, c
else:
return p
# ask component for dimensions, since they could have changed,
# due to temperature, for example.
p = c.getPitchData()

return (p, c) if returnComp else p

def hasPinPitch(self):
"""Return True if the block has enough information to calculate pin pitch."""
Expand Down Expand Up @@ -2343,7 +2338,8 @@ def breakFuelComponentsIntoIndividuals(self):
# update moles at BOL for each pin
self.p.molesHmBOLByPin = []
for pinNum, pin in enumerate(self.iterComponents(Flags.FUEL)):
pin.p.flags = fuelFlags # Update the fuel component flags to be the same as before the split (i.e., DEPLETABLE)
# Update the fuel component flags to be the same as before the split (i.e., DEPLETABLE)
pin.p.flags = fuelFlags
self.p.molesHmBOLByPin.append(pin.getHMMoles())
pin.p.massHmBOL /= nPins

Expand Down Expand Up @@ -2432,10 +2428,7 @@ class HexBlock(Block):

LOCATION_CLASS = locations.HexLocation

PITCH_COMPONENT_TYPE: ClassVar[_PitchDefiningComponent] = (
components.UnshapedComponent,
components.Hexagon,
)
PITCH_COMPONENT_TYPE: ClassVar[_PitchDefiningComponent] = (components.Hexagon,)

def __init__(self, name, height=1.0, location=None):
Block.__init__(self, name, height, location)
Expand Down Expand Up @@ -2702,7 +2695,8 @@ def getPinToDuctGap(self, cold=False):
face to face in cm.
"""
if self.LOCATION_CLASS is None:
return None # can't assume anything about dimensions if there is no location type
# can't assume anything about dimensions if there is no location type
return None

wire = self.getComponent(Flags.WIRE)
ducts = sorted(self.getChildrenWithFlags(Flags.DUCT))
Expand Down Expand Up @@ -2882,7 +2876,7 @@ class CartesianBlock(Block):
LOCATION_CLASS = locations.CartesianLocation

PITCH_DIMENSION = "widthOuter"
PITCH_COMPONENT_TYPE = (components.UnshapedComponent, components.Rectangle)
PITCH_COMPONENT_TYPE = components.Rectangle

def getMaxArea(self):
"""Get area of this block if it were totally full."""
Expand All @@ -2895,30 +2889,6 @@ def setPitch(self, val, updateBolParams=False, updateNumberDensityParams=True):
"not supported"
)

def getPitch(self, returnComp=False):
"""
Get xw and yw of the block.
See Also
--------
Block.getPitch
"""
c, _p = self._pitchDefiningComponent

# Admittedly awkward here, but allows for a clean comparison when adding components to the
# block as opposed to initializing _pitchDefiningComponent to (None, None)
if c is None:
raise ValueError("{} has no valid pitch".format(self))
else:
# ask component for dimensions, since they could have changed
maxLength = c.getDimension("lengthOuter")
maxWidth = c.getDimension("widthOuter")

if returnComp:
return (maxLength, maxWidth), c
else:
return (maxLength, maxWidth)

def getSymmetryFactor(self):
"""
Return a factor between 1 and N where 1/N is how much cut-off by symmetry lines this mesh
Expand Down
3 changes: 1 addition & 2 deletions armi/reactor/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def __init__(
Tinput,
Thot,
area=numpy.NaN,
op=None,
modArea=None,
isotopics=None, # pylint: disable=too-many-arguments
mergeWith=None,
Expand All @@ -136,7 +135,7 @@ def __init__(
mergeWith=mergeWith,
components=components,
)
self._linkAndStoreDimensions(components, op=op, modArea=modArea)
self._linkAndStoreDimensions(components, modArea=modArea)

def getComponentArea(self, cold=False):
"""
Expand Down
39 changes: 39 additions & 0 deletions armi/reactor/components/basicShapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ def getPerimeter(self, Tc=None):
perimeter = 6 * (ip / math.sqrt(3)) * mult
return perimeter

def getPitchData(self):
"""
Return the pitch data that should be used to determine block pitch.
Notes
-----
This pitch data should only be used if this is the pitch defining component in
a block. The block is responsible for determining which component in it is the
pitch defining component.
"""
return self.getDimension("op")


class Rectangle(ShapedComponent):
"""A rectangle component."""
Expand Down Expand Up @@ -209,6 +221,19 @@ def isLatticeComponent(self):
"""Return true if the component is a `lattice component` containing void material and zero area."""
return self.containsVoidMaterial() and self.getArea() == 0.0

def getPitchData(self):
"""
Return the pitch data that should be used to determine block pitch.
Notes
-----
For rectangular components there are two pitches, one for each dimension.
This pitch data should only be used if this is the pitch defining component in
a block. The block is responsible for determining which component in it is the
pitch defining component.
"""
return (self.getDimension("lengthOuter"), self.getDimension("widthOuter"))


class SolidRectangle(Rectangle):
"""Solid rectangle component."""
Expand Down Expand Up @@ -318,6 +343,20 @@ def getBoundingCircleOuterDiameter(self, Tc=None, cold=False):
widthO = self.getDimension("widthOuter", Tc, cold=cold)
return math.sqrt(widthO ** 2 + widthO ** 2)

def getPitchData(self):
"""
Return the pitch data that should be used to determine block pitch.
Notes
-----
For rectangular components there are two pitches, one for each dimension.
This pitch data should only be used if this is the pitch defining component in
a block. The block is responsible for determining which component in it is the
pitch defining component.
"""
# both dimensions are the same for a square.
return (self.getDimension("widthOuter"), self.getDimension("widthOuter"))


class Triangle(ShapedComponent):
"""
Expand Down
15 changes: 15 additions & 0 deletions armi/reactor/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,21 @@ def makeCrossSectionTable(self, nuclides=None):
def getMicroSuffix(self):
return self.parent.getMicroSuffix()

def getPitchData(self):
"""
Return the pitch data that should be used to determine block pitch.
Notes
-----
This pitch data should only be used if this is the pitch defining component in
a block. The block is responsible for determining which component in it is the
pitch defining component.
"""
raise NotImplementedError(
f"Method not implemented on component {self}. "
"Please implement if this component type can be a pitch defining component."
)


class ShapedComponent(Component):
"""A component with well-defined dimensions."""
Expand Down
Loading

0 comments on commit 5e7b7f1

Please sign in to comment.