def cleanARMIFiles(self): r"""delete ARMI run files like MC**2 and REBUS inputs/outputs. Useful if running a clean job that doesn't require restarts. """ runLog.important("Cleaning ARMI files due to smallRun option") for fileName in os.listdir(os.getcwd()): # clean MC**2 and REBUS inputs and outputs for candidate in [".BCD", ".inp", ".out", "ISOTXS-"]: if candidate in fileName: if ".htos.out" in fileName: continue if "sassys.inp" in fileName: continue os.remove(fileName) if re.search("ISO..F?$", fileName): # clean intermediate XS os.remove(fileName) for snapText in self.cs["dumpSnapshot"]: # snapText is a CCCNNN with C=cycle and N=node cycle = int(snapText[0:3]) node = int(snapText[3:]) newFolder = "snapShot{0}_{1}".format(cycle, node) utils.cleanPath(newFolder) # delete database if it's SQLlite # no need to delete because the database won't have copied it back if using fastpath. # clean temp directories. if os.path.exists("shuffleBranches"): utils.cleanPath("shuffleBranches") if os.path.exists("failedRuns"): utils.cleanPath("failedRuns")
def snapshotRequest(self, cycle, node): """ Process a snapshot request at this time. This copies various physics input and output files to a special folder that follow-on analysis be executed upon later. Notes ----- This was originally used to produce MC2/DIF3D inputs for external parties (who didn't have ARMI) to review. Since then, the concept of snapshots has evolved with respect to the :py:class:`~armi.operators.snapshots.OperatorSnapshots`. """ runLog.info("Producing snapshot for cycle {0} node {1}".format( cycle, node)) self.r.core.zones.summary() newFolder = "snapShot{0}_{1}".format(cycle, node) if os.path.exists(newFolder): runLog.important( "Deleting existing snapshot data in {0}".format(newFolder)) utils.cleanPath(newFolder) # careful with cleanPath! # give it a minute. time.sleep(1) if os.path.exists(newFolder): runLog.warning( "Deleting existing snapshot data in {0} failed".format( newFolder)) else: os.mkdir(newFolder) inf = "{0}{1:03d}{2:03d}.inp".format(self.cs.caseTitle, cycle, node) writer = self.getInterface("dif3d") if not writer: writer = self.getInterface("rebus") if not writer: runLog.warning( "There are no interface attached that can write a snapshot input" ) else: writer.writeInput(os.path.join(newFolder, inf)) # copy the cross section inputs for fileName in os.listdir("."): if "mcc" in fileName and re.search(r"[A-Z]AF?\d?.inp", fileName): base, ext = os.path.splitext(fileName) # add the cycle and timenode to the XS input file names so that a rx-coeff case that runs # in here won't overwrite them. shutil.copy( fileName, os.path.join( newFolder, "{0}_{1:03d}_{2:d}{3}".format(base, cycle, node, ext)), ) isoFName = "ISOTXS-c{0}".format(cycle) pathTools.copyOrWarn("ISOTXS for snapshot", isoFName, pathTools.armiAbsPath(newFolder, "ISOTXS")) pathTools.copyOrWarn( "DIF3D output for snapshot", self.cs.caseTitle + "{0:03d}.out".format(cycle), newFolder, ) pathTools.copyOrWarn("Shuffle logic for snapshot", self.cs["shuffleLogic"], newFolder) pathTools.copyOrWarn("Geometry file for snapshot", self.cs["geomFile"], newFolder) pathTools.copyOrWarn("Loading definition for snapshot", self.cs["loadingFile"], newFolder) pathTools.copyOrWarn( "Flow history for snapshot", self.cs.caseTitle + ".flow_history.txt", newFolder, ) pathTools.copyOrWarn( "Pressure history for snapshot", self.cs.caseTitle + ".pressure_history.txt", newFolder, )