-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding temperature dependence when generating cross sections #1987
Changes from 16 commits
b1eef01
03cf800
9672d1a
0c1578f
d994c1f
1f071ee
c3ad810
00c9009
68beaf3
53ec158
9a7f4c1
c515233
67b1614
ad99a0c
79dd567
0bf30b5
e2fab94
2f0105d
3e52acf
9c7c35e
eff1d77
481a853
3635ffb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -95,6 +95,22 @@ def test_createRepresentativeBlock(self): | |||||||||||||
avgB = self.bc.createRepresentativeBlock() | ||||||||||||||
self.assertAlmostEqual(avgB.p.percentBu, 50.0) | ||||||||||||||
|
||||||||||||||
def test_getBlockNuclideTemperature(self): | ||||||||||||||
# doesn't have to be in median block tests, but this is a simpler test | ||||||||||||||
nuc = "U235" | ||||||||||||||
testBlock = self.blockList[0] | ||||||||||||||
amt, amtWeightedTemp = 0, 0 | ||||||||||||||
for c in testBlock: | ||||||||||||||
dens = c.getNumberDensity(nuc) | ||||||||||||||
if dens > 0: | ||||||||||||||
thisAmt = dens * c.getVolume() | ||||||||||||||
amt += thisAmt | ||||||||||||||
amtWeightedTemp += thisAmt * c.temperatureInC | ||||||||||||||
avgTemp = amtWeightedTemp / amt | ||||||||||||||
self.assertAlmostEqual( | ||||||||||||||
avgTemp, crossSectionGroupManager.getBlockNuclideTemperature(testBlock, nuc) | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class TestBlockCollectionAverage(unittest.TestCase): | ||||||||||||||
@classmethod | ||||||||||||||
|
@@ -403,7 +419,7 @@ def test_ComponentAverageRepBlock(self): | |||||||||||||
|
||||||||||||||
assert "AC" in xsgm.representativeBlocks, ( | ||||||||||||||
"Assemblies not in the core should still have XS groups" | ||||||||||||||
"see getUnrepresentedBlocks()" | ||||||||||||||
"see _getMissingBlueprintBlocks()" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -763,29 +779,36 @@ def setUp(self): | |||||||||||||
self.csm._setBuGroupBounds([3, 10, 30, 100]) | ||||||||||||||
self.csm.interactBOL() | ||||||||||||||
|
||||||||||||||
def test_enableBuGroupUpdates(self): | ||||||||||||||
self.csm._buGroupUpdatesEnabled = False | ||||||||||||||
self.csm.enableBuGroupUpdates() | ||||||||||||||
self.assertTrue(self.csm.enableBuGroupUpdates) | ||||||||||||||
|
||||||||||||||
def test_disableBuGroupUpdates(self): | ||||||||||||||
self.csm._buGroupUpdatesEnabled = False | ||||||||||||||
res = self.csm.disableBuGroupUpdates() | ||||||||||||||
self.assertFalse(res) | ||||||||||||||
def test_enableEnvGroupUpdates(self): | ||||||||||||||
self.csm._envGroupUpdatesEnabled = False | ||||||||||||||
self.csm.enableEnvGroupUpdates() | ||||||||||||||
self.assertTrue(self.csm._envGroupUpdatesEnabled) | ||||||||||||||
# test flipping again keeps true | ||||||||||||||
self.csm.enableEnvGroupUpdates() | ||||||||||||||
self.assertTrue(self.csm._envGroupUpdatesEnabled) | ||||||||||||||
|
||||||||||||||
def test_disableEnvGroupUpdates(self): | ||||||||||||||
self.csm._envGroupUpdatesEnabled = True | ||||||||||||||
wasEnabled = self.csm.disableEnvGroupUpdates() | ||||||||||||||
self.assertTrue(wasEnabled) | ||||||||||||||
self.assertFalse(self.csm._envGroupUpdatesEnabled) | ||||||||||||||
wasEnabled = self.csm.disableEnvGroupUpdates() | ||||||||||||||
self.assertFalse(wasEnabled) | ||||||||||||||
self.assertFalse(self.csm._envGroupUpdatesEnabled) | ||||||||||||||
|
||||||||||||||
def test_updateBurnupGroups(self): | ||||||||||||||
self.blockList[1].p.percentBu = 3.1 | ||||||||||||||
self.blockList[2].p.percentBu = 10.0 | ||||||||||||||
|
||||||||||||||
self.csm._updateBurnupGroups(self.blockList) | ||||||||||||||
self.csm._updateEnvironmentGroups(self.blockList) | ||||||||||||||
|
||||||||||||||
self.assertEqual(self.blockList[0].p.buGroup, "A") | ||||||||||||||
self.assertEqual(self.blockList[1].p.buGroup, "B") | ||||||||||||||
self.assertEqual(self.blockList[2].p.buGroup, "B") | ||||||||||||||
self.assertEqual(self.blockList[-1].p.buGroup, "D") | ||||||||||||||
self.assertEqual(self.blockList[0].p.envGroup, "A") | ||||||||||||||
self.assertEqual(self.blockList[1].p.envGroup, "B") | ||||||||||||||
self.assertEqual(self.blockList[2].p.envGroup, "B") | ||||||||||||||
self.assertEqual(self.blockList[-1].p.envGroup, "D") | ||||||||||||||
|
||||||||||||||
def test_setBuGroupBounds(self): | ||||||||||||||
self.assertAlmostEqual(self.csm._upperBuGroupBounds[2], 30.0) | ||||||||||||||
self.assertAlmostEqual(self.csm._buGroupBounds[2], 30.0) | ||||||||||||||
|
||||||||||||||
with self.assertRaises(ValueError): | ||||||||||||||
self.csm._setBuGroupBounds([3, 10, 300]) | ||||||||||||||
|
@@ -796,6 +819,14 @@ def test_setBuGroupBounds(self): | |||||||||||||
with self.assertRaises(ValueError): | ||||||||||||||
self.csm._setBuGroupBounds([1, 5, 3]) | ||||||||||||||
|
||||||||||||||
def test_setTempGroupBounds(self): | ||||||||||||||
# negative temps in C are allowed | ||||||||||||||
self.csm._setTempGroupBounds([-5, 3, 10, 300]) | ||||||||||||||
self.assertAlmostEqual(self.csm._tempGroupBounds[2], 10.0) | ||||||||||||||
|
||||||||||||||
with self.assertRaises(ValueError): | ||||||||||||||
self.csm._setTempGroupBounds([1, 5, 3]) | ||||||||||||||
|
||||||||||||||
def test_addXsGroupsFromBlocks(self): | ||||||||||||||
blockCollectionsByXsGroup = {} | ||||||||||||||
blockCollectionsByXsGroup = self.csm._addXsGroupsFromBlocks( | ||||||||||||||
|
@@ -810,7 +841,7 @@ def test_calcWeightedBurnup(self): | |||||||||||||
self.blockList[3].p.percentBu = 1.5 | ||||||||||||||
for b in self.blockList[4:]: | ||||||||||||||
b.p.percentBu = 0.0 | ||||||||||||||
self.csm._updateBurnupGroups(self.blockList) | ||||||||||||||
self.csm._updateEnvironmentGroups(self.blockList) | ||||||||||||||
blockCollectionsByXsGroup = {} | ||||||||||||||
blockCollectionsByXsGroup = self.csm._addXsGroupsFromBlocks( | ||||||||||||||
blockCollectionsByXsGroup, self.blockList | ||||||||||||||
|
@@ -1077,6 +1108,86 @@ def test_copyPregeneratedFiles(self): | |||||||||||||
self.assertTrue(os.path.exists("rzmflxYA")) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class TestCrossSectionGroupManagerWithTempGrouping(unittest.TestCase): | ||||||||||||||
def setUp(self): | ||||||||||||||
cs = settings.Settings() | ||||||||||||||
cs["tempGroups"] = [300, 400, 500] | ||||||||||||||
self.blockList = makeBlocks(11) | ||||||||||||||
buAndTemps = ( | ||||||||||||||
(1, 340), | ||||||||||||||
(2, 150), | ||||||||||||||
(6, 410), | ||||||||||||||
(10.5, 290), | ||||||||||||||
(2.5, 360), | ||||||||||||||
(4, 460), | ||||||||||||||
(15, 370), | ||||||||||||||
(16, 340), | ||||||||||||||
(15, 700), | ||||||||||||||
(14, 720), | ||||||||||||||
) | ||||||||||||||
for b, env in zip(self.blockList, buAndTemps): | ||||||||||||||
bu, temp = env | ||||||||||||||
comps = b.getComponents(Flags.FUEL) | ||||||||||||||
assert len(comps) == 1 | ||||||||||||||
c = next(iter(comps)) | ||||||||||||||
c.setTemperature(temp) | ||||||||||||||
b.p.percentBu = bu | ||||||||||||||
core = self.blockList[0].core | ||||||||||||||
|
||||||||||||||
def getBlocks(includeAll=True): | ||||||||||||||
return self.blockList | ||||||||||||||
|
||||||||||||||
core.getBlocks = getBlocks | ||||||||||||||
for b in core.getBlocks(): | ||||||||||||||
print(b) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Unless I'm missing something, it looks like this was just used while developing the test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, if you dont do this, xsgm does all blocks in the core rather than just the block list, and you cannot do hand calcs to compare correct grouping. i would remove all blocks except those from the core, but i might have partial assemblies... |
||||||||||||||
self.csm = CrossSectionGroupManager(self.blockList[0].core.r, cs) | ||||||||||||||
self.csm._setBuGroupBounds([3, 10, 30, 100]) | ||||||||||||||
self.csm.interactBOL() | ||||||||||||||
|
||||||||||||||
def test_updateEnvironmentGroups(self): | ||||||||||||||
self.csm.createRepresentativeBlocks() | ||||||||||||||
BL = self.blockList | ||||||||||||||
loners = [BL[1], BL[3]] | ||||||||||||||
for b in BL: | ||||||||||||||
print(b.getMicroSuffix()) | ||||||||||||||
onufer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
self.assertNotEqual(loners[0].getMicroSuffix(), loners[1].getMicroSuffix()) | ||||||||||||||
sameGroups = [(BL[0], BL[4]), (BL[2], BL[5]), (BL[6], BL[7]), (BL[8], BL[9])] | ||||||||||||||
|
||||||||||||||
# check that likes have like and different are different | ||||||||||||||
for group in sameGroups: | ||||||||||||||
b1, b2 = group | ||||||||||||||
xsSuffix = b1.getMicroSuffix() | ||||||||||||||
self.assertEqual(xsSuffix, b2.getMicroSuffix()) | ||||||||||||||
for group in sameGroups: | ||||||||||||||
newb1, newb2 = group | ||||||||||||||
if b1 is newb1: | ||||||||||||||
continue | ||||||||||||||
self.assertNotEqual(xsSuffix, newb1.getMicroSuffix()) | ||||||||||||||
self.assertNotEqual(xsSuffix, newb2.getMicroSuffix()) | ||||||||||||||
for lone in loners: | ||||||||||||||
self.assertNotEqual(xsSuffix, lone.getMicroSuffix()) | ||||||||||||||
self.assertNotEqual(loners[0].getMicroSuffix(), loners[1].getMicroSuffix()) | ||||||||||||||
|
||||||||||||||
# calculated based on the average of buAndTemps | ||||||||||||||
expectedIDs = ["AF", "AA", "AL", "AC", "AH", "AR"] | ||||||||||||||
expectedTemps = [ | ||||||||||||||
(340 + 360) / 2, | ||||||||||||||
150, | ||||||||||||||
(410 + 460) / 2, | ||||||||||||||
290, | ||||||||||||||
(370 + 340) / 2, | ||||||||||||||
(700 + 720) / 2, | ||||||||||||||
] | ||||||||||||||
expectedBurnups = (1.75, 2, 5, 10.5, 15.5, 14.5) | ||||||||||||||
for xsID, expectedTemp, expectedBurnup in zip( | ||||||||||||||
expectedIDs, expectedTemps, expectedBurnups | ||||||||||||||
): | ||||||||||||||
b = self.csm.representativeBlocks[xsID] | ||||||||||||||
thisTemp = self.csm.avgNucTemperatures[xsID]["U238"] | ||||||||||||||
self.assertAlmostEqual(thisTemp, expectedTemp) | ||||||||||||||
self.assertAlmostEqual(b.p.percentBu, expectedBurnup) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class TestXSNumberConverters(unittest.TestCase): | ||||||||||||||
def test_conversion(self): | ||||||||||||||
label = crossSectionGroupManager.getXSTypeLabelFromNumber(65) | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only for homogeneous compositions or does it also work with other modeling options as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd guess it's independent of the treatment since this occurs in the XS group manager rather than specific modeling options applied for the input generation. Also, I assume that U238 is selected here because of fuel, but does this work if you select an isotope that isn't in the composition? For example if the isotope is not in the block, does this fail, should it fail, or should the environment/temperature group never be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for other based my expected implementation and on Mikes testing.