Skip to content
Open
86 changes: 62 additions & 24 deletions src/DataLib/EAFLib.C
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void EAFLib::extract(char* input, float* value)
char section[32];

/* find beginning of exponent */
int expStart = strcspn(input,"+-");
int expStart = strcspn(input+1,"+-") + 1;

/* extract mantissa portion to string variable */
strncpy(section,input,expStart);
Expand Down Expand Up @@ -393,18 +393,45 @@ int EAFLib::getTransData()
/* read the head of the file and get the following info:
* - Title
* and then advance to first isotope */
void EAFLib::getDecayInfo()
int EAFLib::parse_MT(const char* buffer) {
int MT_start = 72;
int MT_length = 3;

if (strlen(buffer) < MT_start + MT_length) return -1;

char mtField[4] = {0};
strncpy(mtField, buffer + MT_start, MT_length);
return atoi(mtField);
}

void EAFLib::getDecayInfo()
{

char buffer[MAXLINELENGTH];
int junkInt,i;
int MT = -1;

/* read number of initial comment lines */
inDecay >> junkInt;
std::streampos lineStart;

/* read end of this line and comment lines */
for (i=0;i<=junkInt;i++)
inDecay.getline(buffer,MAXLINELENGTH);
lineStart = inDecay.tellg();
if (inDecay.getline(buffer, MAXLINELENGTH))
{
MT = parse_MT(buffer);
}

while (inDecay && MT != 457)
{
lineStart = inDecay.tellg();

if (!inDecay.getline(buffer, MAXLINELENGTH))
break;

MT = parse_MT(buffer);
}

if (MT == 457)
{
inDecay.seekg(lineStart);
}
Comment thread
eitan-weinstein marked this conversation as resolved.

decayKza = new int[MAXEAFDCYMODES];
memCheck(decayKza,"EAFLib::getDecayInfo(...): decayKza");
Expand Down Expand Up @@ -433,14 +460,22 @@ int EAFLib::getDecayData()
float pBranch, aBranch, dIsoFlag;


do
{
/* scan for first 457 card */
inDecay.getline(buffer,MAXLINELENGTH);
/* extract the MT number of this line */
buffer[75] = '\0';
MT = atoi(buffer+72);
} while (MT != 457 && !inDecay.eof());
MT = -1;

/* prime loop with first MT value */
if (inDecay.getline(buffer, MAXLINELENGTH))
{
MT = parse_MT(buffer);
}

/* scan for first 457 card */
while (MT != 457 && !inDecay.eof())
{
if (!inDecay.getline(buffer, MAXLINELENGTH))
break;

MT = parse_MT(buffer);
}

if (inDecay.eof())
{
Expand Down Expand Up @@ -552,15 +587,18 @@ int EAFLib::getDecayData()
numSpec = getGammaData();

/* skip to end of this file section */
do
{
/* scan for last 457 card */
inDecay.getline(buffer,MAXLINELENGTH);
/* extract the MT number of this line */
buffer[75] = '\0';
MT = atoi(buffer+72);
} while (MT == 457 && !inDecay.eof());
if (inDecay.getline(buffer, MAXLINELENGTH))
{
MT = parse_MT(buffer);
}

while (MT == 457 && !inDecay.eof())
{
if (!inDecay.getline(buffer, MAXLINELENGTH))
break;

MT = parse_MT(buffer);
}

debug(6,"Returning %d decay branches for %d.",nDRxns,zak);

Expand Down
2 changes: 1 addition & 1 deletion src/DataLib/EAFLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ class EAFLib : public ASCIILib
void readDiscreteGammas(int, int, float, char*);
void readContGammas(int, float, char*);
int getGammaData();
int parse_MT(const char* );

/* Interface from ASCIILib */
void getTransInfo();
void getDecayInfo();
int getTransData();
int getDecayData();


public:

/* Service */
Expand Down
39 changes: 29 additions & 10 deletions tools/ALARAJOYWrapper/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FENDL3 Preprocessor with NJOY Wrapping for ALARA (*ALARAJOYWrapper*)
# FENDL3.2x Preprocessor with NJOY Wrapping for ALARA (*ALARAJOYWrapper*)

This preprocessor is designed to update ALARA's data input capabilities for updated FENDL3.2x data sets formatted as TENDL (ENDF-6) files. Unlike previous versions of [FENDL](https://www-nds.iaea.org/fendl_library/websites/fendl32b/) (Fusion Evaluated Nuclear Data Library), which have available groupwise cross-section data for neutron activation, as is required for ALARA's functionality, FENDL3 data requires conversion to that format.
This preprocessor is designed to update ALARA's data input capabilities for updated FENDL3.2x data sets formatted as TENDL (ENDF-6) files. Unlike previous versions of [FENDL](https://www-nds.iaea.org/fendl/) (Fusion Evaluated Nuclear Data Library), which have available groupwise cross-section data for neutron activation, as is required for ALARA's functionality, FENDL3.2x data requires conversion to that format.

This preprocessor uses [NJOY 2016](https://github.com/njoy/NJOY2016) Nuclear Data Processing System to produce requisite pointwise data (PENDF) to subsequntly convert to the Vitamin-J 175 energy group groupwise format (GENDF) for activation cross-sections and to handle the processed data to be fed back to ALARA. For pointwise conversion, ALARAJOYWrapper uses the NJOY modules MODER, RECONR, BROADR, UNRESR, and GASPR, and for the ultimate conversion to the groupwise format, GROUPR. Note that in order to properly handle isomeric reactions, NJOY 2016 has to be built with from the commit `1dbce787` or newer of the `develop` branch, which includes the necessary support for holistic isomer handling.

Expand All @@ -21,19 +21,38 @@ This preprocessor uses [NJOY 2016](https://github.com/njoy/NJOY2016) Nuclear Dat
* [Pandas](https://pandas.pydata.org/docs/getting_started/install.html)
- Domain-specific packages
* [ENDFtk](https://github.com/njoy/ENDFtk)
* [NJOY 2016](https://github.com/njoy/NJOY2016) (built with `develop` branch)
* [NJOY 2016](https://github.com/njoy/NJOY2016) (at Git hash `1dbce787`)


## Usage
This preprocessor can and should be used independently of any ALARA run. While the data format produced from ALARAJOYWrapper is necessary to run `convert_lib` on ALARA to convert TENDL data to an ALARA binary, once the user has a space-delimited DSV file produced from this preprocessor, usage of this preprocessor is not strictly necessary for the particular isotopes processed by the user.

ALARAJOYWrapper is designed to produce a space-delimited DSV containing data that can be directly read by the ALARA data library, ALARAJOY, without any further processing.
## Data Acquisition

Activation/inventory solvers such as ALARA require both neutron activation cross-sections and decay data. ALARAJOYWrapper is designed with the specific intent for processing FENDL3.2x data in a format readable by ALARA, corresponding to TENDL-2017 activation cross-sections and UKDD-2020 decay data. Nevertheless, to create custom ALARA libraries, any combination of TENDL and EAF or UKDD data can be supplied to ALARAJOYWrapper.

Many decay data libraries are distributed in repositories containing individual data files for each nuclide in the library. ALARA requires a single decay data file, so ALARAJOYWrapper can also compile these data libraries into a single file referable by `decayFname` (see _Application of Processed Data to ALARA Data Conversion Methods_ below).

- Activation Cross-Sections
* [TENDL](https://tendl.imperial.ac.uk/)
- Usable with any TENDL release
- For FENDL3.2x processing, [TENDL 2017](https://tendl.imperial.ac.uk/tendl_2017/tendl2017.html) is the standard version.

- Decay Data
* EAF
- [EAF-2010](https://git.oecd-nea.org/fispact/nuclear_data/EAF2010data.tar.bz2) (Must separate out ` eaf_dec_20100.0*` from the rest of the files after unzipping)
- [EAF-4.1](https://nds.iaea.org/fendl20/fen-decay.htm) (FENDL2.x decay library)
* UKDD
- [UKDD-20](https://www.oecd-nea.org/dbdata/fispact/decay2020.tar.bz2) (FENDL3.2x decay library)
- [UKDD-12](https://git.oecd-nea.org/fispact/nuclear_data/decay.tar.bz2)


## Usage
This preprocessor can and should be used independently of any ALARA run. While the data format produced from ALARAJOYWrapper is necessary to run `convert_lib` on ALARA to convert TENDL data to an ALARA binary, once the user has a space-delimited DSV file produced from this preprocessor, usage of this script is not strictly necessary for the particular isotopes processed by the user.

To run this preprocessor, the user must first have acquired TENDL files for each isotope from a selected [TENDL distribution](https://tendl.imperial.ac.uk/). While this tool is designed specifically for the purpose of making FENDL3.2x activation data available to be used in ALARA, the formatting of TENDL 2017 is not unique to that release, and users can apply any version of TENDL desired from the Imperial College London TENDL database to be processed in the ALARAJOY format. Otherwise, [TENDL 2017](https://tendl.imperial.ac.uk/tendl_2017/tendl2017.html) is the source for FENDL3.2x neutron activation data and is the standard intended input for this tool. All TENDL files to be processed must be in the same directory as each other to be properly identified by ALARAJOYWrapper.
ALARAJOYWrapper is designed to produce a space-delimited DSV containing cross-data that can be directly read by the ALARA data library, ALARAJOY, without any further processing.

Running ALARAJOYWrapper can be done with one Python command:
```
python preprocess_fendl3.py -f /path/to/fendl3_data_dir/ -d /path/to/eaf_decay_library/ -a
python preprocess_fendl3.py -f /path/to/fendl3_data_dir/ -d /path/to/eaf_decay_library/ decay_library_type -a
```
To read in detail about each of these arguments, call this command:
```
Expand All @@ -42,7 +61,7 @@ python preprocess_fendl3.py -h


## Data Output
Running `preprocess_fendl3.py` will return the file path to the resultant space-delimited DSV file containing transmutation reaction pathways for the neutron activation of the given isotope(s). Each row in the DSV represents a different reaction, and contains the following data needed by ALARA for a library conversion:
Running `preprocess_fendl3.py` will produce two file paths. The first is to the compiled decay data file, which will either be identical to the input for the first argument in `-d` if a pre-compiled decay library is being used or to the newly produced compiled decay library. The second is to the resultant space-delimited DSV file containing transmutation reaction pathways for the neutron activation of the given isotope(s). Each row in the DSV represents a different reaction, and contains the following data needed by ALARA for a library conversion:

- Parent KZA: Unique isotope identifier for the parent isotope in the format **ZZAAAM**, where ZZ is the isotope's atomic number, AAA is the mass number, and M is the isomeric state (0 if non-excited).
- Daughter KZA: Unique isotope identifier of the daughter isotope produced from a particular transmutation reaction in the format **ZZAAAM**.
Expand All @@ -69,7 +88,7 @@ Data library conversion to ALARA binary libraries is done with the `convert_lib`
wherein:
- `ajoylib` is the library value for ALARAJOY
- `transFname` is the file path to the DSV containing the preprocessed FENDL3 transmutation data
- `decayFname` is the file path to EAF decay data.
- `decayFname` is the file path to the compiled EAF or UKDD decay library, which may be produced by ALARAJOYWrapper.
- `alaraFname` is the file path template for resultant ALARA data libraries (.lib, .idx. .gam, .gdx)

The ALARA run for library conversion should precede and be independent from subsequent activation calculations with ALARA, as specified in the [ALARA Users' Guide](https://svalinn.github.io/ALARA/usersguide/index.html):
Expand Down
47 changes: 32 additions & 15 deletions tools/ALARAJOYWrapper/preprocess_fendl3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
def args():
parser = argparse.ArgumentParser()
parser.add_argument(
'--decay_lib', '-d', required=True, nargs=1,
'--decay_lib', '-d', required=True, nargs=2,
help=('''
Required argument to direct ALARAJOYWrapper to an EAF decay
library or directory containing EAF decay files for
individual nuclides. Necessary for cross-referencing short-
lived isomeric daughters against known half-life data.

Note: If using --decay_lib to direct to a directory of EAF
decay files, all files must have the extension ".dat".
Required argument pair to direct ALARAJOYWrapper to a decay data
library. The first part of the argument is the path to either
an EAF or UKDD pre-compiled decay file or a repository
containing multiple decay files to be compiled internally. See
the README.md for access to various decay library
distributions.
''')
)
parser.add_argument(
Expand Down Expand Up @@ -99,7 +98,7 @@ def process_pendf(

def process_gendf(
njoy_groupr_input, material_id, MTs, mt_dict,
temperature, pKZA, isomer_dict, all_rxns, eaf_nucs
temperature, pKZA, isomer_dict, all_rxns, all_nucs
):
"""
Prepare and run NJOY run with GROUPR and iteratively extract cross-section
Expand Down Expand Up @@ -134,8 +133,8 @@ def process_gendf(
}
}
}
eaf_nucs (dict): Dictionary keyed by all radionuclides in the EAF
decay library, with values of their half-lives.
all_nucs (dict): Dictionary keyed by all nuclide KZAs in the decay
library, with values of their half-lives (-1 for stable nuclides).

Returns:
all_rxns (collections.defaultdict): Updated dictionary for all
Expand Down Expand Up @@ -165,7 +164,7 @@ def process_gendf(
if gendf_MTs:
all_rxns = tp.iterate_MTs(
gendf_MTs, mt_dict, xs_line_dict, pKZA,
all_rxns, eaf_nucs, isomer_dict, gendf_path
all_rxns, all_nucs, isomer_dict
)
print(f'Finished processing {element}-{A}')

Expand Down Expand Up @@ -331,7 +330,22 @@ def main():
temperature = args().temperature[0]

mt_dict = rxd.process_mt_data(rxd.load_mt_table(dir / 'mt_table.csv'))
eaf_nucs = rxd.find_eaf_ref_data(Path(args().decay_lib[0]))
decay_path, decay_lib_type = args().decay_lib
ukdd_options = ['ukdd', 'ukaeadd', 'decay_2020', 'decay_2012']
if decay_lib_type.lower() in ukdd_options:
decay_lib_type = 'ukdd'

if decay_lib_type.lower() not in ['ukdd', 'eaf']:
raise ValueError(
'Invalid library type. Must be either an EAF or UKDD release.'
)

decay_path = Path(decay_path)
if decay_path.is_dir():
rxd.resolve_decay_file_formatting_issues(decay_path, decay_lib_type)
decay_path = rxd.compile_decay_lib(decay_path, decay_lib_type, dir)

all_nucs = rxd.find_nucs_from_decay_lib(decay_path)
all_rxns = defaultdict(lambda: defaultdict(dict))

for file_properties in tp.search_for_files(search_dir):
Expand All @@ -356,7 +370,7 @@ def main():
if not njoy_prep_error:
all_rxns = process_gendf(
njt.groupr_input, material_id, MTs, mt_dict,
temperature, pKZA, isomer_dict, all_rxns, eaf_nucs
temperature, pKZA, isomer_dict, all_rxns, all_nucs
)

else:
Expand All @@ -375,7 +389,10 @@ def main():

dsv_path = dir / 'cumulative_gendf_data.dsv'
write_dsv(dsv_path, gas_filtered)
print(f'Reaction data saved to: {dsv_path}')

print('-' * 20)
print(f'Compiled decay data: {decay_path}')
print(f'Reaction cross-sections: {dsv_path}')

if __name__ == '__main__':
main()
Loading
Loading