Skip to content

Commit

Permalink
add additional xsdata scripts; update xsdata readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yardasol committed Oct 4, 2022
1 parent dd2a0e1 commit 46c0d25
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 2 deletions.
39 changes: 37 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ This directory contains various scripts to help you set-up and analyze results
of your SaltProc simulations.

### `xsdata`
The script in this directory downloads and processes the JEFF
3.1.2 cross section library -- as well as spontaneous and delayed fission neutron and
The scripts in this directory downloads and processes cross sections data for
use in Serpent and OpenMC

#### `process_jeff312.bash`
Downloads and processes the JEFF 3.1.2 cross section library -- as well as
spontaneous and delayed fission neutron and
decay data -- for running the integration tests
on a UNIX-like machine.

Expand All @@ -23,3 +27,34 @@ XSDIR=[PATH TO XSDIR] bash process_j312.bash
Where `XSDIR` is a path to the directory where you want to store the cross
section libraries. Running the script without setting `XSDIR` will install the cross section library in the current working directory.


#### `download_endfb71.bash`
Downloads and processes the endfb7x incident neutron data, and
ENDFB71 thermal scattering data in ACE format-- as well as
spontaneous and delayed fission neutron and
decay data -- for running Serpent models
on a UNIX-like machine.

To run the script, execute
```
XSDIR=[PATH TO XSDIR] bash download_endfb71.bash
```

Where `XSDIR` is a path to the directory where you want to store the cross
section libraries. Running the script without setting `XSDIR` will install the cross section library in the current working directory.

#### `process_endfb71_to_openmc.bash`
Processes the endfb71 library created by the previous script into
OpenMC's HDF5 format for cross section data on a UNIX-like machine.

*You must have installed OpenMC on your machine and have openmc repo on your
machine in order for this script to work*
Information about how to do this can be found [here](https://docs.openmc.org/en/latest/usersguide/install.html).

To run the script, execute
```
XSDIR=[PATH TO XSDIR] $OPENMC_ENV=[NAME OF OPENMC CONDA ENVIRONMENT] $OPENMC_DIR=[PATH TO OPENMC REPO] bash download_endfb71.bash
```

Where `XSDIR` is a path to the directory where you want to store the cross
section libraries. Running the script without setting `XSDIR` will install the cross section library in the current working directory.
101 changes: 101 additions & 0 deletions scripts/xsdata/download_endfb71.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#! ~/bin/bash

# Get conda working in non interactive shell
CONDA_PATH=$(conda info | grep -i 'base environment' | awk '{print $4}')
source $CONDA_PATH/etc/profile.d/conda.sh

################
### DOWNLOAD ###
################
# DATADIR is the directory where the xs library is extracted to
# @yardasol reccomends naming the parent directory where the files
# will be extractd to as "jeff312"
if [[ -d "$XSDIR" ]]
then
DATADIR=$XSDIR/endfb71_ace
else
DATADIR=$PWD/endfb71_ace
fi
mkdir -p $DATADIR/acedata

# ndy, decay, sfy data
LN="https://www.nndc.bnl.gov/endf-b7.1/zips/"
SLUG="ENDF-B-VII.1-"
DATA=("nfy" "decay" "sfy")
EXT=".zip"
for D in ${DATA[@]}
do
if [[ ! -f $DATADIR/$SLUG$D$EXT ]]
then
wget -P $DATADIR $LN$SLUG$D$EXT
fi
mkdir -p $DATADIR/$D
unzip -j $DATADIR/$SLUG$D$EXT -d $DATADIR/$D
touch $DATADIR/endfb71.$D
files=$(ls $DATADIR/$D/*.[Ee][Nn][Dd][Ff])
for file in $files
do
cat $file >> $DATADIR/endfb71.$D
done
done

# OpenMC depletion chain
#conda activate openmc-env
#python openmc_make_chain.py -D $DATADIR

#########################
### SETUP .xsdir FILE ###
#########################
XSDIR_FILE=endfb71.xsdir
ACESLUG=https://www.nndc.bnl.gov/endf-b7.1/aceFiles/
ACEGZ=ENDF-B-VII.1-tsl.tar.gz
if [[ ! -f $DATADIR/$ACEGZ ]]
then
wget -P $DATADIR $ACESLUG$ACEGZ
fi
tar -xOzf $DATADIR/$ACEGZ xsdir | cat > $DATADIR/$XSDIR_FILE

# Make regex for DATADIR
DATADIR_REGEX=${DATADIR//\//\\\/}

# Fix datapath
sed -i "s/datapath/datapath=$DATADIR_REGEX\/acedata/" $DATADIR/$XSDIR_FILE
#echo "datapath=$DATADIR/acedata" > $DATADIR/$XSDIR_FILE

# Get cutoff line number
echo "Get cutoff"
LN="$(grep -n "directory" $DATADIR/$XSDIR_FILE)"
IFS=':' read -ra arr <<< "$LN"
LN=${arr[0]}

# Remove unused directory paths
head -n$LN $DATADIR/$XSDIR_FILE | cat > $DATADIR/temp
cat $DATADIR/temp > $DATADIR/$XSDIR_FILE
rm $DATADIR/temp
#echo "directory" >> $DATADIR/$XSDIR_FILE

# Neutron and thermal scattering data
LN="https://nucleardata.lanl.gov/lib/"
DATA=("endf71x" "ENDF71SaB")
EXT=".tgz"
for D in ${DATA[@]}
do
if [[ ! -f $DATADIR/$D$EXT ]]
then
wget -P $DATADIR $LN$D$EXT
fi
tar -xzf $DATADIR/"$D$EXT" -C $DATADIR --verbose
mv $DATADIR/$D/$D $DATADIR/acedata/.

cat $DATADIR/$D/xsdir >> $DATADIR/$XSDIR_FILE
done


# download cross section dir convert script
if [[ ! -f $XSDIR/xsdirconvert.pl ]]
then
wget -O $XSDIR/xsdirconvert.pl http://montecarlo.vtt.fi/download/xsdirconvert.pl
fi

# Run the xsdirconvert script
perl $XSDIR/xsdirconvert.pl $DATADIR/$XSDIR_FILE > $DATADIR/endfb71.xsdata
14 changes: 14 additions & 0 deletions scripts/xsdata/process_endfb71_to_openmc.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Get conda working in non interactive shell
CONDA_PATH=$(conda info | grep -i 'base environment' | awk '{print $4}')
source $CONDA_PATH/etc/profile.d/conda.sh

if [[ -d "$XSDIR" ]]
then
DATADIR=$XSDIR/endfb71_h5
else
DATADIR=$PWD/endfb71_h5
fi
mkdir -p $DATADIR

conda activate $OPENMC_ENV
python $OPENMCDIR/scripts/openmc-ace-to-hdf5 --xsdir $XSDIR/endfb71_ace/endfb71.xsdir -d $DATADIR

0 comments on commit 46c0d25

Please sign in to comment.