Skip to content

Commit

Permalink
Identifying non-Framework settings (#443)
Browse files Browse the repository at this point in the history
* Separating out non-Framework settings
* Adding basic unit test for LatticePhysicsWriter
  • Loading branch information
john-science committed Oct 14, 2021
1 parent ac8f316 commit c52e852
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 9 deletions.
80 changes: 80 additions & 0 deletions armi/physics/neutronics/latticePhysics/tests/test_latticeWriter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2021 TerraPower, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Test the Lattice Physics Writer"""

import os
import unittest

from armi.physics.neutronics.const import CONF_CROSS_SECTION
from armi.physics.neutronics.latticePhysics.latticePhysicsWriter import (
LatticePhysicsWriter,
)
from armi.reactor.tests.test_reactors import loadTestReactor
from armi.tests import TEST_ROOT


class FakeLatticePhysicsWriter(LatticePhysicsWriter):
"""LatticePhysicsWriter is abstract, so it must be subclassed to be tested"""

def __init__(self, block, r, eci):
self.testOut = ""
super(FakeLatticePhysicsWriter, self).__init__(block, r, eci, "", False)

def write(self):
pass

def _writeNuclide(
self, fileObj, nuclide, density, nucTemperatureInC, category, xsIdSpecified=None
):
pass

def _writeComment(self, fileObj, msg):
self.testOut += "\n" + str(msg)

def _writeGroupStructure(self, fileObj):
pass


class TestLatticePhysicsWriter(unittest.TestCase):
"""Test Lattice Physics Writer."""

def test_LatticePhysicsWriter(self):
"""Super basic test of the LatticePhysicsWriter"""
o, r = loadTestReactor(TEST_ROOT)
cs = o.cs
o.cs[CONF_CROSS_SECTION].setDefaults(
cs["xsBlockRepresentation"], cs["disableBlockTypeExclusionInXsGeneration"]
)
block = r.core.getFirstBlock()
w = FakeLatticePhysicsWriter(block, r, o)

self.assertEqual(w.xsId, "AA")
self.assertFalse(w.modelFissionProducts)
self.assertEqual(w.driverXsID, "")
self.assertAlmostEqual(w.minimumNuclideDensity, 1e-15, delta=1e-16)

self.assertEqual(w.testOut, "")
self.assertEqual(str(w), "<FakeLatticePhysicsWriter - XS ID AA (Neutron XS)>")

w._writeTitle(None)
self.assertIn("ARMI generated case for caseTitle armiRun", w.testOut)

nucs = w._getAllNuclidesByTemperatureInC(None)
self.assertEqual(len(nucs.keys()), 1)
self.assertAlmostEqual(list(nucs.keys())[0], 450.0, delta=0.1)


if __name__ == "__main__":
unittest.main()
19 changes: 10 additions & 9 deletions armi/settings/fwSettings/globalSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
should only include settings that are not related to any particular physics or plugins.
TODO: There are lots of settings in here that violate the above rule, which still need
to be migrated to their respective plugins.
to be migrated to their respective plugins: they are clearly separated for review.
"""
import os
from typing import List
Expand All @@ -35,7 +35,6 @@
CONF_BURN_CHAIN_FILE_NAME = "burnChainFileName"
CONF_ZONING_STRATEGY = "zoningStrategy"
CONF_AXIAL_MESH_REFINEMENT_FACTOR = "axialMeshRefinementFactor"
CONF_CONDITIONAL_MODULE_NAME = "conditionalModuleName"
CONF_AUTOMATIC_VARIABLE_MESH = "automaticVariableMesh"
CONF_TRACE = "trace"
CONF_PROFILE = "profile"
Expand Down Expand Up @@ -69,30 +68,26 @@
CONF_EQ_DIRECT = "eqDirect" # fuelCycle/equilibrium coupling
CONF_FRESH_FEED_TYPE = "freshFeedType"
CONF_GEOM_FILE = "geomFile"
CONF_GROW_TO_FULL_CORE_AFTER_LOAD = "growToFullCoreAfterLoad"
CONF_START_CYCLE = "startCycle"
CONF_LOADING_FILE = "loadingFile"
CONF_START_NODE = "startNode"
CONF_LOAD_STYLE = "loadStyle"
CONF_LOW_POWER_REGION_FRACTION = "lowPowerRegionFraction" # reports
CONF_MEM_PER_NODE = "memPerNode"
CONF_MODULE_VERBOSITY = "moduleVerbosity"
CONF_MPI_TASKS_PER_NODE = "mpiTasksPerNode"
CONF_N_CYCLES = "nCycles"
CONF_NUM_CONTROL_BLOCKS = "numControlBlocks" # dif3d
CONF_NUM_COUPLED_ITERATIONS = "numCoupledIterations"
CONF_OPERATOR_LOCATION = "operatorLocation"
CONF_OUTPUT_FILE_EXTENSION = "outputFileExtension"
CONF_PLOTS = "plots"
CONF_POWER = "power"
CONF_REMOVE_PER_CYCLE = "removePerCycle" # fuel handler
CONF_RUN_TYPE = "runType"
CONF_EXPLICIT_REPEAT_SHUFFLES = "explicitRepeatShuffles"
CONF_SKIP_CYCLES = "skipCycles"
CONF_SMALL_RUN = "smallRun"
CONF_REALLY_SMALL_RUN = "reallySmallRun"
CONF_STATIONARY_BLOCKS = "stationaryBlocks"
CONF_TARGET_K = "targetK" # lots of things use this; not clear who should own
CONF_TARGET_K = "targetK" # lots of things use this
CONF_TRACK_ASSEMS = "trackAssems"
CONF_VERBOSITY = "verbosity"
CONF_ZONE_DEFINITIONS = "zoneDefinitions"
Expand All @@ -105,18 +100,24 @@
CONF_LOOSE_COUPLING = "looseCoupling"
CONF_T_IN = "Tin"
CONF_T_OUT = "Tout"
CONF_USE_INPUT_TEMPERATURES_ON_DBLOAD = "useInputTemperaturesOnDBLoad"
CONF_DEFERRED_INTERFACES_CYCLE = "deferredInterfacesCycle"
CONF_DEFERRED_INTERFACE_NAMES = "deferredInterfaceNames"
CONF_OUTPUT_CACHE_LOCATION = "outputCacheLocation"
CONF_MATERIAL_NAMESPACE_ORDER = "materialNamespaceOrder"
CONF_DETAILED_AXIAL_EXPANSION = "detailedAxialExpansion"
CONF_BLOCK_AUTO_GRID = "autoGenerateBlockGrids"

# Unused by ARMI, slated for removal
CONF_CONDITIONAL_MODULE_NAME = "conditionalModuleName" # mcfr
CONF_GROW_TO_FULL_CORE_AFTER_LOAD = "growToFullCoreAfterLoad" # mcnp & gui
CONF_MEM_PER_NODE = "memPerNode" # unused?
CONF_NUM_CONTROL_BLOCKS = "numControlBlocks" # dif3d
CONF_REMOVE_PER_CYCLE = "removePerCycle" # fuel handler, equilibrium, mcnp
CONF_USE_INPUT_TEMPERATURES_ON_DBLOAD = "useInputTemperaturesOnDBLoad" # th


def defineSettings() -> List[setting.Setting]:
"""Return a list of global framework settings."""

settings = [
setting.Setting(
CONF_NUM_PROCESSORS,
Expand Down

0 comments on commit c52e852

Please sign in to comment.