def test_setMass(self): """ test: setMass setMasses """ loc = locations.Location(i1=1, i2=1, axial=1) mass = 1.0 aB = batch.Batch("testBatch") c = shapes.UnshapedVolumetricComponent( "batchMassAdditionComponent", custom.Custom(), 0.0, 0.0, volume=1 ) b = blocks.Block("testBlock", location=loc) b.add(c) a = assemblies.Assembly("testAssembly") a.spatialGrid = grids.axialUnitGrid(1, a) a.add(b) r = getEmptyHexReactor() a.spatialLocator = r.core.spatialGrid[0, 0, 0] r.core.add(a) # these armi objects have setMass implemented for armiObj in [aB, c, b]: for nucName in ["U235"]: masses = {nucName: mass} armiObj.setMasses(masses) self.assertAlmostEqual(armiObj.getMass(nucName), mass, 6)
def buildOperatorOfEmptyHexBlocks(customSettings=None): """ Builds a operator w/ a reactor object with some hex assemblies and blocks, but all are empty Doesn't depend on inputs and loads quickly. Params ------ customSettings : dict Dictionary of off-default settings to update """ settings.setMasterCs(None) # clear cs = settings.getMasterCs() # fetch new cs["db"] = False # stop use of database if customSettings is not None: cs.update(customSettings) r = tests.getEmptyHexReactor() r.core.setOptionsFromCs(cs) o = operators.Operator(cs) o.initializeInterfaces(r) a = assemblies.HexAssembly("fuel") a.spatialGrid = grids.axialUnitGrid(1) b = blocks.HexBlock("TestBlock") b.setType("fuel") dims = {"Tinput": 600, "Thot": 600, "op": 16.0, "ip": 1, "mult": 1} c = Hexagon("fuel", uZr.UZr(), **dims) b.add(c) a.add(b) a.spatialLocator = r.core.spatialGrid[1, 0, 0] o.r.core.add(a) return o
def test_addMass(self): """ test: addMasses addMass removeMass getMasses right now it doesn't make sense to add mass to anything other than a component, some one else can implement addMass and update this test on block, assembly and reactor. """ loc = locations.Location(i1=1, i2=1, axial=1) mass = 1.0 aB = batch.Batch("testBatch") c = shapes.UnshapedVolumetricComponent("batchMassAdditionComponent", custom.Custom(), 0.0, 0.0, volume=1) b = blocks.Block("testBlock", location=loc) b.add(c) a = assemblies.Assembly("testAssembly") a.spatialGrid = grids.axialUnitGrid(1) a.add(b) r = getEmptyHexReactor() a.spatialLocator = r.core.spatialGrid[0, 0, 0] r.core.add(a) # these armi objects have addMass implemented for armiObj in [aB, c]: for nucName in ["U235"]: masses = {nucName: mass} armiObj.addMasses(masses) self.assertAlmostEqual(armiObj.getMass(nucName), mass, 6) armiObj.removeMass(nucName, mass) self.assertAlmostEqual(armiObj.getMass(nucName), 0, 6) # create a global lumped fission product collection with a single lfp Fpdf = test_lumpedFissionProduct.getDummyLFPFile() cLfps = Fpdf.createSingleLFPCollectionFromFile("LFP35") self.assertAlmostEqual(aB.getMass(), 0, 6) aB.addMass("LFP35", mass, lumpedFissionProducts=cLfps) self.assertAlmostEqual(aB.getMass(), mass, 6) self.assertAlmostEqual(c.getMass(), 0, 6) c.addMass("LFP35", mass, lumpedFissionProducts=cLfps) self.assertAlmostEqual(c.getMass(), mass, 6)
def test_kineticsParameterAssignment(self): """Test that the delayed neutron fraction and precursor decay constants are applied from settings.""" def _getModifiedSettings(customSettings): cs = settings.Settings() newSettings = {} for key, val in customSettings.items(): newSettings[key] = val return cs.modified(newSettings=newSettings) r = tests.getEmptyHexReactor() self.assertIsNone(r.core.p.beta) self.assertIsNone(r.core.p.betaComponents) self.assertIsNone(r.core.p.betaDecayConstants) # Test that the group-wise beta and decay constants are assigned # together given that they are the same length. r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "beta": [0.0] * 6, "decayConstants": [0.0] * 6, }) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) r.core.setOptionsFromCs(cs) self.assertEqual(r.core.p.beta, sum(cs["beta"])) self.assertListEqual(list(r.core.p.betaComponents), cs["beta"]) self.assertListEqual(list(r.core.p.betaDecayConstants), cs["decayConstants"]) # Test the assignment of total beta as a float r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={"beta": 0.00670}, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) self.assertEqual(r.core.p.beta, cs["beta"]) self.assertIsNone(r.core.p.betaComponents) self.assertIsNone(r.core.p.betaDecayConstants) # Test that nothing is assigned if the beta is specified as a list # without a corresponding decay constants list. r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "beta": [0.0] * 6, }, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) self.assertIsNone(r.core.p.beta) self.assertIsNone(r.core.p.betaComponents) self.assertIsNone(r.core.p.betaDecayConstants) # Test that 1 group beta components and decay constants can be assigned. # Since beta is a list, ensure that it's assigned to the `betaComponents` # parameter. r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "beta": [0.0], "decayConstants": [0.0] }, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) self.assertEqual(r.core.p.beta, sum(cs["beta"])) self.assertListEqual(list(r.core.p.betaComponents), cs["beta"]) self.assertListEqual(list(r.core.p.betaDecayConstants), cs["decayConstants"]) # Test that decay constants are not assigned without a corresponding # group-wise beta input. r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={"decayConstants": [0.0] * 6}, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) self.assertIsNone(r.core.p.beta) self.assertIsNone(r.core.p.betaComponents) self.assertIsNone(r.core.p.betaDecayConstants) # Test that decay constants are not assigned without a corresponding # group-wise beta input. This also demonstrates that the total beta # is still assigned. r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "decayConstants": [0.0] * 6, "beta": 0.0 }, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) self.assertEqual(r.core.p.beta, cs["beta"]) self.assertIsNone(r.core.p.betaComponents) self.assertIsNone(r.core.p.betaDecayConstants) # Test the demonstrates that None values are acceptable # and that nothing is assigned. r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "decayConstants": None, "beta": None }, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) self.assertEqual(r.core.p.beta, cs["beta"]) self.assertIsNone(r.core.p.betaComponents) self.assertIsNone(r.core.p.betaDecayConstants) # Test that an error is raised if the decay constants # and group-wise beta are inconsistent sizes with self.assertRaises(ValueError): r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "decayConstants": [0.0] * 6, "beta": [0.0] }, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) # Test that an error is raised if the decay constants # and group-wise beta are inconsistent sizes with self.assertRaises(ValueError): r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={ "decayConstants": [0.0] * 6, "beta": [0.0] * 5 }, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) # The following tests check the voluptuous schema definition. This # ensures that anything except NoneType, [float], float are not valid # inputs. with self.assertRaises(vol.AnyInvalid): r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={"decayConstants": [1]}, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) with self.assertRaises(vol.AnyInvalid): r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={"beta": [1]}, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) with self.assertRaises(vol.AnyInvalid): r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={"beta": 1}, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs) with self.assertRaises(vol.AnyInvalid): r = tests.getEmptyHexReactor() cs = _getModifiedSettings(customSettings={"beta": (1, 2, 3)}, ) getPluginManagerOrFail().hook.onProcessCoreLoading(core=r.core, cs=cs)
def setUp(self): self.name = "A0015" self.assemNum = 15 self.height = 10 self.cs = settings.getMasterCs() # Print nothing to the screen that would normally go to the log. runLog.setVerbosity("error") self.r = tests.getEmptyHexReactor() self.r.core.symmetry = geometry.SymmetryType( geometry.DomainType.THIRD_CORE, geometry.BoundaryType.PERIODIC) self.assembly = makeTestAssembly(NUM_BLOCKS, self.assemNum, r=self.r) self.r.core.add(self.assembly) # Use these if they are needed self.blockParams = { "height": self.height, "avgFuelTemp": 873.0, "bondRemoved": 0.0, "bu": 15.1, "buGroupNum": 0, "buLimit": 35, "buRate": 0.0, "eqRegion": -1, "id": 212.0, "pdens": 10.0, "percentBu": 25.3, "power": 100000.0, "residence": 4.0, "smearDensity": 0.6996721711791459, "timeToLimit": 2.7e5, "xsTypeNum": 40, "zbottom": 97.3521, "ztop": 111.80279999999999, } self.blockSettings = { "axMesh": 1, "baseBu": 0.0, "basePBu": 0.0, "bondBOL": 0.0028698019026172574, "buGroup": "A", "height": 14.4507, "molesHmAtBOL": 65.8572895758245, "nHMAtBOL": 0.011241485251783766, "nPins": 169.0, "name": "B0011F", "newDPA": 0.0, "pitch": 16.79, "regName": False, "topIndex": 5, "tsIndex": 0, "type": "igniter fuel", "xsType": "C", "z": 104.57745, } # add some blocks with a component self.blockList = [] for i in range(NUM_BLOCKS): b = blocks.HexBlock("TestHexBlock") b.setHeight(self.height) self.hexDims = { "Tinput": 273.0, "Thot": 273.0, "op": 0.76, "ip": 0.0, "mult": 1.0, } h = components.Hexagon("fuel", "UZr", **self.hexDims) # non-flaggy name important for testing b.setType("igniter fuel unitst") b.add(h) b.parent = self.assembly b.setName(b.makeName(self.assembly.getNum(), i)) self.assembly.add(b) self.blockList.append(b) self.assembly.calculateZCoords()
def test_getMgFluxes(self): """ test: getMgFlux getIntegratedMgFlux """ mgFlux1 = [ 0.0860473241399844, 0.104859413902775, 0.958730499751868, 0.0608613995961131, 0.286847241591555, 0.255889308191141, 0.0116901206385536, 0.713409716738126, 0.430296361167501, 0.807797711781478, 0.0337645123548413, 0.486499349955704, 0.734614285636136, 0.74230952191973, 0.262181249681019, 0.499163237742064, 0.522320530090222, 0.269684933319214, 0.286697941919085, 0.173049285638012, 0.881264543688633, 0.99461769495224, 0.267737005223648, 0.957400117341211, 0.767927939604005, 0.149702253058259, 0.332924880721111, 0.611969570430789, 0.227989279697323, 0.411852641375799, 0.500275641106796, 0.654655431372318, 0.223981131922656, ] loc = locations.Location(i1=1, i2=1, axial=1) c = UnshapedVolumetricComponent("testComponent", "Custom", 0.0, 0.0, volume=1) b = blocks.Block("testBlock", location=loc) b.add(c) b.p.mgFlux = mgFlux1 a = assemblies.Assembly("testAssembly") a.spatialGrid = grids.axialUnitGrid(1, a) a.add(b) r = getEmptyHexReactor() a.spatialLocator = r.core.spatialGrid[0, 0, 0] r.core.add(a) aB = batch.Batch("testBatch") aB.add(b) for armiObject in [c, b, a, r, aB]: for refFlux, testFlux in zip(mgFlux1, armiObject.getIntegratedMgFlux()): err = math.fabs((testFlux - refFlux) / refFlux) try: assert err < 1e-6 except AssertionError: raise AssertionError( "Integrated MgFlux test is failing for {}".format( type(armiObject) ) ) for refFlux, testFlux in zip(mgFlux1, armiObject.getMgFlux()): err = math.fabs((testFlux - refFlux) / refFlux) try: assert err < 1e-6 except AssertionError: raise AssertionError( "Integrated MgFlux test is failing for {}".format( type(armiObject) ) )
def test_getReactionRates(self): """ test: getReactionRates getReactionRates """ mgFlux1 = [ 0.0860473241399844, 0.104859413902775, 0.958730499751868, 0.0608613995961131, 0.286847241591555, 0.255889308191141, 0.0116901206385536, 0.713409716738126, 0.430296361167501, 0.807797711781478, 0.0337645123548413, 0.486499349955704, 0.734614285636136, 0.74230952191973, 0.262181249681019, 0.499163237742064, 0.522320530090222, 0.269684933319214, 0.286697941919085, 0.173049285638012, 0.881264543688633, 0.99461769495224, 0.267737005223648, 0.957400117341211, 0.767927939604005, 0.149702253058259, 0.332924880721111, 0.611969570430789, 0.227989279697323, 0.411852641375799, 0.500275641106796, 0.654655431372318, 0.223981131922656, ] lib = isotxs.readBinary(ISOAA_PATH) loc = locations.Location(i1=1, i2=1, axial=1) nDens = 0.02 # arbitrary number density for U235 c = UnshapedVolumetricComponent("testComponent", "Custom", 0.0, 0.0, volume=1) c.setNumberDensity("U235", nDens) b = blocks.Block("testBlock", location=loc) b.add(c) b.p.mgFlux = mgFlux1[:33] b.p.xsType = "A" a = assemblies.Assembly("testAssembly") a.spatialGrid = grids.axialUnitGrid(1, a) a.add(b) r = getEmptyHexReactor() a.spatialLocator = r.core.spatialGrid[0, 0, 0] r.core.add(a) r.core.lib = lib aB = batch.Batch("testBatch") aB.add(b) # reference data made with this ISOTXS and this MG flux spectrum referenceRxRateData = { "nG": 2.10693674, "nF": 6.500339249, "n2n": 0.001446367, "nA": 0, "nP": 0, "n3n": 0, } referenceXsData = { "nG": 7.162060679, "nF": 22.09645085, "n2n": 0.004916601, "nA": 0, "nP": 0, "n3n": 0, } u235 = lib["U235AA"] assert not hasattr(u235.micros, "n3n") for armiObject in [c, b, a, r, aB]: rxnRates = armiObject.getReactionRates("U235") for rxName, rxRate in rxnRates.items(): self.assertAlmostEqual(rxRate, referenceRxRateData[rxName], 6) xsTable = armiObject.getCrossSectionTable(nuclides=["U235"]) u235Zaid = 92235 for rxName, rxRate in xsTable[u235Zaid].items(): self.assertAlmostEqual(rxRate, referenceXsData[rxName], 6)