Merge branch 'source_interval' into read_sourcefile

This commit is contained in:
Bryan Herman 2014-02-22 17:27:59 -05:00
commit a13a7e92d5
15 changed files with 3704 additions and 1740 deletions

3
.gitignore vendored
View file

@ -29,3 +29,6 @@ src/templates/*.f90
# Test results error file
results_error.dat
# HDF5 files
*.h5

1716
data/cross_sections_nndc.xml Normal file

File diff suppressed because it is too large Load diff

96
data/get_nndc_data.py Executable file
View file

@ -0,0 +1,96 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import shutil
import subprocess
import sys
import tarfile
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
baseUrl = 'http://www.nndc.bnl.gov/endf/b7.1/aceFiles/'
files = ['ENDF-B-VII.1-neutron-293.6K.tar.gz',
'ENDF-B-VII.1-neutron-300K.tar.gz',
'ENDF-B-VII.1-neutron-900K.tar.gz',
'ENDF-B-VII.1-neutron-1500K.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)
# ==============================================================================
# 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)

View file

@ -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.
@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -348,8 +348,10 @@ attributes/sub-elements:
The ``<state_point>`` element indicates at what batches a state point file
should be written. A state point file can be used to restart a run or to get
tally results at any batch. This element has the following
attributes/sub-elements:
tally results at any batch. The default behavior when using this tag is to
write out the source bank in the state_point file. This behavior can be
customized by using the ``<source_point>`` element. This element has the
following attributes/sub-elements:
:batches:
A list of integers separated by spaces indicating at what batches a state
@ -364,19 +366,52 @@ attributes/sub-elements:
*Default*: None
``<source_point>`` Element
--------------------------
The ``<source_point>`` element indicates at what batches the source bank
should be written. The source bank can be either written out within a state
point file or separately in a source point file. This element has the following
attributes/sub-elements:
:batches:
A list of integers separated by spaces indicating at what batches a state
point file should be written. It should be noted that if source_separate
tag is not set to "true", this list must be a subset of state point batches.
*Default*: Last batch only
:interval:
A single integer :math:`n` indicating that a state point should be written
every :math:`n` batches. This option can be given in lieu of listing
batches explicitly. It should be noted that if source_separate tag is not
set to "true", this value should produce a list of batches that is a subset
of state point batches.
*Default*: None
:source_separate:
If this element is set to "true", a separate binary source file will be
If this element is set to "true", a separate binary source point file will be
written. Otherwise, the source sites will be written in the state point
directly.
*Default*: false
:source_write: If this element is set to "false", source sites are not written
to the state point file. This can substantially reduce the size of state
points if large numbers of particles per batch are used.
:source_write:
If this element is set to "false", source sites are not written
to the state point or source point file. This can substantially reduce the
size of state points if large numbers of particles per batch are used.
*Default*: true
:overwrite_latest:
If this element is set to "true", a source point file containing
the source bank will be written out to a separate file named
``source.binary`` or ``source.h5`` depending on if HDF5 is enabled.
This file will be overwritten at every single batch so that the latest
source bank will be available. It should be noted that a user can set both
this element to "true" and specify batches to write a permanent source bank.
``<survival_biasing>`` Element
------------------------------

View file

@ -264,10 +264,27 @@ Cross Section Configuration
In order to run a simulation with OpenMC, you will need cross section data for
each nuclide in your problem. Since OpenMC uses ACE format cross sections, you
can use nuclear data that was processed with NJOY, such as that distributed with
MCNP_ or Serpent_. The TALYS-based evaluated nuclear data library, TENDL_, is
can use nuclear data that was processed with NJOY_, such as that distributed
with MCNP_ or Serpent_. Several sources provide free processed ACE data as
described below. The TALYS-based evaluated nuclear data library, TENDL_, is also
openly available in ACE format.
Using ENDF/B-VII.1 Cross Sections from NNDC
-------------------------------------------
The NNDC_ provides ACE data from the ENDF/B-VII.1 neutron and thermal scattering
sublibraries at four temperatures processed using NJOY_. To use this data with
OpenMC, a script is provided with OpenMC that will automatically download,
extract, and set up a confiuration file:
.. code-block:: sh
cd openmc/data
python get_nndc_data.py
At this point, you should set the :envvar:`CROSS_SECTIONS` environment variable
to the absolute path of the file ``openmc/data/nndc/cross_sections.xml``.
Using JEFF Cross Sections from OECD/NEA
---------------------------------------
@ -314,6 +331,8 @@ distribution to the location of the Serpent cross sections. Then, either set the
environment variable to the absolute path of the ``cross_sections_serpent.xml``
file.
.. _NJOY: http://t2.lanl.gov/nis/codes.shtml
.. _NNDC: http://www.nndc.bnl.gov/endf/b7.1/acefiles.html
.. _NEA: http://www.oecd-nea.org
.. _JEFF: http://www.oecd-nea.org/dbdata/jeff/
.. _here: http://www.oecd-nea.org/dbdata/pubs/jeff312-cd.html

View file

@ -5,11 +5,11 @@ Data Processing and Visualization
=================================
This section is intended to explain in detail the recommended procedures for
carrying out common tasks with OpenMC. While several utilities of varying
complexity are provided to help automate the process, in many cases it will be
extremely beneficial to do some coding in Python to quickly obtain results. In
these cases, and for many of the provided utilities, it is necessary for your
Python installation to contain:
carrying out common post-processing tasks with OpenMC. While several utilities
of varying complexity are provided to help automate the process, in many cases
it will be extremely beneficial to do some coding in Python to quickly obtain
results. In these cases, and for many of the provided utilities, it is necessary
for your Python installation to contain:
* [1]_ `Numpy <http://www.numpy.org/>`_
* [1]_ `Scipy <http://www.scipy.org/>`_
@ -41,6 +41,55 @@ Plotting in 2D
.. image:: ../_images/atr.png
:height: 200px
See below for a simple example of a plots xml file that demonstrates the
capabilities of 2D slice plots. Here we assume that there is a ``geometry.xml``
file containing 7 cells.
.. code-block:: xml
<?xml version="1.0" encoding="UTF-8"?>
<plots>
<plot id="1" type="slice" color="cell" basis="xy">
<filename> myplot </filename>
<origin> 0 0 </origin>
<width> 10 10 </width>
<pixels> 2000 2000 </pixels>
<background> 0 0 0 </background>
<col_spec id="1" rgb="198 226 255"/>
<col_spec id="2" rgb="255 218 185"/>
<col_spec id="3" rgb="255 255 255"/>
<col_spec id="4" rgb="101 101 101"/>
<col_spec id="7" rgb="123 123 231"/>
<mask background="255 255 255">
<components> 1 3 4 5 6 </components>
</mask>
</plot>
</plots>
In this example, OpenMC will produce a plot named ``myplot.ppm`` when run in
plotting mode. The picture will be on the xy-plane, depicting the rectangle
between points (-5,-5) and (5,5) with 2000 pixels along each dimension. The
color of each pixel is determined by placing a particle at the center of that
pixel and using OpenMC's internal ``find_cell`` routine (the same one used for
particle tracking during simulation) to determine the cell and material at that
location. In this example, pixels are 10/2000=0.005 cm wide, so points will be
at (-4.9975,-4.9975), (-4.9950,-4.9975), (-4.9925,-4.9975), etc. This is pointed
out to demonstrate that this plot may miss any features smaller than 0.005 cm,
since they could exist between pixel centers. More pixels can be used to resolve
finer features, but could result in larger files.
The ``background``, ``col_spec``, and ``mask`` elements define how to set pixel
colors based on the cell ids at each pixel center. In this example, RGB colors
are specified for cells 1,2,3,4, and 7, a random color will be assigned to cells
5 and 6, and a black background color (``rgb="0 0 0"``) will be applied to
locations where no cell is defined. However, the ``mask`` element here says that
only cells 1,3,4,5, and 6 should be displayed, with other cells taking a white
color (``rgb="255 255 255"``), which overrides the ``col_spec`` for cell 2 and
the random color assigned to cell 7.
After running OpenMC to obtain PPM files, images should be saved to another
format before using them elsewhere. This cuts down the size of the file by
orders of magnitude. Most image viewers and editors that can view PPM images
@ -53,7 +102,7 @@ Ubuntu: ``sudo apt-get install imagemagick``). Images are then converted like:
.. code-block:: sh
convert plot.ppm plot.png
convert myplot.ppm myplot.png
Plotting in 3D
--------------
@ -61,10 +110,37 @@ Plotting in 3D
.. image:: ../_images/3dgeomplot.png
:height: 200px
See below for a simple example of a plots xml file that demonstrates the
capabilities of 3D voxel plots.
.. code-block:: xml
<?xml version="1.0" encoding="UTF-8"?>
<plots>
<plot id="1" type="voxel" color="mat">
<filename> myplot </filename>
<origin> 0 0 0 </origin>
<width> 10 10 10 </width>
<pixels> 500 500 500 </pixels>
</plot>
</plots>
Voxel plots are built the same way 2D slice plots are, by determining the cell
or material id of a particle at the center of each voxel. In this example, the
space covered is the cube between the points (-5,-5,-5) and (5,5,5), with voxel
centers 10/500 = 0.02 cm apart. The binary VOXEL files that are produced do not
specify any color - instead containing only material or cell ids (material id
in this example) - and thus the ``background``, ``col_spec``, and ``mask``
elements are not used. If no cell is found at a voxel center, an id of -1 is
stored.
The binary VOXEL files output by OpenMC can not be viewed directly by any
existing viewers. In order to view them, they must be converted into a standard
mesh format that can be viewed in ParaView, Visit, etc. The provided utility
voxel.py accomplishes this for SILO:
mesh format that can be viewed in ParaView, Visit, etc. This typically will
compress the size of the file significantly. The provided utility voxel.py
accomplishes this for SILO:
.. code-block:: sh
@ -88,13 +164,21 @@ or
Users can process the binary into any other format if desired by following the
example of voxel.py. For the binary file structure, see :ref:`devguide_voxel`.
Once processed into a standard 3D file format, colors and masks can be defined
using the stored id numbers to better explore the geometry. The process for
doing this will depend on the 3D viewer, but should be straightforward.
.. image:: ../_images/3dba.png
:height: 200px
.. note:: 3D voxel plotting can be very computer intensive for the viewing
program (Visit, Paraview, etc.) if the number of voxels is large (>10
million or so). Thus if you want an accurate picture that renders
smoothly, consider using only one voxel in a certain direction. For
instance, the 3D pin lattice figure above was generated with a
500x500x1 voxel mesh, which allows for resolution of the cylinders
without wasting too many voxels on the axial dimension.
instance, the 3D pin lattice figure at the beginning of this section
was generated with a 500x500x1 voxel mesh, which allows for resolution
of the cylinders without wasting too many voxels on the axial
dimension.
-------------------

14
tests/cleanup.bash Executable file
View file

@ -0,0 +1,14 @@
# This simple script ensures that all binary
# output files have been deleted in all the
# folders. This can occur if a previous error
# occurred and the test suite was rerun without
# deleting left over binary files. This will
# cause an assertion error in some of the
# tests.
for i in ./*; do
if [ -d "$i" ]; then
cd $i
rm -f *.binary *.h5
cd ..
fi
done

View file

@ -1,2 +0,0 @@
k-combined:
3.011353E-01 2.854556E-03

View file

@ -1,3 +1,2 @@
k-combined:
0.000000E+00 0.000000E+00
-9.438655E-02 -4.436810E+00 -2.416825E+00
3.011353E-01 2.854556E-03

View file

@ -11,7 +11,7 @@ import statepoint
if len(sys.argv) > 1:
sp = statepoint.StatePoint(sys.argv[1])
else:
sp = statepoint.StatePoint('statepoint.7.binary')
sp = statepoint.StatePoint('statepoint.10.binary')
sp.read_results()
# extract tally results and convert to vector

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<settings>
<state_point batches="7" />
<source_point source_separate="true" />
<state_point batches="7 10" />
<source_point batches="7" source_separate="true" />
<eigenvalue>
<batches>10</batches>

View file

@ -24,49 +24,49 @@ def test_run():
assert returncode == 0
def test_created_statepoint():
statepoint = glob.glob(pwd + '/statepoint.7.*')
assert len(statepoint) == 1
statepoint = glob.glob(pwd + '/statepoint.*')
assert len(statepoint) == 2
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
sourcepoint = glob.glob(pwd + '/source.7.*')
assert len(sourcepoint) == 1
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
def test_results():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
call(['python', 'results.py', statepoint[0]])
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
if not compare:
os.rename('results_test.dat', 'results_error.dat')
assert compare
os.remove(statepoint[0])
def test_restart_form1():
statepoint = glob.glob(pwd + '/statepoint.7.*')
sourcepoint = glob.glob(pwd + '/source.7.*')
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
'-r', statepoint[0]],
'-r', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path, '-r', statepoint[0]], stderr=STDOUT, stdout=PIPE)
proc = Popen([openmc_path, '-r', statepoint[0], sourcepoint[0]], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint_form1():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
sourcepoint = glob.glob(pwd + '/source.7.*')
assert len(sourcepoint) == 1
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
def test_results_form1():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
call(['python', 'results.py', statepoint[0]])
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
if not compare:
os.rename('results_test.dat', 'results_error.dat')
assert compare
os.remove(statepoint[0])
def test_restart_form2():
statepoint = glob.glob(pwd + '/statepoint.7.*')
@ -74,50 +74,46 @@ def test_restart_form2():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
'--restart', statepoint[0], source[0]],
'--restart', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path, '--restart', statepoint[0]],
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint_form2():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
sourcepoint = glob.glob(pwd + '/source.7.*')
assert len(sourcepoint) == 1
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
def test_results_form2():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
call(['python', 'results.py', statepoint[0]])
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
if not compare:
os.rename('results_test.dat', 'results_error.dat')
assert compare
os.remove(statepoint[0])
def test_restart_serial():
statepoint = glob.glob(pwd + '/statepoint.7.*')
sourcepoint = glob.glob(pwd + '/source.7.*')
openmc_path = pwd + '/../../src/openmc'
proc = Popen([openmc_path, '--restart', statepoint[0]],
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint_serial():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
sourcepoint = glob.glob(pwd + '/source.7.*')
assert len(sourcepoint) == 1
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
def test_results_serial():
statepoint = glob.glob(pwd + '/statepoint.7.*')
statepoint = glob.glob(pwd + '/statepoint.10.*')
call(['python', 'results.py', statepoint[0]])
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
if not compare:
@ -125,8 +121,8 @@ def test_results_serial():
assert compare
def teardown():
output = glob.glob(pwd + '/statepoint.7.*')
output += glob.glob(pwd + '/sourcepoint.7.*')
output = glob.glob(pwd + '/statepoint.*')
output += glob.glob(pwd + '/source.*')
output.append(pwd + '/results_test.dat')
for f in output:
if os.path.exists(f):