def insertInitialCoreFuelAssem(r, report): """Creates table of initial core fuel assemblies Parameters ---------- r: Reactor report: ReportContent """ report[NEUTRONICS_SECTION][INITIAL_CORE_FUEL_ASSEMBLY] = newReports.Table( INITIAL_CORE_FUEL_ASSEMBLY, "Summary of Initial Core Fuel Assembly", header=[ "Assembly Name", "Enrichment %", "# of Assemblies at BOL", ], ) assemTypes = defaultdict(int) enrichment = defaultdict(float) for assem in r.core.getAssemblies(Flags.FUEL): enrichment[assem.p.type] = round(assem.getFissileMassEnrich() * 100, 7) assemTypes[assem.p.type] = assemTypes[assem.p.type] + 1 for typeA in assemTypes: report[NEUTRONICS_SECTION][INITIAL_CORE_FUEL_ASSEMBLY].addRow([ typeA, enrichment[typeA], assemTypes[typeA], ])
def test_TableCreation(self): header = ["item", "value"] table = newReports.Table("Assembly Table", "table of assemblies", header) for assem in self.r.core.getAssemblies(): table.addRow([assem.p.type, assem.p.powerDecay]) result = table.render(0) self.assertTrue(isinstance(result, htmltree.HtmlElement))
def insertBlockDesignReport(blueprint, report, cs): r"""Summarize the block designs from the loading file Parameters ---------- blueprint : Blueprint report: ReportContent cs: Case Settings """ report[DESIGN]["Block Summaries"] = newReports.Section("Block Summaries") for bDesign in blueprint.blockDesigns: loadingFileTable = newReports.Table( "Summary Of Block: {}".format(bDesign.name), "block contents") loadingFileTable.header = ["", "Input Parameter"] constructedBlock = bDesign.construct(cs, blueprint, 0, 1, 0, "A", dict()) loadingFileTable.addRow(["Number of Components", len(bDesign)]) lst = [i for i in range(len(bDesign))] for i, cDesign, c in zip(lst, bDesign, constructedBlock): cType = cDesign.name componentSplitter = (i + 1) * " " + "\n" loadingFileTable.addRow([componentSplitter, ""]) loadingFileTable.addRow([ "{} {}".format(cType, "Shape"), "{} {}".format(cDesign.shape, ""), ]) loadingFileTable.addRow([ "{} {}".format(cType, "Material"), "{} {}".format(cDesign.material, ""), ]) loadingFileTable.addRow([ "{} {}".format(cType, "Hot Temperature"), "{} {}".format(cDesign.Thot, ""), ]) loadingFileTable.addRow([ "{} {}".format(cType, "Cold Temperature"), "{} {}".format(cDesign.Tinput, ""), ]) for pd in c.pDefs: if pd.name in c.DIMENSION_NAMES: value = c.getDimension(pd.name, cold=True) unit = "" if pd.units is not None: unit = pd.units if value is not None: loadingFileTable.addRow([ "{} {}".format(cType, pd.name), "{} {}".format(value, unit), ]) loadingFileTable.title = "Summary of Block: {}".format(bDesign.name) report[DESIGN]["Block Summaries"].addChildElement( loadingFileTable, loadingFileTable.title)
def insertSettingsData(cs, report): """Creates tableSections of Parameters (Case Parameters, Reactor Parameters, Case Controls and Snapshots of the run Parameters ---------- cs: Case Settings report: ReportContent The report to be added to """ report[COMPREHENSIVE_REPORT][CASE_PARAMETERS] = newReports.Table( "Case Parameters") report[COMPREHENSIVE_REPORT][REACTOR_PARAMS] = newReports.Table( "Reactor Parameters") report[COMPREHENSIVE_REPORT][CASE_CONTROLS] = newReports.Table( "Case Controls") report[COMPREHENSIVE_REPORT][SNAPSHOT] = newReports.Table("Snapshot") report[COMPREHENSIVE_REPORT][BURNUP_GROUPS] = newReports.Table( "Burn Up Groups") for key in [ "nCycles", "burnSteps", "skipCycles", "cycleLength", "numProcessors", ]: report[COMPREHENSIVE_REPORT][CASE_PARAMETERS].addRow([key, cs[key]]) for key in cs.environmentSettings: report[COMPREHENSIVE_REPORT][SETTINGS].addRow([key, str(cs[key])]) for key in ["reloadDBName", "startCycle", "startNode"]: report[COMPREHENSIVE_REPORT][SNAPSHOT].addRow([key, cs[key]]) for key in ["power", "Tin", "Tout"]: report[COMPREHENSIVE_REPORT][REACTOR_PARAMS].addRow([key, cs[key]]) for key in ["genXS", "neutronicsKernel"]: report[COMPREHENSIVE_REPORT][CASE_CONTROLS].addRow([key, str(cs[key])]) for key in ["buGroups"]: report[COMPREHENSIVE_REPORT][BURNUP_GROUPS].addRow([key, str(cs[key])])
def insertMetaTable(cs, report): """Generates part of the Settings table Parameters ---------- cs: Case Settings report: ReportContent """ section = report[COMPREHENSIVE_REPORT] tableList = section.get( SETTINGS, newReports.Table("Settings", "General overview of the run")) tableList.addRow(["outputFileExtension", cs["outputFileExtension"]]) tableList.addRow(["Total Core Power", "%8.5E MWt" % (cs["power"] / 1.0e6)]) if not cs["cycleLengths"]: tableList.addRow(["Cycle Length", "%8.5f days" % cs["cycleLength"]]) tableList.addRow(["BU Groups", str(cs["buGroups"])])
def insertCoreDesignReport(core, cs, report): r"""Builds report to summarize core design inputs Parameters ---------- core: armi.reactor.reactors.Core cs: armi.settings.caseSettings.Settings """ coreDesignTable = newReports.Table("Core Report Table") coreDesignTable.header = ["", "Input Parameter"] report["Design"]["Core Design Table"] = coreDesignTable _setGeneralCoreDesignData(cs, coreDesignTable) _setGeneralCoreParametersData(core, cs, coreDesignTable) _setGeneralSimulationData(core, cs, coreDesignTable)
def test_writeReports(self): with directoryChangers.TemporaryDirectoryChanger(): reportTest = newReports.ReportContent("Test") table = newReports.Table("Example") table.addRow(["example", 1]) table.addRow(["example", 2]) reportTest["TableTest"]["Table Example"] = table reportTest.writeReports() # Want to check that two <tr> exists... times = 0 with open("index.html") as f: for line in f: if "<tr>" in line: times = times + 1 self.assertEqual(times, 2)
def insertNeutronicsBOLContent(r, cs, report): """Add BOL content to Neutronics Section of the Report This currently includes addtions to Comprehensive Reports Settings table, and an Initial Core Fuel Assembly Table. Parameters ---------- r: Reactor cs: Case Settings report: ReportContent """ section = report[newReportUtils.COMPREHENSIVE_REPORT] table = section.get(newReportUtils.SETTINGS, newReports.Table("Settings", "Overview of the Run")) for key in ["boundaries", "neutronicsKernel", "neutronicsType", "fpModel"]: table.addRow([key, cs[key]]) insertInitialCoreFuelAssem(r, report)
def comprehensiveBOLContent(cs, r, report): """Adds BOL content to the Comprehensive section of the report Parameters ---------- cs: Case Settings r: Reactor report: ReportContent """ insertMetaTable(cs, report) first_fuel_block = r.core.getFirstBlock(Flags.FUEL) if first_fuel_block is not None: report[COMPREHENSIVE_REPORT][ASSEMBLY_AREA] = newReports.Table( "Assembly Area Fractions (of First Fuel Block)", header=["Component", "Area (cm<sup>2</sup>)", "Fraction"], ) insertAreaFractionsReport(first_fuel_block, report) insertSettingsData(cs, report)
def createDimensionReport(comp): """Gives a report of the dimensions of this component. Parameters ---------- comp: Component Returns ------- newReports.Table that corresponds to the passed componenets dimension report """ REPORT_GROUPS = { Flags.INTERCOOLANT: INTERCOOLANT_DIMS, Flags.BOND: BOND_DIMS, Flags.DUCT: DUCT_DIMS, Flags.COOLANT: COOLANT_DIMS, Flags.CLAD: CLAD_DIMS, Flags.FUEL: FUEL_DIMS, Flags.WIRE: WIRE_DIMS, Flags.LINER: LINER_DIMS, Flags.GAP: GAP_DIMS, } reportGroup = None for componentType, componentReport in REPORT_GROUPS.items(): if comp.hasFlags(componentType): reportGroup = newReports.Table(componentReport.capitalize()) break if not reportGroup: return "No report group designated for {} component.".format( comp.getName()) # reportGroup must be of type TableSection... reportGroup.header = [ "", "Tcold ({0})".format(comp.inputTemperatureInC), "Thot ({0})".format(comp.temperatureInC), ] dimensions = { k: comp.p[k] for k in comp.DIMENSION_NAMES if k not in ("modArea", "area") and comp.p[k] is not None } # py3 cannot format None # Set component name and material reportGroup.addRow(["Name", comp.getName(), ""]) reportGroup.addRow(["Material", comp.getProperties().name, ""]) for dimName in dimensions: niceName = component._NICE_DIM_NAMES.get(dimName, dimName) refVal = comp.getDimension(dimName, cold=True) hotVal = comp.getDimension(dimName) try: reportGroup.addRow([niceName, refVal, hotVal]) except ValueError: runLog.info( "{0} has an invalid dimension for {1}. refVal: {2} hotVal: {3}" .format(comp, dimName, refVal, hotVal)) # calculate thickness if applicable. suffix = None if "id" in dimensions: suffix = "d" elif "ip" in dimensions: suffix = "p" if suffix: coldIn = comp.getDimension("i{0}".format(suffix), cold=True) hotIn = comp.getDimension("i{0}".format(suffix)) coldOut = comp.getDimension("o{0}".format(suffix), cold=True) hotOut = comp.getDimension("o{0}".format(suffix)) if suffix and coldIn > 0.0: hotThick = (hotOut - hotIn) / 2.0 coldThick = (coldOut - coldIn) / 2.0 vals = ( "Thickness (cm)", "{0:.7f}".format(coldThick), "{0:.7f}".format(hotThick), ) reportGroup.addRow([vals[0], vals[1], vals[2]]) return reportGroup
def getPinDesignTable(core): """Summarizes Pin and Assembly Design for the input Parameters ---------- core: Core """ designInfo = collections.defaultdict(list) try: for b in core.getBlocks(Flags.FUEL): fuel = b.getComponent(Flags.FUEL) duct = b.getComponent(Flags.DUCT) clad = b.getComponent(Flags.CLAD) wire = b.getComponent(Flags.WIRE) designInfo["hot sd"].append(b.getSmearDensity(cold=False)) designInfo["sd"].append(b.getSmearDensity()) designInfo["ductThick"].append( (duct.getDimension("op") - duct.getDimension("ip")) * 5.0) # convert to mm and divide by 2 designInfo["cladThick"].append( (clad.getDimension("od") - clad.getDimension("id")) * 5.0) pinOD = clad.getDimension("od") * 10.0 wireOD = wire.getDimension("od") * 10.0 pitch = pinOD + wireOD # pitch has half a wire on each side. assemPitch = b.getPitch() * 10 # convert cm to mm. designInfo["pinOD"].append(pinOD) designInfo["wireOD"].append(wireOD) designInfo["pin pitch"].append(pitch) pinToDuctGap = b.getPinToDuctGap() if pinToDuctGap is not None: designInfo["pinToDuct"].append(b.getPinToDuctGap() * 10.0) designInfo["assemPitch"].append(assemPitch) designInfo["duct gap"].append(assemPitch - duct.getDimension("op") * 10.0) designInfo["nPins"].append(b.p.nPins) designInfo["zrFrac"].append(fuel.getMassFrac("ZR")) # assumption made that all lists contain only numerical data designInfo = { key: numpy.average(data) for key, data in designInfo.items() } tableRows = newReports.Table("Pin Design", header=None) dimensionless = {"sd", "hot sd", "zrFrac", "nPins"} for key, average_value in designInfo.items(): dim = "{0:10s}".format(key) val = "{0:.4f}".format(average_value) if key not in dimensionless: val += " mm" # want to basically add a row to a table with dim ---> val tableRows.addRow([dim, val]) a = core.refAssem tableRows.addRow( ["Fuel Height (cm):", "{0:.2f}".format(a.getHeight(Flags.FUEL))]) tableRows.addRow([ "Plenum Height (cm):", "{0:.2f}".format(a.getHeight(Flags.PLENUM)) ]) return tableRows except Exception as error: # pylint: disable=broad-except runLog.warning("Pin summarization failed to work") runLog.warning(error)