Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into uniformMeshFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehader committed Apr 18, 2022
2 parents 7b1480c + 907f2b4 commit aa58016
Show file tree
Hide file tree
Showing 26 changed files with 163 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yaml
Expand Up @@ -13,6 +13,6 @@ jobs:
with:
python-version: 3.9
- name: Install Black
run: pip install 'black==20.8b1'
run: pip install 'black==20.8b1' 'click==8.0.1'
- name: Run black --check .
run: black --check .
1 change: 0 additions & 1 deletion MANIFEST.in
Expand Up @@ -38,7 +38,6 @@ include armi/nuclearDataIO/tests/library-file-generation/mc2v3-dlayxs.inp
include armi/nuclearDataIO/tests/longLivedRipleData.dat
include armi/nuclearDataIO/tests/simple_hexz.inp
include armi/nuclearDataIO/tests/z036.dat
include armi/settings/tests/old_xml_settings_input.xml
include armi/tests/1DslabXSByCompTest.yaml
include armi/tests/armiRun-SHUFFLES.txt
include armi/tests/armiRun.yaml
Expand Down
7 changes: 0 additions & 7 deletions armi/cli/compareCases.py
Expand Up @@ -182,14 +182,7 @@ def invoke(self):
# contains all tests that user had access to
allTests = []
for pat in self.args.patterns + self.args.additional_comparisons:
name, ext = os.path.splitext(pat)
allTests.append(pat)
if ext == ".yaml":
# auto-add XML variants of yaml settings
# to accommodate comparisons against xml suites (e.g. testing)
xmlName = name + ".xml"
runLog.extra("Including {} in reference patterns.".format(xmlName))
allTests.append(xmlName)
refSuite.discover(
rootDir=self.args.reference,
patterns=allTests,
Expand Down
6 changes: 1 addition & 5 deletions armi/cli/database.py
Expand Up @@ -120,11 +120,7 @@ def invoke(self):
with db:
settings, geom, bp = db.readInputsFromDB()

settingsExt = ".yaml"
if settings.lstrip()[0] == "<":
settingsExt = ".xml"

settingsPath = self.args.output_base + "_settings" + settingsExt
settingsPath = self.args.output_base + "_settings.yaml"
bpPath = self.args.output_base + "_blueprints.yaml"

geomPath = None
Expand Down
1 change: 0 additions & 1 deletion armi/cli/migrateInputs.py
Expand Up @@ -61,7 +61,6 @@ def _migrate(settingsPath, dbPath):
Notes
-----
Some migrations change the paths so we update them one by one.
For example, a migration converts a settings file from xml to yaml.
"""
for migrationI in ACTIVE_MIGRATIONS:
if (
Expand Down
7 changes: 2 additions & 5 deletions armi/nuclearDataIO/xsLibraries.py
Expand Up @@ -406,7 +406,7 @@ def get(self, nuclideLabel, default):

def getNuclide(self, nucName, suffix):
"""
Get a nuclide object from the XS library or None.
Get a nuclide object from the XS library.
Parameters
----------
Expand All @@ -420,8 +420,8 @@ def getNuclide(self, nucName, suffix):
nuclide : Nuclide object
A nuclide from the library or None
"""

libLabel = nuclideBases.byName[nucName].label + suffix

try:
return self[libLabel]
except KeyError:
Expand Down Expand Up @@ -512,7 +512,6 @@ def getScatterWeights(self, scatterMatrixKey="elasticScatter"):
--------
_buildScatterWeights
"""

if not self._scatterWeights.get(scatterMatrixKey):
self._scatterWeights[scatterMatrixKey] = self._buildScatterWeights(
scatterMatrixKey
Expand Down Expand Up @@ -557,7 +556,6 @@ def plotNucXs(
"""
generates a XS plot for a nuclide on the ISOTXS library
nucName : str or list
The nuclides to plot
xsName : str or list
Expand All @@ -583,7 +581,6 @@ def plotNucXs(
armi.nucDirectory.nuclide.plotScatterMatrix
"""

# convert all input to lists
if isinstance(nucNames, str):
nucNames = [nucNames]
Expand Down
7 changes: 0 additions & 7 deletions armi/operators/settingsValidation.py
Expand Up @@ -312,13 +312,6 @@ def _inspectSettings(self):
# import here to avoid cyclic issues
from armi import operators

self.addQuery(
lambda: self.cs.path.endswith(".xml"),
"Your settings were loaded from a XML file. These are being converted to yaml files.",
"Would you like to auto-convert it to YAML?",
lambda: settings.convertSettingsFromXMLToYaml(self.cs),
)

self.addQueryBadLocationWillLikelyFail("operatorLocation")

self.addQuery(
Expand Down
5 changes: 0 additions & 5 deletions armi/physics/fuelCycle/fuelHandlers.py
Expand Up @@ -1453,11 +1453,6 @@ def _swapFluxParam(self, incoming, outgoing):
----------
incoming, outgoing : Assembly
Assembly objects to be swapped
Notes
-----
Assumes assemblies have the same block structure. If not, blocks will be swapped one-for-one until
the shortest one has been used up and then the process will truncate.
"""
# Find the block-based mesh points for each assembly
meshIn = self.r.core.findAllAxialMeshPoints([incoming], False)
Expand Down
31 changes: 22 additions & 9 deletions armi/reactor/components/__init__.py
Expand Up @@ -118,9 +118,13 @@ class UnshapedComponent(Component):
A component with undefined dimensions.
Useful for situations where you just want to enter the area directly.
For instance, in filler situations where the exact shape of this component is
is unknown but you have some left-over space between other components filled
with a known material you might need to model.
For instance, when you want to model neutronic behavior of an assembly based
on only knowing the area fractions of each material in the assembly.
See Also
--------
DerivedShape : Useful to just fill leftover space in a block with a material
"""

pDefs = componentParameters.getUnshapedParameterDefinitions()
Expand Down Expand Up @@ -159,32 +163,41 @@ def getComponentArea(self, cold=False):
cold : bool, optional
Ignored for this component
"""
return self.p.area
coldArea = self.p.area
if cold:
return coldArea

def setArea(self, val):
self.p.area = val
self.clearCache()
return self.getThermalExpansionFactor(self.temperatureInC) ** 2 * coldArea

def getBoundingCircleOuterDiameter(self, Tc=None, cold=False):
"""
Approximate it as circular and return the radius.
This is the smallest it can possibly be. Since this is used to determine
the outer component, it will never be allowed to be the outer one.
Notes
-----
Tc is not used in this method for this particular component.
"""
return math.sqrt(self.p.area / math.pi)
return 2 * math.sqrt(self.getComponentArea(cold=cold) / math.pi)

@staticmethod
def fromComponent(otherComponent):
"""
Build a new UnshapedComponent that has area equal to that of another component.
This can be used to "freeze" a DerivedShape, among other things.
Notes
-----
Components created in this manner will not thermally expand beyond the expanded
area of the original component, but will retain their hot temperature.
"""
newC = UnshapedComponent(
name=otherComponent.name,
material=otherComponent.material,
Tinput=otherComponent.inputTemperatureInC,
Tinput=otherComponent.temperatureInC,
Thot=otherComponent.temperatureInC,
area=otherComponent.getComponentArea(),
)
Expand Down
71 changes: 63 additions & 8 deletions armi/reactor/tests/test_components.py
Expand Up @@ -134,7 +134,13 @@ class TestGeneralComponents(unittest.TestCase):
componentMaterial = "HT9"
componentDims = {"Tinput": 25.0, "Thot": 25.0}

def setUp(self):
def setUp(self, component=None):
"""
Most of the time nothing will be passed as `component` and the result will
be stored in self, but you can also pass a component object as `component`,
in which case the object will be returned with the `parent` attribute assigned.
"""

class _Parent:
def getSymmetryFactor(self):
return 1.0
Expand All @@ -150,10 +156,14 @@ def getChildren(self):

derivedMustUpdate = False

self.component = self.componentCls(
"TestComponent", self.componentMaterial, **self.componentDims
)
self.component.parent = _Parent()
if component == None:
self.component = self.componentCls(
"TestComponent", self.componentMaterial, **self.componentDims
)
self.component.parent = _Parent()
else:
component.parent = _Parent()
return component


class TestComponent(TestGeneralComponents):
Expand Down Expand Up @@ -189,14 +199,59 @@ def test_getDimension(self):

class TestUnshapedComponent(TestGeneralComponents):
componentCls = UnshapedComponent
componentMaterial = "Material"
componentMaterial = "HT9"
componentDims = {"Tinput": 25.0, "Thot": 430.0, "area": math.pi}

def test_getComponentArea(self):
# a case without thermal expansion
self.assertEqual(self.component.getComponentArea(cold=True), math.pi)

# a case with thermal expansion
self.assertEqual(
self.component.getComponentArea(cold=False),
math.pi
* self.component.getThermalExpansionFactor(self.component.temperatureInC)
** 2,
)

# show that area expansion is consistent with the density change in the material
hotDensity = self.component.density()
hotArea = self.component.getArea()
thermalExpansionFactor = self.component.getThermalExpansionFactor(
self.component.temperatureInC
)

coldComponent = self.setUp(
UnshapedComponent(
name="coldComponent",
material=self.componentMaterial,
Tinput=self.component.inputTemperatureInC,
Thot=self.component.inputTemperatureInC,
area=math.pi,
)
)
coldDensity = coldComponent.density()
coldArea = coldComponent.getArea()

self.assertGreater(thermalExpansionFactor, 1)
self.assertAlmostEqual(
(coldDensity / hotDensity) / (thermalExpansionFactor * hotArea / coldArea),
1,
) # account for density being 3D while area is 2D

def test_getBoundingCircleOuterDiameter(self):
self.assertEqual(self.component.getBoundingCircleOuterDiameter(cold=True), 1.0)
# a case without thermal expansion
self.assertEqual(self.component.getBoundingCircleOuterDiameter(cold=True), 2.0)

# a case with thermal expansion
self.assertEqual(
self.component.getBoundingCircleOuterDiameter(cold=False),
2.0
* self.component.getThermalExpansionFactor(self.component.temperatureInC),
)

def test_fromComponent(self):
circle = components.Circle("testCircle", "Material", 25, 25, 1.0)
circle = components.Circle("testCircle", "HT9", 25, 500, 1.0)
unshaped = components.UnshapedComponent.fromComponent(circle)
self.assertEqual(circle.getComponentArea(), unshaped.getComponentArea())

Expand Down
2 changes: 0 additions & 2 deletions armi/scripts/migration/__init__.py
Expand Up @@ -33,15 +33,13 @@
"""

from . import (
m0_1_0_settings,
m0_1_3,
m0_1_0_newDbFormat,
crossSectionBlueprintsToSettings,
m0_1_6_locationLabels,
)

ACTIVE_MIGRATIONS = [
m0_1_0_settings.ConvertXmlSettingsToYaml,
m0_1_0_newDbFormat.ConvertDB2toDB3,
m0_1_3.RemoveCentersFromBlueprints,
m0_1_3.UpdateElementalNuclides,
Expand Down
63 changes: 0 additions & 63 deletions armi/scripts/migration/m0_1_0_settings.py

This file was deleted.

0 comments on commit aa58016

Please sign in to comment.