Skip to content

Commit

Permalink
Merge branch 'develop' into python3
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Aug 5, 2014
2 parents f7f61bb + 5808ed4 commit 497e2a2
Show file tree
Hide file tree
Showing 422 changed files with 23,835 additions and 49,720 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ src/openmc
docs/build
docs/source/_images/*.pdf

# Source build
src/build

# build from src/utils/setup.py
src/utils/build

# xml-fortran reader
src/xml-fortran/xmlreader

Expand All @@ -32,3 +38,6 @@ results_error.dat

# HDF5 files
*.h5

# Data downloaded from NNDC
data/nndc
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/xml/fox"]
path = src/xml/fox
url = https://github.com/mit-crpg/fox.git
1,716 changes: 1,716 additions & 0 deletions data/cross_sections_nndc.xml

Large diffs are not rendered by default.

149 changes: 149 additions & 0 deletions data/get_nndc_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/usr/bin/env python

from __future__ import print_function
import os
import shutil
import subprocess
import sys
import tarfile
import glob

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen

cwd = os.getcwd()
sys.path.append(os.path.join(cwd, '..', 'src', 'utils'))
from convert_binary import ascii_to_binary

baseUrl = 'http://www.nndc.bnl.gov/endf/b7.1/aceFiles/'
files = ['ENDF-B-VII.1-neutron-293.6K.tar.gz',
'ENDF-B-VII.1-tsl.tar.gz']
block_size = 16384

# ==============================================================================
# DOWNLOAD FILES FROM NNDC SITE

filesComplete = []
for f in files:
# Establish connection to URL
url = baseUrl + f
req = urlopen(url)

# Get file size from header
file_size = int(req.info().getheaders('Content-Length')[0])
downloaded = 0

# Check if file already downloaded
if os.path.exists(f):
if os.path.getsize(f) == file_size:
print('Skipping ' + f)
filesComplete.append(f)
continue
else:
if sys.version_info[0] < 3:
overwrite = raw_input('Overwrite {0}? ([y]/n) '.format(f))
else:
overwrite = input('Overwrite {0}? ([y]/n) '.format(f))
if overwrite.lower().startswith('n'):
continue

# Copy file to disk
print('Downloading {0}... '.format(f), end='')
with open(f, 'wb') as fh:
while True:
chunk = req.read(block_size)
if not chunk: break
fh.write(chunk)
downloaded += len(chunk)
status = '{0:10} [{1:3.2f}%]'.format(downloaded, downloaded * 100. / file_size)
print(status + chr(8)*len(status), end='')
print('')
filesComplete.append(f)

# ==============================================================================
# EXTRACT FILES FROM TGZ

for f in files:
if not f in filesComplete:
continue

# Extract files
suffix = f[f.rindex('-') + 1:].rstrip('.tar.gz')
with tarfile.open(f, 'r') as tgz:
print('Extracting {0}...'.format(f))
tgz.extractall(path='nndc/' + suffix)

#===============================================================================
# EDIT GRAPHITE ZAID (6012 to 6000)

print('Changing graphite ZAID from 6012 to 6000')
graphite = os.path.join('nndc', 'tsl', 'graphite.acer')
with open(graphite) as fh:
text = fh.read()
text = text.replace('6012', '6000', 1)
with open(graphite, 'w') as fh:
fh.write(text)

# ==============================================================================
# COPY CROSS_SECTIONS.XML

print('Copying cross_sections_nndc.xml...')
shutil.copyfile('cross_sections_nndc.xml', 'nndc/cross_sections.xml')

# ==============================================================================
# PROMPT USER TO DELETE .TAR.GZ FILES

# Ask user to delete
if sys.version_info[0] < 3:
response = raw_input('Delete *.tar.gz files? ([y]/n) ')
else:
response = input('Delete *.tar.gz files? ([y]/n) ')

# Delete files if requested
if not response or response.lower().startswith('y'):
for f in files:
if os.path.exists(f):
print('Removing {0}...'.format(f))
os.remove(f)

# ==============================================================================
# PROMPT USER TO CONVERT ASCII TO BINARY

# Ask user to convert
if sys.version_info[0] < 3:
response = raw_input('Convert ACE files to binary? ([y]/n) ')
else:
response = input('Convert ACE files to binary? ([y]/n) ')

# Convert files if requested
if not response or response.lower().startswith('y'):

# get a list of directories
ace_dirs = glob.glob(os.path.join('nndc', '*K'))
ace_dirs += glob.glob(os.path.join('nndc', 'tsl'))

# loop around ace directories
for d in ace_dirs:
print('Coverting {0}...'.format(d))

# get a list of files to convert
ace_files = glob.glob(os.path.join(d, '*.ace*'))

# convert files
for f in ace_files:
print(' Coverting {0}...'.format(os.path.split(f)[1]))
ascii_to_binary(f, f)

# Change cross_sections.xml file
xs_file = os.path.join('nndc', 'cross_sections.xml')
asc_str = "<filetype>ascii</filetype>"
bin_str = "<filetype> binary </filetype>\n "
bin_str += "<record_length> 4096 </record_length>\n "
bin_str += "<entries> 512 </entries>"
with open(xs_file) as fh:
text = fh.read()
text = text.replace(asc_str, bin_str)
with open(xs_file, 'w') as fh:
fh.write(text)
4 changes: 4 additions & 0 deletions data/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ work with a few common cross section sources.
- **cross_sections_ascii.xml** -- This file matches ENDF/B-VII.0 cross sections
distributed with MCNP5 / MCNP6 beta.

- **cross_sections_nndc.xml** -- This file matches ENDF/B-VII.1 cross sections
distributed from the `NNDC website`_.

- **cross_sections_serpent.xml** -- This file matches ENDF/B-VII.0 cross
sections distributed with Serpent 1.1.7.

Expand All @@ -31,3 +34,4 @@ element in your settings.xml, or set the CROSS_SECTIONS environment variable to
the full path of the cross_sections.xml file.

.. _user's guide: http://mit-crpg.github.io/openmc/usersguide/install.html#cross-section-configuration
.. _NNDC website: http://www.nndc.bnl.gov/endf/b7.1/acefiles.html
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
# built documents.
#
# The short X.Y version.
version = "0.5"
version = "0.6"
# The full version, including alpha/beta/rc tags.
release = "0.5.3"
release = "0.6.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/devguide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ as debugging.

.. toctree::
:numbered:
:maxdepth: 2
:maxdepth: 3

structures
styleguide
Expand Down
Loading

0 comments on commit 497e2a2

Please sign in to comment.