Skip to content

Commit

Permalink
resolve errors in tests that specially accounted for symmetry
Browse files Browse the repository at this point in the history
  • Loading branch information
bsculac committed Dec 5, 2024
1 parent 8e7185c commit 7ca1e13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
11 changes: 3 additions & 8 deletions armi/reactor/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,21 +790,16 @@ def completeInitialLoading(self, bolBlock=None):

self.p.enrichmentBOL = self.getFissileMassEnrich()
massHmBOL = 0.0
sf = self.getSymmetryFactor()
for child in self:
# multiplying by sf ends up cancelling out the symmetry factor used in
# Component.getMass(). So massHmBOL does not respect the symmetry factor.
hmMass = child.getHMMass() * sf
hmMass = child.getHMMass()
massHmBOL += hmMass
# Components have the following parameters but not every composite will
# massHmBOL, molesHmBOL, puFrac
if isinstance(child, components.Component):
child.p.massHmBOL = hmMass
# to stay consistent with massHmBOL, molesHmBOL and puFrac should be
# independent of sf. As such, the need to be scaled by 1/sf.
child.p.molesHmBOL = child.getHMMoles() / sf
child.p.molesHmBOL = child.getHMMoles()
child.p.puFrac = (
self.getPuMoles() / sf / child.p.molesHmBOL
self.getPuMoles() / child.p.molesHmBOL
if child.p.molesHmBOL > 0.0
else 0.0
)
Expand Down
19 changes: 4 additions & 15 deletions armi/reactor/composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,29 +1947,18 @@ def getHMMass(self):

def getHMMoles(self):
"""
Get the number of moles of heavy metal in this object in full symmetry.
Get the number of moles of heavy metal in this object.
Notes
-----
If an object is on a symmetry line, the number of moles will be scaled up by the
symmetry factor. This is done because this is typically used for tracking
burnup, and BOL moles are computed in full objects too so there are no
complications as things move on and off of symmetry lines.
Warning
-------
getHMMoles is different than every other get mass call since it multiplies by
symmetry factor but getVolume() on the block level divides by symmetry factor
causing them to cancel out.
This was needed so that HM moles mass did not change based on if the
block/assembly was on a symmetry line or not.
If an object is on a symmetry line, the volume reported by getVolume
is reduced to reflect that the block is not wholly within the reactor. This
reduction in volume reduces the reported HM moles.
"""
return (
self.getHMDens()
/ units.MOLES_PER_CC_TO_ATOMS_PER_BARN_CM
* self.getVolume()
* self.getSymmetryFactor()
)

def getHMDens(self):
Expand Down
18 changes: 4 additions & 14 deletions armi/reactor/tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,34 +1230,24 @@ def test_completeInitialLoading(self, mock_sf):

sf = self.block.getSymmetryFactor()
cur = self.block.p.molesHmBOL
ref = (
self.block.getHMDens()
/ MOLES_PER_CC_TO_ATOMS_PER_BARN_CM
* height
* area
* sf
)
ref = self.block.getHMDens() / MOLES_PER_CC_TO_ATOMS_PER_BARN_CM * height * area
self.assertAlmostEqual(cur, ref, places=12)

totalHMMass = 0.0
for c in self.block:
nucs = c.getNuclides()
hmNucs = [nuc for nuc in nucs if nucDir.isHeavyMetal(nuc)]
hmNDens = {hmNuc: c.getNumberDensity(hmNuc) for hmNuc in hmNucs}
hmMass = densityTools.calculateMassDensity(hmNDens) * c.getVolume()
# use sf to account for only a 1/sf portion of the component being in the block
hmMass = densityTools.calculateMassDensity(hmNDens) * c.getVolume() / sf
totalHMMass += hmMass
if hmMass:
# hmMass does not need to account for sf since what's calculated in blocks.completeInitialLoading
# ends up cancelling out sf
self.assertAlmostEqual(c.p.massHmBOL, hmMass, places=12)
# since sf is cancelled out in massHmBOL, there needs to be a factor 1/sf here to cancel out the
# factor of sf in getHMMoles.
self.assertAlmostEqual(
c.p.molesHmBOL,
sum(ndens for ndens in hmNDens.values())
/ units.MOLES_PER_CC_TO_ATOMS_PER_BARN_CM
* c.getVolume()
/ sf,
* c.getVolume(),
places=12,
)
else:
Expand Down

0 comments on commit 7ca1e13

Please sign in to comment.