def buildBlockWithTSL(): """Return a simple block containing something with a TSL (graphite).""" b = blocks.HexBlock("fuel", height=10.0) fuelDims = { "Tinput": 25.0, "Thot": 600, "od": 0.76, "id": 0.00, "mult": 127.0 } cladDims = { "Tinput": 25.0, "Thot": 450, "od": 0.80, "id": 0.77, "mult": 127.0 } coolDims = {"Tinput": 25.0, "Thot": 400} fuel = components.Circle("fuel", "UZr", **fuelDims) clad = components.Circle("clad", "Graphite", **cladDims) coolant = components.DerivedShape("coolant", "Sodium", **coolDims) b.add(fuel) b.add(clad) b.add(coolant) return b
def setUp(self): r""" Build a dummy reactor without using input files. There are some igniters and feeds but none of these have any number densities. """ self.o, self.r = test_reactors.loadTestReactor( self.directoryChanger.destination ) blockList = self.r.core.getBlocks() for bi, b in enumerate(blockList): b.p.flux = 5e10 if b.isFuel(): b.p.percentBu = 30.0 * bi / len(blockList) self.nfeed = len(self.r.core.getAssemblies(Flags.FEED)) self.nigniter = len(self.r.core.getAssemblies(Flags.IGNITER)) self.nSfp = len(self.r.core.sfp) # generate a reactor with assemblies # generate components with materials nPins = 271 fuelDims = {"Tinput": 273.0, "Thot": 273.0, "od": 1.0, "id": 0.0, "mult": nPins} fuel = components.Circle("fuel", "UZr", **fuelDims) cladDims = {"Tinput": 273.0, "Thot": 273.0, "od": 1.1, "id": 1.0, "mult": nPins} clad = components.Circle("clad", "HT9", **cladDims) interDims = { "Tinput": 273.0, "Thot": 273.0, "op": 16.8, "ip": 16.0, "mult": 1.0, } interSodium = components.Hexagon("interCoolant", "Sodium", **interDims) # generate a block self.block = blocks.HexBlock("TestHexBlock", self.o.cs) self.block.setType("fuel") self.block.setHeight(10.0) self.block.add(fuel) self.block.add(clad) self.block.add(interSodium) # generate an assembly self.assembly = assemblies.HexAssembly("TestAssemblyType") self.assembly.spatialGrid = grids.axialUnitGrid(1) for _ in range(1): self.assembly.add(copy.deepcopy(self.block)) # copy the assembly to make a list of assemblies and have a reference assembly self.aList = [] for _ in range(6): self.aList.append(copy.deepcopy(self.assembly)) self.refAssembly = copy.deepcopy(self.assembly) self.directoryChanger.open()
def setUpClass(cls): caseSetting = settings.Settings() _, cls.r = test_reactors.loadTestReactor() cls.hexBlock = cls.r.core.getBlocks()[0] cls.cartesianBlock = blocks.CartesianBlock("TestCartesianBlock", caseSetting) cartesianComponent = components.HoledSquare( "duct", "UZr", Tinput=273.0, Thot=273.0, holeOD=68.0, widthOuter=12.5, mult=1.0, ) cls.cartesianBlock.add(cartesianComponent) cls.cartesianBlock.add( components.Circle("clad", "HT9", Tinput=273.0, Thot=273.0, od=68.0, mult=169.0))
def test_getHMMass(self): fuelDims = { "Tinput": 273.0, "Thot": 273.0, "od": 0.76, "id": 0.0, "mult": 1.0 } self.fuelComponent = components.Circle("fuel", "UZr", **fuelDims) self.Block.add(self.fuelComponent) self.Block.clearNumberDensities() self.refDict = { "U235": 0.00275173784234, "U238": 0.0217358415457, "W182": 1.09115150103e-05, "W183": 5.89214392093e-06, "W184": 1.26159558164e-05, "W186": 1.17057432664e-05, "V": 3e-2, "NA23": 2e-2, "ZR": 0.00709003962772, } self.Block.setNumberDensities(self.refDict) cur = self.Block.getHMMass() mass = 0.0 for nucName in self.refDict.keys(): if nucDir.isHeavyMetal(nucName): mass += self.Block.getMass(nucName) places = 6 self.assertAlmostEqual(cur, mass, places=places)
def test_failOnMultiple(self): """HT9 has carbon in it with no TSL, while graphite has C with TSL. This should crash""" b = buildBlockWithTSL() cladDims = {"Tinput": 25.0, "Thot": 450, "od": 0.80, "id": 0.79, "mult": 127.0} clad2 = components.Circle("clad", "HT9", **cladDims) b.add(clad2) with self.assertRaises(RuntimeError): getNuclideThermalScatteringData(b)
def _addSolidMaterialRing(baseComponent, innerDiameter, outDiameter, name): circle = components.Circle( name, baseComponent.material, baseComponent.temperatureInC, baseComponent.temperatureInC, id=innerDiameter, od=outDiameter, mult=1, ) circle.setNumberDensities(baseComponent.getNumberDensities()) return circle
def _buildJoyoFuel(): """Build some JOYO components.""" fuel = components.Circle( name="fuel", material="UO2", Tinput=20.0, Thot=20.0, od=0.28 * 2, id=0.0, mult=91, ) clad = components.Circle( name="fuel", material="HT9", Tinput=20.0, Thot=20.0, od=0.315 * 2, id=0.28 * 2, mult=91, ) return fuel, clad
def _addBlockRings(self, blockToAdd, blockName, numRingsToAdd, firstRing, mainComponent=None): """Add a homogenous block ring to the converted block.""" runLog.info( "Converting representative block {} to its equivalent cylindrical model" .format(self._sourceBlock)) innerDiam = (self.convertedBlock[-1].getDimension("od") if len(self.convertedBlock) else 0.0) if mainComponent is not None: newCompProps = mainComponent.material tempInput = tempHot = mainComponent.temperatureInC else: # no component specified so just use block vals newCompProps = ( "Custom" # this component shouldn't change temperature anyway ) tempInput = tempHot = blockToAdd.getAverageTempInC() if isinstance(blockToAdd, blocks.HexBlock): grid = grids.HexGrid.fromPitch(1.0) elif isinstance(blockToAdd, blocks.CartesianBlock): grid = grids.CartesianGrid.fromRectangle(1.0, 1.0) else: raise ValueError( f"The `sourceBlock` of type {type(blockToAdd)} is not supported in {self}." ) for ringNum in range(firstRing, firstRing + numRingsToAdd): numFuelBlocksInRing = grid.getPositionsInRing(ringNum) assert numFuelBlocksInRing is not None fuelBlockTotalArea = numFuelBlocksInRing * blockToAdd.getArea() driverOuterDiam = getOuterDiamFromIDAndArea( innerDiam, fuelBlockTotalArea) driverRing = components.Circle( blockName, newCompProps, tempInput, tempHot, od=driverOuterDiam, id=innerDiam, mult=1, ) driverRing.setNumberDensities(blockToAdd.getNumberDensities()) self.convertedBlock.add(driverRing) innerDiam = driverOuterDiam
def _addCoolantRing(self, coolantOD, nameSuffix): innerDiam = self.convertedBlock[-1].getDimension("od") irc = self.interRingComponent interRing = components.Circle( irc.name + nameSuffix, irc.material, irc.temperatureInC, irc.temperatureInC, od=coolantOD, id=innerDiam, mult=1, ) interRing.setNumberDensities(irc.getNumberDensities()) self.convertedBlock.add(interRing) self._remainingCoolantFillArea -= interRing.getArea()
def test_getFPMass(self): fuelDims = {"Tinput": 273.0, "Thot": 273.0, "od": 0.76, "id": 0.0, "mult": 1.0} self.fuelComponent = components.Circle("fuel", "UZr", **fuelDims) self.fuelComponent.material.setMassFrac("LFP38", 0.25) self.Block.addComponent(self.fuelComponent) refDict = {"LFP35": 0.1, "LFP38": 0.05, "LFP39": 0.7} self.fuelComponent.setNumberDensities(refDict) cur = self.Block.getFPMass() mass = 0.0 for nucName in refDict.keys(): mass += self.Block.getMass(nucName) ref = mass places = 6 self.assertAlmostEqual(cur, ref, places=places)
def _addBlockRings(self, blockToAdd, blockName, numRingsToAdd, firstRing, mainComponent=None): """Add a homogenous block ring to the converted block.""" runLog.info( "Converting representative block {} to its equivalent cylindrical model" .format(self._sourceBlock)) innerDiam = (self.convertedBlock[-1].getDimension("od") if len(self.convertedBlock) else 0.0) if mainComponent is not None: newCompProps = mainComponent.material tempInput = tempHot = mainComponent.temperatureInC else: # no component specified so just use block vals newCompProps = ( "Custom" # this component shouldn't change temperature anyway ) tempInput = tempHot = blockToAdd.getAverageTempInC() for ringNum in range(firstRing, firstRing + numRingsToAdd): numFuelBlocksInRing = locations.numPositionsInRing( blockToAdd, ringNum) assert numFuelBlocksInRing is not None fuelBlockTotalArea = numFuelBlocksInRing * self._driverFuelBlock.getArea( ) driverOuterDiam = getOuterDiamFromIDAndArea( innerDiam, fuelBlockTotalArea) driverRing = components.Circle( blockName, newCompProps, tempInput, tempHot, od=driverOuterDiam, id=innerDiam, mult=1, ) driverRing.setNumberDensities(blockToAdd.getNumberDensities()) self.convertedBlock.add(driverRing) innerDiam = driverOuterDiam
def test_fromComponent(self): circle = components.Circle("testCircle", "Material", 25, 25, 1.0) unshaped = components.UnshapedComponent.fromComponent(circle) self.assertEqual(circle.getComponentArea(), unshaped.getComponentArea())
def buildTestAssemblies(): """ Build some assembly objects that will be used in testing. This builds 2 HexBlocks: * One with half UZr pins and half UTh pins * One with all UThZr pins """ caseSetting = settings.Settings() settings.setMasterCs(caseSetting) temperature = 273.0 fuelID = 0.0 fuelOD = 1.0 cladOD = 1.1 # generate a reactor with assemblies # generate components with materials nPins = 100 fuelDims = { "Tinput": temperature, "Thot": temperature, "od": fuelOD, "id": fuelID, "mult": nPins, } fuelUZr = components.Circle("fuel", "UZr", **fuelDims) fuelUTh = components.Circle("fuel UTh", "ThU", **fuelDims) fuelDims2nPins = { "Tinput": temperature, "Thot": temperature, "od": fuelOD, "id": fuelID, "mult": 2 * nPins, } fuelUThZr = components.Circle("fuel B", "UThZr", **fuelDims2nPins) cladDims = { "Tinput": temperature, "Thot": temperature, "od": cladOD, "id": fuelOD, "mult": 2 * nPins, } clad = components.Circle("clad", "HT9", **cladDims) interDims = { "Tinput": temperature, "Thot": temperature, "op": 16.8, "ip": 16.0, "mult": 1.0, } interSodium = components.Hexagon("interCoolant", "Sodium", **interDims) block = blocks.HexBlock("fuel") block2 = blocks.HexBlock("fuel") block.setType("fuel") block.setHeight(10.0) block.add(fuelUZr) block.add(fuelUTh) block.add(clad) block.add(interSodium) block.p.axMesh = 1 block.p.molesHmBOL = 1.0 block.p.molesHmNow = 1.0 block2.setType("fuel") block2.setHeight(10.0) block2.add(fuelUThZr) block2.add(clad) block2.add(interSodium) block2.p.axMesh = 1 block2.p.molesHmBOL = 2 block2.p.molesHmNow = 1.0 assemblieObjs = [] for numBlocks, blockTemplate in zip([1, 1, 5, 4], [block, block2, block, block]): assembly = assemblies.HexAssembly("testAssemblyType") assembly.spatialGrid = grids.axialUnitGrid(numBlocks) assembly.spatialGrid.armiObject = assembly for _i in range(numBlocks): newBlock = copy.deepcopy(blockTemplate) assembly.add(newBlock) assembly.calculateZCoords() assembly.reestablishBlockOrder() assemblieObjs.append(assembly) return assemblieObjs