def get_union_parameters(materials, globalTDict, globalBXSDict, globalTXSDict, useBXS=False, verbosity=False): # Sab is for S(alpha,beta), the free/bound thermal treatment used by each nuclide globalZASabList = get_union_sab_nuclide_list(materials) globalZAList = get_union_nuclide_list(materials) globalZList = get_union_element_list(materials) # check_unique_short_names(materials, verbosity) # potXSDict = {} dirDict = get_common_directories() get_endf_files(globalZAList, dirDict, potXSDict, useBXS, verbosity) get_thermal_endf_files(globalZASabList, dirDict, verbosity) # get_global_temperature_dict(globalZASabList, materials, globalTDict) # calc_background_xs(materials, potXSDict, useBXS) get_global_background_xs_dict(globalZASabList, materials, globalBXSDict) # get_global_thermal_xs_dict(globalZASabList, materials, globalTXSDict) # # return globalZASabList, globalZAList, globalZList
def perform_bondarenko_iterations(inputDict, materials, verbosity): '''Driver for Bondarenko iterations''' maxIterations = inputDict['numberiterationsmax'] maxError = inputDict['errormax'] useSimpleRxn = inputDict['simplereactions'] scatMatrixFormat = inputDict['format'] rxnsToPrint = inputDict['printopt'] energyMeshPath = inputDict['mesh'] fluxBasePath = inputDict['fluxes'] # dirDict = get_common_directories() rootDirr = dirDict['gendf'] outDirr = dirDict['pdtxs'] # energyMesh = None if energyMeshPath is not None: energyMesh = np.loadtxt(energyMeshPath, dtype=np.int, skiprows=2, usecols=[0])[:-1] numElements = len(np.unique(energyMesh)) energyMeshFilenameOut = 'mesh_{0}.txt'.format(numElements) energyMeshPathOut = os.path.join(outDirr, energyMeshFilenameOut) shutil.copy2(energyMeshPath, energyMeshPathOut) # if verbosity: print '------- Bondarenko -------' fluxDict = read_fluxes(fluxBasePath, materials) for material in materials: backgroundXSDict = iterate_one_material(rootDirr, material, maxError, maxIterations, energyMesh, fluxDict, verbosity) if maxIterations < 0: unset_background_xs_dict(material, backgroundXSDict, verbosity) print_one_material(rootDirr, outDirr, material, backgroundXSDict, scatMatrixFormat, useSimpleRxn, rxnsToPrint, energyMesh, fluxDict, verbosity) if verbosity: key = backgroundXSDict.keys()[0] numGroups = len(backgroundXSDict[key]) print 'Number of groups is', numGroups
def create_ace_copier(aceFilesDict): '''Create a script that copies the ACE files to xdata''' dirDict = get_common_directories() scriptname = 'copyAce.sh' runDirr = dirDict['xdata'] scriptPath = os.path.join(runDirr, scriptname) # deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append([""]) deck.append(["echo 'Copying ACE XS data'"]) for nuclide in sorted(aceFilesDict): for aceFile in sorted(aceFilesDict[nuclide]): deck.append(["cp -f ../{}/{} .".format(nuclide, aceFile)]) deck.append([""]) deck.append(["echo 'Copying ACE directory data'"]) deck.append(["rm -f xsdir_tail"]) for nuclide in sorted(aceFilesDict): for aceFile in sorted(aceFilesDict[nuclide]): aceFileDir = 'xsdir.{}'.format(aceFile) deck.append(["awk '{{$3=\"{}\"; $4=\"0\"; print }}' ../{}/{} >> xsdir_tail".format(aceFile, nuclide, aceFileDir)]) deck.append(["echo '{}' > xsdir_date".format(datetime.strftime(datetime.now(), '%m/%d/%Y'))]) deck.append(["echo 'directory' >> xsdir_date"]) deck.append(["cat xsdir_head xsdir_date xsdir_tail > xsdir"]) deck.append([""]) deck.append(["echo 'Copying ACE figures'"]) for nuclide in sorted(aceFilesDict): for aceFile in sorted(aceFilesDict[nuclide]): plotName = 'p_xs_{}.pdf'.format(aceFile) deck.append(["cp -f ../{}/{} figures".format(nuclide, plotName)]) print_njoy_file(scriptPath, deck)
def finish_parsing_inputs(inputDict): dirDict = get_common_directories() if inputDict['mesh'] in ['none', 'None']: inputDict['mesh'] = None inputDict['fluxes'] = None else: if not inputDict['mesh'].count('.'): inputDict['mesh'] += '.txt' if not inputDict['fluxes'].count('.'): inputDict['fluxes'] += '.txt' if not os.path.split(inputDict['mesh'])[0]: inputDict['mesh'] = os.path.join(dirDict['dat/energy_groups'], inputDict['mesh']) if not os.path.split(inputDict['fluxes'])[0]: inputDict['fluxes'] = os.path.join(dirDict['dat/indicators'], inputDict['fluxes']) if not (inputDict['njoy'] or inputDict['bondarenko']): inputDict['njoy'] = True inputDict['materialslist'] = set(inputDict['materialslist']) if inputDict['energybounds'][1] > 2E7: print 'Current ENDF data does not exist above 20 MeV. Changing energy upperbound to this value.' inputDict['energybounds'][1] = 2E7 inputDict['energybounds'][0] = max(0, inputDict['energybounds'][0]) if inputDict['verbosity'] > 1: print inputDict inputDict['finishedParsing'] = True
def populate_directories(dataDict): '''Add directory entries to dataDict''' # Inputs dirDict = get_common_directories() # Outputs dataDict['indicatorsDatDirr'] = dirDict['dat/indicators'] dataDict['energyDatDirr'] = dirDict['dat/energy_groups'] dataDict['plotDirr'] = dirDict['figures/clustering']
def define_input_parser(): dirDict = get_common_directories() pyDirr = dirDict['src'] groupDirr = dirDict['dat/energy_groups'] parser = argparse.ArgumentParser(description='Group structure specification functions.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) # If nothing is specified, verbosity is False. If -v or --verbose is specified, verbosity is 1. If -v N is specified, verbosity is N. parser.add_argument('-v', '--verbose', dest='verbosity', nargs='?', const=1, default=0, choices=[0,1,2,3,4], type=int) parser.add_argument('-i', '--inputdir', dest='inDirr', help='Input directory with MG library specifications', default=groupDirr) parser.add_argument('-I', '--inputname', dest='inName', help='Name of MG library to start with.', default='energy_in_default.txt') parser.add_argument('-o', '--outputdir', dest='outDirr', help='Output directory.', default=groupDirr) parser.add_argument('-O', '--outname', dest='outName', help="Short name for output files. A value of 'none' means do not print", default='custom') parser.add_argument('-d', '--defaultuse', dest='useDefault', help="Use a pre-defined input scheme. If not 'none', overrides 'rangeresolved,' 'finelethargyspacing,' and 'outname.'", choices=['none', 'low', 'med', 'high'], default='none') parser.add_argument('-r', '--rangeresolved', dest='resolvedRange', help='The resolved resonance range to be refined (energies in eV). If multiple ranges are desired, this program may be run multiple times.', nargs=2, type=float, default=[3.0, 1000.0]) parser.add_argument('-R', '--rangefull', dest='fullRange', help='The full energy range for the group structure.', nargs=2, type=float, default=[1e-5, 2e7]) parser.add_argument('-e', '--noextend', dest='noExtend', help="If specified, do not crop to 'rangefull.'", action='store_true', default=False) energyMeshGroup = parser.add_argument_group('Number of groups specification', 'If both number of groups and lethargy spacing are provided, the finer of the two is used.') energyMeshGroup.add_argument('-g', '--groups', help='Total number of groups to use.', type=int, default=1) energyMeshGroup.add_argument('-f', '--finelethargyspacing', dest='fineLethargySpacing', help='Lethargy spacing to use inside the resolve resonance region.', type=float, default=1e4) energyMeshGroup.add_argument('-b', '--boundarylethargyspacing', dest='boundaryLethargySpacing', help='Lethargy spacing for the boundary between resolved and unresolved resonance regions. The boundary acts as a buffer for downscattering from medium-to-heavy nuclei so the two regions do not see each other directly. Use a value of 0 for no buffer.', type=float, default=0.3) return parser
def create_njoy_driver(pendfScriptPaths, gendfScriptPaths, aceScriptPaths): '''Create a driver script to run all the NJOY calculations in parallel''' dirDict = get_common_directories() runDirr = dirDict['xs'] # pendfJobFile = 'runPendf.txt' pendfJobPath = os.path.join(runDirr, pendfJobFile) pendfDriverFile = 'RunPendf.sh' pendfDriverPath = os.path.join(runDirr, pendfDriverFile) pendfDirrs = [os.path.dirname(path) for path in pendfScriptPaths] relPathsPendfRun = [os.path.relpath(path, runDirr) for path in pendfDirrs] pendfScriptName = './{0}'.format(os.path.split(pendfScriptPaths[0])[-1]) write_job_file(pendfJobPath, pendfScriptName, relPathsPendfRun) write_job_driver(pendfDriverPath, pendfJobFile) # gendfJobFile = 'runGendf.txt' gendfJobPath = os.path.join(runDirr, gendfJobFile) gendfDriverFile = 'RunGendf.sh' gendfDriverPath = os.path.join(runDirr, gendfDriverFile) gendfDirrs = [os.path.dirname(path) for path in gendfScriptPaths] relPathsPendfRun = [os.path.relpath(path, runDirr) for path in gendfDirrs] gendfScriptName = './{0}'.format(os.path.split(gendfScriptPaths[0])[-1]) write_job_file(gendfJobPath, gendfScriptName, relPathsPendfRun) write_job_driver(gendfDriverPath, gendfJobFile) # aceJobFile = 'runAce.txt' aceJobPath = os.path.join(runDirr, aceJobFile) aceDriverFile = 'RunAce.sh' aceDriverPath = os.path.join(runDirr, aceDriverFile) aceDirrs = [os.path.dirname(path) for path in aceScriptPaths] relPathsPendfRun = [os.path.relpath(path, runDirr) for path in aceDirrs] aceScriptName = './{0}'.format(os.path.split(aceScriptPaths[0])[-1]) write_job_file(aceJobPath, aceScriptName, relPathsPendfRun) write_job_driver(aceDriverPath, aceJobFile) # driverDriverFile = 'RunNJOY.sh' driverDriverPath = os.path.join(runDirr, driverDriverFile) driversToDrive = [pendfDriverFile, gendfDriverFile, aceDriverFile] driversToDrive = ['./{0}'.format(driver) for driver in driversToDrive] write_driver_driver(driverDriverPath, driversToDrive, 'Run ENDF -> PENDF -> GENDF / ACE in 2 steps.')
def perform_bondarenko_iterations(inputDict, materials, verbosity): '''Driver for Bondarenko iterations''' maxIterations = inputDict['numberiterationsmax'] maxError = inputDict['errormax'] useSimpleRxn = inputDict['simplereactions'] scatMatrixFormat = inputDict['format'] rxnsToPrint = inputDict['printopt'] energyMeshPath = inputDict['mesh'] fluxBasePath = inputDict['fluxes'] # dirDict = get_common_directories() rootDirr = dirDict['gendf'] outDirr = dirDict['pdtxs'] # energyMesh = None if energyMeshPath is not None: energyMesh = np.loadtxt(energyMeshPath, dtype=np.int, skiprows=2, usecols=[0])[:-1] numElements = len(np.unique(energyMesh)) energyMeshFilenameOut = 'mesh_{0}.txt'.format(numElements) energyMeshPathOut = os.path.join(outDirr, energyMeshFilenameOut) shutil.copy2(energyMeshPath, energyMeshPathOut) # if verbosity: print '------- Bondarenko -------' fluxDict = read_fluxes(fluxBasePath, materials) for material in materials: backgroundXSDict = iterate_one_material(rootDirr, material, maxError, maxIterations, energyMesh, fluxDict, verbosity) if maxIterations < 0: unset_background_xs_dict(material, backgroundXSDict, verbosity) print_one_material(rootDirr, outDirr, material, backgroundXSDict, scatMatrixFormat, useSimpleRxn, rxnsToPrint, energyMesh, fluxDict, verbosity) if verbosity: key = backgroundXSDict.keys()[0] numGroups = len(backgroundXSDict[key]) print 'Number of groups is', numGroups
def create_njoy_driver(pendfScriptPaths, gendfScriptPaths, aceScriptPaths): '''Create a driver script to run all the NJOY calculations in parallel''' dirDict = get_common_directories() runDirr = dirDict['xs'] # pendfJobFile = 'runPendf.txt' pendfJobPath = os.path.join(runDirr, pendfJobFile) pendfDriverFile = 'RunPendf.sh' pendfDriverPath = os.path.join(runDirr, pendfDriverFile) pendfDirrs = [os.path.dirname(path) for path in pendfScriptPaths] relPathsPendfRun = [os.path.relpath(path, runDirr) for path in pendfDirrs] pendfScriptName = './{0}'.format(os.path.split(pendfScriptPaths[0])[-1]) write_job_file(pendfJobPath, pendfScriptName, relPathsPendfRun) write_job_driver(pendfDriverPath, pendfJobFile) # gendfJobFile = 'runGendf.txt' gendfJobPath = os.path.join(runDirr, gendfJobFile) gendfDriverFile = 'RunGendf.sh' gendfDriverPath = os.path.join(runDirr, gendfDriverFile) gendfDirrs = [os.path.dirname(path) for path in gendfScriptPaths] relPathsPendfRun = [os.path.relpath(path, runDirr) for path in gendfDirrs] gendfScriptName = './{0}'.format(os.path.split(gendfScriptPaths[0])[-1]) write_job_file(gendfJobPath, gendfScriptName, relPathsPendfRun) write_job_driver(gendfDriverPath, gendfJobFile) # aceJobFile = 'runAce.txt' aceJobPath = os.path.join(runDirr, aceJobFile) aceDriverFile = 'RunAce.sh' aceDriverPath = os.path.join(runDirr, aceDriverFile) aceDirrs = [os.path.dirname(path) for path in aceScriptPaths] relPathsPendfRun = [os.path.relpath(path, runDirr) for path in aceDirrs] aceScriptName = './{0}'.format(os.path.split(aceScriptPaths[0])[-1]) write_job_file(aceJobPath, aceScriptName, relPathsPendfRun) write_job_driver(aceDriverPath, aceJobFile) # driverDriverFile = 'RunNJOY.sh' driverDriverPath = os.path.join(runDirr, driverDriverFile) driversToDrive = [pendfDriverFile, gendfDriverFile, aceDriverFile] driversToDrive = ['./{0}'.format(driver) for driver in driversToDrive] write_driver_driver(driverDriverPath, driversToDrive, 'Run ENDF -> PENDF -> GENDF / ACE in 2 steps.')
def get_union_parameters(materials, globalTDict, globalBXSDict, globalTXSDict, useBXS=False, verbosity=False): # Sab is for S(alpha,beta), the free/bound thermal treatment used by each nuclide globalZASabList = get_union_sab_nuclide_list(materials) globalZAList = get_union_nuclide_list(materials) globalZList = get_union_element_list(materials) # check_unique_short_names(materials, verbosity) # potXSDict = {} dirDict = get_common_directories() get_endf_files(globalZAList, dirDict, potXSDict, useBXS, verbosity) get_thermal_endf_files(globalZASabList, dirDict, verbosity) # get_global_temperature_dict(globalZASabList, materials, globalTDict) # calc_background_xs(materials, potXSDict, useBXS) get_global_background_xs_dict(globalZASabList, materials, globalBXSDict) # get_global_thermal_xs_dict(globalZASabList, materials, globalTXSDict) # # return globalZASabList, globalZAList, globalZList
def create_ace_copier(aceFilesDict): '''Create a script that copies the ACE files to xdata''' dirDict = get_common_directories() scriptname = 'copyAce.sh' runDirr = dirDict['xdata'] scriptPath = os.path.join(runDirr, scriptname) # deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append([""]) deck.append(["echo 'Copying ACE XS data'"]) for nuclide in sorted(aceFilesDict): for aceFile in sorted(aceFilesDict[nuclide]): deck.append(["cp -f ../{}/{} .".format(nuclide, aceFile)]) deck.append([""]) deck.append(["echo 'Copying ACE directory data'"]) deck.append(["rm -f xsdir_tail"]) for nuclide in sorted(aceFilesDict): for aceFile in sorted(aceFilesDict[nuclide]): aceFileDir = 'xsdir.{}'.format(aceFile) deck.append([ "awk '{{$3=\"{}\"; $4=\"0\"; print }}' ../{}/{} >> xsdir_tail". format(aceFile, nuclide, aceFileDir) ]) deck.append([ "echo '{}' > xsdir_date".format( datetime.strftime(datetime.now(), '%m/%d/%Y')) ]) deck.append(["echo 'directory' >> xsdir_date"]) deck.append(["cat xsdir_head xsdir_date xsdir_tail > xsdir"]) deck.append([""]) deck.append(["echo 'Copying ACE figures'"]) for nuclide in sorted(aceFilesDict): for aceFile in sorted(aceFilesDict[nuclide]): plotName = 'p_xs_{}.pdf'.format(aceFile) deck.append(["cp -f ../{}/{} figures".format(nuclide, plotName)]) print_njoy_file(scriptPath, deck)
def finish_parsing_inputs(inputDict): dirDict = get_common_directories() if inputDict['mesh'] in ['none', 'None']: inputDict['mesh'] = None inputDict['fluxes'] = None else: if not inputDict['mesh'].count('.'): inputDict['mesh'] += '.txt' if not inputDict['fluxes'].count('.'): inputDict['fluxes'] += '.txt' if not os.path.split(inputDict['mesh'])[0]: inputDict['mesh'] = os.path.join(dirDict['dat/energy_groups'], inputDict['mesh']) if not os.path.split(inputDict['fluxes'])[0]: inputDict['fluxes'] = os.path.join(dirDict['dat/indicators'], inputDict['fluxes']) if not(inputDict['njoy'] or inputDict['bondarenko']): inputDict['njoy'] = True inputDict['materialslist'] = set(inputDict['materialslist']) if inputDict['energybounds'][1] > 2E7: print 'Current ENDF data does not exist above 20 MeV. Changing energy upperbound to this value.' inputDict['energybounds'][1] = 2E7 inputDict['energybounds'][0] = max(0, inputDict['energybounds'][0]) if inputDict['verbosity'] > 1: print inputDict inputDict['finishedParsing'] = True
''' Andrew Till Summer 2014 NJOY utilities for materials ''' #MINE from directories import get_common_directories #STDLIB import os import sys import shutil import copy sys.path.insert(1, get_common_directories()['nuclideData']) #TPL import numpy as np import nuclide_data as nd #MINE from Readgroupr import get_short2mt_dict, get_endf_mt_list import materials_util as util import write_njoy as njoy import makegroups as mg def create_njoy_decks(inputDict, globalZASabList, njoyTDict, njoyBXSDict, globalTXSDict, verbosity=False): endfLib = 'vii1' legendreOrder = inputDict['legendreorder'] groupOpt = inputDict['groupopt'] ignoreTransferMatrices = inputDict['smallscattering']
BNL's non-thermal neutron data files can sometimes be bad (will produce garbage when processed with NJOY). The code uses the most up-to-date data while requiring consistency. Hence, automatic downloads of the non-thermal neutron data from LANL T2 and automatic downloads of the bound-thermal neutron data from BNL. A copy of the bound-thermal neutron data from BNL is included locally in case BNL changes its URL's. ''' #MINE from directories import get_common_directories, copy_thermal_endf_xs, make_endf_directory #STDLIB import os import sys import shutil from subprocess import check_output sys.path.insert(1, get_common_directories()['nuclideData']) #TPL import nuclide_data as nd #MINE from Readgroupr import get_pot_scat_xs import materials_util as util ############################################################################### def get_endf_files(ZAList, dirDict, potXSDict, useBXS=False, verbosity=False): if verbosity > 1: print '------- ENDF Files -------' make_endf_directory() endfDirr = dirDict['endf']
def create_njoy_script(dat, tapes): '''Create three NJOY files: one to generate a PENDF output, one to generate a GENDF output, and one to generate an ACE output''' #Directories dirDict = get_common_directories() pyDirr = dirDict['src'] endfDirr = dirDict['endf'] pendfRootDirr = dirDict['pendf'] gendfRootDirr = dirDict['gendf'] aceRootDirr = dirDict['ace'] njoyPath = os.path.join(dirDict['njoyInstall'], 'xnjoy_thermr') # pendfDirr = os.path.join(pendfRootDirr, str(dat.nuclideName)) gendfDirr = os.path.join(gendfRootDirr, str(dat.nuclideName)) aceDirr = os.path.join(aceRootDirr, str(dat.nuclideName)) # relPathNJOYPendf = os.path.relpath(njoyPath, pendfDirr) relPathNJOYGendf = os.path.relpath(njoyPath, gendfDirr) relPathNJOYAce = os.path.relpath(njoyPath, aceDirr) # endfPath = os.path.join(endfDirr, dat.endfFile) relPathEndfPendf = os.path.relpath(endfPath, pendfDirr) relPathEndfGendf = os.path.relpath(endfPath, gendfDirr) relPathEndfAce = os.path.relpath(endfPath, aceDirr) # numThermals = len(dat.endfThermalFileList) numTemperatures = len(dat.thermList) pendfOutTape = get_pendf_out_tape(tapes, numThermals) endfThermalPathList = [ os.path.join(endfDirr, thermalFile) for thermalFile in dat.endfThermalFileList if thermalFile ] relPathThermalPendfList = [ os.path.relpath(thermalPath, pendfDirr) for thermalPath in endfThermalPathList ] endfThermalTapeList = map(lambda x: x + tapes.endfThermalStart, range(numThermals)) endfNonFreeThermalTapeList = [ tape for (mt, tape) in zip(dat.inelasticMTList, endfThermalTapeList) if mt != 221 ] # pendfScriptFile = 'runNJOY.sh' pendfScriptPath = os.path.join(pendfDirr, pendfScriptFile) pendfFile = 'pendf' pendfFileASCII = 'pendf_ascii.txt' pendfPath = os.path.join(pendfDirr, pendfFile) # gendfScriptFile = 'runNJOY.sh' gendfScriptPath = os.path.join(gendfDirr, gendfScriptFile) gendfFile = 'gendf' gendfPath = os.path.join(gendfDirr, gendfFile) relPathPendfGendf = os.path.relpath(pendfPath, gendfDirr) readgrouprPath = os.path.join(pyDirr, 'Readgroupr.py') # matxsFile = 'matxs' matxsDir = '/scratch/yunhuang/barnfire/xs/cert_matxs' # aceScriptFile = 'runNJOY.sh' aceScriptPath = os.path.join(aceDirr, aceScriptFile) aceFileTemplate = '{Z}{A:03}.{e}{s}c' relPathPendfAce = os.path.relpath(pendfPath, aceDirr) # Script to run NJOY from ENDF to PENDF: deck = [] deck.append(['#! /usr/bin/env bash']) deck.append([ "echo 'NJOY Problem {0} {1} (ENDF to PENDF)'".format( dat.nuclideName, dat.endfName) ]) deck.append(["echo 'Getting ENDF input tapes and NJOY executable'"]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYPendf)]) deck.append( ['ln -fs {0} tape{1:02g}'.format(relPathEndfPendf, tapes.endf)]) for endfTape, relPath in zip(endfNonFreeThermalTapeList, relPathThermalPendfList): deck.append(['ln -fs {0} tape{1:02g}'.format(relPath, endfTape)]) deck.append(["echo 'Running NJOY'"]) deck.append(['cat>input <<EOF']) create_moder_input(deck, dat, tapes.endf, tapes.bendf) create_reconr_input(deck, dat, tapes.bendf, tapes.reconrOut) create_broadr_input(deck, dat, tapes.bendf, tapes.reconrOut, tapes.broadrOut) # Warning: 9547 (Am-242m) and (Np-238) have negative values here sometimes for low Sigma_0 create_unresr_input(deck, dat, tapes.bendf, tapes.broadrOut, tapes.unresrOut) create_heatr_input(deck, dat, tapes.bendf, tapes.unresrOut, tapes.heatrOut) for i, endfThermal in enumerate(endfThermalTapeList): thermrInTape, thermrOutTape = get_thermr_tapes(tapes, i) if dat.inelasticMTList[i] == 221: endfThermal = 0 create_thermr_input(deck, dat, i, endfThermal, thermrInTape, thermrOutTape) create_moder_input(deck, dat, pendfOutTape, tapes.pendfOutASCII) deck.append(['stop']) deck.append(['EOF']) deck.append(['./xnjoy<input']) deck.append(["echo 'Cleaning up and saving PENDF file'"]) deck.append(['cp -f tape{0:02g} {1}'.format(abs(pendfOutTape), pendfFile)]) deck.append( ['cp -f tape{0:02g} {1}'.format(tapes.pendfOutASCII, pendfFileASCII)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join( get_temporary_tapes_pendf(tapes, endfNonFreeThermalTapeList, numThermals)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) try_mkdir(pendfDirr) print_njoy_file(pendfScriptPath, deck) # Script to run NJOY from PENDF to MATXS: doPlotr = False deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append([ "echo 'NJOY Problem {0} {1} (PENDF to GENDF)'".format( dat.nuclideName, dat.endfName) ]) deck.append([ "echo 'Getting ENDF input tape, PENDF input tape and NJOY executable'" ]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYGendf)]) deck.append( ['ln -fs {0} tape{1:02g}'.format(relPathEndfGendf, tapes.endf)]) deck.append([ 'ln -fs {0} tape{1:02g}'.format(relPathPendfGendf, abs(pendfOutTape)) ]) deck.append(["echo 'Running NJOY'"]) deck.append(["cat>input <<EOF"]) create_moder_input(deck, dat, tapes.endf, tapes.bendf) dat.hasDelayedNu, dat.hasDelayedChis = hasDelayed(endfPath) create_groupr_input(deck, dat, tapes.bendf, pendfOutTape, tapes.grouprIn, tapes.grouprOut) create_moder_input(deck, dat, tapes.grouprOut, tapes.gendfOut) # get GENDF in ASCII for record create_matxsr_input(deck, dat, tapes.gendfOut, tapes.gaminrOut, tapes.matxsOut) # It seems MODER is not needed after MATXSR # create_moder_input(deck, dat, tapes.matxsOut, tapes.gendfOut) if False and dat.numGroups <= 200: doPlotr = True plotNames = create_plotr_inputs(deck, dat, tapes.gendfOut, tapes.plotrOut, tapes.viewrOut) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) deck.append(["echo 'Cleaning up, saving GROUPR and MATXS file'"]) if doPlotr: for plotName, viewrOut in zip(plotNames, tapes.viewrOut): deck.append(['ps2pdf tape{0:02g} {1}'.format(viewrOut, plotName)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapes.gendfOut, gendfFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapes.matxsOut, matxsFile)]) deck.append(['cp -f matxs {0}/{1}.dat'.format(matxsDir, dat.nuclideName)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join( get_temporary_tapes_gendf(tapes, pendfOutTape, doPlotr)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) optionalComment = '' if True and dat.numGroups > 200: optionalComment = '#' # deck.append(["{0}echo 'Reading in XS file and pickling for future use'".format(optionalComment)]) # deck.append(['{0} {1} -I {2} -p all -f csc'.format(optionalComment, readgrouprPath, gendfFile)]) try_mkdir(gendfDirr) print_njoy_file(gendfScriptPath, deck) # Script to run NJOY from PENDF to (non-thermal) ACE: deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append([ "echo 'NJOY Problem {0} {1} (PENDF to ACE)'".format( dat.nuclideName, dat.endfName) ]) deck.append([ "echo 'Getting ENDF input tape, PENDF input tape and NJOY executable'" ]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYAce)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathEndfAce, tapes.endf)]) deck.append( ['ln -fs {0} tape{1:02g}'.format(relPathPendfAce, abs(pendfOutTape))]) deck.append(["echo 'Running NJOY'"]) deck.append(["cat>input <<EOF"]) create_moder_input(deck, dat, tapes.endf, tapes.bendf) if dat.usePURR: create_purr_input(deck, dat, tapes.bendf, pendfOutTape, tapes.purrOut) else: create_moder_input(deck, dat, pendfOutTape, tapes.purrOut) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) for iT in range(numTemperatures): # Do multiple calls to NJOY (bug in NJOY somewhere) deck.append(["cat>input <<EOF"]) create_acer_input(deck, dat, tapes.bendf, tapes.purrOut, tapes.aceStart, tapes.aceXSDirStart, iT) create_acer_visualization_input(deck, dat, tapes.aceStart, tapes.acerViewStart, tapes.viewrAceStart, iT) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) deck.append(["echo 'Cleaning up and saving ACE files'"]) aceFiles = [] aceCERTDir = '/scratch/yunhuang/barnfire/xs/cert_ace' for i in range(numTemperatures): tapeAceOut, tapeXSDirOut, viewrOut = tapes.aceStart + i, tapes.aceXSDirStart + i, tapes.viewrAceStart + i aceFile = aceFileTemplate.format(A=dat.A, Z=dat.Z, s=i, e=dat.aceExt) aceFiles.append(aceFile) aceFileDir = 'xsdir.{}'.format(aceFile) plotName = 'p_xs_{}.pdf'.format(aceFile) deck.append(['cp -f tape{0:02g} {1}'.format(tapeAceOut, aceFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapeXSDirOut, aceFileDir)]) deck.append(['cp -f {0} {1}/'.format(aceFile, aceCERTDir)]) deck.append(['cp -f {0} {1}/'.format(aceFileDir, aceCERTDir)]) deck.append(['ps2pdf tape{0:02g} {1}'.format(viewrOut, plotName)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join( get_temporary_tapes_ace(tapes, pendfOutTape, [], numTemperatures, True)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) try_mkdir(aceDirr) print_njoy_file(aceScriptPath, deck) return pendfScriptPath, gendfScriptPath, aceScriptPath, aceFiles
def create_thermal_ace_njoy_script(dat, tapes): '''Create NJOY file to generate a thermal ACE output. These are done for each thermal treatment and each temperature.''' #Directories dirDict = get_common_directories() pyDirr = dirDict['src'] endfDirr = dirDict['endf'] pendfRootDirr = dirDict['pendf'] aceRootDirr = dirDict['ace'] njoyPath = os.path.join(dirDict['njoyInstall'], 'xnjoy_thermr') #using the latest patched NJOY2012 # pendfDirr = os.path.join(pendfRootDirr, str(dat.nuclideName)) aceDirr = os.path.join(aceRootDirr, str(dat.thermalFileName)) # pendfFile = 'pendf' endfPath = os.path.join(endfDirr, dat.endfFile) pendfPath = os.path.join(pendfDirr, pendfFile) # relPathNJOYAce = os.path.relpath(njoyPath, aceDirr) relPathEndfAce = os.path.relpath(endfPath, aceDirr) relPathPendfAce = os.path.relpath(pendfPath, aceDirr) # numThermals = len(dat.endfThermalFileList) numTemperatures = len(dat.thermList) pendfOutTape = get_pendf_out_tape(tapes, numThermals) endfThermalPathList = [os.path.join(endfDirr, thermalFile) for thermalFile in dat.endfThermalFileList if thermalFile] relPathThermalAceList = [os.path.relpath(thermalPath, aceDirr) for thermalPath in endfThermalPathList] endfThermalTapeList = map(lambda x: x + tapes.endfThermalStart, range(numThermals)) endfNonFreeThermalTapeList = [tape for (mt,tape) in zip(dat.inelasticMTList, endfThermalTapeList) if mt != 221] # aceScriptFile = 'runNJOY.sh' aceScriptPath = os.path.join(aceDirr, aceScriptFile) aceFileTemplate = '{H}.{e}{s}t' # Script to run NJOY from PENDF to thermal ACE: deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append(["echo 'NJOY Problem {0} {1} (PENDF to thermal ACE)'".format(dat.thermalNuclideName, dat.endfName)]) deck.append(["echo 'Getting ENDF input tape, PENDF input tape and NJOY executable'"]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYAce)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathEndfAce, tapes.endf)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathPendfAce, abs(pendfOutTape))]) for endfTape, relPath in zip(endfNonFreeThermalTapeList, relPathThermalAceList): deck.append(['ln -fs {0} tape{1:02g}'.format(relPath, endfTape)]) deck.append(["echo 'Running NJOY'"]) deck.append(["cat>input <<EOF"]) create_moder_input(deck, dat, tapes.endf, tapes.bendf) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) for iT in range(numTemperatures): # Do multiple calls to NJOY (bug in NJOY somewhere) deck.append(["cat>input <<EOF"]) create_thermal_acer_input(deck, dat, tapes.bendf, pendfOutTape, tapes.aceStart, tapes.aceXSDirStart, iT) create_acer_visualization_input(deck, dat, tapes.aceStart, tapes.acerViewStart, tapes.viewrAceStart, iT) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) deck.append(["echo 'Cleaning up and saving ACE files'"]) aceFiles = [] aceCERTDir = '/scratch/yunhuang/barnfire/xs/cert_ace' for i in range(numTemperatures): tapeAceOut, tapeXSDirOut, viewrOut = tapes.aceStart + i, tapes.aceXSDirStart + i, tapes.viewrAceStart + i aceFile = aceFileTemplate.format(H=dat.thermalFileName, s=i, e=dat.aceExt) aceFiles.append(aceFile) aceFileDir = 'xsdir.{}'.format(aceFile) plotName = 'p_xs_{}.pdf'.format(aceFile) deck.append(['cp -f tape{0:02g} {1}'.format(tapeAceOut, aceFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapeXSDirOut, aceFileDir)]) deck.append(['cp -f {0} {1}/'.format(aceFile, aceCERTDir)]) deck.append(['cp -f {0} {1}/'.format(aceFileDir, aceCERTDir)]) deck.append(['ps2pdf tape{0:02g} {1}'.format(viewrOut, plotName)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join(get_temporary_tapes_ace(tapes, pendfOutTape, endfNonFreeThermalTapeList, numTemperatures, False)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) try_mkdir(aceDirr) print_njoy_file(aceScriptPath, deck) return aceScriptPath, aceFiles
def create_njoy_script(dat, tapes): '''Create three NJOY files: one to generate a PENDF output, one to generate a GENDF output, and one to generate an ACE output''' #Directories dirDict = get_common_directories() pyDirr = dirDict['src'] endfDirr = dirDict['endf'] pendfRootDirr = dirDict['pendf'] gendfRootDirr = dirDict['gendf'] aceRootDirr = dirDict['ace'] njoyPath = os.path.join(dirDict['njoyInstall'], 'xnjoy_thermr') # pendfDirr = os.path.join(pendfRootDirr, str(dat.nuclideName)) gendfDirr = os.path.join(gendfRootDirr, str(dat.nuclideName)) aceDirr = os.path.join(aceRootDirr, str(dat.nuclideName)) # relPathNJOYPendf = os.path.relpath(njoyPath, pendfDirr) relPathNJOYGendf = os.path.relpath(njoyPath, gendfDirr) relPathNJOYAce = os.path.relpath(njoyPath, aceDirr) # endfPath = os.path.join(endfDirr, dat.endfFile) relPathEndfPendf = os.path.relpath(endfPath, pendfDirr) relPathEndfGendf = os.path.relpath(endfPath, gendfDirr) relPathEndfAce = os.path.relpath(endfPath, aceDirr) # numThermals = len(dat.endfThermalFileList) numTemperatures = len(dat.thermList) pendfOutTape = get_pendf_out_tape(tapes, numThermals) endfThermalPathList = [os.path.join(endfDirr, thermalFile) for thermalFile in dat.endfThermalFileList if thermalFile] relPathThermalPendfList = [os.path.relpath(thermalPath, pendfDirr) for thermalPath in endfThermalPathList] endfThermalTapeList = map(lambda x: x + tapes.endfThermalStart, range(numThermals)) endfNonFreeThermalTapeList = [tape for (mt,tape) in zip(dat.inelasticMTList, endfThermalTapeList) if mt != 221] # pendfScriptFile = 'runNJOY.sh' pendfScriptPath = os.path.join(pendfDirr, pendfScriptFile) pendfFile = 'pendf' pendfFileASCII = 'pendf_ascii.txt' pendfPath = os.path.join(pendfDirr, pendfFile) # gendfScriptFile = 'runNJOY.sh' gendfScriptPath = os.path.join(gendfDirr, gendfScriptFile) gendfFile = 'gendf' gendfPath = os.path.join(gendfDirr, gendfFile) relPathPendfGendf = os.path.relpath(pendfPath, gendfDirr) readgrouprPath = os.path.join(pyDirr, 'Readgroupr.py') # matxsFile = 'matxs' matxsDir = '/scratch/yunhuang/barnfire/xs/cert_matxs' # aceScriptFile = 'runNJOY.sh' aceScriptPath = os.path.join(aceDirr, aceScriptFile) aceFileTemplate = '{Z}{A:03}.{e}{s}c' relPathPendfAce = os.path.relpath(pendfPath, aceDirr) # Script to run NJOY from ENDF to PENDF: deck = [] deck.append(['#! /usr/bin/env bash']) deck.append(["echo 'NJOY Problem {0} {1} (ENDF to PENDF)'".format(dat.nuclideName, dat.endfName)]) deck.append(["echo 'Getting ENDF input tapes and NJOY executable'"]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYPendf)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathEndfPendf, tapes.endf)]) for endfTape, relPath in zip(endfNonFreeThermalTapeList, relPathThermalPendfList): deck.append(['ln -fs {0} tape{1:02g}'.format(relPath, endfTape)]) deck.append(["echo 'Running NJOY'"]) deck.append(['cat>input <<EOF']) create_moder_input(deck, dat, tapes.endf, tapes.bendf) create_reconr_input(deck, dat, tapes.bendf, tapes.reconrOut) create_broadr_input(deck, dat, tapes.bendf, tapes.reconrOut, tapes.broadrOut) # Warning: 9547 (Am-242m) and (Np-238) have negative values here sometimes for low Sigma_0 create_unresr_input(deck, dat, tapes.bendf, tapes.broadrOut, tapes.unresrOut) create_heatr_input(deck, dat, tapes.bendf, tapes.unresrOut, tapes.heatrOut) for i, endfThermal in enumerate(endfThermalTapeList): thermrInTape, thermrOutTape = get_thermr_tapes(tapes, i) if dat.inelasticMTList[i] == 221: endfThermal = 0 create_thermr_input(deck, dat, i, endfThermal, thermrInTape, thermrOutTape) create_moder_input(deck, dat, pendfOutTape, tapes.pendfOutASCII) deck.append(['stop']) deck.append(['EOF']) deck.append(['./xnjoy<input']) deck.append(["echo 'Cleaning up and saving PENDF file'"]) deck.append(['cp -f tape{0:02g} {1}'.format(abs(pendfOutTape), pendfFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapes.pendfOutASCII, pendfFileASCII)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join(get_temporary_tapes_pendf(tapes, endfNonFreeThermalTapeList, numThermals)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) try_mkdir(pendfDirr) print_njoy_file(pendfScriptPath, deck) # Script to run NJOY from PENDF to MATXS: doPlotr = False deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append(["echo 'NJOY Problem {0} {1} (PENDF to GENDF)'".format(dat.nuclideName, dat.endfName)]) deck.append(["echo 'Getting ENDF input tape, PENDF input tape and NJOY executable'"]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYGendf)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathEndfGendf, tapes.endf)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathPendfGendf, abs(pendfOutTape))]) deck.append(["echo 'Running NJOY'"]) deck.append(["cat>input <<EOF"]) create_moder_input(deck, dat, tapes.endf, tapes.bendf) dat.hasDelayedNu, dat.hasDelayedChis = hasDelayed(endfPath) create_groupr_input(deck, dat, tapes.bendf, pendfOutTape, tapes.grouprIn, tapes.grouprOut) create_moder_input(deck, dat, tapes.grouprOut, tapes.gendfOut) # get GENDF in ASCII for record create_matxsr_input(deck, dat, tapes.gendfOut, tapes.gaminrOut, tapes.matxsOut) # It seems MODER is not needed after MATXSR # create_moder_input(deck, dat, tapes.matxsOut, tapes.gendfOut) if False and dat.numGroups <= 200: doPlotr = True plotNames = create_plotr_inputs(deck, dat, tapes.gendfOut, tapes.plotrOut, tapes.viewrOut) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) deck.append(["echo 'Cleaning up, saving GROUPR and MATXS file'"]) if doPlotr: for plotName, viewrOut in zip(plotNames, tapes.viewrOut): deck.append(['ps2pdf tape{0:02g} {1}'.format(viewrOut, plotName)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapes.gendfOut, gendfFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapes.matxsOut, matxsFile)]) deck.append(['cp -f matxs {0}/{1}.dat'.format(matxsDir, dat.nuclideName)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join(get_temporary_tapes_gendf(tapes, pendfOutTape, doPlotr)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) optionalComment = '' if True and dat.numGroups > 200: optionalComment = '#' # deck.append(["{0}echo 'Reading in XS file and pickling for future use'".format(optionalComment)]) # deck.append(['{0} {1} -I {2} -p all -f csc'.format(optionalComment, readgrouprPath, gendfFile)]) try_mkdir(gendfDirr) print_njoy_file(gendfScriptPath, deck) # Script to run NJOY from PENDF to (non-thermal) ACE: deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append(["echo 'NJOY Problem {0} {1} (PENDF to ACE)'".format(dat.nuclideName, dat.endfName)]) deck.append(["echo 'Getting ENDF input tape, PENDF input tape and NJOY executable'"]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYAce)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathEndfAce, tapes.endf)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathPendfAce, abs(pendfOutTape))]) deck.append(["echo 'Running NJOY'"]) deck.append(["cat>input <<EOF"]) create_moder_input(deck, dat, tapes.endf, tapes.bendf) if dat.usePURR: create_purr_input(deck, dat, tapes.bendf, pendfOutTape, tapes.purrOut) else: create_moder_input(deck, dat, pendfOutTape, tapes.purrOut) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) for iT in range(numTemperatures): # Do multiple calls to NJOY (bug in NJOY somewhere) deck.append(["cat>input <<EOF"]) create_acer_input(deck, dat, tapes.bendf, tapes.purrOut, tapes.aceStart, tapes.aceXSDirStart, iT) create_acer_visualization_input(deck, dat, tapes.aceStart, tapes.acerViewStart, tapes.viewrAceStart, iT) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) deck.append(["echo 'Cleaning up and saving ACE files'"]) aceFiles = [] aceCERTDir = '/scratch/yunhuang/barnfire/xs/cert_ace' for i in range(numTemperatures): tapeAceOut, tapeXSDirOut, viewrOut = tapes.aceStart + i, tapes.aceXSDirStart + i, tapes.viewrAceStart + i aceFile = aceFileTemplate.format(A=dat.A, Z=dat.Z, s=i, e=dat.aceExt) aceFiles.append(aceFile) aceFileDir = 'xsdir.{}'.format(aceFile) plotName = 'p_xs_{}.pdf'.format(aceFile) deck.append(['cp -f tape{0:02g} {1}'.format(tapeAceOut, aceFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapeXSDirOut, aceFileDir)]) deck.append(['cp -f {0} {1}/'.format(aceFile, aceCERTDir)]) deck.append(['cp -f {0} {1}/'.format(aceFileDir, aceCERTDir)]) deck.append(['ps2pdf tape{0:02g} {1}'.format(viewrOut, plotName)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join(get_temporary_tapes_ace(tapes, pendfOutTape, [], numTemperatures, True)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) try_mkdir(aceDirr) print_njoy_file(aceScriptPath, deck) return pendfScriptPath, gendfScriptPath, aceScriptPath, aceFiles
def create_thermal_ace_njoy_script(dat, tapes): '''Create NJOY file to generate a thermal ACE output. These are done for each thermal treatment and each temperature.''' #Directories dirDict = get_common_directories() pyDirr = dirDict['src'] endfDirr = dirDict['endf'] pendfRootDirr = dirDict['pendf'] aceRootDirr = dirDict['ace'] njoyPath = os.path.join(dirDict['njoyInstall'], 'xnjoy_thermr') #using the latest patched NJOY2012 # pendfDirr = os.path.join(pendfRootDirr, str(dat.nuclideName)) aceDirr = os.path.join(aceRootDirr, str(dat.thermalFileName)) # pendfFile = 'pendf' endfPath = os.path.join(endfDirr, dat.endfFile) pendfPath = os.path.join(pendfDirr, pendfFile) # relPathNJOYAce = os.path.relpath(njoyPath, aceDirr) relPathEndfAce = os.path.relpath(endfPath, aceDirr) relPathPendfAce = os.path.relpath(pendfPath, aceDirr) # numThermals = len(dat.endfThermalFileList) numTemperatures = len(dat.thermList) pendfOutTape = get_pendf_out_tape(tapes, numThermals) endfThermalPathList = [ os.path.join(endfDirr, thermalFile) for thermalFile in dat.endfThermalFileList if thermalFile ] relPathThermalAceList = [ os.path.relpath(thermalPath, aceDirr) for thermalPath in endfThermalPathList ] endfThermalTapeList = map(lambda x: x + tapes.endfThermalStart, range(numThermals)) endfNonFreeThermalTapeList = [ tape for (mt, tape) in zip(dat.inelasticMTList, endfThermalTapeList) if mt != 221 ] # aceScriptFile = 'runNJOY.sh' aceScriptPath = os.path.join(aceDirr, aceScriptFile) aceFileTemplate = '{H}.{e}{s}t' # Script to run NJOY from PENDF to thermal ACE: deck = [] deck.append(["#! /usr/bin/env bash"]) deck.append([ "echo 'NJOY Problem {0} {1} (PENDF to thermal ACE)'".format( dat.thermalNuclideName, dat.endfName) ]) deck.append([ "echo 'Getting ENDF input tape, PENDF input tape and NJOY executable'" ]) deck.append(['ln -fs {0} xnjoy'.format(relPathNJOYAce)]) deck.append(['ln -fs {0} tape{1:02g}'.format(relPathEndfAce, tapes.endf)]) deck.append( ['ln -fs {0} tape{1:02g}'.format(relPathPendfAce, abs(pendfOutTape))]) for endfTape, relPath in zip(endfNonFreeThermalTapeList, relPathThermalAceList): deck.append(['ln -fs {0} tape{1:02g}'.format(relPath, endfTape)]) deck.append(["echo 'Running NJOY'"]) deck.append(["cat>input <<EOF"]) create_moder_input(deck, dat, tapes.endf, tapes.bendf) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) for iT in range(numTemperatures): # Do multiple calls to NJOY (bug in NJOY somewhere) deck.append(["cat>input <<EOF"]) create_thermal_acer_input(deck, dat, tapes.bendf, pendfOutTape, tapes.aceStart, tapes.aceXSDirStart, iT) create_acer_visualization_input(deck, dat, tapes.aceStart, tapes.acerViewStart, tapes.viewrAceStart, iT) deck.append(['stop']) deck.append(["EOF"]) deck.append(["./xnjoy<input"]) deck.append(["echo 'Cleaning up and saving ACE files'"]) aceFiles = [] aceCERTDir = '/scratch/yunhuang/barnfire/xs/cert_ace' for i in range(numTemperatures): tapeAceOut, tapeXSDirOut, viewrOut = tapes.aceStart + i, tapes.aceXSDirStart + i, tapes.viewrAceStart + i aceFile = aceFileTemplate.format(H=dat.thermalFileName, s=i, e=dat.aceExt) aceFiles.append(aceFile) aceFileDir = 'xsdir.{}'.format(aceFile) plotName = 'p_xs_{}.pdf'.format(aceFile) deck.append(['cp -f tape{0:02g} {1}'.format(tapeAceOut, aceFile)]) deck.append(['cp -f tape{0:02g} {1}'.format(tapeXSDirOut, aceFileDir)]) deck.append(['cp -f {0} {1}/'.format(aceFile, aceCERTDir)]) deck.append(['cp -f {0} {1}/'.format(aceFileDir, aceCERTDir)]) deck.append(['ps2pdf tape{0:02g} {1}'.format(viewrOut, plotName)]) deck.append(['rm -f xnjoy']) tapeNamesToRemove = ' '.join( get_temporary_tapes_ace(tapes, pendfOutTape, endfNonFreeThermalTapeList, numTemperatures, False)) deck.append(['rm -f {0}'.format(tapeNamesToRemove)]) try_mkdir(aceDirr) print_njoy_file(aceScriptPath, deck) return aceScriptPath, aceFiles
def define_input_parser(): dirDict = get_common_directories() pyDirr = dirDict['src'] groupDirr = dirDict['dat/energy_groups'] parser = argparse.ArgumentParser( description='Group structure specification functions.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) # If nothing is specified, verbosity is False. If -v or --verbose is specified, verbosity is 1. If -v N is specified, verbosity is N. parser.add_argument('-v', '--verbose', dest='verbosity', nargs='?', const=1, default=0, choices=[0, 1, 2, 3, 4], type=int) parser.add_argument('-i', '--inputdir', dest='inDirr', help='Input directory with MG library specifications', default=groupDirr) parser.add_argument('-I', '--inputname', dest='inName', help='Name of MG library to start with.', default='energy_in_default.txt') parser.add_argument('-o', '--outputdir', dest='outDirr', help='Output directory.', default=groupDirr) parser.add_argument( '-O', '--outname', dest='outName', help= "Short name for output files. A value of 'none' means do not print", default='custom') parser.add_argument( '-d', '--defaultuse', dest='useDefault', help= "Use a pre-defined input scheme. If not 'none', overrides 'rangeresolved,' 'finelethargyspacing,' and 'outname.'", choices=['none', 'low', 'med', 'high'], default='none') parser.add_argument( '-r', '--rangeresolved', dest='resolvedRange', help= 'The resolved resonance range to be refined (energies in eV). If multiple ranges are desired, this program may be run multiple times.', nargs=2, type=float, default=[3.0, 1000.0]) parser.add_argument('-R', '--rangefull', dest='fullRange', help='The full energy range for the group structure.', nargs=2, type=float, default=[1e-5, 2e7]) parser.add_argument('-e', '--noextend', dest='noExtend', help="If specified, do not crop to 'rangefull.'", action='store_true', default=False) energyMeshGroup = parser.add_argument_group( 'Number of groups specification', 'If both number of groups and lethargy spacing are provided, the finer of the two is used.' ) energyMeshGroup.add_argument('-g', '--groups', help='Total number of groups to use.', type=int, default=1) energyMeshGroup.add_argument( '-f', '--finelethargyspacing', dest='fineLethargySpacing', help='Lethargy spacing to use inside the resolve resonance region.', type=float, default=1e4) energyMeshGroup.add_argument( '-b', '--boundarylethargyspacing', dest='boundaryLethargySpacing', help= 'Lethargy spacing for the boundary between resolved and unresolved resonance regions. The boundary acts as a buffer for downscattering from medium-to-heavy nuclei so the two regions do not see each other directly. Use a value of 0 for no buffer.', type=float, default=0.3) return parser
def define_input_parser(): dirDict = get_common_directories() thisDirr = os.path.abspath('.') xsInDirr = dirDict['pdtxs'] xsOutDirr = dirDict['pdtxs'] # parser = argparse.ArgumentParser( description='Cross section merger', formatter_class=argparse.ArgumentDefaultsHelpFormatter) # # If nothing is specified, verbosity is False. If -v or --verbose is specified, verbosity is 1. If -v N is specified, verbosity is N. parser.add_argument('-v', '--verbose', dest='verbosity', nargs='?', const=1, default=0, choices=[0, 1, 2, 3, 4], type=int) parser.add_argument( '-m', '--materialslist', help= 'List of materials to use (for more advanced options, see materials_materials.py).', nargs='+', default=[]) parser.add_argument( '-M', '--micromacro', help= 'Which type of cross section(s) are desired: microscopic, macroscopic, or both?', default='macro', choices=['micro', 'macro', 'both']) parser.add_argument( '-a', '--aggregationopt', help= "Which cross sections to merge. 'auto' means combine all cross sections with the same materialName but different temperatures, assuming materials are named like '{materialName}_{temperatureIndex}. 'all' means combine all cross sections in the materials list into one new cross section.", default='auto', choices=['auto', 'all']) parser.add_argument( '-g', '--groups', help="Number of groups to use when determining the input name.", type=int, default=0) parser.add_argument('-i', '--inputdir', help='Input directory with PDT XS.', default=xsInDirr) parser.add_argument('-o', '--outputdir', help='Output directory', default=xsOutDirr) parser.add_argument( '-I', '--inputformat', help= 'Format for determining the cross section. {m} is replaced with the material name. {g} is replaced by the number of groups', default='xs_{m}_{g}.data') parser.add_argument( '-O', '--outputformat', help= "Format for determining the output cross section. {b} is replaced with the base material name (no temperature index; for 'all' aggregation, base name is 'all'). {g} is replaced by the number of groups. {n} is replaced by the number of XS to be merged", default='xs_{b}_{n}T_{g}.data') return parser