Skip to content

Commit

Permalink
Add testing and validation checks to the cross section settings. (#289)
Browse files Browse the repository at this point in the history
Adding validation checks in `crossSectionSettings` to warn the user
if extra options are provided in the various geometry options amd
enforcing that the `fileLocation` and `geometry` cannot both be set
simultaneously. The settings validation and the unit testing around 
the cross section settings were improved.
  • Loading branch information
jakehader authored May 1, 2021
1 parent f6bc7dc commit bb1d08d
Show file tree
Hide file tree
Showing 30 changed files with 772 additions and 272 deletions.
4 changes: 2 additions & 2 deletions armi/bookkeeping/db/database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def interactEveryNode(self, cycle, node):
self._db.syncToSharedFolder()

def interactEOC(self, cycle=None):
"""In case anything changed since last cycle (e.g. rxSwing), update DB. """
"""In case anything changed since last cycle (e.g. rxSwing), update DB."""
# We cannot presume whether we are at EOL based on cycle and cs["nCycles"],
# since cs["nCycles"] is not a difinitive indicator of EOL; ultimately the
# Operator has the final say.
Expand All @@ -248,7 +248,7 @@ def interactEOC(self, cycle=None):
self._db.writeToDB(self.r)

def interactEOL(self):
"""DB's should be closed at run's end. """
"""DB's should be closed at run's end."""
# minutesSinceStarts should include as much of the ARMI run as possible so EOL
# is necessary, too.
self.r.core.p.minutesSinceStart = (time.time() - self.r.core.timeOfStart) / 60.0
Expand Down
2 changes: 1 addition & 1 deletion armi/bookkeeping/db/tests/test_database3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


class TestDatabase3(unittest.TestCase):
r""" Tests for the Database3 class """
r"""Tests for the Database3 class"""

def setUp(self):
self.td = TemporaryDirectoryChanger()
Expand Down
2 changes: 1 addition & 1 deletion armi/bookkeeping/historyTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def getTimeIndices(self, a=None, boc=False, moc=False, eoc=False):
return self.filterTimeIndices(timeIndices, boc, moc, eoc)

def getBOCEOCTimeIndices(self, assem=None):
r"""returns a list of time step indices that only include BOC and EOC, no intermediate ones. """
r"""returns a list of time step indices that only include BOC and EOC, no intermediate ones."""
tIndices = self.getTimeIndices(assem) # list of times in years
counter = 0
filtered = []
Expand Down
2 changes: 1 addition & 1 deletion armi/bookkeeping/mainInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _moveFiles(self):
raise InputError("Failed to process copyFilesTo/copyFilesFrom")

def interactBOC(self, cycle=None):
r"""typically the first interface to interact beginning of cycle. """
r"""typically the first interface to interact beginning of cycle."""

runLog.important("Beginning of Cycle {0}".format(cycle))
runLog.LOG.clearSingleWarnings()
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def volumetricExpansion(self, Tk=None, Tc=None):
return 1.0 / (9516.9 - Tk)

def setDefaultMassFracs(self):
r""" mass fractions"""
r"""mass fractions"""
self.setMassFrac("PB", 1)

def density(self, Tk=None, Tc=None):
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/leadBismuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LeadBismuth(material.Fluid):
name = "Lead Bismuth"

def setDefaultMassFracs(self):
r""" mass fractions"""
r"""mass fractions"""
self.setMassFrac("PB", 0.445)
self.setMassFrac("BI209", 0.555)

Expand Down
4 changes: 2 additions & 2 deletions armi/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def thermalConductivity(self, Tk=None, Tc=None):
return self.p.thermalConductivity

def getProperty(self, propName, Tk=None, Tc=None, **kwargs):
r"""gets properties in a way that caches them. """
r"""gets properties in a way that caches them."""
Tk = getTk(Tc, Tk)

cached = self._getCached(propName)
Expand Down Expand Up @@ -512,7 +512,7 @@ def getMassFrac(
return self.p.massFrac.get(nucName, 0.0)

def clearMassFrac(self):
r"""zero out all nuclide mass fractions. """
r"""zero out all nuclide mass fractions."""
self.p.massFrac.clear()
self.p.massFracNorm = 0.0

Expand Down
2 changes: 1 addition & 1 deletion armi/materials/mgO.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MgO(Material):
name = "MgO"

def setDefaultMassFracs(self):
r""" mass fractions"""
r"""mass fractions"""
self.setMassFrac("MG", 0.603035897)
self.setMassFrac("O16", 0.396964103)

Expand Down
2 changes: 1 addition & 1 deletion armi/materials/siC.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class SiC(Material):
r""""""
r""" """
name = "Silicon Carbide"
thermalScatteringLaws = (
tsl.byNbAndCompound[nb.byName["C"], tsl.SIC],
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/sulfur.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setDefaultMassFracs(self):
self.setMassFrac("S36", 0.002)

def density(self, Tk=None, Tc=None):
r""" P. Espeau, R. Ceolin "density of molten sulfur in the 334-508K range" """
r"""P. Espeau, R. Ceolin "density of molten sulfur in the 334-508K range" """
Tk = getTk(Tc, Tk)

self.checkTempRange(334, 430, Tk, "density")
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/uThZr.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def applyInputParams(self, U235_wt_frac=None, ZR_wt_frac=None, TH_wt_frac=None):
self.p.zrFrac = ZR_wt_frac

def setDefaultMassFracs(self):
r""" U-ZR mass fractions"""
r"""U-ZR mass fractions"""
self.setMassFrac("U238", 0.8)
self.setMassFrac("U235", 0.1)
self.setMassFrac("ZR", 0.09999)
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/uZr.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class UZr(material.FuelMaterial):
uFracDefault = 1.0 - zrFracDefault

def setDefaultMassFracs(self):
r""" U-Pu-Zr mass fractions"""
r"""U-Pu-Zr mass fractions"""
u235Enrichment = 0.1
self.p.uFrac = self.uFracDefault
self.p.zrFrac = self.zrFracDefault
Expand Down
6 changes: 3 additions & 3 deletions armi/nucDirectory/nucDir.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ def getRebusLabel(name):


def getMc2LabelFromRebusLabel(rebusLabel):
r""""""
r""" """
return getMc2Label(rebusLabel)


def getRebusLabelFromMc2Label(mc2Label):
r""""""
r""" """
return getRebusNameFromMC2(mc2Label)


Expand Down Expand Up @@ -470,7 +470,7 @@ def getNameFromMC2(mc2LibLabel=None, mc2Label=None):


def getStructuralElements():
r""" return list of element symbol in structure """
r"""return list of element symbol in structure"""
return ["MN", "W", "HE", "C", "CR", "FE", "MO", "NI", "SI", "V"]


Expand Down
4 changes: 2 additions & 2 deletions armi/nuclearDataIO/xsNuclides.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _mergeAttributes(this, other, attrName):


def plotScatterMatrix(scatterMatrix, scatterTypeLabel="", fName=None):
r"""plots a matrix to show scattering. """
r"""plots a matrix to show scattering."""
from matplotlib import pyplot

pyplot.imshow(scatterMatrix.todense(), interpolation="nearest")
Expand All @@ -244,7 +244,7 @@ def plotScatterMatrix(scatterMatrix, scatterTypeLabel="", fName=None):


def compareScatterMatrix(scatterMatrix1, scatterMatrix2, fName=None):
"""Compares scatter matrices graphically between libraries. """
"""Compares scatter matrices graphically between libraries."""
from matplotlib import pyplot

diff = scatterMatrix1 - scatterMatrix2
Expand Down
4 changes: 0 additions & 4 deletions armi/physics/neutronics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ def defineSettings():
settings = [
crossSectionSettings.XSSettingDef(
CONF_CROSS_SECTION,
default=crossSectionSettings.XSSettings(),
label="Cross section control",
description="Data structure defining how cross sections are created",
schema=crossSectionSettings.XS_SCHEMA,
)
]
settings += neutronicsSettings.defineSettings()
Expand Down
12 changes: 5 additions & 7 deletions armi/physics/neutronics/crossSectionGroupManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,11 @@ def __init__(self, r, cs):

def interactBOL(self):
# now that all cs settings are loaded, apply defaults to compound XS settings
self.cs[CONF_CROSS_SECTION].setDefaults(self.cs)

self.cs[CONF_CROSS_SECTION].setDefaults(
self.cs["xsBlockRepresentation"],
self.cs["disableBlockTypeExclusionInXsGeneration"],
)

def interactBOC(self, cycle=None):
"""
Expand Down Expand Up @@ -1131,12 +1135,6 @@ def updateNuclideTemperatures(self, blockCollectionByXsGroup=None):
"FluxWeightedAverage": FluxWeightedAverageBlockCollection,
}

HOMOGENEOUS_BLOCK_COLLECTIONS = {
"Median": MedianBlockCollection,
"Average": AverageBlockCollection,
"FluxWeightedAverage": FluxWeightedAverageBlockCollection,
}


def blockCollectionFactory(xsSettings, allNuclidesInProblem):
"""
Expand Down
Loading

0 comments on commit bb1d08d

Please sign in to comment.