def plotConvertedReactor(self): bpAssems = list(self.convReactor.blueprints.assemblies.values()) assemsToPlot = [] for bpAssem in bpAssems: coreAssems = self.convReactor.core.getAssemblies(bpAssem.p.flags) if not coreAssems: continue assemsToPlot.append(coreAssems[0]) # Obtain the plot numbering based on the existing files so that existing plots # are not overwritten. start = 0 existingFiles = glob.glob( f"{self.convReactor.core.name}AssemblyTypes" + "*" + ".png") # This loops over the existing files for the assembly types outputs # and makes a unique integer value so that plots are not overwritten. The # regular expression here captures the first integer as AssemblyTypesX and # then ensures that the numbering in the next enumeration below is 1 above that. for f in existingFiles: newStart = int(re.search(r"\d+", f).group()) if newStart > start: start = newStart for plotNum, assemBatch in enumerate(iterables.chunk(assemsToPlot, 6), start=start + 1): assemPlotName = f"{self.convReactor.core.name}AssemblyTypes{plotNum}-rank{armi.MPI_RANK}.png" plotting.plotAssemblyTypes( self.convReactor.blueprints, assemPlotName, assemBatch, maxAssems=6, showBlockAxMesh=True, )
def plotConvertedReactor(self): assemsToPlot = self.convReactor.core[:12] for plotNum, assemBatch in enumerate(iterables.chunk(assemsToPlot, 6), start=1): assemPlotName = f"{self.convReactor.core.name}AssemblyTypes{plotNum}.png" plotting.plotAssemblyTypes( self.convReactor.core.parent.blueprints, assemPlotName, assemBatch, maxAssems=6, showBlockAxMesh=True, )
def test_plotAssemblyTypes(self): plotPath = "coreAssemblyTypes1.png" plotting.plotAssemblyTypes(self.r.core.parent.blueprints, plotPath) self._checkExists(plotPath) plotPath = "coreAssemblyTypes2.png" plotting.plotAssemblyTypes(self.r.core.parent.blueprints, plotPath, yAxisLabel="y axis", title="title") self._checkExists(plotPath)
def test_plotAssemblyTypes(self): plotting.plotAssemblyTypes(self.r.core.parent.blueprints, "coreAssemblyTypes1.png") self._checkExists("coreAssemblyTypes1.png")
def makeCoreAndAssemblyMaps(r, cs, generateFullCoreMap=False, showBlockAxMesh=True): r"""Create core and assembly design plots Parameters ---------- r : armi.reactor.reactors.Reactor cs: armi.settings.caseSettings.Settings generateFullCoreMap : bool, default False showBlockAxMesh : bool, default True """ assemsInCore = list(r.blueprints.assemblies.values()) core = r.core for plotNum, assemBatch in enumerate(iterables.chunk( assemsInCore, MAX_ASSEMS_PER_ASSEM_PLOT), start=1): assemPlotImage = copy(report.ASSEM_TYPES) assemPlotImage.title = assemPlotImage.title + " ({})".format(plotNum) report.data.Report.groupsOrderFirst.insert(-1, assemPlotImage) report.data.Report.componentWellGroups.insert(-1, assemPlotImage) assemPlotName = os.path.abspath( f"{core.name}AssemblyTypes{plotNum}.png") plotting.plotAssemblyTypes( core.parent.blueprints, assemPlotName, assemBatch, maxAssems=MAX_ASSEMS_PER_ASSEM_PLOT, showBlockAxMesh=showBlockAxMesh, ) report.setData( "Assem Types {}".format(plotNum), assemPlotName, assemPlotImage, report.DESIGN, ) # Create radial core map if generateFullCoreMap: core.growToFullCore(cs) counts = { assemDesign.name: len(core.getChildrenOfType(assemDesign.name)) for assemDesign in r.blueprints.assemDesigns } # assemDesigns.keys is ordered based on input, assemOrder only contains types that are in the core assemOrder = [ aType for aType in r.blueprints.assemDesigns.keys() if counts[aType] > 0 ] data = [assemOrder.index(a.p.type) for a in core] labels = [r.blueprints.assemDesigns[a.p.type].specifier for a in core] legendMap = [( ai, assemDesign.specifier, "{} ({})".format(assemDesign.name, counts[assemDesign.name]), ) for ai, assemDesign in enumerate(r.blueprints.assemDesigns) if counts[assemDesign.name] > 0] fName = "".join( [cs.caseTitle, "RadialCoreMap.", cs["outputFileExtension"]]) plotting.plotFaceMap( core, title="{} Radial Core Map".format(cs.caseTitle), fName=fName, cmapName="RdYlBu", data=data, labels=labels, legendMap=legendMap, axisEqual=True, bare=True, titleSize=10, fontSize=8, ) plotting.close() report.setData("Radial Core Map", os.path.abspath(fName), report.FACE_MAP, report.DESIGN)
def insertCoreAndAssemblyMaps(r, cs, report, blueprint, generateFullCoreMap=False, showBlockAxMesh=True): r"""Create core and assembly design plots Parameters ---------- r : armi.reactor.reactors.Reactor cs: armi.settings.caseSettings.Settings report : armi.bookkeeping.newReports.ReportContent blueprint: Blueprint generateFullCoreMap : bool, default False showBlockAxMesh : bool, default True """ assemPrototypes = set() for aKey in blueprint.assemDesigns.keys(): assemPrototypes.add(blueprint.constructAssem(cs, name=aKey)) counts = { assemDesign.name: len(r.core.getChildrenOfType(assemDesign.name)) for assemDesign in blueprint.assemDesigns } core = r.core imageCaption = "The axial block and enrichment distributions of assemblies in the core at beginning of life. The percentage represents the block enrichment (U-235 or B-10), where as the additional character represents the cross section id of the block. The number of fine-mesh subdivisions are provided on the secondary y-axis." report[DESIGN]["Assembly Designs"] = newReports.Section("Assembly Designs") currentSection = report[DESIGN]["Assembly Designs"] for plotNum, assemBatch in enumerate(iterables.chunk( list(assemPrototypes), MAX_ASSEMS_PER_ASSEM_PLOT), start=1): assemPlotImage = newReports.Image( imageCaption, os.path.abspath(f"{core.name}AssemblyTypes{plotNum}.png"), ) assemPlotName = os.path.abspath( f"{core.name}AssemblyTypes{plotNum}.png") plotting.plotAssemblyTypes( blueprint, assemPlotName, assemBatch, maxAssems=MAX_ASSEMS_PER_ASSEM_PLOT, showBlockAxMesh=showBlockAxMesh, ) currentSection.addChildElement(assemPlotImage, assemPlotName) # Create radial core map if generateFullCoreMap: core.growToFullCore(cs) assemList = [a.p.type for a in assemPrototypes] # Sort so it has the same colors each time. assemList.sort() assemTypeMap = {specifier: i for i, specifier in enumerate(assemList)} data = [assemTypeMap[a.p.type] for a in core] labels = [blueprint.assemDesigns[a.p.type].specifier for a in core] legendMap = [( assemTypeMap[assemDesign.name], assemDesign.specifier, "{} ({})".format(assemDesign.name, counts[assemDesign.name]), ) for ai, assemDesign in enumerate(blueprint.assemDesigns) if counts[assemDesign.name] > 0] fName = "".join( [cs.caseTitle, "RadialCoreMap.", cs["outputFileExtension"]]) plotting.plotFaceMap( core, title="{} Radial Core Map".format(cs.caseTitle), fName=fName, cmapName="RdYlBu", data=data, labels=labels, legendMap=legendMap, axisEqual=True, bare=True, titleSize=10, fontSize=8, ) plotting.close() report[DESIGN][CORE_MAP] = newReports.Image("Map of the Core at BOL", os.path.abspath(fName))
def test_plotAssemblyTypes(self): fName = plotting.plotAssemblyTypes(self.r.core.parent.blueprints, self.r.core.name) self._checkExists(fName)