Skip to content
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

Move max assembly number out of global scope #1383

Merged
merged 15 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include armi/bookkeeping/tests/armiRun-A0039-aHist-ref.txt
include armi/bookkeeping/tests/armiRun-A0032-aHist-ref.txt
include armi/nuclearDataIO/cccc/tests/fixtures/labels.ascii
include armi/nuclearDataIO/cccc/tests/fixtures/labels.binary
include armi/nuclearDataIO/cccc/tests/fixtures/mc2v3.dlayxs
Expand Down
8 changes: 1 addition & 7 deletions armi/bookkeeping/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

# re-export package components for easier import
from .permissions import Permissions
from .database3 import Database3, updateGlobalAssemblyNum
from .database3 import Database3
from .databaseInterface import DatabaseInterface
from .compareDB3 import compareDatabases
from .factory import databaseFactory
Expand Down Expand Up @@ -144,12 +144,6 @@ def loadOperator(pathToDb, loadCycle, loadNode, allowMissing=False):

settings.setMasterCs(cs)

# Update the global assembly number because, if the user is loading a reactor from
# blueprints and does not have access to an operator, it is unlikely that there is
# another reactor that has alter the global assem num. Fresh cases typically want
# this updated.
updateGlobalAssemblyNum(r)

o = thisCase.initializeOperator(r=r)
runLog.important(
"The operator will not be in the same state that it was at that cycle and "
Expand Down
22 changes: 5 additions & 17 deletions armi/bookkeeping/db/database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
from armi.bookkeeping.db.typedefs import History, Histories
from armi.nucDirectory import nuclideBases
from armi.physics.neutronics.settings import CONF_LOADING_FILE
from armi.reactor import assemblies
from armi.reactor import grids
from armi.reactor import parameters
from armi.reactor import systemLayoutInput
Expand Down Expand Up @@ -101,18 +100,6 @@ def getH5GroupName(cycle: int, timeNode: int, statePointName: str = None) -> str
return "c{:0>2}n{:0>2}{}".format(cycle, timeNode, statePointName or "")


def updateGlobalAssemblyNum(r) -> None:
"""
Updated the global assembly number counter in ARMI, using the assemblies
read from a database.
"""
assemNum = r.core.p.maxAssemNum
if assemNum is not None:
assemblies.setAssemNumCounter(int(assemNum + 1))
else:
raise ValueError("Could not load maxAssemNum from the database")


class Database3:
"""
Version 3 of the ARMI Database, handling serialization and loading of Reactor states.
Expand Down Expand Up @@ -691,8 +678,7 @@ def load(
Whether to emit a warning, rather than crash if reading a database
with undefined parameters. Default False.
updateGlobalAssemNum : bool, optional
Whether to update the global assembly number to the value stored in
r.core.p.maxAssemNum. Default True.
DeprecationWarning: This is unused.
updateMasterCs : bool, optional
Whether to apply the cs (whether provided as an argument or read from
the database) as the primary for the case. Default True. Can be useful
Expand Down Expand Up @@ -741,9 +727,11 @@ def load(
)
root = comps[0][0]

# ensure the max assembly number is correct, unless the user says no
if updateGlobalAssemNum:
updateGlobalAssemblyNum(root)
runLog.warning(
"The method input `updateGlobalAssemNum` is no longer used.",
single=True,
)
john-science marked this conversation as resolved.
Show resolved Hide resolved

# return a Reactor object
if cs[CONF_SORT_REACTOR]:
Expand Down
4 changes: 2 additions & 2 deletions armi/bookkeeping/db/tests/test_comparedb3.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_compareDatabaseDuplicate(self):
self.assertEqual(diffs.nDiffs(), 0)

def test_compareDatabaseSim(self):
"""end-to-end test of compareDatabases() on very simlar databases."""
"""End-to-end test of compareDatabases() on very simlar databases."""
# build two super-simple H5 files for testing
o, r = test_reactors.loadTestReactor(
TEST_ROOT, customSettings={"reloadDBName": "reloadingDB.h5"}
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_compareDatabaseSim(self):
dbs[1]._fullPath,
timestepCompare=[(0, 0), (0, 1)],
)
self.assertEqual(len(diffs.diffs), 465)
self.assertEqual(len(diffs.diffs), 468)
# Cycle length is only diff (x3)
self.assertEqual(diffs.nDiffs(), 3)

Expand Down
45 changes: 9 additions & 36 deletions armi/bookkeeping/db/tests/test_database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ def test_writeToDB(self):
self.assertEqual(sorted(self.db.h5db["c00n00"].keys()), sorted(keys))

# validate availabilityFactor did not make it into the H5 file
rKeys = ["cycle", "cycleLength", "flags", "serialNum", "timeNode"]
rKeys = [
"maxAssemNum",
"cycle",
"cycleLength",
"flags",
"serialNum",
"timeNode",
]
self.assertEqual(
sorted(self.db.h5db["c00n00"]["Reactor"].keys()), sorted(rKeys)
)
Expand Down Expand Up @@ -109,8 +116,7 @@ def makeShuffleHistory(self):
# Serial numbers *are not stable* (i.e., they can be different between test runs
# due to parallelism and test run order). However, they are the simplest way to
# check correctness of location-based history tracking. So we stash the serial
# numbers at the location of interest so that we can use them later to check our
# work.
# numbers at the location of interest so we can use them later to check our work.
self.centralAssemSerialNums = []
self.centralTopBlockSerialNums = []

Expand Down Expand Up @@ -365,39 +371,6 @@ def test_loadSortSetting(self):
self.assertEqual(len(r0), len(r1))
self.assertEqual(len(r0.core), len(r1.core))

def test_load_updateGlobalAssemNum(self):
from armi.reactor import assemblies
from armi.reactor.assemblies import resetAssemNumCounter

self.makeHistory()

resetAssemNumCounter()
self.assertEqual(assemblies._assemNum, 0)

r = self.db.load(0, 0, allowMissing=True, updateGlobalAssemNum=False)
# len(r.sfp) is zero but these nums are still reserved
numSFPBlueprints = 4
expectedNum = len(r.core) + numSFPBlueprints
self.assertEqual(assemblies._assemNum, expectedNum)

# now do the same call again and show that the global _assemNum keeps going up.
# in db.load, rector objects are built in layout._initComps() so the global assem num
# will continue to grow (in this case, double).
self.db.load(0, 0, allowMissing=True, updateGlobalAssemNum=False)
self.assertEqual(assemblies._assemNum, expectedNum * 2)

# now load but set updateGlobalAssemNum=True and show that the global assem num
# is updated and equal to self.r.p.maxAssemNum + 1 which is equal to the number of
# assemblies in blueprints/core.
r = self.db.load(0, 0, allowMissing=True, updateGlobalAssemNum=True)
expected = len(self.r.core) + len(self.r.blueprints.assemblies.values())
self.assertEqual(15, expected)

# repeat the test above to show that subsequent db loads (with updateGlobalAssemNum=True)
# do not continue to increase the global assem num.
self.db.load(0, 0, allowMissing=True, updateGlobalAssemNum=True)
self.assertEqual(15, expected)
john-science marked this conversation as resolved.
Show resolved Hide resolved

def test_history(self):
self.makeShuffleHistory()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ EOL bottom top center


Assembly info
A0039 outer core fuel
A0032 outer core fuel
"reflector" C A
"fuel" C A
"fuel" C A
Expand Down
3 changes: 0 additions & 3 deletions armi/mpiActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
from armi import settings
from armi import utils
from armi.reactor import reactors
from armi.reactor import assemblies
from armi.reactor.parameters import parameterDefinitions
from armi.utils import iterables

Expand Down Expand Up @@ -610,8 +609,6 @@ def _distributeReactor(self, cs):
runLog.debug(
"The reactor has {} assemblies".format(len(self.r.core.getAssemblies()))
)
numAssemblies = self.broadcast(assemblies.getAssemNum())
assemblies.setAssemNumCounter(numAssemblies)
# attach here so any interface actions use a properly-setup reactor.
self.o.reattach(self.r, cs) # sets r and cs

Expand Down
1 change: 1 addition & 0 deletions armi/physics/fuelCycle/fuelHandlerInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def manageFuel(self, cycle):
self.r.core.locateAllAssemblies()
shuffleFactors, _ = fh.getFactorList(cycle)
fh.outage(shuffleFactors) # move the assemblies around

if self.cs[CONF_PLOT_SHUFFLE_ARROWS]:
arrows = fh.makeShuffleArrows()
plotting.plotFaceMap(
Expand Down
2 changes: 1 addition & 1 deletion armi/physics/fuelCycle/fuelHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def r(self):
return self.o.r

def outage(self, factor=1.0):
r"""
"""
Simulates a reactor reload outage. Moves and tracks fuel.

This sets the moveList structure.
Expand Down
6 changes: 3 additions & 3 deletions armi/physics/fuelCycle/tests/test_fuelHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def test_repeatShuffles(self):
for a in self.r.sfp.getChildren():
self.assertEqual(a.getLocation(), "SFP")

# do some shuffles.
# do some shuffles
fh = self.r.o.getInterface("fuelHandler")
self.runShuffling(fh) # changes caseTitle

Expand Down Expand Up @@ -455,7 +455,7 @@ def test_readMoves(self):
sfpMove = moves[2][-2]
self.assertEqual(sfpMove[0], "SFP")
self.assertEqual(sfpMove[1], "005-003")
self.assertEqual(sfpMove[4], "A0085") # name of assem in SFP
self.assertEqual(sfpMove[4], "A0077") # name of assem in SFP

def test_processMoveList(self):
fh = fuelHandlers.FuelHandler(self.o)
Expand All @@ -468,7 +468,7 @@ def test_processMoveList(self):
loadNames,
_,
) = fh.processMoveList(moves[2])
self.assertIn("A0085", loadNames)
self.assertIn("A0077", loadNames)
self.assertIn(None, loadNames)
self.assertNotIn("SFP", loadChains)
self.assertNotIn("LoadQueue", loadChains)
Expand Down
Loading
Loading