Merge pull request #852 from paulromano/model

Model class and test suite improvements
This commit is contained in:
Will Boyd 2017-04-11 09:02:44 -04:00 committed by GitHub
commit b7440ae3e3
111 changed files with 1481 additions and 1819 deletions

View file

@ -105,15 +105,20 @@ in the tests directory. We recommend to developers to test their branches
before submitting a formal pull request using gfortran and Intel compilers
if available.
The test suite is designed to integrate with cmake using ctest_.
It is configured to run with cross sections from NNDC_. To
download these cross sections please do the following:
The test suite is designed to integrate with cmake using ctest_. It is
configured to run with cross sections from NNDC_ augmented with 0 K elastic
scattering data for select nuclides as well as multipole data. To download the
proper data, run the following commands:
.. code-block:: sh
cd ../scripts
./openmc-get-nndc-data
export OPENMC_CROSS_SECTIONS=<path_to_data_folder>/nndc_hdf5/cross_sections.xml
wget -O nndc_hdf5.tar.xz $(cat <openmc_root>/.travis.yml | grep anl.box | awk '{print $2}')
tar xJvf nndc_hdf5.tar.xz
export OPENMC_CROSS_SECTIONS=$(pwd)/nndc_hdf5/cross_sections.xml
git clone --branch=master git://github.com/smharper/windowed_multipole_library.git wmp_lib
tar xzvf wmp_lib/multipole_lib.tar.gz
export OPENMC_MULTIPOLE_LIBRARY=$(pwd)/multipole_lib
The test suite can be run on an already existing build using:

View file

@ -0,0 +1,25 @@
----------------------------------------
:mod:`openmc.examples` -- Example Models
----------------------------------------
Simple Models
-------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: myfunction.rst
openmc.examples.slab_mg
Reactor Models
--------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: myfunction.rst
openmc.examples.pwr_pin_cell
openmc.examples.pwr_assembly
openmc.examples.pwr_core

View file

@ -47,4 +47,5 @@ Modules
mgxs
model
data
examples
openmoc

View file

@ -199,6 +199,30 @@ OpenMC.
etc. For a more thorough overview of the capabilities of this class,
see the :ref:`notebook_nuclear_data` example notebook.
Enabling Resonance Scattering Treatments
----------------------------------------
In order for OpenMC to correctly treat elastic scattering in heavy nuclides
where low-lying resonances might be present (see
:ref:`energy_dependent_xs_model`), the elastic scattering cross section at 0 K
must be present. To add the 0 K elastic scattering cross section to existing
:class:`IncidentNeutron` instance, you can use the
:meth:`IncidentNeutron.add_elastic_0K_from_endf` method which requires an ENDF
file for the nuclide you are modifying::
u238 = openmc.data.IncidentNeutron.from_hdf5('U238.h5')
u238.add_elastic_0K_from_endf('n-092_U_238.endf')
u238.export_to_hdf5('U238_with_0K.h5')
With 0 K elastic scattering data present, you can turn on a resonance scattering
method using :attr:`Settings.resonance_scattering`.
.. note:: The process of reconstructing resonances and generating tabulated 0 K
cross sections can be computationally expensive, especially for
nuclides like U-238 where thousands of resonances are present. Thus,
running the :meth:`IncidentNeutron.add_elastic_0K_from_endf` method
may take several minutes to complete.
-----------------------
Windowed Multipole Data
-----------------------

629
openmc/examples.py Normal file
View file

@ -0,0 +1,629 @@
import numpy as np
import openmc
import openmc.model
def pwr_pin_cell():
"""Create a PWR pin-cell model.
This model is a single fuel pin with 2.4 w/o enriched UO2 corresponding to a
beginning-of-cycle condition and borated water. The specifications are from
the `BEAVRS <http://crpg.mit.edu/research/beavrs>`_ benchmark. Note that the
number of particles/batches is initially set very low for testing purposes.
Returns
-------
model : openmc.model.Model
A PWR pin-cell model
"""
model = openmc.model.Model()
# Define materials.
fuel = openmc.Material(name='UO2 (2.4%)')
fuel.set_density('g/cm3', 10.29769)
fuel.add_nuclide("U234", 4.4843e-6)
fuel.add_nuclide("U235", 5.5815e-4)
fuel.add_nuclide("U238", 2.2408e-2)
fuel.add_nuclide("O16", 4.5829e-2)
clad = openmc.Material(name='Zircaloy')
clad.set_density('g/cm3', 6.55)
clad.add_nuclide("Zr90", 2.1827e-2)
clad.add_nuclide("Zr91", 4.7600e-3)
clad.add_nuclide("Zr92", 7.2758e-3)
clad.add_nuclide("Zr94", 7.3734e-3)
clad.add_nuclide("Zr96", 1.1879e-3)
hot_water = openmc.Material(name='Hot borated water')
hot_water.set_density('g/cm3', 0.740582)
hot_water.add_nuclide("H1", 4.9457e-2)
hot_water.add_nuclide("O16", 2.4672e-2)
hot_water.add_nuclide("B10", 8.0042e-6)
hot_water.add_nuclide("B11", 3.2218e-5)
hot_water.add_s_alpha_beta('c_H_in_H2O')
# Define the materials file.
model.materials = (fuel, clad, hot_water)
# Instantiate ZCylinder surfaces
pitch = 1.26
fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR')
clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR')
left = openmc.XPlane(x0=-pitch/2, name='left', boundary_type='reflective')
right = openmc.XPlane(x0=pitch/2, name='right', boundary_type='reflective')
bottom = openmc.YPlane(y0=-pitch/2, name='bottom',
boundary_type='reflective')
top = openmc.YPlane(y0=pitch/2, name='top', boundary_type='reflective')
# Instantiate Cells
fuel_pin = openmc.Cell(name='Fuel', fill=fuel)
cladding = openmc.Cell(name='Cladding', fill=clad)
water = openmc.Cell(name='Water', fill=hot_water)
# Use surface half-spaces to define regions
fuel_pin.region = -fuel_or
cladding.region = +fuel_or & -clad_or
water.region = +clad_or & +left & -right & +bottom & -top
# Create root universe
model.geometry.root_universe = openmc.Universe(0, name='root universe')
model.geometry.root_universe.add_cells([fuel_pin, cladding, water])
model.settings.batches = 10
model.settings.inactive = 5
model.settings.particles = 100
model.settings.source = openmc.Source(space=openmc.stats.Box(
[-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1], only_fissionable=True))
plot = openmc.Plot.from_geometry(model.geometry)
plot.pixels = (300, 300)
plot.color_by = 'material'
model.plots.append(plot)
return model
def pwr_core():
"""Create a PWR full-core model.
This model is the OECD/NEA Monte Carlo Performance benchmark which is a
grossly simplified pressurized water reactor (PWR) with 241 fuel
assemblies. Note that the number of particles/batches is initially set very
low for testing purposes.
Returns
-------
model : openmc.model.Model
Full-core PWR model
"""
model = openmc.model.Model()
# Define materials.
fuel = openmc.Material(1, name='UOX fuel')
fuel.set_density('g/cm3', 10.062)
fuel.add_nuclide("U234", 4.9476e-6)
fuel.add_nuclide("U235", 4.8218e-4)
fuel.add_nuclide("U238", 2.1504e-2)
fuel.add_nuclide("Xe135", 1.0801e-8)
fuel.add_nuclide("O16", 4.5737e-2)
clad = openmc.Material(2, name='Zircaloy')
clad.set_density('g/cm3', 5.77)
clad.add_nuclide("Zr90", 0.5145)
clad.add_nuclide("Zr91", 0.1122)
clad.add_nuclide("Zr92", 0.1715)
clad.add_nuclide("Zr94", 0.1738)
clad.add_nuclide("Zr96", 0.0280)
cold_water = openmc.Material(3, name='Cold borated water')
cold_water.set_density('atom/b-cm', 0.07416)
cold_water.add_nuclide("H1", 2.0)
cold_water.add_nuclide("O16", 1.0)
cold_water.add_nuclide("B10", 6.490e-4)
cold_water.add_nuclide("B11", 2.689e-3)
cold_water.add_s_alpha_beta('c_H_in_H2O')
hot_water = openmc.Material(4, name='Hot borated water')
hot_water.set_density('atom/b-cm', 0.06614)
hot_water.add_nuclide("H1", 2.0)
hot_water.add_nuclide("O16", 1.0)
hot_water.add_nuclide("B10", 6.490e-4)
hot_water.add_nuclide("B11", 2.689e-3)
hot_water.add_s_alpha_beta('c_H_in_H2O')
rpv_steel = openmc.Material(5, name='Reactor pressure vessel steel')
rpv_steel.set_density('g/cm3', 7.9)
rpv_steel.add_nuclide("Fe54", 0.05437098, 'wo')
rpv_steel.add_nuclide("Fe56", 0.88500663, 'wo')
rpv_steel.add_nuclide("Fe57", 0.0208008, 'wo')
rpv_steel.add_nuclide("Fe58", 0.00282159, 'wo')
rpv_steel.add_nuclide("Ni58", 0.0067198, 'wo')
rpv_steel.add_nuclide("Ni60", 0.0026776, 'wo')
rpv_steel.add_nuclide("Mn55", 0.01, 'wo')
rpv_steel.add_nuclide("Cr52", 0.002092475, 'wo')
rpv_steel.add_nuclide("C0", 0.0025, 'wo')
rpv_steel.add_nuclide("Cu63", 0.0013696, 'wo')
lower_rad_ref = openmc.Material(6, name='Lower radial reflector')
lower_rad_ref.set_density('g/cm3', 4.32)
lower_rad_ref.add_nuclide("H1", 0.0095661, 'wo')
lower_rad_ref.add_nuclide("O16", 0.0759107, 'wo')
lower_rad_ref.add_nuclide("B10", 3.08409e-5, 'wo')
lower_rad_ref.add_nuclide("B11", 1.40499e-4, 'wo')
lower_rad_ref.add_nuclide("Fe54", 0.035620772088, 'wo')
lower_rad_ref.add_nuclide("Fe56", 0.579805982228, 'wo')
lower_rad_ref.add_nuclide("Fe57", 0.01362750048, 'wo')
lower_rad_ref.add_nuclide("Fe58", 0.001848545204, 'wo')
lower_rad_ref.add_nuclide("Ni58", 0.055298376566, 'wo')
lower_rad_ref.add_nuclide("Mn55", 0.0182870, 'wo')
lower_rad_ref.add_nuclide("Cr52", 0.145407678031, 'wo')
lower_rad_ref.add_s_alpha_beta('c_H_in_H2O')
upper_rad_ref = openmc.Material(7, name='Upper radial reflector / Top plate region')
upper_rad_ref.set_density('g/cm3', 4.28)
upper_rad_ref.add_nuclide("H1", 0.0086117, 'wo')
upper_rad_ref.add_nuclide("O16", 0.0683369, 'wo')
upper_rad_ref.add_nuclide("B10", 2.77638e-5, 'wo')
upper_rad_ref.add_nuclide("B11", 1.26481e-4, 'wo')
upper_rad_ref.add_nuclide("Fe54", 0.035953677186, 'wo')
upper_rad_ref.add_nuclide("Fe56", 0.585224740891, 'wo')
upper_rad_ref.add_nuclide("Fe57", 0.01375486056, 'wo')
upper_rad_ref.add_nuclide("Fe58", 0.001865821363, 'wo')
upper_rad_ref.add_nuclide("Ni58", 0.055815129186, 'wo')
upper_rad_ref.add_nuclide("Mn55", 0.0184579, 'wo')
upper_rad_ref.add_nuclide("Cr52", 0.146766614995, 'wo')
upper_rad_ref.add_s_alpha_beta('c_H_in_H2O')
bot_plate = openmc.Material(8, name='Bottom plate region')
bot_plate.set_density('g/cm3', 7.184)
bot_plate.add_nuclide("H1", 0.0011505, 'wo')
bot_plate.add_nuclide("O16", 0.0091296, 'wo')
bot_plate.add_nuclide("B10", 3.70915e-6, 'wo')
bot_plate.add_nuclide("B11", 1.68974e-5, 'wo')
bot_plate.add_nuclide("Fe54", 0.03855611055, 'wo')
bot_plate.add_nuclide("Fe56", 0.627585036425, 'wo')
bot_plate.add_nuclide("Fe57", 0.014750478, 'wo')
bot_plate.add_nuclide("Fe58", 0.002000875025, 'wo')
bot_plate.add_nuclide("Ni58", 0.059855207342, 'wo')
bot_plate.add_nuclide("Mn55", 0.0197940, 'wo')
bot_plate.add_nuclide("Cr52", 0.157390026871, 'wo')
bot_plate.add_s_alpha_beta('c_H_in_H2O')
bot_nozzle = openmc.Material(9, name='Bottom nozzle region')
bot_nozzle.set_density('g/cm3', 2.53)
bot_nozzle.add_nuclide("H1", 0.0245014, 'wo')
bot_nozzle.add_nuclide("O16", 0.1944274, 'wo')
bot_nozzle.add_nuclide("B10", 7.89917e-5, 'wo')
bot_nozzle.add_nuclide("B11", 3.59854e-4, 'wo')
bot_nozzle.add_nuclide("Fe54", 0.030411411144, 'wo')
bot_nozzle.add_nuclide("Fe56", 0.495012237964, 'wo')
bot_nozzle.add_nuclide("Fe57", 0.01163454624, 'wo')
bot_nozzle.add_nuclide("Fe58", 0.001578204652, 'wo')
bot_nozzle.add_nuclide("Ni58", 0.047211231662, 'wo')
bot_nozzle.add_nuclide("Mn55", 0.0156126, 'wo')
bot_nozzle.add_nuclide("Cr52", 0.124142524198, 'wo')
bot_nozzle.add_s_alpha_beta('c_H_in_H2O')
top_nozzle = openmc.Material(10, name='Top nozzle region')
top_nozzle.set_density('g/cm3', 1.746)
top_nozzle.add_nuclide("H1", 0.0358870, 'wo')
top_nozzle.add_nuclide("O16", 0.2847761, 'wo')
top_nozzle.add_nuclide("B10", 1.15699e-4, 'wo')
top_nozzle.add_nuclide("B11", 5.27075e-4, 'wo')
top_nozzle.add_nuclide("Fe54", 0.02644016154, 'wo')
top_nozzle.add_nuclide("Fe56", 0.43037146399, 'wo')
top_nozzle.add_nuclide("Fe57", 0.0101152584, 'wo')
top_nozzle.add_nuclide("Fe58", 0.00137211607, 'wo')
top_nozzle.add_nuclide("Ni58", 0.04104621835, 'wo')
top_nozzle.add_nuclide("Mn55", 0.0135739, 'wo')
top_nozzle.add_nuclide("Cr52", 0.107931450781, 'wo')
top_nozzle.add_s_alpha_beta('c_H_in_H2O')
top_fa = openmc.Material(11, name='Top of fuel assemblies')
top_fa.set_density('g/cm3', 3.044)
top_fa.add_nuclide("H1", 0.0162913, 'wo')
top_fa.add_nuclide("O16", 0.1292776, 'wo')
top_fa.add_nuclide("B10", 5.25228e-5, 'wo')
top_fa.add_nuclide("B11", 2.39272e-4, 'wo')
top_fa.add_nuclide("Zr90", 0.43313403903, 'wo')
top_fa.add_nuclide("Zr91", 0.09549277374, 'wo')
top_fa.add_nuclide("Zr92", 0.14759527104, 'wo')
top_fa.add_nuclide("Zr94", 0.15280552077, 'wo')
top_fa.add_nuclide("Zr96", 0.02511169542, 'wo')
top_fa.add_s_alpha_beta('c_H_in_H2O')
bot_fa = openmc.Material(12, name='Bottom of fuel assemblies')
bot_fa.set_density('g/cm3', 1.762)
bot_fa.add_nuclide("H1", 0.0292856, 'wo')
bot_fa.add_nuclide("O16", 0.2323919, 'wo')
bot_fa.add_nuclide("B10", 9.44159e-5, 'wo')
bot_fa.add_nuclide("B11", 4.30120e-4, 'wo')
bot_fa.add_nuclide("Zr90", 0.3741373658, 'wo')
bot_fa.add_nuclide("Zr91", 0.0824858164, 'wo')
bot_fa.add_nuclide("Zr92", 0.1274914944, 'wo')
bot_fa.add_nuclide("Zr94", 0.1319920622, 'wo')
bot_fa.add_nuclide("Zr96", 0.0216912612, 'wo')
bot_fa.add_s_alpha_beta('c_H_in_H2O')
# Define the materials file.
model.materials = (fuel, clad, cold_water, hot_water, rpv_steel,
lower_rad_ref, upper_rad_ref, bot_plate,
bot_nozzle, top_nozzle, top_fa, bot_fa)
# Define surfaces.
s1 = openmc.ZCylinder(R=0.41, surface_id=1)
s2 = openmc.ZCylinder(R=0.475, surface_id=2)
s3 = openmc.ZCylinder(R=0.56, surface_id=3)
s4 = openmc.ZCylinder(R=0.62, surface_id=4)
s5 = openmc.ZCylinder(R=187.6, surface_id=5)
s6 = openmc.ZCylinder(R=209.0, surface_id=6)
s7 = openmc.ZCylinder(R=229.0, surface_id=7)
s8 = openmc.ZCylinder(R=249.0, surface_id=8, boundary_type='vacuum')
s31 = openmc.ZPlane(z0=-229.0, surface_id=31, boundary_type='vacuum')
s32 = openmc.ZPlane(z0=-199.0, surface_id=32)
s33 = openmc.ZPlane(z0=-193.0, surface_id=33)
s34 = openmc.ZPlane(z0=-183.0, surface_id=34)
s35 = openmc.ZPlane(z0=0.0, surface_id=35)
s36 = openmc.ZPlane(z0=183.0, surface_id=36)
s37 = openmc.ZPlane(z0=203.0, surface_id=37)
s38 = openmc.ZPlane(z0=215.0, surface_id=38)
s39 = openmc.ZPlane(z0=223.0, surface_id=39, boundary_type='vacuum')
# Define pin cells.
fuel_cold = openmc.Universe(name='Fuel pin, cladding, cold water',
universe_id=1)
c21 = openmc.Cell(cell_id=21, fill=fuel, region=-s1)
c22 = openmc.Cell(cell_id=22, fill=clad, region=+s1 & -s2)
c23 = openmc.Cell(cell_id=23, fill=cold_water, region=+s2)
fuel_cold.add_cells((c21, c22, c23))
tube_cold = openmc.Universe(name='Instrumentation guide tube, '
'cold water', universe_id=2)
c24 = openmc.Cell(cell_id=24, fill=cold_water, region=-s3)
c25 = openmc.Cell(cell_id=25, fill=clad, region=+s3 & -s4)
c26 = openmc.Cell(cell_id=26, fill=cold_water, region=+s4)
tube_cold.add_cells((c24, c25, c26))
fuel_hot = openmc.Universe(name='Fuel pin, cladding, hot water',
universe_id=3)
c27 = openmc.Cell(cell_id=27, fill=fuel, region=-s1)
c28 = openmc.Cell(cell_id=28, fill=clad, region=+s1 & -s2)
c29 = openmc.Cell(cell_id=29, fill=hot_water, region=+s2)
fuel_hot.add_cells((c27, c28, c29))
tube_hot = openmc.Universe(name='Instrumentation guide tube, hot water',
universe_id=4)
c30 = openmc.Cell(cell_id=30, fill=hot_water, region=-s3)
c31 = openmc.Cell(cell_id=31, fill=clad, region=+s3 & -s4)
c32 = openmc.Cell(cell_id=32, fill=hot_water, region=+s4)
tube_hot.add_cells((c30, c31, c32))
# Set positions occupied by guide tubes
tube_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14,
2, 5, 8, 11, 14, 3, 13, 5, 8, 11])
tube_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8,
11, 11, 11, 11, 11, 13, 13, 14, 14, 14])
# Define fuel lattices.
l100 = openmc.RectLattice(name='Fuel assembly (lower half)', lattice_id=100)
l100.lower_left = (-10.71, -10.71)
l100.pitch = (1.26, 1.26)
l100.universes = np.tile(fuel_cold, (17, 17))
l100.universes[tube_x, tube_y] = tube_cold
l101 = openmc.RectLattice(name='Fuel assembly (upper half)', lattice_id=101)
l101.lower_left = (-10.71, -10.71)
l101.pitch = (1.26, 1.26)
l101.universes = np.tile(fuel_hot, (17, 17))
l101.universes[tube_x, tube_y] = tube_hot
# Define assemblies.
fa_cw = openmc.Universe(name='Water assembly (cold)', universe_id=5)
c50 = openmc.Cell(cell_id=50, fill=cold_water, region=+s34 & -s35)
fa_cw.add_cell(c50)
fa_hw = openmc.Universe(name='Water assembly (hot)', universe_id=7)
c70 = openmc.Cell(cell_id=70, fill=hot_water, region=+s35 & -s36)
fa_hw.add_cell(c70)
fa_cold = openmc.Universe(name='Fuel assembly (cold)', universe_id=6)
c60 = openmc.Cell(cell_id=60, fill=l100, region=+s34 & -s35)
fa_cold.add_cell(c60)
fa_hot = openmc.Universe(name='Fuel assembly (hot)', universe_id=8)
c80 = openmc.Cell(cell_id=80, fill=l101, region=+s35 & -s36)
fa_hot.add_cell(c80)
# Define core lattices
l200 = openmc.RectLattice(name='Core lattice (lower half)', lattice_id=200)
l200.lower_left = (-224.91, -224.91)
l200.pitch = (21.42, 21.42)
l200.universes = [
[fa_cw]*21,
[fa_cw]*21,
[fa_cw]*7 + [fa_cold]*7 + [fa_cw]*7,
[fa_cw]*5 + [fa_cold]*11 + [fa_cw]*5,
[fa_cw]*4 + [fa_cold]*13 + [fa_cw]*4,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*4 + [fa_cold]*13 + [fa_cw]*4,
[fa_cw]*5 + [fa_cold]*11 + [fa_cw]*5,
[fa_cw]*7 + [fa_cold]*7 + [fa_cw]*7,
[fa_cw]*21,
[fa_cw]*21]
l201 = openmc.RectLattice(name='Core lattice (lower half)', lattice_id=201)
l201.lower_left = (-224.91, -224.91)
l201.pitch = (21.42, 21.42)
l201.universes = [
[fa_hw]*21,
[fa_hw]*21,
[fa_hw]*7 + [fa_hot]*7 + [fa_hw]*7,
[fa_hw]*5 + [fa_hot]*11 + [fa_hw]*5,
[fa_hw]*4 + [fa_hot]*13 + [fa_hw]*4,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*4 + [fa_hot]*13 + [fa_hw]*4,
[fa_hw]*5 + [fa_hot]*11 + [fa_hw]*5,
[fa_hw]*7 + [fa_hot]*7 + [fa_hw]*7,
[fa_hw]*21,
[fa_hw]*21]
# Define root universe.
root = openmc.Universe(universe_id=0, name='root universe')
c1 = openmc.Cell(cell_id=1, fill=l200, region=-s6 & +s34 & -s35)
c2 = openmc.Cell(cell_id=2, fill=l201, region=-s6 & +s35 & -s36)
c3 = openmc.Cell(cell_id=3, fill=bot_plate, region=-s7 & +s31 & -s32)
c4 = openmc.Cell(cell_id=4, fill=bot_nozzle, region=-s5 & +s32 & -s33)
c5 = openmc.Cell(cell_id=5, fill=bot_fa, region=-s5 & +s33 & -s34)
c6 = openmc.Cell(cell_id=6, fill=top_fa, region=-s5 & +s36 & -s37)
c7 = openmc.Cell(cell_id=7, fill=top_nozzle, region=-s5 & +s37 & -s38)
c8 = openmc.Cell(cell_id=8, fill=upper_rad_ref, region=-s7 & +s38 & -s39)
c9 = openmc.Cell(cell_id=9, fill=bot_nozzle, region=+s6 & -s7 & +s32 & -s38)
c10 = openmc.Cell(cell_id=10, fill=rpv_steel, region=+s7 & -s8 & +s31 & -s39)
c11 = openmc.Cell(cell_id=11, fill=lower_rad_ref, region=+s5 & -s6 & +s32 & -s34)
c12 = openmc.Cell(cell_id=12, fill=upper_rad_ref, region=+s5 & -s6 & +s36 & -s38)
root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12))
# Assign root universe to geometry
model.geometry.root_universe = root
model.settings.batches = 10
model.settings.inactive = 5
model.settings.particles = 100
model.settings.source = openmc.Source(space=openmc.stats.Box(
[-160, -160, -183], [160, 160, 183]))
plot = openmc.Plot()
plot.origin = (125, 125, 0)
plot.width = (250, 250)
plot.pixels = (3000, 3000)
plot.color_by = 'material'
model.plots.append(plot)
return model
def pwr_assembly():
"""Create a PWR assembly model.
This model is a reflected 17x17 fuel assembly from the the `BEAVRS
<http://crpg.mit.edu/research/beavrs>`_ benchmark. The fuel is 2.4 w/o
enriched UO2 corresponding to a beginning-of-cycle condition. Note that the
number of particles/batches is initially set very low for testing purposes.
Returns
-------
model : openmc.model.Model
A PWR assembly model
"""
model = openmc.model.Model()
# Define materials.
fuel = openmc.Material(name='Fuel')
fuel.set_density('g/cm3', 10.29769)
fuel.add_nuclide("U234", 4.4843e-6)
fuel.add_nuclide("U235", 5.5815e-4)
fuel.add_nuclide("U238", 2.2408e-2)
fuel.add_nuclide("O16", 4.5829e-2)
clad = openmc.Material(name='Cladding')
clad.set_density('g/cm3', 6.55)
clad.add_nuclide("Zr90", 2.1827e-2)
clad.add_nuclide("Zr91", 4.7600e-3)
clad.add_nuclide("Zr92", 7.2758e-3)
clad.add_nuclide("Zr94", 7.3734e-3)
clad.add_nuclide("Zr96", 1.1879e-3)
hot_water = openmc.Material(name='Hot borated water')
hot_water.set_density('g/cm3', 0.740582)
hot_water.add_nuclide("H1", 4.9457e-2)
hot_water.add_nuclide("O16", 2.4672e-2)
hot_water.add_nuclide("B10", 8.0042e-6)
hot_water.add_nuclide("B11", 3.2218e-5)
hot_water.add_s_alpha_beta('c_H_in_H2O')
# Define the materials file.
model.materials = (fuel, clad, hot_water)
# Instantiate ZCylinder surfaces
fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR')
clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR')
# Create boundary planes to surround the geometry
pitch = 21.42
min_x = openmc.XPlane(x0=-pitch/2, boundary_type='reflective')
max_x = openmc.XPlane(x0=+pitch/2, boundary_type='reflective')
min_y = openmc.YPlane(y0=-pitch/2, boundary_type='reflective')
max_y = openmc.YPlane(y0=+pitch/2, boundary_type='reflective')
# Create a fuel pin universe
fuel_pin_universe = openmc.Universe(name='Fuel Pin')
fuel_cell = openmc.Cell(name='fuel', fill=fuel, region=-fuel_or)
clad_cell = openmc.Cell(name='clad', fill=clad, region=+fuel_or & -clad_or)
hot_water_cell = openmc.Cell(name='hot water', fill=hot_water, region=+clad_or)
fuel_pin_universe.add_cells([fuel_cell, clad_cell, hot_water_cell])
# Create a control rod guide tube universe
guide_tube_universe = openmc.Universe(name='Guide Tube')
gt_inner_cell = openmc.Cell(name='guide tube inner water', fill=hot_water,
region=-fuel_or)
gt_clad_cell = openmc.Cell(name='guide tube clad', fill=clad,
region=+fuel_or & -clad_or)
gt_outer_cell = openmc.Cell(name='guide tube outer water', fill=hot_water,
region=+clad_or)
guide_tube_universe.add_cells([gt_inner_cell, gt_clad_cell, gt_outer_cell])
# Create fuel assembly Lattice
assembly = openmc.RectLattice(name='Fuel Assembly')
assembly.pitch = (pitch/17, pitch/17)
assembly.lower_left = (-pitch/2, -pitch/2)
# Create array indices for guide tube locations in lattice
template_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8,
11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11])
template_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8,
8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14])
# Create 17x17 array of universes
assembly.universes = np.tile(fuel_pin_universe, (17, 17))
assembly.universes[template_x, template_y] = guide_tube_universe
# Create root Cell
root_cell = openmc.Cell(name='root cell', fill=assembly)
root_cell.region = +min_x & -max_x & +min_y & -max_y
# Create root Universe
model.geometry.root_universe = openmc.Universe(name='root universe')
model.geometry.root_universe.add_cell(root_cell)
model.settings.batches = 10
model.settings.inactive = 5
model.settings.particles = 100
model.settings.source = openmc.Source(space=openmc.stats.Box(
[-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1], only_fissionable=True))
plot = openmc.Plot()
plot.origin = (0.0, 0.0, 0)
plot.width = (21.42, 21.42)
plot.pixels = (300, 300)
plot.color_by = 'material'
model.plots.append(plot)
return model
def slab_mg(reps=None, as_macro=True):
"""Create a one-group, 1D slab model.
Parameters
----------
reps : list, optional
List of angular representations. Each item corresponds to materials and
dictates the angular representation of the multi-group cross
sections---isotropic ('iso') or angle-dependent ('ang'), and if Legendre
scattering or tabular scattering ('mu') is used. Thus, items can be
'ang', 'ang_mu', 'iso', or 'iso_mu'.
as_macro : bool, optional
Whether :class:`openmc.Macroscopic` is used
Returns
-------
model : openmc.model.Model
One-group, 1D slab model
"""
model = openmc.model.Model()
# Define materials needed for 1D/1G slab problem
mat_names = ['uo2', 'clad', 'lwtr']
mgxs_reps = ['ang', 'ang_mu', 'iso', 'iso_mu']
if reps is None:
reps = mgxs_reps
xs = []
i = 0
for mat in mat_names:
for rep in reps:
i += 1
if as_macro:
xs.append(openmc.Macroscopic(mat + '_' + rep))
m = openmc.Material(name=str(i))
m.set_density('macro', 1.)
m.add_macroscopic(xs[-1])
else:
xs.append(openmc.Nuclide(mat + '_' + rep))
m = openmc.Material(name=str(i))
m.set_density('atom/b-cm', 1.)
m.add_nuclide(xs[-1].name, 1.0, 'ao')
model.materials.append(m)
# Define the materials file
model.xs_data = xs
model.materials.cross_sections = "../1d_mgxs.h5"
# Define surfaces.
# Assembly/Problem Boundary
left = openmc.XPlane(x0=0.0, boundary_type='reflective')
right = openmc.XPlane(x0=10.0, boundary_type='reflective')
bottom = openmc.YPlane(y0=0.0, boundary_type='reflective')
top = openmc.YPlane(y0=10.0, boundary_type='reflective')
# for each material add a plane
planes = [openmc.ZPlane(z0=0.0, boundary_type='reflective')]
dz = round(5. / float(len(model.materials)), 4)
for i in range(len(model.materials) - 1):
planes.append(openmc.ZPlane(z0=dz * float(i + 1)))
planes.append(openmc.ZPlane(z0=5.0, boundary_type='reflective'))
# Define cells for each material
model.geometry.root_universe = openmc.Universe(name='root universe')
xy = +left & -right & +bottom & -top
for i, mat in enumerate(model.materials):
c = openmc.Cell(fill=mat, region=xy & +planes[i] & -planes[i + 1])
model.geometry.root_universe.add_cell(c)
model.settings.batches = 10
model.settings.inactive = 5
model.settings.particles = 100
model.settings.source = openmc.Source(space=openmc.stats.Box(
[0.0, 0.0, 0.0], [10.0, 10.0, 5.]))
model.settings.energy_mode = "multi-group"
plot = openmc.Plot()
plot.filename = 'mat'
plot.origin = (5.0, 5.0, 2.5)
plot.width = (2.5, 2.5)
plot.basis = 'xz'
plot.pixels = (3000, 3000)
plot.color_by = 'material'
model.plots.append(plot)
return model

View file

@ -1,26 +1,34 @@
from collections import Iterable
import openmc
from openmc.checkvalue import check_type
class Model(object):
"""OpenMC model container for the openmc.Geometry, openmc.Materials,
openmc.Settings, openmc.Tallies, openmc.CMFD objects, and openmc.Plot
objects
"""Model container.
This class can be used to store instances of :class:`openmc.Geometry`,
:class:`openmc.Materials`, :class:`openmc.Settings`,
:class:`openmc.Tallies`, :class:`openmc.Plots`, and :class:`openmc.CMFD`,
thus making a complete model. The :meth:`Model.export_to_xml` method will
export XML files for all attributes that have been set. If the
:meth:`Model.materials` attribute is not set, it will attempt to create a
``materials.xml`` file based on all materials appearing in the geometry.
Parameters
----------
geometry : openmc.Geometry
geometry : openmc.Geometry, optional
Geometry information
materials : openmc.Materials
materials : openmc.Materials, optional
Materials information
settings : openmc.Settings
settings : openmc.Settings, optional
Settings information
tallies : openmc.Tallies
Tallies information, optional
cmfd : openmc.CMFD
CMFD information, optional
plots : openmc.Plots
Plot information, optional
tallies : openmc.Tallies, optional
Tallies information
cmfd : openmc.CMFD, optional
CMFD information
plots : openmc.Plots, optional
Plot information
Attributes
----------
@ -39,25 +47,25 @@ class Model(object):
"""
def __init__(self, geometry, materials, settings, tallies=None, cmfd=None,
plots=None):
self.geometry = geometry
self.materials = materials
self.settings = settings
if tallies:
self.tallies = tallies
else:
self._tallies = openmc.Tallies()
if cmfd:
self.cmfd = cmfd
else:
self._cmfd = None
if plots:
self.plots = plots
else:
self.plots = openmc.Plots()
def __init__(self, geometry=None, materials=None, settings=None,
tallies=None, cmfd=None, plots=None):
self.geometry = openmc.Geometry()
self.materials = openmc.Materials()
self.settings = openmc.Settings()
self.cmfd = cmfd
self.tallies = openmc.Tallies()
self.plots = openmc.Plots()
self.sp = None
if geometry is not None:
self.geometry = geometry
if materials is not None:
self.materials = materials
if settings is not None:
self.settings = settings
if tallies is not None:
self.tallies = tallies
if plots is not None:
self.plots = plots
@property
def geometry(self):
@ -90,8 +98,13 @@ class Model(object):
@materials.setter
def materials(self, materials):
check_type('materials', materials, openmc.Materials)
self._materials = materials
check_type('materials', materials, Iterable, openmc.Material)
if isinstance(materials, openmc.Materials):
self._materials = materials
else:
del self._materials[:]
for mat in materials:
self._materials.append(mat)
@settings.setter
def settings(self, settings):
@ -100,33 +113,55 @@ class Model(object):
@tallies.setter
def tallies(self, tallies):
check_type('tallies', tallies, openmc.Tallies)
self._tallies = tallies
check_type('tallies', tallies, Iterable, openmc.Tally)
if isinstance(tallies, openmc.Tallies):
self._tallies = tallies
else:
del self._tallies[:]
for tally in tallies:
self._tallies.append(tally)
@cmfd.setter
def cmfd(self, cmfd):
check_type('cmfd', cmfd, openmc.CMFD)
check_type('cmfd', cmfd, (openmc.CMFD, type(None)))
self._cmfd = cmfd
@plots.setter
def plots(self, plots):
check_type('plots', plots, openmc.Plots)
self._plots = plots
check_type('plots', plots, Iterable, openmc.Plot)
if isinstance(plots, openmc.Plots):
self._plots = plots
else:
del self._plots[:]
for plot in plots:
self._plots.append(plot)
def export_to_xml(self):
"""Export model settings to XML files.
"""Export model to XML files.
"""
self.geometry.export_to_xml()
self.materials.export_to_xml()
self.settings.export_to_xml()
self.tallies.export_to_xml()
self.geometry.export_to_xml()
# If a materials collection was specified, export it. Otherwise, look
# for all materials in the geometry and use that to automatically build
# a collection.
if self.materials:
self.materials.export_to_xml()
else:
materials = openmc.Materials(self.geometry.get_all_materials()
.values())
materials.export_to_xml()
if self.tallies:
self.tallies.export_to_xml()
if self.cmfd is not None:
self.cmfd.export_to_xml()
self.plots.export_to_xml()
if self.plots:
self.plots.export_to_xml()
def run(self, **kwargs):
"""Creates the XML files, runs OpenMC, and loads the statepoint.
"""Creates the XML files, runs OpenMC, and returns k-effective
Parameters
----------
@ -136,29 +171,19 @@ class Model(object):
Returns
-------
2-tuple of float
k_combined from the statepoint
Combined estimator of k-effective from the statepoint
"""
self.export_to_xml()
return_code = openmc.run(**kwargs)
assert (return_code == 0), "OpenMC did not execute successfully"
statepoint_batches = self.settings.batches
n = self.settings.batches
if self.settings.statepoint is not None:
if 'batches' in self.settings.statepoint:
statepoint_batches = self.settings.statepoint['batches'][-1]
self.sp = \
openmc.StatePoint('statepoint.{}.h5'.format(statepoint_batches))
n = self.settings.statepoint['batches'][-1]
return self.sp.k_combined
def close(self):
"""Close the statepoint and summary files
"""
if self.sp is not None:
self.sp._f.close()
self.sp.summary._f.close()
with openmc.StatePoint('statepoint.{}.h5'.format(n)) as sp:
return sp.k_combined

View file

@ -51,10 +51,6 @@ def _search_keff(guess, target, model_builder, model_args, print_iterations,
# Run the model and obtain keff
keff = model.run(output=print_output)
# Close the model to ensure HDF5 will allow access during the next
# OpenMC execution
model.close()
# Record the history
guesses.append(guess)
results.append(keff)

View file

@ -138,6 +138,12 @@ class StatePoint(object):
vol = openmc.VolumeCalculation.from_hdf5(path_i)
self.add_volume_information(vol)
def __enter__(self):
return self
def __exit__(self, *exc):
self._f.close()
@property
def cmfd_on(self):
return self._f.attrs['cmfd_on'] > 0

View file

@ -42,8 +42,8 @@ def main():
for fname in args.input:
# Write coordinate values to points array.
track = h5py.File(fname)
n_particles = track['n_particles'].value
n_coords = track['n_coords']
n_particles = track.attrs['n_particles']
n_coords = track.attrs['n_coords']
coords = []
for i in range(n_particles):
coords.append(track['coordinates_' + str(i + 1)].value)

View file

@ -5303,6 +5303,13 @@ contains
do i = 1, size(res_scat_nuclides)
if (nuc % name == res_scat_nuclides(i)) then
! Make sure nuclide has 0K data
if (.not. allocated(nuc % energy_0K)) then
call fatal_error("Cannot treat " // trim(nuc % name) // " as a &
&resonant scatterer because 0 K elastic scattering data is not &
&present.")
end if
! Set nuclide to be resonant
nuc % resonant = .true.

View file

@ -1,798 +0,0 @@
import numpy as np
import openmc
from openmc.source import Source
from openmc.stats import Box
class InputSet(object):
def __init__(self):
self.settings = openmc.Settings()
self.materials = openmc.Materials()
self.geometry = openmc.Geometry()
self.tallies = None
self.plots = None
def export(self):
self.settings.export_to_xml()
self.materials.export_to_xml()
self.geometry.export_to_xml()
if self.tallies is not None:
self.tallies.export_to_xml()
if self.plots is not None:
self.plots.export_to_xml()
def build_default_materials_and_geometry(self):
# Define materials.
fuel = openmc.Material(name='Fuel', material_id=1)
fuel.set_density('g/cm3', 10.062)
fuel.add_nuclide("U234", 4.9476e-6)
fuel.add_nuclide("U235", 4.8218e-4)
fuel.add_nuclide("U238", 2.1504e-2)
fuel.add_nuclide("Xe135", 1.0801e-8)
fuel.add_nuclide("O16", 4.5737e-2)
clad = openmc.Material(name='Cladding', material_id=2)
clad.set_density('g/cm3', 5.77)
clad.add_nuclide("Zr90", 0.5145)
clad.add_nuclide("Zr91", 0.1122)
clad.add_nuclide("Zr92", 0.1715)
clad.add_nuclide("Zr94", 0.1738)
clad.add_nuclide("Zr96", 0.0280)
cold_water = openmc.Material(name='Cold borated water', material_id=3)
cold_water.set_density('atom/b-cm', 0.07416)
cold_water.add_nuclide("H1", 2.0)
cold_water.add_nuclide("O16", 1.0)
cold_water.add_nuclide("B10", 6.490e-4)
cold_water.add_nuclide("B11", 2.689e-3)
cold_water.add_s_alpha_beta('c_H_in_H2O')
hot_water = openmc.Material(name='Hot borated water', material_id=4)
hot_water.set_density('atom/b-cm', 0.06614)
hot_water.add_nuclide("H1", 2.0)
hot_water.add_nuclide("O16", 1.0)
hot_water.add_nuclide("B10", 6.490e-4)
hot_water.add_nuclide("B11", 2.689e-3)
hot_water.add_s_alpha_beta('c_H_in_H2O')
rpv_steel = openmc.Material(name='Reactor pressure vessel steel',
material_id=5)
rpv_steel.set_density('g/cm3', 7.9)
rpv_steel.add_nuclide("Fe54", 0.05437098, 'wo')
rpv_steel.add_nuclide("Fe56", 0.88500663, 'wo')
rpv_steel.add_nuclide("Fe57", 0.0208008, 'wo')
rpv_steel.add_nuclide("Fe58", 0.00282159, 'wo')
rpv_steel.add_nuclide("Ni58", 0.0067198, 'wo')
rpv_steel.add_nuclide("Ni60", 0.0026776, 'wo')
rpv_steel.add_nuclide("Mn55", 0.01, 'wo')
rpv_steel.add_nuclide("Cr52", 0.002092475, 'wo')
rpv_steel.add_nuclide("C0", 0.0025, 'wo')
rpv_steel.add_nuclide("Cu63", 0.0013696, 'wo')
lower_rad_ref = openmc.Material(name='Lower radial reflector',
material_id=6)
lower_rad_ref.set_density('g/cm3', 4.32)
lower_rad_ref.add_nuclide("H1", 0.0095661, 'wo')
lower_rad_ref.add_nuclide("O16", 0.0759107, 'wo')
lower_rad_ref.add_nuclide("B10", 3.08409e-5, 'wo')
lower_rad_ref.add_nuclide("B11", 1.40499e-4, 'wo')
lower_rad_ref.add_nuclide("Fe54", 0.035620772088, 'wo')
lower_rad_ref.add_nuclide("Fe56", 0.579805982228, 'wo')
lower_rad_ref.add_nuclide("Fe57", 0.01362750048, 'wo')
lower_rad_ref.add_nuclide("Fe58", 0.001848545204, 'wo')
lower_rad_ref.add_nuclide("Ni58", 0.055298376566, 'wo')
lower_rad_ref.add_nuclide("Mn55", 0.0182870, 'wo')
lower_rad_ref.add_nuclide("Cr52", 0.145407678031, 'wo')
lower_rad_ref.add_s_alpha_beta('c_H_in_H2O')
upper_rad_ref = openmc.Material(name='Upper radial reflector /'
'Top plate region', material_id=7)
upper_rad_ref.set_density('g/cm3', 4.28)
upper_rad_ref.add_nuclide("H1", 0.0086117, 'wo')
upper_rad_ref.add_nuclide("O16", 0.0683369, 'wo')
upper_rad_ref.add_nuclide("B10", 2.77638e-5, 'wo')
upper_rad_ref.add_nuclide("B11", 1.26481e-4, 'wo')
upper_rad_ref.add_nuclide("Fe54", 0.035953677186, 'wo')
upper_rad_ref.add_nuclide("Fe56", 0.585224740891, 'wo')
upper_rad_ref.add_nuclide("Fe57", 0.01375486056, 'wo')
upper_rad_ref.add_nuclide("Fe58", 0.001865821363, 'wo')
upper_rad_ref.add_nuclide("Ni58", 0.055815129186, 'wo')
upper_rad_ref.add_nuclide("Mn55", 0.0184579, 'wo')
upper_rad_ref.add_nuclide("Cr52", 0.146766614995, 'wo')
upper_rad_ref.add_s_alpha_beta('c_H_in_H2O')
bot_plate = openmc.Material(name='Bottom plate region', material_id=8)
bot_plate.set_density('g/cm3', 7.184)
bot_plate.add_nuclide("H1", 0.0011505, 'wo')
bot_plate.add_nuclide("O16", 0.0091296, 'wo')
bot_plate.add_nuclide("B10", 3.70915e-6, 'wo')
bot_plate.add_nuclide("B11", 1.68974e-5, 'wo')
bot_plate.add_nuclide("Fe54", 0.03855611055, 'wo')
bot_plate.add_nuclide("Fe56", 0.627585036425, 'wo')
bot_plate.add_nuclide("Fe57", 0.014750478, 'wo')
bot_plate.add_nuclide("Fe58", 0.002000875025, 'wo')
bot_plate.add_nuclide("Ni58", 0.059855207342, 'wo')
bot_plate.add_nuclide("Mn55", 0.0197940, 'wo')
bot_plate.add_nuclide("Cr52", 0.157390026871, 'wo')
bot_plate.add_s_alpha_beta('c_H_in_H2O')
bot_nozzle = openmc.Material(name='Bottom nozzle region',
material_id=9)
bot_nozzle.set_density('g/cm3', 2.53)
bot_nozzle.add_nuclide("H1", 0.0245014, 'wo')
bot_nozzle.add_nuclide("O16", 0.1944274, 'wo')
bot_nozzle.add_nuclide("B10", 7.89917e-5, 'wo')
bot_nozzle.add_nuclide("B11", 3.59854e-4, 'wo')
bot_nozzle.add_nuclide("Fe54", 0.030411411144, 'wo')
bot_nozzle.add_nuclide("Fe56", 0.495012237964, 'wo')
bot_nozzle.add_nuclide("Fe57", 0.01163454624, 'wo')
bot_nozzle.add_nuclide("Fe58", 0.001578204652, 'wo')
bot_nozzle.add_nuclide("Ni58", 0.047211231662, 'wo')
bot_nozzle.add_nuclide("Mn55", 0.0156126, 'wo')
bot_nozzle.add_nuclide("Cr52", 0.124142524198, 'wo')
bot_nozzle.add_s_alpha_beta('c_H_in_H2O')
top_nozzle = openmc.Material(name='Top nozzle region', material_id=10)
top_nozzle.set_density('g/cm3', 1.746)
top_nozzle.add_nuclide("H1", 0.0358870, 'wo')
top_nozzle.add_nuclide("O16", 0.2847761, 'wo')
top_nozzle.add_nuclide("B10", 1.15699e-4, 'wo')
top_nozzle.add_nuclide("B11", 5.27075e-4, 'wo')
top_nozzle.add_nuclide("Fe54", 0.02644016154, 'wo')
top_nozzle.add_nuclide("Fe56", 0.43037146399, 'wo')
top_nozzle.add_nuclide("Fe57", 0.0101152584, 'wo')
top_nozzle.add_nuclide("Fe58", 0.00137211607, 'wo')
top_nozzle.add_nuclide("Ni58", 0.04104621835, 'wo')
top_nozzle.add_nuclide("Mn55", 0.0135739, 'wo')
top_nozzle.add_nuclide("Cr52", 0.107931450781, 'wo')
top_nozzle.add_s_alpha_beta('c_H_in_H2O')
top_fa = openmc.Material(name='Top of fuel assemblies', material_id=11)
top_fa.set_density('g/cm3', 3.044)
top_fa.add_nuclide("H1", 0.0162913, 'wo')
top_fa.add_nuclide("O16", 0.1292776, 'wo')
top_fa.add_nuclide("B10", 5.25228e-5, 'wo')
top_fa.add_nuclide("B11", 2.39272e-4, 'wo')
top_fa.add_nuclide("Zr90", 0.43313403903, 'wo')
top_fa.add_nuclide("Zr91", 0.09549277374, 'wo')
top_fa.add_nuclide("Zr92", 0.14759527104, 'wo')
top_fa.add_nuclide("Zr94", 0.15280552077, 'wo')
top_fa.add_nuclide("Zr96", 0.02511169542, 'wo')
top_fa.add_s_alpha_beta('c_H_in_H2O')
bot_fa = openmc.Material(name='Bottom of fuel assemblies',
material_id=12)
bot_fa.set_density('g/cm3', 1.762)
bot_fa.add_nuclide("H1", 0.0292856, 'wo')
bot_fa.add_nuclide("O16", 0.2323919, 'wo')
bot_fa.add_nuclide("B10", 9.44159e-5, 'wo')
bot_fa.add_nuclide("B11", 4.30120e-4, 'wo')
bot_fa.add_nuclide("Zr90", 0.3741373658, 'wo')
bot_fa.add_nuclide("Zr91", 0.0824858164, 'wo')
bot_fa.add_nuclide("Zr92", 0.1274914944, 'wo')
bot_fa.add_nuclide("Zr94", 0.1319920622, 'wo')
bot_fa.add_nuclide("Zr96", 0.0216912612, 'wo')
bot_fa.add_s_alpha_beta('c_H_in_H2O')
# Define the materials file.
self.materials += (fuel, clad, cold_water, hot_water, rpv_steel,
lower_rad_ref, upper_rad_ref, bot_plate,
bot_nozzle, top_nozzle, top_fa, bot_fa)
# Define surfaces.
s1 = openmc.ZCylinder(R=0.41, surface_id=1)
s2 = openmc.ZCylinder(R=0.475, surface_id=2)
s3 = openmc.ZCylinder(R=0.56, surface_id=3)
s4 = openmc.ZCylinder(R=0.62, surface_id=4)
s5 = openmc.ZCylinder(R=187.6, surface_id=5)
s6 = openmc.ZCylinder(R=209.0, surface_id=6)
s7 = openmc.ZCylinder(R=229.0, surface_id=7)
s8 = openmc.ZCylinder(R=249.0, surface_id=8)
s8.boundary_type = 'vacuum'
s31 = openmc.ZPlane(z0=-229.0, surface_id=31)
s31.boundary_type = 'vacuum'
s32 = openmc.ZPlane(z0=-199.0, surface_id=32)
s33 = openmc.ZPlane(z0=-193.0, surface_id=33)
s34 = openmc.ZPlane(z0=-183.0, surface_id=34)
s35 = openmc.ZPlane(z0=0.0, surface_id=35)
s36 = openmc.ZPlane(z0=183.0, surface_id=36)
s37 = openmc.ZPlane(z0=203.0, surface_id=37)
s38 = openmc.ZPlane(z0=215.0, surface_id=38)
s39 = openmc.ZPlane(z0=223.0, surface_id=39)
s39.boundary_type = 'vacuum'
# Define pin cells.
fuel_cold = openmc.Universe(name='Fuel pin, cladding, cold water',
universe_id=1)
c21 = openmc.Cell(cell_id=21)
c21.region = -s1
c21.fill = fuel
c22 = openmc.Cell(cell_id=22)
c22.region = +s1 & -s2
c22.fill = clad
c23 = openmc.Cell(cell_id=23)
c23.region = +s2
c23.fill = cold_water
fuel_cold.add_cells((c21, c22, c23))
tube_cold = openmc.Universe(name='Instrumentation guide tube, '
'cold water', universe_id=2)
c24 = openmc.Cell(cell_id=24)
c24.region = -s3
c24.fill = cold_water
c25 = openmc.Cell(cell_id=25)
c25.region = +s3 & -s4
c25.fill = clad
c26 = openmc.Cell(cell_id=26)
c26.region = +s4
c26.fill = cold_water
tube_cold.add_cells((c24, c25, c26))
fuel_hot = openmc.Universe(name='Fuel pin, cladding, hot water',
universe_id=3)
c27 = openmc.Cell(cell_id=27)
c27.region = -s1
c27.fill = fuel
c28 = openmc.Cell(cell_id=28)
c28.region = +s1 & -s2
c28.fill = clad
c29 = openmc.Cell(cell_id=29)
c29.region = +s2
c29.fill = hot_water
fuel_hot.add_cells((c27, c28, c29))
tube_hot = openmc.Universe(name='Instrumentation guide tube, hot water',
universe_id=4)
c30 = openmc.Cell(cell_id=30)
c30.region = -s3
c30.fill = hot_water
c31 = openmc.Cell(cell_id=31)
c31.region = +s3 & -s4
c31.fill = clad
c32 = openmc.Cell(cell_id=32)
c32.region = +s4
c32.fill = hot_water
tube_hot.add_cells((c30, c31, c32))
# Define fuel lattices.
l100 = openmc.RectLattice(name='Fuel assembly (lower half)',
lattice_id=100)
l100.lower_left = (-10.71, -10.71)
l100.pitch = (1.26, 1.26)
l100.universes = [
[fuel_cold]*17,
[fuel_cold]*17,
[fuel_cold]*5 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*5,
[fuel_cold]*3 + [tube_cold] + [fuel_cold]*9 + [tube_cold]
+ [fuel_cold]*3,
[fuel_cold]*17,
[fuel_cold]*2 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*2,
[fuel_cold]*17,
[fuel_cold]*17,
[fuel_cold]*2 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*2,
[fuel_cold]*17,
[fuel_cold]*17,
[fuel_cold]*2 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*2,
[fuel_cold]*17,
[fuel_cold]*3 + [tube_cold] + [fuel_cold]*9 + [tube_cold]
+ [fuel_cold]*3,
[fuel_cold]*5 + [tube_cold] + [fuel_cold]*2 + [tube_cold]
+ [fuel_cold]*2 + [tube_cold] + [fuel_cold]*5,
[fuel_cold]*17,
[fuel_cold]*17 ]
l101 = openmc.RectLattice(name='Fuel assembly (upper half)',
lattice_id=101)
l101.lower_left = (-10.71, -10.71)
l101.pitch = (1.26, 1.26)
l101.universes = [
[fuel_hot]*17,
[fuel_hot]*17,
[fuel_hot]*5 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*5,
[fuel_hot]*3 + [tube_hot] + [fuel_hot]*9 + [tube_hot]
+ [fuel_hot]*3,
[fuel_hot]*17,
[fuel_hot]*2 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*2,
[fuel_hot]*17,
[fuel_hot]*17,
[fuel_hot]*2 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*2,
[fuel_hot]*17,
[fuel_hot]*17,
[fuel_hot]*2 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*2,
[fuel_hot]*17,
[fuel_hot]*3 + [tube_hot] + [fuel_hot]*9 + [tube_hot]
+ [fuel_hot]*3,
[fuel_hot]*5 + [tube_hot] + [fuel_hot]*2 + [tube_hot]
+ [fuel_hot]*2 + [tube_hot] + [fuel_hot]*5,
[fuel_hot]*17,
[fuel_hot]*17 ]
# Define assemblies.
fa_cw = openmc.Universe(name='Water assembly (cold)', universe_id=5)
c50 = openmc.Cell(cell_id=50)
c50.region = +s34 & -s35
c50.fill = cold_water
fa_cw.add_cells((c50, ))
fa_hw = openmc.Universe(name='Water assembly (hot)', universe_id=7)
c70 = openmc.Cell(cell_id=70)
c70.region = +s35 & -s36
c70.fill = hot_water
fa_hw.add_cells((c70, ))
fa_cold = openmc.Universe(name='Fuel assembly (cold)', universe_id=6)
c60 = openmc.Cell(cell_id=60)
c60.region = +s34 & -s35
c60.fill = l100
fa_cold.add_cells((c60, ))
fa_hot = openmc.Universe(name='Fuel assembly (hot)', universe_id=8)
c80 = openmc.Cell(cell_id=80)
c80.region = +s35 & -s36
c80.fill = l101
fa_hot.add_cells((c80, ))
# Define core lattices
l200 = openmc.RectLattice(name='Core lattice (lower half)',
lattice_id=200)
l200.lower_left = (-224.91, -224.91)
l200.pitch = (21.42, 21.42)
l200.universes = [
[fa_cw]*21,
[fa_cw]*21,
[fa_cw]*7 + [fa_cold]*7 + [fa_cw]*7,
[fa_cw]*5 + [fa_cold]*11 + [fa_cw]*5,
[fa_cw]*4 + [fa_cold]*13 + [fa_cw]*4,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3,
[fa_cw]*4 + [fa_cold]*13 + [fa_cw]*4,
[fa_cw]*5 + [fa_cold]*11 + [fa_cw]*5,
[fa_cw]*7 + [fa_cold]*7 + [fa_cw]*7,
[fa_cw]*21,
[fa_cw]*21]
l201 = openmc.RectLattice(name='Core lattice (lower half)',
lattice_id=201)
l201.lower_left = (-224.91, -224.91)
l201.pitch = (21.42, 21.42)
l201.universes = [
[fa_hw]*21,
[fa_hw]*21,
[fa_hw]*7 + [fa_hot]*7 + [fa_hw]*7,
[fa_hw]*5 + [fa_hot]*11 + [fa_hw]*5,
[fa_hw]*4 + [fa_hot]*13 + [fa_hw]*4,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3,
[fa_hw]*4 + [fa_hot]*13 + [fa_hw]*4,
[fa_hw]*5 + [fa_hot]*11 + [fa_hw]*5,
[fa_hw]*7 + [fa_hot]*7 + [fa_hw]*7,
[fa_hw]*21,
[fa_hw]*21]
# Define root universe.
root = openmc.Universe(universe_id=0, name='root universe')
c1 = openmc.Cell(cell_id=1)
c1.region = -s6 & +s34 & -s35
c1.fill = l200
c2 = openmc.Cell(cell_id=2)
c2.region = -s6 & +s35 & -s36
c2.fill = l201
c3 = openmc.Cell(cell_id=3)
c3.region = -s7 & +s31 & -s32
c3.fill = bot_plate
c4 = openmc.Cell(cell_id=4)
c4.region = -s5 & +s32 & -s33
c4.fill = bot_nozzle
c5 = openmc.Cell(cell_id=5)
c5.region = -s5 & +s33 & -s34
c5.fill = bot_fa
c6 = openmc.Cell(cell_id=6)
c6.region = -s5 & +s36 & -s37
c6.fill = top_fa
c7 = openmc.Cell(cell_id=7)
c7.region = -s5 & +s37 & -s38
c7.fill = top_nozzle
c8 = openmc.Cell(cell_id=8)
c8.region = -s7 & +s38 & -s39
c8.fill = upper_rad_ref
c9 = openmc.Cell(cell_id=9)
c9.region = +s6 & -s7 & +s32 & -s38
c9.fill = bot_nozzle
c10 = openmc.Cell(cell_id=10)
c10.region = +s7 & -s8 & +s31 & -s39
c10.fill = rpv_steel
c11 = openmc.Cell(cell_id=11)
c11.region = +s5 & -s6 & +s32 & -s34
c11.fill = lower_rad_ref
c12 = openmc.Cell(cell_id=12)
c12.region = +s5 & -s6 & +s36 & -s38
c12.fill = upper_rad_ref
root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12))
# Assign root universe to geometry
self.geometry.root_universe = root
def build_default_settings(self):
self.settings.batches = 10
self.settings.inactive = 5
self.settings.particles = 100
self.settings.source = Source(space=Box(
[-160, -160, -183], [160, 160, 183]))
def build_defualt_plots(self):
plot = openmc.Plot()
plot.filename = 'mat'
plot.origin = (125, 125, 0)
plot.width = (250, 250)
plot.pixels = (3000, 3000)
plot.color_by = 'material'
self.plots.add_plot(plot)
class PinCellInputSet(object):
def __init__(self):
self.settings = openmc.Settings()
self.materials = openmc.Materials()
self.geometry = openmc.Geometry()
self.tallies = None
self.plots = None
def export(self):
self.settings.export_to_xml()
self.materials.export_to_xml()
self.geometry.export_to_xml()
if self.tallies is not None:
self.tallies.export_to_xml()
if self.plots is not None:
self.plots.export_to_xml()
def build_default_materials_and_geometry(self):
# Define materials.
fuel = openmc.Material(name='Fuel')
fuel.set_density('g/cm3', 10.29769)
fuel.add_nuclide("U234", 4.4843e-6)
fuel.add_nuclide("U235", 5.5815e-4)
fuel.add_nuclide("U238", 2.2408e-2)
fuel.add_nuclide("O16", 4.5829e-2)
clad = openmc.Material(name='Cladding')
clad.set_density('g/cm3', 6.55)
clad.add_nuclide("Zr90", 2.1827e-2)
clad.add_nuclide("Zr91", 4.7600e-3)
clad.add_nuclide("Zr92", 7.2758e-3)
clad.add_nuclide("Zr94", 7.3734e-3)
clad.add_nuclide("Zr96", 1.1879e-3)
hot_water = openmc.Material(name='Hot borated water')
hot_water.set_density('g/cm3', 0.740582)
hot_water.add_nuclide("H1", 4.9457e-2)
hot_water.add_nuclide("O16", 2.4672e-2)
hot_water.add_nuclide("B10", 8.0042e-6)
hot_water.add_nuclide("B11", 3.2218e-5)
hot_water.add_s_alpha_beta('c_H_in_H2O')
# Define the materials file.
self.materials += (fuel, clad, hot_water)
# Instantiate ZCylinder surfaces
fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR')
clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR')
left = openmc.XPlane(x0=-0.63, name='left', boundary_type='reflective')
right = openmc.XPlane(x0=0.63, name='right', boundary_type='reflective')
bottom = openmc.YPlane(y0=-0.63, name='bottom',
boundary_type='reflective')
top = openmc.YPlane(y0=0.63, name='top', boundary_type='reflective')
# Instantiate Cells
fuel_pin = openmc.Cell(name='cell 1', fill=fuel)
cladding = openmc.Cell(name='cell 3', fill=clad)
water = openmc.Cell(name='cell 2', fill=hot_water)
# Use surface half-spaces to define regions
fuel_pin.region = -fuel_or
cladding.region = +fuel_or & -clad_or
water.region = +clad_or & +left & -right & +bottom & -top
# Instantiate Universe
root = openmc.Universe(universe_id=0, name='root universe')
# Register Cells with Universe
root.add_cells([fuel_pin, cladding, water])
# Instantiate a Geometry, register the root Universe, and export to XML
self.geometry.root_universe = root
def build_default_settings(self):
self.settings.batches = 10
self.settings.inactive = 5
self.settings.particles = 100
self.settings.source = Source(space=Box([-0.63, -0.63, -1],
[0.63, 0.63, 1],
only_fissionable=True))
def build_defualt_plots(self):
plot = openmc.Plot()
plot.filename = 'mat'
plot.origin = (0.0, 0.0, 0)
plot.width = (1.26, 1.26)
plot.pixels = (300, 300)
plot.color_by = 'material'
self.plots.add_plot(plot)
class AssemblyInputSet(object):
def __init__(self):
self.settings = openmc.Settings()
self.materials = openmc.Materials()
self.geometry = openmc.Geometry()
self.tallies = None
self.plots = None
def export(self):
self.settings.export_to_xml()
self.materials.export_to_xml()
self.geometry.export_to_xml()
if self.tallies is not None:
self.tallies.export_to_xml()
if self.plots is not None:
self.plots.export_to_xml()
def build_default_materials_and_geometry(self):
# Define materials.
fuel = openmc.Material(name='Fuel')
fuel.set_density('g/cm3', 10.29769)
fuel.add_nuclide("U234", 4.4843e-6)
fuel.add_nuclide("U235", 5.5815e-4)
fuel.add_nuclide("U238", 2.2408e-2)
fuel.add_nuclide("O16", 4.5829e-2)
clad = openmc.Material(name='Cladding')
clad.set_density('g/cm3', 6.55)
clad.add_nuclide("Zr90", 2.1827e-2)
clad.add_nuclide("Zr91", 4.7600e-3)
clad.add_nuclide("Zr92", 7.2758e-3)
clad.add_nuclide("Zr94", 7.3734e-3)
clad.add_nuclide("Zr96", 1.1879e-3)
hot_water = openmc.Material(name='Hot borated water')
hot_water.set_density('g/cm3', 0.740582)
hot_water.add_nuclide("H1", 4.9457e-2)
hot_water.add_nuclide("O16", 2.4672e-2)
hot_water.add_nuclide("B10", 8.0042e-6)
hot_water.add_nuclide("B11", 3.2218e-5)
hot_water.add_s_alpha_beta('c_H_in_H2O')
# Define the materials file.
self.materials += (fuel, clad, hot_water)
# Instantiate ZCylinder surfaces
fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR')
clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR')
# Create boundary planes to surround the geometry
min_x = openmc.XPlane(x0=-10.71, boundary_type='reflective')
max_x = openmc.XPlane(x0=+10.71, boundary_type='reflective')
min_y = openmc.YPlane(y0=-10.71, boundary_type='reflective')
max_y = openmc.YPlane(y0=+10.71, boundary_type='reflective')
# Create a Universe to encapsulate a fuel pin
fuel_pin_universe = openmc.Universe(name='Fuel Pin')
# Create fuel Cell
fuel_cell = openmc.Cell(name='fuel')
fuel_cell.fill = fuel
fuel_cell.region = -fuel_or
fuel_pin_universe.add_cell(fuel_cell)
# Create a clad Cell
clad_cell = openmc.Cell(name='clad')
clad_cell.fill = clad
clad_cell.region = +fuel_or & -clad_or
fuel_pin_universe.add_cell(clad_cell)
# Create a moderator Cell
hot_water_cell = openmc.Cell(name='hot water')
hot_water_cell.fill = hot_water
hot_water_cell.region = +clad_or
fuel_pin_universe.add_cell(hot_water_cell)
# Create a Universe to encapsulate a control rod guide tube
guide_tube_universe = openmc.Universe(name='Guide Tube')
# Create guide tube inner Cell
gt_inner_cell = openmc.Cell(name='guide tube inner water')
gt_inner_cell.fill = hot_water
gt_inner_cell.region = -fuel_or
guide_tube_universe.add_cell(gt_inner_cell)
# Create a clad Cell
gt_clad_cell = openmc.Cell(name='guide tube clad')
gt_clad_cell.fill = clad
gt_clad_cell.region = +fuel_or & -clad_or
guide_tube_universe.add_cell(gt_clad_cell)
# Create a guide tube outer Cell
gt_outer_cell = openmc.Cell(name='guide tube outer water')
gt_outer_cell.fill = hot_water
gt_outer_cell.region = +clad_or
guide_tube_universe.add_cell(gt_outer_cell)
# Create fuel assembly Lattice
assembly = openmc.RectLattice(name='Fuel Assembly')
assembly.pitch = (1.26, 1.26)
assembly.lower_left = [-1.26 * 17. / 2.0] * 2
# Create array indices for guide tube locations in lattice
template_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8,
11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11])
template_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8,
8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14])
# Initialize an empty 17x17 array of the lattice universes
universes = np.empty((17, 17), dtype=openmc.Universe)
# Fill the array with the fuel pin and guide tube universes
universes[:,:] = fuel_pin_universe
universes[template_x, template_y] = guide_tube_universe
# Store the array of universes in the lattice
assembly.universes = universes
# Create root Cell
root_cell = openmc.Cell(name='root cell')
root_cell.fill = assembly
# Add boundary planes
root_cell.region = +min_x & -max_x & +min_y & -max_y
# Create root Universe
root_universe = openmc.Universe(universe_id=0, name='root universe')
root_universe.add_cell(root_cell)
# Instantiate a Geometry, register the root Universe, and export to XML
self.geometry.root_universe = root_universe
def build_default_settings(self):
self.settings.batches = 10
self.settings.inactive = 5
self.settings.particles = 100
self.settings.source = Source(space=Box([-10.71, -10.71, -1],
[10.71, 10.71, 1],
only_fissionable=True))
def build_defualt_plots(self):
plot = openmc.Plot()
plot.filename = 'mat'
plot.origin = (0.0, 0.0, 0)
plot.width = (21.42, 21.42)
plot.pixels = (300, 300)
plot.color_by = 'material'
self.plots.add_plot(plot)
class MGInputSet(InputSet):
def build_default_materials_and_geometry(self, reps=None, as_macro=True):
# Define materials needed for 1D/1G slab problem
mat_names = ['uo2', 'clad', 'lwtr']
mgxs_reps = ['ang', 'ang_mu', 'iso', 'iso_mu']
if reps is None:
reps = mgxs_reps
xs = []
mats = []
i = 0
for mat in mat_names:
for rep in reps:
i += 1
if as_macro:
xs.append(openmc.Macroscopic(mat + '_' + rep))
mats.append(openmc.Material(name=str(i)))
mats[-1].set_density('macro', 1.)
mats[-1].add_macroscopic(xs[-1])
else:
xs.append(openmc.Nuclide(mat + '_' + rep))
mats.append(openmc.Material(name=str(i)))
mats[-1].set_density('atom/b-cm', 1.)
mats[-1].add_nuclide(xs[-1].name, 1.0, 'ao')
# Define the materials file
self.xs_data = xs
self.materials += mats
self.materials.cross_sections = "../1d_mgxs.h5"
# Define surfaces.
# Assembly/Problem Boundary
left = openmc.XPlane(x0=0.0, boundary_type='reflective')
right = openmc.XPlane(x0=10.0, boundary_type='reflective')
bottom = openmc.YPlane(y0=0.0, boundary_type='reflective')
top = openmc.YPlane(y0=10.0, boundary_type='reflective')
# for each material add a plane
planes = [openmc.ZPlane(z0=0.0, boundary_type='reflective')]
dz = round(5. / float(len(mats)), 4)
for i in range(len(mats) - 1):
planes.append(openmc.ZPlane(z0=dz * float(i + 1)))
planes.append(openmc.ZPlane(z0=5.0, boundary_type='reflective'))
# Define cells for each material
cells = []
xy = +left & -right & +bottom & -top
for i, mat in enumerate(mats):
cells.append(openmc.Cell())
cells[-1].region = xy & +planes[i] & -planes[i + 1]
cells[-1].fill = mat
# Define root universe.
root = openmc.Universe(universe_id=0, name='root universe')
root.add_cells(cells)
# Assign root universe to geometry
self.geometry.root_universe = root
def build_default_settings(self):
self.settings.batches = 10
self.settings.inactive = 5
self.settings.particles = 100
self.settings.source = Source(space=Box([0.0, 0.0, 0.0],
[10.0, 10.0, 5.]))
self.settings.energy_mode = "multi-group"
def build_defualt_plots(self):
plot = openmc.Plot()
plot.filename = 'mat'
plot.origin = (5.0, 5.0, 2.5)
plot.width = (2.5, 2.5)
plot.basis = 'xz'
plot.pixels = (3000, 3000)
plot.color_by = 'material'
self.plots.add_plot(plot)

View file

@ -56,7 +56,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -105,7 +105,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -157,7 +157,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />

View file

@ -10,15 +10,11 @@ import openmc
class AsymmetricLatticeTestHarness(PyAPITestHarness):
def _build_inputs(self):
"""Build an axis-asymmetric lattice of fuel assemblies"""
# Build full core geometry from underlying input set
self._input_set.build_default_materials_and_geometry()
def __init__(self, *args, **kwargs):
super(AsymmetricLatticeTestHarness, self).__init__(*args, **kwargs)
# Extract universes encapsulating fuel and water assemblies
geometry = self._input_set.geometry
geometry = self._model.geometry
water = geometry.get_universes_by_name('water assembly (hot)')[0]
fuel = geometry.get_universes_by_name('fuel assembly (hot)')[0]
@ -46,7 +42,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
root_univ.add_cell(root_cell)
# Over-ride geometry in the input set with this 3x3 lattice
self._input_set.geometry.root_universe = root_univ
self._model.geometry.root_universe = root_univ
# Initialize a "distribcell" filter for the fuel pin cell
distrib_filter = openmc.DistribcellFilter(27)
@ -56,22 +52,12 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
tally.filters.append(distrib_filter)
tally.scores.append('nu-fission')
# Initialize the tallies file
tallies_file = openmc.Tallies([tally])
# Assign the tallies file to the input set
self._input_set.tallies = tallies_file
# Build default settings
self._input_set.build_default_settings()
self._model.tallies.append(tally)
# Specify summary output and correct source sampling box
source = openmc.Source(space=openmc.stats.Box([-32, -32, 0], [32, 32, 32]))
source.space.only_fissionable = True
self._input_set.settings.source = source
# Write input XML files
self._input_set.export()
self._model.settings.source = openmc.Source(space=openmc.stats.Box(
[-32, -32, 0], [32, 32, 32], only_fissionable = True))
def _get_results(self, hash_output=True):
"""Digest info in statepoint and summary and return as a string."""
@ -105,5 +91,5 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = AsymmetricLatticeTestHarness('statepoint.10.h5', True)
harness = AsymmetricLatticeTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import CMFDTestHarness
if __name__ == '__main__':
harness = CMFDTestHarness('statepoint.20.*', True)
harness = CMFDTestHarness('statepoint.20.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import CMFDTestHarness
if __name__ == '__main__':
harness = CMFDTestHarness('statepoint.20.*', True)
harness = CMFDTestHarness('statepoint.20.h5')
harness.main()

View file

@ -6,5 +6,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*', True)
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*', True)
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -70,5 +70,5 @@ class CreateFissionNeutronsTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = CreateFissionNeutronsTestHarness('statepoint.10.h5', True)
harness = CreateFissionNeutronsTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />

View file

@ -11,19 +11,16 @@ from testing_harness import PyAPITestHarness
import openmc
class DiffTallyTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Build default materials/geometry
self._input_set.build_default_materials_and_geometry()
def __init__(self, *args, **kwargs):
super(DiffTallyTestHarness, self).__init__(*args, **kwargs)
# Set settings explicitly
self._input_set.settings.batches = 3
self._input_set.settings.inactive = 0
self._input_set.settings.particles = 100
self._input_set.settings.source = openmc.Source(space=openmc.stats.Box(
self._model.settings.batches = 3
self._model.settings.inactive = 0
self._model.settings.particles = 100
self._model.settings.source = openmc.Source(space=openmc.stats.Box(
[-160, -160, -183], [160, 160, 183]))
self._input_set.settings.temperature['multipole'] = True
self._input_set.tallies = openmc.Tallies()
self._model.settings.temperature['multipole'] = True
filt_mats = openmc.MaterialFilter((1, 3))
filt_eout = openmc.EnergyoutFilter((0.0, 0.625, 20.0e6))
@ -64,7 +61,7 @@ class DiffTallyTestHarness(PyAPITestHarness):
t.add_score('flux')
t.add_filter(filt_mats)
t.derivative = derivs[i]
self._input_set.tallies.append(t)
self._model.tallies.append(t)
# Cover supported scores with a collision estimator.
for i in range(5):
@ -78,7 +75,7 @@ class DiffTallyTestHarness(PyAPITestHarness):
t.add_nuclide('total')
t.add_nuclide('U235')
t.derivative = derivs[i]
self._input_set.tallies.append(t)
self._model.tallies.append(t)
# Cover an analog estimator.
for i in range(5):
@ -87,7 +84,7 @@ class DiffTallyTestHarness(PyAPITestHarness):
t.add_filter(filt_mats)
t.estimator = 'analog'
t.derivative = derivs[i]
self._input_set.tallies.append(t)
self._model.tallies.append(t)
# Energyout filter and total nuclide for the density derivatives.
for i in range(2):
@ -99,7 +96,7 @@ class DiffTallyTestHarness(PyAPITestHarness):
t.add_nuclide('total')
t.add_nuclide('U235')
t.derivative = derivs[i]
self._input_set.tallies.append(t)
self._model.tallies.append(t)
# Energyout filter without total nuclide for other derivatives.
for i in range(2, 5):
@ -110,9 +107,7 @@ class DiffTallyTestHarness(PyAPITestHarness):
t.add_filter(filt_eout)
t.add_nuclide('U235')
t.derivative = derivs[i]
self._input_set.tallies.append(t)
self._input_set.export()
self._model.tallies.append(t)
def _get_results(self):
# Read the statepoint and summary files.
@ -131,5 +126,5 @@ class DiffTallyTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = DiffTallyTestHarness('statepoint.3.h5', True)
harness = DiffTallyTestHarness('statepoint.3.h5')
harness.main()

View file

@ -46,9 +46,6 @@
<parameters>-1 -1 -1 1 1 1</parameters>
</space>
</source>
<output>
<summary>true</summary>
</output>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<plots>

View file

@ -5,8 +5,6 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness, PyAPITestHarness
import openmc
from openmc.stats import Box
from openmc.source import Source
class DistribmatTestHarness(PyAPITestHarness):
@ -31,25 +29,18 @@ class DistribmatTestHarness(PyAPITestHarness):
mats_file = openmc.Materials([moderator, dense_fuel, light_fuel])
mats_file.export_to_xml()
####################
# Geometry
####################
c1 = openmc.Cell(cell_id=1)
c1.fill = moderator
mod_univ = openmc.Universe(universe_id=1)
mod_univ.add_cell(c1)
c1 = openmc.Cell(cell_id=1, fill=moderator)
mod_univ = openmc.Universe(universe_id=1, cells=[c1])
r0 = openmc.ZCylinder(R=0.3)
c11 = openmc.Cell(cell_id=11)
c11.region = -r0
c11 = openmc.Cell(cell_id=11, region=-r0)
c11.fill = [dense_fuel, light_fuel, None, dense_fuel]
c12 = openmc.Cell(cell_id=12)
c12.region = +r0
c12.fill = moderator
fuel_univ = openmc.Universe(universe_id=11)
fuel_univ.add_cells((c11, c12))
c12 = openmc.Cell(cell_id=12, region=+r0, fill=moderator)
fuel_univ = openmc.Universe(universe_id=11, cells=[c11, c12])
lat = openmc.RectLattice(lattice_id=101)
lat.lower_left = [-2.0, -2.0]
@ -63,17 +54,13 @@ class DistribmatTestHarness(PyAPITestHarness):
y1 = openmc.YPlane(y0=3.0)
for s in [x0, x1, y0, y1]:
s.boundary_type = 'reflective'
c101 = openmc.Cell(cell_id=101)
c101 = openmc.Cell(cell_id=101, fill=lat)
c101.region = +x0 & -x1 & +y0 & -y1
c101.fill = lat
root_univ = openmc.Universe(universe_id=0)
root_univ.add_cell(c101)
root_univ = openmc.Universe(universe_id=0, cells=[c101])
geometry = openmc.Geometry()
geometry.root_universe = root_univ
geometry = openmc.Geometry(root_univ)
geometry.export_to_xml()
####################
# Settings
####################
@ -82,36 +69,32 @@ class DistribmatTestHarness(PyAPITestHarness):
sets_file.batches = 5
sets_file.inactive = 0
sets_file.particles = 1000
sets_file.source = Source(space=Box([-1, -1, -1], [1, 1, 1]))
sets_file.output = {'summary': True}
sets_file.source = openmc.Source(space=openmc.stats.Box(
[-1, -1, -1], [1, 1, 1]))
sets_file.export_to_xml()
####################
# Plots
####################
plots_file = openmc.Plots()
plot1 = openmc.Plot(plot_id=1)
plot1.basis = 'xy'
plot1.color_by = 'cell'
plot1.filename = 'cellplot'
plot1.origin = (0, 0, 0)
plot1.width = (7, 7)
plot1.pixels = (400, 400)
plot = openmc.Plot(plot_id=1)
plot.basis = 'xy'
plot.color_by = 'cell'
plot.filename = 'cellplot'
plot.origin = (0, 0, 0)
plot.width = (7, 7)
plot.pixels = (400, 400)
plots_file.add_plot(plot)
plot2 = openmc.Plot(plot_id=2)
plot2.basis = 'xy'
plot2.color_by = 'material'
plot2.filename = 'matplot'
plot2.origin = (0, 0, 0)
plot2.width = (7, 7)
plot2.pixels = (400, 400)
plot = openmc.Plot(plot_id=2)
plot.basis = 'xy'
plot.color_by = 'material'
plot.filename = 'matplot'
plot.origin = (0, 0, 0)
plot.width = (7, 7)
plot.pixels = (400, 400)
plots_file.add_plot(plot)
plots_file.export_to_xml()
plots = openmc.Plots([plot1, plot2])
plots.export_to_xml()
def _get_results(self):
outstr = super(DistribmatTestHarness, self)._get_results()
@ -119,12 +102,6 @@ class DistribmatTestHarness(PyAPITestHarness):
outstr += str(su.geometry.get_all_cells()[11])
return outstr
def _cleanup(self):
f = os.path.join(os.getcwd(), 'plots.xml')
if os.path.exists(f):
os.remove(f)
super(DistribmatTestHarness, self)._cleanup()
if __name__ == '__main__':
harness = DistribmatTestHarness('statepoint.5.h5')

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.7.*')
harness = TestHarness('statepoint.7.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -74,5 +74,5 @@ class EnergyCutoffTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = EnergyCutoffTestHarness('statepoint.10.h5', True)
harness = EnergyCutoffTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -26,5 +26,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -5,7 +5,7 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
from openmc.statepoint import StatePoint
from openmc import StatePoint
class EntropyTestHarness(TestHarness):
@ -13,21 +13,19 @@ class EntropyTestHarness(TestHarness):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = StatePoint(statepoint)
with StatePoint(statepoint) as sp:
# Write out k-combined.
outstr = 'k-combined:\n'
outstr += '{0:12.6E} {1:12.6E}\n'.format(*sp.k_combined)
# Write out k-combined.
outstr = 'k-combined:\n'
form = '{0:12.6E} {1:12.6E}\n'
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
# Write out entropy data.
outstr += 'entropy:\n'
results = ['{0:12.6E}'.format(x) for x in sp.entropy]
outstr += '\n'.join(results) + '\n'
# Write out entropy data.
outstr += 'entropy:\n'
results = ['{0:12.6E}'.format(x) for x in sp.entropy]
outstr += '\n'.join(results) + '\n'
return outstr
if __name__ == '__main__':
harness = EntropyTestHarness('statepoint.10.*')
harness = EntropyTestHarness('statepoint.10.h5')
harness.main()

View file

@ -10,7 +10,7 @@ from testing_harness import *
class DistribcellTestHarness(TestHarness):
def __init__(self):
super(DistribcellTestHarness, self).__init__(None, True)
super(DistribcellTestHarness, self).__init__(None)
def execute_test(self):
"""Run OpenMC with the appropriate arguments and check the outputs."""
@ -41,8 +41,8 @@ class DistribcellTestHarness(TestHarness):
base_dir = os.getcwd()
try:
dirs = ('case-1', '../case-2', '../case-3', '../case-4')
sps = ('statepoint.1.*', 'statepoint.1.*', 'statepoint.3.*',
'statepoint.1.*')
sps = ('statepoint.1.h5', 'statepoint.1.h5', 'statepoint.3.h5',
'statepoint.1.h5')
tallies_out_present = (True, True, False, True)
hash_out = (False, False, True, False)
for i in range(len(dirs)):

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -250,7 +250,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />

View file

@ -3,20 +3,17 @@
import os
import sys
import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
import openmc
class FilterEnergyFunHarness(PyAPITestHarness):
def _build_inputs(self):
# Build the default material, geometry, settings inputs.
self._input_set.build_default_materials_and_geometry()
self._input_set.build_default_settings()
def __init__(self, *args, **kwargs):
super(FilterEnergyFunHarness, self).__init__(*args, **kwargs)
# Add Am241 to the fuel.
self._input_set.materials[1].add_nuclide('Am241', 1e-7)
self._model.materials[1].add_nuclide('Am241', 1e-7)
# Define Am242m / Am242 branching ratio from ENDF/B-VII.1 data.
x = [1e-5, 3.69e-1, 1e3, 1e5, 6e5, 1e6, 2e6, 4e6, 3e7]
@ -37,10 +34,7 @@ class FilterEnergyFunHarness(PyAPITestHarness):
t.scores = ['(n,gamma)']
t.nuclides = ['Am241']
tallies[1].filters = [filt1]
self._input_set.tallies = openmc.Tallies(tallies)
# Export inputs to xml.
self._input_set.export()
self._model.tallies = tallies
def _get_results(self):
# Read the statepoint file.
@ -55,5 +49,5 @@ class FilterEnergyFunHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = FilterEnergyFunHarness('statepoint.10.h5', True)
harness = FilterEnergyFunHarness('statepoint.10.h5')
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />
@ -306,9 +306,6 @@
<parameters>-160 -160 -183 160 160 183</parameters>
</space>
</source>
<output>
<summary>true</summary>
</output>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>

View file

@ -2,21 +2,14 @@
import os
import sys
import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import HashedPyAPITestHarness
import openmc
class FilterMeshTestHarness(HashedPyAPITestHarness):
def _build_inputs(self):
# The summary.h5 file needs to be created to read in the tallies
self._input_set.settings.output = {'summary': True}
# Initialize the tallies file
tallies_file = openmc.Tallies()
def __init__(self, *args, **kwargs):
super(FilterMeshTestHarness, self).__init__(*args, **kwargs)
# Initialize Meshes
mesh_1d = openmc.Mesh(mesh_id=1)
@ -38,46 +31,42 @@ class FilterMeshTestHarness(HashedPyAPITestHarness):
mesh_3d.upper_right = [182.07, 182.07, 183.00]
# Initialize the filters
mesh_1d_filter = openmc.MeshFilter(mesh_1d)
mesh_2d_filter = openmc.MeshFilter(mesh_2d)
mesh_3d_filter = openmc.MeshFilter(mesh_3d)
mesh_1d_filter = openmc.MeshFilter(mesh_1d)
mesh_2d_filter = openmc.MeshFilter(mesh_2d)
mesh_3d_filter = openmc.MeshFilter(mesh_3d)
# Initialized the tallies
tally = openmc.Tally(name='tally 1')
tally.filters = [mesh_1d_filter]
tally.scores = ['total']
tallies_file.append(tally)
self._model.tallies.append(tally)
tally = openmc.Tally(name='tally 2')
tally.filters = [mesh_1d_filter]
tally.scores = ['current']
tallies_file.append(tally)
self._model.tallies.append(tally)
tally = openmc.Tally(name='tally 3')
tally.filters = [mesh_2d_filter]
tally.scores = ['total']
tallies_file.append(tally)
self._model.tallies.append(tally)
tally = openmc.Tally(name='tally 4')
tally.filters = [mesh_2d_filter]
tally.scores = ['current']
tallies_file.append(tally)
self._model.tallies.append(tally)
tally = openmc.Tally(name='tally 5')
tally.filters = [mesh_3d_filter]
tally.scores = ['total']
tallies_file.append(tally)
self._model.tallies.append(tally)
tally = openmc.Tally(name='tally 6')
tally.filters = [mesh_3d_filter]
tally.scores = ['current']
tallies_file.append(tally)
# Export tallies to file
self._input_set.tallies = tallies_file
super(FilterMeshTestHarness, self)._build_inputs()
self._model.tallies.append(tally)
if __name__ == '__main__':
harness = FilterMeshTestHarness('statepoint.10.h5', True)
harness = FilterMeshTestHarness('statepoint.10.h5')
harness.main()

View file

@ -6,7 +6,7 @@ import sys
import numpy as np
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
from openmc.statepoint import StatePoint
from openmc import StatePoint
class FixedSourceTestHarness(TestHarness):
@ -14,31 +14,27 @@ class FixedSourceTestHarness(TestHarness):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = StatePoint(statepoint)
# Write out tally data.
outstr = ''
if self._tallies:
tally_num = 1
for tally_ind in sp.tallies:
with StatePoint(statepoint) as sp:
# Write out tally data.
for i, tally_ind in enumerate(sp.tallies):
tally = sp.tallies[tally_ind]
results = np.zeros((tally.sum.size*2, ))
results[0::2] = tally.sum.ravel()
results[1::2] = tally.sum_sq.ravel()
results = ['{0:12.6E}'.format(x) for x in results]
outstr += 'tally ' + str(tally_num) + ':\n'
outstr += 'tally ' + str(i + 1) + ':\n'
outstr += '\n'.join(results) + '\n'
tally_num += 1
gt = sp.global_tallies
outstr += 'leakage:\n'
outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum']) + '\n'
outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum_sq']) + '\n'
gt = sp.global_tallies
outstr += 'leakage:\n'
outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum']) + '\n'
outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum_sq']) + '\n'
return outstr
if __name__ == '__main__':
harness = FixedSourceTestHarness('statepoint.10.*', True)
harness = FixedSourceTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" scattering="iso-in-lab" />
<nuclide ao="0.00048218" name="U235" scattering="iso-in-lab" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" scattering="iso-in-lab" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" scattering="iso-in-lab" />
<nuclide ao="0.1122" name="Zr91" scattering="iso-in-lab" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" scattering="iso-in-lab" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" scattering="iso-in-lab" wo="0.0086117" />
<nuclide name="O16" scattering="iso-in-lab" wo="0.0683369" />

View file

@ -2,25 +2,12 @@
import os
import sys
import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
import openmc
import openmc.mgxs
class IsoInLabTestHarness(PyAPITestHarness):
def _build_inputs(self):
"""Write input XML files with iso-in-lab scattering."""
self._input_set.build_default_materials_and_geometry()
self._input_set.build_default_settings()
self._input_set.materials.make_isotropic_in_lab()
self._input_set.export()
if __name__ == '__main__':
harness = IsoInLabTestHarness('statepoint.10.*')
# Force iso-in-lab scattering.
harness = PyAPITestHarness('statepoint.10.h5')
harness._model.materials.make_isotropic_in_lab()
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -1,17 +1,17 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="0" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="0" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="0" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="0" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="0" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="0" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="0" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="0" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="0" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="0" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="0" />
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="10000" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="10000" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="10000" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="10000" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="10000" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="10000" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="10000" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="10000" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="10000" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="10000" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="10000" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="10000" />
<surface boundary="reflective" coeffs="0.0" id="10000" type="x-plane" />
<surface boundary="reflective" coeffs="10.0" id="10001" type="x-plane" />
<surface boundary="reflective" coeffs="0.0" id="10002" type="y-plane" />

View file

@ -3,15 +3,11 @@
import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness, PyAPITestHarness
import openmc
class MGBasicTestHarness(PyAPITestHarness):
def _build_inputs(self):
super(MGBasicTestHarness, self)._build_inputs()
from testing_harness import PyAPITestHarness
from openmc.examples import slab_mg
if __name__ == '__main__':
harness = MGBasicTestHarness('statepoint.10.*', False, mg=True)
model = slab_mg()
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -206,5 +206,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.*', False)
harness = MGXSTestHarness('statepoint.10.h5')
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="0" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="0" />
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="10000" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="10000" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="10000" />
<surface boundary="reflective" coeffs="0.0" id="10000" type="x-plane" />
<surface boundary="reflective" coeffs="10.0" id="10001" type="x-plane" />
<surface boundary="reflective" coeffs="0.0" id="10002" type="y-plane" />

View file

@ -5,24 +5,12 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import MGInputSet
class MGMaxOrderTestHarness(PyAPITestHarness):
def __init__(self, statepoint_name, tallies_present, mg=False):
PyAPITestHarness.__init__(self, statepoint_name, tallies_present)
self._input_set = MGInputSet()
def _build_inputs(self):
"""Write input XML files."""
reps = ['iso']
self._input_set.build_default_materials_and_geometry(reps=reps)
self._input_set.build_default_settings()
# Enforce Legendre scattering
self._input_set.settings.tabular_legendre = {'enable': False}
self._input_set.export()
from openmc.examples import slab_mg
if __name__ == '__main__':
harness = MGMaxOrderTestHarness('statepoint.10.*', False, mg=True)
model = slab_mg(reps=['iso'])
model.settings.tabular_legendre = {'enable': False}
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="0" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="0" />
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="10000" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="10000" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="10000" />
<surface boundary="reflective" coeffs="0.0" id="10000" type="x-plane" />
<surface boundary="reflective" coeffs="10.0" id="10001" type="x-plane" />
<surface boundary="reflective" coeffs="0.0" id="10002" type="y-plane" />

View file

@ -5,24 +5,11 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import MGInputSet
class MGMaxOrderTestHarness(PyAPITestHarness):
def __init__(self, statepoint_name, tallies_present, mg=False):
PyAPITestHarness.__init__(self, statepoint_name, tallies_present)
self._input_set = MGInputSet()
def _build_inputs(self):
"""Write input XML files."""
reps = ['iso']
self._input_set.build_default_materials_and_geometry(reps=reps)
self._input_set.build_default_settings()
# Set P1 scattering
self._input_set.settings.max_order = 1
self._input_set.export()
from openmc.examples import slab_mg
if __name__ == '__main__':
harness = MGMaxOrderTestHarness('statepoint.10.*', False, mg=True)
model = slab_mg(reps=['iso'])
model.settings.max_order = 1
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,17 +1,17 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="0" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="0" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="0" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="0" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="0" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="0" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="0" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="0" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="0" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="0" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="0" />
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="10000" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="10000" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="10000" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="10000" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="10000" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="10000" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="10000" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="10000" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="10000" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="10000" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="10000" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="10000" />
<surface boundary="reflective" coeffs="0.0" id="10000" type="x-plane" />
<surface boundary="reflective" coeffs="10.0" id="10001" type="x-plane" />
<surface boundary="reflective" coeffs="0.0" id="10002" type="y-plane" />

View file

@ -5,21 +5,10 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import MGInputSet
class MGNuclideTestHarness(PyAPITestHarness):
def __init__(self, statepoint_name, tallies_present, mg=False):
PyAPITestHarness.__init__(self, statepoint_name, tallies_present)
self._input_set = MGInputSet()
def _build_inputs(self):
"""Write input XML files."""
self._input_set.build_default_materials_and_geometry(as_macro=False)
self._input_set.build_default_settings()
self._input_set.export()
from openmc.examples import slab_mg
if __name__ == '__main__':
harness = MGNuclideTestHarness('statepoint.10.*', False, mg=True)
model = slab_mg(as_macro=False)
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,17 +1,17 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="0" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="0" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="0" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="0" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="0" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="0" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="0" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="0" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="0" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="0" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="0" />
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="10000" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="10000" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="10000" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="10000" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="10000" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="10000" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="10000" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="10000" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="10000" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="10000" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="10000" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="10000" />
<surface boundary="reflective" coeffs="0.0" id="10000" type="x-plane" />
<surface boundary="reflective" coeffs="10.0" id="10001" type="x-plane" />
<surface boundary="reflective" coeffs="0.0" id="10002" type="y-plane" />

View file

@ -3,19 +3,12 @@
import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness, PyAPITestHarness
import openmc
class MGBasicTestHarness(PyAPITestHarness):
def _build_inputs(self):
"""Write input XML files."""
self._input_set.build_default_materials_and_geometry()
self._input_set.build_default_settings()
self._input_set.settings.survival_biasing = True
self._input_set.export()
from testing_harness import PyAPITestHarness
from openmc.examples import slab_mg
if __name__ == '__main__':
harness = MGBasicTestHarness('statepoint.10.h5', False, mg=True)
model = slab_mg()
model.settings.survival_biasing = True
harness = PyAPITestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,17 +1,17 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="0" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="0" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="0" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="0" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="0" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="0" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="0" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="0" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="0" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="0" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="0" />
<cell id="10000" material="10000" region="10000 -10001 10002 -10003 10004 -10005" universe="10000" />
<cell id="10001" material="10001" region="10000 -10001 10002 -10003 10005 -10006" universe="10000" />
<cell id="10002" material="10002" region="10000 -10001 10002 -10003 10006 -10007" universe="10000" />
<cell id="10003" material="10003" region="10000 -10001 10002 -10003 10007 -10008" universe="10000" />
<cell id="10004" material="10004" region="10000 -10001 10002 -10003 10008 -10009" universe="10000" />
<cell id="10005" material="10005" region="10000 -10001 10002 -10003 10009 -10010" universe="10000" />
<cell id="10006" material="10006" region="10000 -10001 10002 -10003 10010 -10011" universe="10000" />
<cell id="10007" material="10007" region="10000 -10001 10002 -10003 10011 -10012" universe="10000" />
<cell id="10008" material="10008" region="10000 -10001 10002 -10003 10012 -10013" universe="10000" />
<cell id="10009" material="10009" region="10000 -10001 10002 -10003 10013 -10014" universe="10000" />
<cell id="10010" material="10010" region="10000 -10001 10002 -10003 10014 -10015" universe="10000" />
<cell id="10011" material="10011" region="10000 -10001 10002 -10003 10015 -10016" universe="10000" />
<surface boundary="reflective" coeffs="0.0" id="10000" type="x-plane" />
<surface boundary="reflective" coeffs="10.0" id="10001" type="x-plane" />
<surface boundary="reflective" coeffs="0.0" id="10002" type="y-plane" />

View file

@ -5,100 +5,92 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import HashedPyAPITestHarness
import openmc
class MGTalliesTestHarness(HashedPyAPITestHarness):
def _build_inputs(self):
"""Write input XML files."""
self._input_set.build_default_materials_and_geometry(as_macro=False)
self._input_set.build_default_settings()
# Instantiate a tally mesh
mesh = openmc.Mesh(mesh_id=1)
mesh.type = 'regular'
mesh.dimension = [1, 1, 10]
mesh.lower_left = [0.0, 0.0, 0.0]
mesh.upper_right = [10, 10, 5]
# Instantiate some tally filters
energy_filter = openmc.EnergyFilter([0.0, 20.0e6])
energyout_filter = openmc.EnergyoutFilter([0.0, 20.0e6])
matching_energy_filter = openmc.EnergyFilter([1e-5, 0.0635, 10.0,
1.0e2, 1.0e3, 0.5e6,
1.0e6, 20.0e6])
matching_eout_filter = openmc.EnergyoutFilter([1e-5, 0.0635, 10.0,
1.0e2, 1.0e3, 0.5e6,
1.0e6, 20.0e6])
mesh_filter = openmc.MeshFilter(mesh)
mat_ids = [mat.id for mat in self._input_set.materials]
mat_filter = openmc.MaterialFilter(mat_ids)
nuclides = [xs.name for xs in self._input_set.xs_data]
scores= {False: ['total', 'absorption', 'flux', 'fission', 'nu-fission'],
True: ['total', 'absorption', 'fission', 'nu-fission']}
tallies = []
for do_nuclides in [False, True]:
tallies.append(openmc.Tally())
tallies[-1].filters = [mesh_filter]
tallies[-1].estimator = 'analog'
tallies[-1].scores = scores[do_nuclides]
if do_nuclides:
tallies[-1].nuclides = nuclides
tallies.append(openmc.Tally())
tallies[-1].filters = [mesh_filter]
tallies[-1].estimator = 'tracklength'
tallies[-1].scores = scores[do_nuclides]
if do_nuclides:
tallies[-1].nuclides = nuclides
# Impose energy bins that dont match the MG structure and those
# that do
for match_energy_bins in [False, True]:
if match_energy_bins:
e_filter = matching_energy_filter
eout_filter = matching_eout_filter
else:
e_filter = energy_filter
eout_filter = energyout_filter
tallies.append(openmc.Tally())
tallies[-1].filters = [mat_filter, e_filter]
tallies[-1].estimator = 'analog'
tallies[-1].scores = scores[do_nuclides] + ['scatter',
'nu-scatter']
if do_nuclides:
tallies[-1].nuclides = nuclides
tallies.append(openmc.Tally())
tallies[-1].filters = [mat_filter, e_filter]
tallies[-1].estimator = 'collision'
tallies[-1].scores = scores[do_nuclides]
if do_nuclides:
tallies[-1].nuclides = nuclides
tallies.append(openmc.Tally())
tallies[-1].filters = [mat_filter, e_filter]
tallies[-1].estimator = 'tracklength'
tallies[-1].scores = scores[do_nuclides]
if do_nuclides:
tallies[-1].nuclides = nuclides
tallies.append(openmc.Tally())
tallies[-1].filters = [mat_filter, e_filter, eout_filter]
tallies[-1].scores = ['scatter', 'nu-scatter', 'nu-fission']
if do_nuclides:
tallies[-1].nuclides = nuclides
self._input_set.tallies = openmc.Tallies(tallies)
self._input_set.export()
from openmc.examples import slab_mg
if __name__ == '__main__':
harness = MGTalliesTestHarness('statepoint.10.h5', True, mg=True)
model = slab_mg(as_macro=False)
# Instantiate a tally mesh
mesh = openmc.Mesh(mesh_id=1)
mesh.type = 'regular'
mesh.dimension = [1, 1, 10]
mesh.lower_left = [0.0, 0.0, 0.0]
mesh.upper_right = [10, 10, 5]
# Instantiate some tally filters
energy_filter = openmc.EnergyFilter([0.0, 20.0e6])
energyout_filter = openmc.EnergyoutFilter([0.0, 20.0e6])
energies = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6]
matching_energy_filter = openmc.EnergyFilter(energies)
matching_eout_filter = openmc.EnergyoutFilter(energies)
mesh_filter = openmc.MeshFilter(mesh)
mat_ids = [mat.id for mat in model.materials]
mat_filter = openmc.MaterialFilter(mat_ids)
nuclides = [xs.name for xs in model.xs_data]
scores= {False: ['total', 'absorption', 'flux', 'fission', 'nu-fission'],
True: ['total', 'absorption', 'fission', 'nu-fission']}
for do_nuclides in [False, True]:
t = openmc.Tally()
t.filters = [mesh_filter]
t.estimator = 'analog'
t.scores = scores[do_nuclides]
if do_nuclides:
t.nuclides = nuclides
model.tallies.append(t)
t = openmc.Tally()
t.filters = [mesh_filter]
t.estimator = 'tracklength'
t.scores = scores[do_nuclides]
if do_nuclides:
t.nuclides = nuclides
model.tallies.append(t)
# Impose energy bins that dont match the MG structure and those
# that do
for match_energy_bins in [False, True]:
if match_energy_bins:
e_filter = matching_energy_filter
eout_filter = matching_eout_filter
else:
e_filter = energy_filter
eout_filter = energyout_filter
t = openmc.Tally()
t.filters = [mat_filter, e_filter]
t.estimator = 'analog'
t.scores = scores[do_nuclides] + ['scatter', 'nu-scatter']
if do_nuclides:
t.nuclides = nuclides
model.tallies.append(t)
t = openmc.Tally()
t.filters = [mat_filter, e_filter]
t.estimator = 'collision'
t.scores = scores[do_nuclides]
if do_nuclides:
t.nuclides = nuclides
model.tallies.append(t)
t = openmc.Tally()
t.filters = [mat_filter, e_filter]
t.estimator = 'tracklength'
t.scores = scores[do_nuclides]
if do_nuclides:
t.nuclides = nuclides
model.tallies.append(t)
t = openmc.Tally()
t.filters = [mat_filter, e_filter, eout_filter]
t.scores = ['scatter', 'nu-scatter', 'nu-fission']
if do_nuclides:
t.nuclides = nuclides
model.tallies.append(t)
harness = HashedPyAPITestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" name="cell 1" region="-10000" universe="0" />
<cell id="10001" material="10001" name="cell 3" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="cell 2" region="10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10000" material="10000" name="Fuel" region="-10000" universe="0" />
<cell id="10001" material="10001" name="Cladding" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="Water" region="10001 10002 -10003 10004 -10005" universe="0" />
<surface coeffs="0 0 0.39218" id="10000" name="Fuel OR" type="z-cylinder" />
<surface coeffs="0 0 0.4572" id="10001" name="Clad OR" type="z-cylinder" />
<surface boundary="reflective" coeffs="-0.63" id="10002" name="left" type="x-plane" />
@ -12,14 +12,14 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="10000" name="Fuel">
<material id="10000" name="UO2 (2.4%)">
<density units="g/cm3" value="10.29769" />
<nuclide ao="4.4843e-06" name="U234" />
<nuclide ao="0.00055815" name="U235" />
<nuclide ao="0.022408" name="U238" />
<nuclide ao="0.045829" name="O16" />
</material>
<material id="10001" name="Cladding">
<material id="10001" name="Zircaloy">
<density units="g/cm3" value="6.55" />
<nuclide ao="0.021827" name="Zr90" />
<nuclide ao="0.00476" name="Zr91" />

View file

@ -3,27 +3,23 @@
import os
import sys
import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import PinCellInputSet
import openmc
import openmc.mgxs
from openmc.examples import pwr_pin_cell
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Set the input set to use the pincell model
self._input_set = PinCellInputSet()
def __init__(self, *args, **kwargs):
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a two-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = False
self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix',
'nu-scatter matrix', 'multiplicity matrix']
@ -34,9 +30,7 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
def _run_openmc(self):
# Initial run
@ -55,18 +49,18 @@ class MGXSTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
self.mgxs_lib.load_from_statepoint(sp)
self._input_set.mgxs_file, self._input_set.materials, \
self._input_set.geometry = self.mgxs_lib.create_mg_mode()
self._model.mgxs_file, self._model.materials, \
self._model.geometry = self.mgxs_lib.create_mg_mode()
# Modify materials and settings so we can run in MG mode
self._input_set.materials.cross_sections = './mgxs.h5'
self._input_set.settings.energy_mode = 'multi-group'
self._model.materials.cross_sections = './mgxs.h5'
self._model.settings.energy_mode = 'multi-group'
# Write modified input files
self._input_set.settings.export_to_xml()
self._input_set.geometry.export_to_xml()
self._input_set.materials.export_to_xml()
self._input_set.mgxs_file.export_to_hdf5()
self._model.settings.export_to_xml()
self._model.geometry.export_to_xml()
self._model.materials.export_to_xml()
self._model.mgxs_file.export_to_hdf5()
# Dont need tallies.xml, so remove the file
if os.path.exists('./tallies.xml'):
os.remove('./tallies.xml')
@ -92,5 +86,8 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.*', False)
# Set the input set to use the pincell model
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" name="cell 1" region="-10000" universe="0" />
<cell id="10001" material="10001" name="cell 3" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="cell 2" region="10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10000" material="10000" name="Fuel" region="-10000" universe="0" />
<cell id="10001" material="10001" name="Cladding" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="Water" region="10001 10002 -10003 10004 -10005" universe="0" />
<surface coeffs="0 0 0.39218" id="10000" name="Fuel OR" type="z-cylinder" />
<surface coeffs="0 0 0.4572" id="10001" name="Clad OR" type="z-cylinder" />
<surface boundary="reflective" coeffs="-0.63" id="10002" name="left" type="x-plane" />
@ -12,14 +12,14 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="10000" name="Fuel">
<material id="10000" name="UO2 (2.4%)">
<density units="g/cm3" value="10.29769" />
<nuclide ao="4.4843e-06" name="U234" />
<nuclide ao="0.00055815" name="U235" />
<nuclide ao="0.022408" name="U238" />
<nuclide ao="0.045829" name="O16" />
</material>
<material id="10001" name="Cladding">
<material id="10001" name="Zircaloy">
<density units="g/cm3" value="6.55" />
<nuclide ao="0.021827" name="Zr90" />
<nuclide ao="0.00476" name="Zr91" />

View file

@ -6,24 +6,20 @@ import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import PinCellInputSet
import openmc
import openmc.mgxs
from openmc.examples import pwr_pin_cell
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Set the input set to use the pincell model
self._input_set = PinCellInputSet()
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
def __init__(self, *args, **kwargs):
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a two-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = False
# Test all MGXS types
@ -35,10 +31,8 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.domain_type = 'material'
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
# Add tallies
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -72,5 +66,7 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.*', True)
# Use the pincell model
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -6,7 +6,7 @@
<cell id="10003" material="10002" name="guide tube inner water" region="-10000" universe="10001" />
<cell id="10004" material="10001" name="guide tube clad" region="10000 -10001" universe="10001" />
<cell id="10005" material="10002" name="guide tube outer water" region="10001" universe="10001" />
<cell fill="10002" id="10006" name="root cell" region="10002 -10003 10004 -10005" universe="0" />
<cell fill="10002" id="10006" name="root cell" region="10002 -10003 10004 -10005" universe="10003" />
<lattice id="10002" name="Fuel Assembly">
<pitch>1.26 1.26</pitch>
<dimension>17 17</dimension>

View file

@ -6,25 +6,22 @@ import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import AssemblyInputSet
import openmc
import openmc.mgxs
from openmc.examples import pwr_assembly
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Set the input set to use the pincell model
self._input_set = AssemblyInputSet()
def __init__(self, *args, **kwargs):
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a one-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 20.e6])
# Initialize MGXS Library for a few cross section types
# for one material-filled cell in the geometry
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = False
# Test all MGXS types
@ -38,10 +35,9 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.domains = [c for c in cells if c.name == 'fuel']
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
# Add tallies
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
self._model.tallies.export_to_xml()
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -74,5 +70,6 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.h5', True)
model = pwr_assembly()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" name="cell 1" region="-10000" universe="0" />
<cell id="10001" material="10001" name="cell 3" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="cell 2" region="10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10000" material="10000" name="Fuel" region="-10000" universe="0" />
<cell id="10001" material="10001" name="Cladding" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="Water" region="10001 10002 -10003 10004 -10005" universe="0" />
<surface coeffs="0 0 0.39218" id="10000" name="Fuel OR" type="z-cylinder" />
<surface coeffs="0 0 0.4572" id="10001" name="Clad OR" type="z-cylinder" />
<surface boundary="reflective" coeffs="-0.63" id="10002" name="left" type="x-plane" />
@ -12,14 +12,14 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="10000" name="Fuel">
<material id="10000" name="UO2 (2.4%)">
<density units="g/cm3" value="10.29769" />
<nuclide ao="4.4843e-06" name="U234" />
<nuclide ao="0.00055815" name="U235" />
<nuclide ao="0.022408" name="U238" />
<nuclide ao="0.045829" name="O16" />
</material>
<material id="10001" name="Cladding">
<material id="10001" name="Zircaloy">
<density units="g/cm3" value="6.55" />
<nuclide ao="0.021827" name="Zr90" />
<nuclide ao="0.00476" name="Zr91" />

View file

@ -10,27 +10,24 @@ import h5py
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import PinCellInputSet
import openmc
import openmc.mgxs
from openmc.examples import pwr_pin_cell
np.set_printoptions(formatter={'float_kind': '{:.8e}'.format})
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Set the input set to use the pincell model
self._input_set = PinCellInputSet()
def __init__(self, *args, **kwargs):
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a two-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = False
# Test all MGXS types
@ -42,10 +39,8 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.domain_type = 'material'
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
# Add tallies
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -59,21 +54,18 @@ class MGXSTestHarness(PyAPITestHarness):
# Export the MGXS Library to an HDF5 file
self.mgxs_lib.build_hdf5_store(directory='.')
# Open the MGXS HDF5 file
f = h5py.File('mgxs.h5', 'r')
with h5py.File('mgxs.h5', 'r') as f:
# Build a string from the datasets in the HDF5 file
outstr = ''
for domain in self.mgxs_lib.domains:
for mgxs_type in self.mgxs_lib.mgxs_types:
outstr += 'domain={0} type={1}\n'.format(domain.id, mgxs_type)
avg_key = 'material/{0}/{1}/average'.format(domain.id, mgxs_type)
std_key = 'material/{0}/{1}/std. dev.'.format(domain.id, mgxs_type)
outstr += '{}\n{}\n'.format(f[avg_key][...], f[std_key][...])
# Close the MGXS HDF5 file
f.close()
# Build a string from the datasets in the HDF5 file
outstr = ''
for domain in self.mgxs_lib.domains:
for mgxs_type in self.mgxs_lib.mgxs_types:
outstr += 'domain={0} type={1}\n'.format(domain.id, mgxs_type)
avg_key = 'material/{0}/{1}/average'.format(domain.id, mgxs_type)
std_key = 'material/{0}/{1}/std. dev.'.format(domain.id, mgxs_type)
outstr += '{}\n{}\n'.format(f[avg_key][...], f[std_key][...])
# Hash the results if necessary
if hash_output:
@ -85,12 +77,12 @@ class MGXSTestHarness(PyAPITestHarness):
def _cleanup(self):
super(MGXSTestHarness, self)._cleanup()
f = os.path.join(os.getcwd(), 'tallies.xml')
if os.path.exists(f): os.remove(f)
f = os.path.join(os.getcwd(), 'mgxs.h5')
if os.path.exists(f): os.remove(f)
if os.path.exists(f):
os.remove(f)
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.*', True)
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />

View file

@ -11,16 +11,15 @@ import openmc.mgxs
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
def __init__(self, *args, **kwargs):
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a one-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 20.e6])
# Initialize MGXS Library for a few cross section types
# for one material-filled cell in the geometry
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = False
# Test all MGXS types
@ -41,10 +40,8 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.domains = [mesh]
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
# Add tallies
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -74,5 +71,5 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.h5', True)
harness = MGXSTestHarness('statepoint.10.h5')
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" name="cell 1" region="-10000" universe="0" />
<cell id="10001" material="10001" name="cell 3" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="cell 2" region="10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10000" material="10000" name="Fuel" region="-10000" universe="0" />
<cell id="10001" material="10001" name="Cladding" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="Water" region="10001 10002 -10003 10004 -10005" universe="0" />
<surface coeffs="0 0 0.39218" id="10000" name="Fuel OR" type="z-cylinder" />
<surface coeffs="0 0 0.4572" id="10001" name="Clad OR" type="z-cylinder" />
<surface boundary="reflective" coeffs="-0.63" id="10002" name="left" type="x-plane" />
@ -12,14 +12,14 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="10000" name="Fuel">
<material id="10000" name="UO2 (2.4%)">
<density units="g/cm3" value="10.29769" />
<nuclide ao="4.4843e-06" name="U234" />
<nuclide ao="0.00055815" name="U235" />
<nuclide ao="0.022408" name="U238" />
<nuclide ao="0.045829" name="O16" />
</material>
<material id="10001" name="Cladding">
<material id="10001" name="Zircaloy">
<density units="g/cm3" value="6.55" />
<nuclide ao="0.021827" name="Zr90" />
<nuclide ao="0.00476" name="Zr91" />

View file

@ -6,24 +6,21 @@ import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import PinCellInputSet
import openmc
import openmc.mgxs
from openmc.examples import pwr_pin_cell
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Set the input set to use the pincell model
self._input_set = PinCellInputSet()
def __init__(self, *args, **kwargs):
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a two-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = False
# Test all MGXS types
@ -35,10 +32,8 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.domain_type = 'material'
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
# Add tallies
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -68,5 +63,6 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.h5', True)
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="10000" material="10000" name="cell 1" region="-10000" universe="0" />
<cell id="10001" material="10001" name="cell 3" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="cell 2" region="10001 10002 -10003 10004 -10005" universe="0" />
<cell id="10000" material="10000" name="Fuel" region="-10000" universe="0" />
<cell id="10001" material="10001" name="Cladding" region="10000 -10001" universe="0" />
<cell id="10002" material="10002" name="Water" region="10001 10002 -10003 10004 -10005" universe="0" />
<surface coeffs="0 0 0.39218" id="10000" name="Fuel OR" type="z-cylinder" />
<surface coeffs="0 0 0.4572" id="10001" name="Clad OR" type="z-cylinder" />
<surface boundary="reflective" coeffs="-0.63" id="10002" name="left" type="x-plane" />
@ -12,14 +12,14 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="10000" name="Fuel">
<material id="10000" name="UO2 (2.4%)">
<density units="g/cm3" value="10.29769" />
<nuclide ao="4.4843e-06" name="U234" />
<nuclide ao="0.00055815" name="U235" />
<nuclide ao="0.022408" name="U238" />
<nuclide ao="0.045829" name="O16" />
</material>
<material id="10001" name="Cladding">
<material id="10001" name="Zircaloy">
<density units="g/cm3" value="6.55" />
<nuclide ao="0.021827" name="Zr90" />
<nuclide ao="0.00476" name="Zr91" />

View file

@ -6,24 +6,20 @@ import glob
import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from input_set import PinCellInputSet
import openmc
import openmc.mgxs
from openmc.examples import pwr_pin_cell
class MGXSTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Set the input set to use the pincell model
self._input_set = PinCellInputSet()
# Generate inputs using parent class routine
super(MGXSTestHarness, self)._build_inputs()
def __init__(self, *args, **kwargs):
super(MGXSTestHarness, self).__init__(*args, **kwargs)
# Initialize a two-group structure
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625, 20.e6])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
self.mgxs_lib.by_nuclide = True
# Test all MGXS types
self.mgxs_lib.mgxs_types = openmc.mgxs.MGXS_TYPES
@ -32,10 +28,8 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.domain_type = 'material'
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
# Add tallies
self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False)
def _get_results(self, hash_output=True):
"""Digest info in the statepoint and return as a string."""
@ -65,5 +59,6 @@ class MGXSTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = MGXSTestHarness('statepoint.10.h5', True)
model = pwr_pin_cell()
harness = MGXSTestHarness('statepoint.10.h5', model)
harness.main()

View file

@ -43,9 +43,6 @@
<parameters>-1 -1 -1 1 1 1</parameters>
</space>
</source>
<output>
<summary>true</summary>
</output>
<temperature_multipole>True</temperature_multipole>
<temperature_tolerance>1000</temperature_tolerance>
</settings>

View file

@ -4,8 +4,6 @@ import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness, PyAPITestHarness
import openmc
from openmc.stats import Box
from openmc.source import Source
class MultipoleTestHarness(PyAPITestHarness):
def _build_inputs(self):
@ -66,8 +64,8 @@ class MultipoleTestHarness(PyAPITestHarness):
sets_file.batches = 5
sets_file.inactive = 0
sets_file.particles = 1000
sets_file.source = Source(space=Box([-1, -1, -1], [1, 1, 1]))
sets_file.output = {'summary': True}
sets_file.source = openmc.Source(space=openmc.stats.Box(
[-1, -1, -1], [1, 1, 1]))
sets_file.temperature = {'tolerance': 1000, 'multipole': True}
sets_file.export_to_xml()
@ -75,27 +73,24 @@ class MultipoleTestHarness(PyAPITestHarness):
# Plots
####################
plots_file = openmc.Plots()
plot1 = openmc.Plot(plot_id=1)
plot1.basis = 'xy'
plot1.color_by = 'cell'
plot1.filename = 'cellplot'
plot1.origin = (0, 0, 0)
plot1.width = (7, 7)
plot1.pixels = (400, 400)
plot = openmc.Plot(plot_id=1)
plot.basis = 'xy'
plot.color_by = 'cell'
plot.filename = 'cellplot'
plot.origin = (0, 0, 0)
plot.width = (7, 7)
plot.pixels = (400, 400)
plots_file.append(plot)
plot2 = openmc.Plot(plot_id=2)
plot2.basis = 'xy'
plot2.color_by = 'material'
plot2.filename = 'matplot'
plot2.origin = (0, 0, 0)
plot2.width = (7, 7)
plot2.pixels = (400, 400)
plot = openmc.Plot(plot_id=2)
plot.basis = 'xy'
plot.color_by = 'material'
plot.filename = 'matplot'
plot.origin = (0, 0, 0)
plot.width = (7, 7)
plot.pixels = (400, 400)
plots_file.append(plot)
plots_file.export_to_xml()
plots = openmc.Plots([plot1, plot2])
plots.export_to_xml()
def execute_test(self):
if not 'OPENMC_MULTIPOLE_LIBRARY' in os.environ:
@ -110,12 +105,6 @@ class MultipoleTestHarness(PyAPITestHarness):
outstr += str(su.geometry.get_all_cells()[11])
return outstr
def _cleanup(self):
f = os.path.join(os.getcwd(), 'plots.xml')
if os.path.exists(f):
os.remove(f)
super(MultipoleTestHarness, self)._cleanup()
if __name__ == '__main__':
harness = MultipoleTestHarness('statepoint.5.h5')

View file

@ -29,5 +29,5 @@ class OutputTestHarness(TestHarness):
if __name__ == '__main__':
harness = OutputTestHarness('statepoint.10.*')
harness = OutputTestHarness('statepoint.10.h5')
harness.main()

View file

@ -15,7 +15,7 @@ import openmc
class PlotTestHarness(TestHarness):
"""Specialized TestHarness for running OpenMC plotting tests."""
def __init__(self, plot_names):
super(PlotTestHarness, self).__init__(None, False)
super(PlotTestHarness, self).__init__(None)
self._plot_names = plot_names
def _run_openmc(self):

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import HashedTestHarness
if __name__ == '__main__':
harness = HashedTestHarness('statepoint.10.*', True)
harness = HashedTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -98,5 +98,5 @@ class SourceFileTestHarness(TestHarness):
if __name__ == '__main__':
harness = SourceFileTestHarness('statepoint.10.*')
harness = SourceFileTestHarness('statepoint.10.h5')
harness.main()

View file

@ -5,7 +5,7 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
from openmc.statepoint import StatePoint
from openmc import StatePoint
class SourcepointTestHarness(TestHarness):
@ -18,21 +18,20 @@ class SourcepointTestHarness(TestHarness):
def _get_results(self):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = StatePoint(statepoint)
# Get the eigenvalue information.
outstr = TestHarness._get_results(self)
# Add the source information.
xyz = sp.source[0]['xyz']
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
outstr += "\n"
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
with StatePoint(statepoint) as sp:
# Add the source information.
xyz = sp.source[0]['xyz']
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
outstr += "\n"
return outstr
if __name__ == '__main__':
harness = SourcepointTestHarness('statepoint.08.*')
harness = SourcepointTestHarness('statepoint.08.h5')
harness.main()

View file

@ -18,5 +18,5 @@ class SourcepointTestHarness(TestHarness):
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*', True)
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python
import os
import sys
@ -8,11 +8,11 @@ from testing_harness import TestHarness
class StatepointTestHarness(TestHarness):
def __init__(self):
super(StatepointTestHarness, self).__init__(None, False)
super(StatepointTestHarness, self).__init__(None)
def _test_output_created(self):
"""Make sure statepoint files have been created."""
sps = ('statepoint.03.*', 'statepoint.06.*', 'statepoint.09.*')
sps = ('statepoint.03.h5', 'statepoint.06.h5', 'statepoint.09.h5')
for sp in sps:
self._sp_name = sp
TestHarness._test_output_created(self)

View file

@ -9,9 +9,8 @@ import openmc
class StatepointRestartTestHarness(TestHarness):
def __init__(self, final_sp, restart_sp, tallies_present=False):
super(StatepointRestartTestHarness, self).__init__(final_sp,
tallies_present)
def __init__(self, final_sp, restart_sp):
super(StatepointRestartTestHarness, self).__init__(final_sp)
self._restart_sp = restart_sp
def execute_test(self):
@ -63,5 +62,5 @@ class StatepointRestartTestHarness(TestHarness):
if __name__ == '__main__':
harness = StatepointRestartTestHarness('statepoint.10.h5',
'statepoint.07.h5', True)
'statepoint.07.h5')
harness.main()

View file

@ -26,5 +26,5 @@ class SourcepointTestHarness(TestHarness):
if __name__ == '__main__':
harness = SourcepointTestHarness('statepoint.10.*')
harness = SourcepointTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*', True)
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />

View file

@ -4,180 +4,168 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from testing_harness import HashedPyAPITestHarness
from openmc.filter import *
from openmc import Mesh, Tally, Tallies
from openmc.source import Source
from openmc.stats import Box
class TalliesTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Build default materials/geometry
self._input_set.build_default_materials_and_geometry()
# Set settings explicitly
self._input_set.settings.batches = 5
self._input_set.settings.inactive = 0
self._input_set.settings.particles = 400
self._input_set.settings.source = Source(space=Box(
[-160, -160, -183], [160, 160, 183]))
azimuthal_bins = (-3.14159, -1.8850, -0.6283, 0.6283, 1.8850, 3.14159)
azimuthal_filter = AzimuthalFilter(azimuthal_bins)
azimuthal_tally1 = Tally()
azimuthal_tally1.filters = [azimuthal_filter]
azimuthal_tally1.scores = ['flux']
azimuthal_tally1.estimator = 'tracklength'
azimuthal_tally2 = Tally()
azimuthal_tally2.filters = [azimuthal_filter]
azimuthal_tally2.scores = ['flux']
azimuthal_tally2.estimator = 'analog'
mesh_2x2 = Mesh(mesh_id=1)
mesh_2x2.lower_left = [-182.07, -182.07]
mesh_2x2.upper_right = [182.07, 182.07]
mesh_2x2.dimension = [2, 2]
mesh_filter = MeshFilter(mesh_2x2)
azimuthal_tally3 = Tally()
azimuthal_tally3.filters = [azimuthal_filter, mesh_filter]
azimuthal_tally3.scores = ['flux']
azimuthal_tally3.estimator = 'tracklength'
cellborn_tally = Tally()
cellborn_tally.filters = [CellbornFilter((10, 21, 22, 23))]
cellborn_tally.scores = ['total']
dg_tally = Tally()
dg_tally.filters = [DelayedGroupFilter((1, 2, 3, 4, 5, 6))]
dg_tally.scores = ['delayed-nu-fission']
four_groups = (0.0, 0.253, 1.0e3, 1.0e6, 20.0e6)
energy_filter = EnergyFilter(four_groups)
energy_tally = Tally()
energy_tally.filters = [energy_filter]
energy_tally.scores = ['total']
energyout_filter = EnergyoutFilter(four_groups)
energyout_tally = Tally()
energyout_tally.filters = [energyout_filter]
energyout_tally.scores = ['scatter']
transfer_tally = Tally()
transfer_tally.filters = [energy_filter, energyout_filter]
transfer_tally.scores = ['scatter', 'nu-fission']
material_tally = Tally()
material_tally.filters = [MaterialFilter((1, 2, 3, 4))]
material_tally.scores = ['total']
mu_bins = (-1.0, -0.5, 0.0, 0.5, 1.0)
mu_filter = MuFilter(mu_bins)
mu_tally1 = Tally()
mu_tally1.filters = [mu_filter]
mu_tally1.scores = ['scatter', 'nu-scatter']
mu_tally2 = Tally()
mu_tally2.filters = [mu_filter, mesh_filter]
mu_tally2.scores = ['scatter', 'nu-scatter']
polar_bins = (0.0, 0.6283, 1.2566, 1.8850, 2.5132, 3.14159)
polar_filter = PolarFilter(polar_bins)
polar_tally1 = Tally()
polar_tally1.filters = [polar_filter]
polar_tally1.scores = ['flux']
polar_tally1.estimator = 'tracklength'
polar_tally2 = Tally()
polar_tally2.filters = [polar_filter]
polar_tally2.scores = ['flux']
polar_tally2.estimator = 'analog'
polar_tally3 = Tally()
polar_tally3.filters = [polar_filter, mesh_filter]
polar_tally3.scores = ['flux']
polar_tally3.estimator = 'tracklength'
universe_tally = Tally()
universe_tally.filters = [UniverseFilter((1, 2, 3, 4, 6, 8))]
universe_tally.scores = ['total']
cell_filter = CellFilter((10, 21, 22, 23, 60))
score_tallies = [Tally(), Tally(), Tally()]
for t in score_tallies:
t.filters = [cell_filter]
t.scores = ['absorption', 'delayed-nu-fission', 'events', 'fission',
'inverse-velocity', 'kappa-fission', '(n,2n)', '(n,n1)',
'(n,gamma)', 'nu-fission', 'scatter', 'elastic',
'total', 'prompt-nu-fission', 'fission-q-prompt',
'fission-q-recoverable']
score_tallies[0].estimator = 'tracklength'
score_tallies[1].estimator = 'analog'
score_tallies[2].estimator = 'collision'
cell_filter2 = CellFilter((21, 22, 23, 27, 28, 29, 60))
flux_tallies = [Tally() for i in range(4)]
for t in flux_tallies:
t.filters = [cell_filter2]
flux_tallies[0].scores = ['flux']
for t in flux_tallies[1:]:
t.scores = ['flux-y5']
flux_tallies[1].estimator = 'tracklength'
flux_tallies[2].estimator = 'analog'
flux_tallies[3].estimator = 'collision'
scatter_tally1 = Tally()
scatter_tally1.filters = [cell_filter]
scatter_tally1.scores = ['scatter', 'scatter-1', 'scatter-2', 'scatter-3',
'scatter-4', 'nu-scatter', 'nu-scatter-1',
'nu-scatter-2', 'nu-scatter-3', 'nu-scatter-4']
scatter_tally2 = Tally()
scatter_tally2.filters = [cell_filter]
scatter_tally2.scores = ['scatter-p4', 'scatter-y4', 'nu-scatter-p4',
'nu-scatter-y3']
total_tallies = [Tally() for i in range(4)]
for t in total_tallies:
t.filters = [cell_filter]
total_tallies[0].scores = ['total']
for t in total_tallies[1:]:
t.scores = ['total-y4']
t.nuclides = ['U235', 'total']
total_tallies[1].estimator = 'tracklength'
total_tallies[2].estimator = 'analog'
total_tallies[3].estimator = 'collision'
all_nuclide_tallies = [Tally() for i in range(4)]
for t in all_nuclide_tallies:
t.filters = [cell_filter]
t.estimator = 'tracklength'
t.nuclides = ['all']
t.scores = ['total']
all_nuclide_tallies[1].estimator = 'collision'
all_nuclide_tallies[2].filters = [mesh_filter]
all_nuclide_tallies[3].filters = [mesh_filter]
all_nuclide_tallies[3].nuclides = ['U235']
self._input_set.tallies = Tallies()
self._input_set.tallies += (
[azimuthal_tally1, azimuthal_tally2, azimuthal_tally3,
cellborn_tally, dg_tally, energy_tally, energyout_tally,
transfer_tally, material_tally, mu_tally1, mu_tally2,
polar_tally1, polar_tally2, polar_tally3, universe_tally])
self._input_set.tallies += score_tallies
self._input_set.tallies += flux_tallies
self._input_set.tallies += (scatter_tally1, scatter_tally2)
self._input_set.tallies += total_tallies
self._input_set.tallies += all_nuclide_tallies
self._input_set.export()
def _get_results(self):
return super(TalliesTestHarness, self)._get_results(hash_output=True)
if __name__ == '__main__':
harness = TalliesTestHarness('statepoint.5.h5', True)
harness = HashedPyAPITestHarness('statepoint.5.h5')
model = harness._model
# Set settings explicitly
model.settings.batches = 5
model.settings.inactive = 0
model.settings.particles = 400
model.settings.source = openmc.Source(space=openmc.stats.Box(
[-160, -160, -183], [160, 160, 183]))
azimuthal_bins = (-3.14159, -1.8850, -0.6283, 0.6283, 1.8850, 3.14159)
azimuthal_filter = AzimuthalFilter(azimuthal_bins)
azimuthal_tally1 = Tally()
azimuthal_tally1.filters = [azimuthal_filter]
azimuthal_tally1.scores = ['flux']
azimuthal_tally1.estimator = 'tracklength'
azimuthal_tally2 = Tally()
azimuthal_tally2.filters = [azimuthal_filter]
azimuthal_tally2.scores = ['flux']
azimuthal_tally2.estimator = 'analog'
mesh_2x2 = Mesh(mesh_id=1)
mesh_2x2.lower_left = [-182.07, -182.07]
mesh_2x2.upper_right = [182.07, 182.07]
mesh_2x2.dimension = [2, 2]
mesh_filter = MeshFilter(mesh_2x2)
azimuthal_tally3 = Tally()
azimuthal_tally3.filters = [azimuthal_filter, mesh_filter]
azimuthal_tally3.scores = ['flux']
azimuthal_tally3.estimator = 'tracklength'
cellborn_tally = Tally()
cellborn_tally.filters = [CellbornFilter((10, 21, 22, 23))]
cellborn_tally.scores = ['total']
dg_tally = Tally()
dg_tally.filters = [DelayedGroupFilter((1, 2, 3, 4, 5, 6))]
dg_tally.scores = ['delayed-nu-fission']
four_groups = (0.0, 0.253, 1.0e3, 1.0e6, 20.0e6)
energy_filter = EnergyFilter(four_groups)
energy_tally = Tally()
energy_tally.filters = [energy_filter]
energy_tally.scores = ['total']
energyout_filter = EnergyoutFilter(four_groups)
energyout_tally = Tally()
energyout_tally.filters = [energyout_filter]
energyout_tally.scores = ['scatter']
transfer_tally = Tally()
transfer_tally.filters = [energy_filter, energyout_filter]
transfer_tally.scores = ['scatter', 'nu-fission']
material_tally = Tally()
material_tally.filters = [MaterialFilter((1, 2, 3, 4))]
material_tally.scores = ['total']
mu_bins = (-1.0, -0.5, 0.0, 0.5, 1.0)
mu_filter = MuFilter(mu_bins)
mu_tally1 = Tally()
mu_tally1.filters = [mu_filter]
mu_tally1.scores = ['scatter', 'nu-scatter']
mu_tally2 = Tally()
mu_tally2.filters = [mu_filter, mesh_filter]
mu_tally2.scores = ['scatter', 'nu-scatter']
polar_bins = (0.0, 0.6283, 1.2566, 1.8850, 2.5132, 3.14159)
polar_filter = PolarFilter(polar_bins)
polar_tally1 = Tally()
polar_tally1.filters = [polar_filter]
polar_tally1.scores = ['flux']
polar_tally1.estimator = 'tracklength'
polar_tally2 = Tally()
polar_tally2.filters = [polar_filter]
polar_tally2.scores = ['flux']
polar_tally2.estimator = 'analog'
polar_tally3 = Tally()
polar_tally3.filters = [polar_filter, mesh_filter]
polar_tally3.scores = ['flux']
polar_tally3.estimator = 'tracklength'
universe_tally = Tally()
universe_tally.filters = [UniverseFilter((1, 2, 3, 4, 6, 8))]
universe_tally.scores = ['total']
cell_filter = CellFilter((10, 21, 22, 23, 60))
score_tallies = [Tally(), Tally(), Tally()]
for t in score_tallies:
t.filters = [cell_filter]
t.scores = ['absorption', 'delayed-nu-fission', 'events', 'fission',
'inverse-velocity', 'kappa-fission', '(n,2n)', '(n,n1)',
'(n,gamma)', 'nu-fission', 'scatter', 'elastic',
'total', 'prompt-nu-fission', 'fission-q-prompt',
'fission-q-recoverable']
score_tallies[0].estimator = 'tracklength'
score_tallies[1].estimator = 'analog'
score_tallies[2].estimator = 'collision'
cell_filter2 = CellFilter((21, 22, 23, 27, 28, 29, 60))
flux_tallies = [Tally() for i in range(4)]
for t in flux_tallies:
t.filters = [cell_filter2]
flux_tallies[0].scores = ['flux']
for t in flux_tallies[1:]:
t.scores = ['flux-y5']
flux_tallies[1].estimator = 'tracklength'
flux_tallies[2].estimator = 'analog'
flux_tallies[3].estimator = 'collision'
scatter_tally1 = Tally()
scatter_tally1.filters = [cell_filter]
scatter_tally1.scores = ['scatter', 'scatter-1', 'scatter-2', 'scatter-3',
'scatter-4', 'nu-scatter', 'nu-scatter-1',
'nu-scatter-2', 'nu-scatter-3', 'nu-scatter-4']
scatter_tally2 = Tally()
scatter_tally2.filters = [cell_filter]
scatter_tally2.scores = ['scatter-p4', 'scatter-y4', 'nu-scatter-p4',
'nu-scatter-y3']
total_tallies = [Tally() for i in range(4)]
for t in total_tallies:
t.filters = [cell_filter]
total_tallies[0].scores = ['total']
for t in total_tallies[1:]:
t.scores = ['total-y4']
t.nuclides = ['U235', 'total']
total_tallies[1].estimator = 'tracklength'
total_tallies[2].estimator = 'analog'
total_tallies[3].estimator = 'collision'
all_nuclide_tallies = [Tally() for i in range(4)]
for t in all_nuclide_tallies:
t.filters = [cell_filter]
t.estimator = 'tracklength'
t.nuclides = ['all']
t.scores = ['total']
all_nuclide_tallies[1].estimator = 'collision'
all_nuclide_tallies[2].filters = [mesh_filter]
all_nuclide_tallies[3].filters = [mesh_filter]
all_nuclide_tallies[3].nuclides = ['U235']
model.tallies += [
azimuthal_tally1, azimuthal_tally2, azimuthal_tally3,
cellborn_tally, dg_tally, energy_tally, energyout_tally,
transfer_tally, material_tally, mu_tally1, mu_tally2,
polar_tally1, polar_tally2, polar_tally3, universe_tally]
model.tallies += score_tallies
model.tallies += flux_tallies
model.tallies += (scatter_tally1, scatter_tally2)
model.tallies += total_tallies
model.tallies += all_nuclide_tallies
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />
@ -306,9 +306,6 @@
<parameters>-160 -160 -183 160 160 183</parameters>
</space>
</source>
<output>
<summary>true</summary>
</output>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>

View file

@ -10,15 +10,8 @@ import openmc
class TallyAggregationTestHarness(PyAPITestHarness):
def _build_inputs(self):
# The summary.h5 file needs to be created to read in the tallies
self._input_set.settings.output = {'summary': True}
# Initialize the nuclides
u234 = openmc.Nuclide('U234')
u235 = openmc.Nuclide('U235')
u238 = openmc.Nuclide('U238')
def __init__(self, *args, **kwargs):
super(TallyAggregationTestHarness, self).__init__(*args, **kwargs)
# Initialize the filters
energy_filter = openmc.EnergyFilter([0.0, 0.253, 1.0e3, 1.0e6, 20.0e6])
@ -28,12 +21,8 @@ class TallyAggregationTestHarness(PyAPITestHarness):
tally = openmc.Tally(name='distribcell tally')
tally.filters = [energy_filter, distrib_filter]
tally.scores = ['nu-fission', 'total']
tally.nuclides = [u234, u235, u238]
tallies_file = openmc.Tallies([tally])
# Export tallies to file
self._input_set.tallies = tallies_file
super(TallyAggregationTestHarness, self)._build_inputs()
tally.nuclides = ['U234', 'U235', 'U238']
self._model.tallies.append(tally)
def _get_results(self, hash_output=True):
"""Digest info in the statepoint and return as a string."""
@ -78,5 +67,5 @@ class TallyAggregationTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = TallyAggregationTestHarness('statepoint.10.h5', True)
harness = TallyAggregationTestHarness('statepoint.10.h5')
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />
@ -306,9 +306,6 @@
<parameters>-160 -160 -183 160 160 183</parameters>
</space>
</source>
<output>
<summary>true</summary>
</output>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>

View file

@ -10,18 +10,8 @@ import openmc
class TallyArithmeticTestHarness(PyAPITestHarness):
def _build_inputs(self):
# The summary.h5 file needs to be created to read in the tallies
self._input_set.settings.output = {'summary': True}
# Initialize the tallies file
tallies_file = openmc.Tallies()
# Initialize the nuclides
u234 = openmc.Nuclide('U234')
u235 = openmc.Nuclide('U235')
u238 = openmc.Nuclide('U238')
def __init__(self, *args, **kwargs):
super(TallyArithmeticTestHarness, self).__init__(*args, **kwargs)
# Initialize Mesh
mesh = openmc.Mesh(mesh_id=1)
@ -40,18 +30,14 @@ class TallyArithmeticTestHarness(PyAPITestHarness):
tally = openmc.Tally(name='tally 1')
tally.filters = [material_filter, energy_filter, distrib_filter]
tally.scores = ['nu-fission', 'total']
tally.nuclides = [u234, u235]
tallies_file.append(tally)
tally.nuclides = ['U234', 'U235']
self._model.tallies.append(tally)
tally = openmc.Tally(name='tally 2')
tally.filters = [energy_filter, mesh_filter]
tally.scores = ['total', 'fission']
tally.nuclides = [u238, u235]
tallies_file.append(tally)
# Export tallies to file
self._input_set.tallies = tallies_file
super(TallyArithmeticTestHarness, self)._build_inputs()
tally.nuclides = ['U238', 'U235']
self._model.tallies.append(tally)
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -95,5 +81,5 @@ class TallyArithmeticTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = TallyArithmeticTestHarness('statepoint.10.h5', True)
harness = TallyArithmeticTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*', True)
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*', True)
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -148,7 +148,7 @@
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="1" name="Fuel">
<material id="1" name="UOX fuel">
<density units="g/cm3" value="10.062" />
<nuclide ao="4.9476e-06" name="U234" />
<nuclide ao="0.00048218" name="U235" />
@ -197,7 +197,7 @@
<nuclide name="Zr96" wo="0.0216912612" />
<sab name="c_H_in_H2O" />
</material>
<material id="2" name="Cladding">
<material id="2" name="Zircaloy">
<density units="g/cm3" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
@ -249,7 +249,7 @@
<nuclide name="Cr52" wo="0.145407678031" />
<sab name="c_H_in_H2O" />
</material>
<material id="7" name="Upper radial reflector /Top plate region">
<material id="7" name="Upper radial reflector / Top plate region">
<density units="g/cm3" value="4.28" />
<nuclide name="H1" wo="0.0086117" />
<nuclide name="O16" wo="0.0683369" />

View file

@ -13,9 +13,8 @@ import openmc
class TallySliceMergeTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Initialize the tallies file
tallies_file = openmc.Tallies()
def __init__(self, *args, **kwargs):
super(TallySliceMergeTestHarness, self).__init__(*args, **kwargs)
# Define nuclides and scores to add to both tallies
self.nuclides = ['U235', 'U238']
@ -49,10 +48,10 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
for score in self.scores:
tally = openmc.Tally()
tally.estimator = 'tracklength'
tally.add_score(score)
tally.add_nuclide(nuclide)
tally.add_filter(cell_filter)
tally.add_filter(energy_filter)
tally.scores.append(score)
tally.nuclides.append(nuclide)
tally.filters.append(cell_filter)
tally.filters.append(energy_filter)
tallies.append(tally)
# Merge all cell tallies together
@ -69,9 +68,9 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
distribcell_tally.estimator = 'tracklength'
distribcell_tally.filters = [distribcell_filter, merged_energies]
for score in self.scores:
distribcell_tally.add_score(score)
distribcell_tally.scores.append(score)
for nuclide in self.nuclides:
distribcell_tally.add_nuclide(nuclide)
distribcell_tally.nuclides.append(nuclide)
mesh_tally = openmc.Tally(name='mesh tally')
mesh_tally.estimator = 'tracklength'
@ -80,12 +79,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
mesh_tally.nuclides = self.nuclides
# Add tallies to a Tallies object
tallies_file = openmc.Tallies((tallies[0], distribcell_tally,
mesh_tally))
# Export tallies to file
self._input_set.tallies = tallies_file
super(TallySliceMergeTestHarness, self)._build_inputs()
self._model.tallies = [tallies[0], distribcell_tally, mesh_tally]
def _get_results(self, hash_output=False):
"""Digest info in the statepoint and return as a string."""
@ -178,5 +172,5 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
if __name__ == '__main__':
harness = TallySliceMergeTestHarness('statepoint.10.h5', True)
harness = TallySliceMergeTestHarness('statepoint.10.h5')
harness.main()

View file

@ -7,5 +7,5 @@ from testing_harness import TestHarness
if __name__ == '__main__':
harness = TestHarness('statepoint.10.*')
harness = TestHarness('statepoint.10.h5')
harness.main()

View file

@ -14,32 +14,26 @@ class TrackTestHarness(TestHarness):
"""Make sure statepoint.* and track* have been created."""
TestHarness._test_output_created(self)
outputs = [glob.glob(''.join((os.getcwd(), '/track_1_1_1.*')))]
outputs.append(glob.glob(''.join((os.getcwd(), '/track_1_1_2.*'))))
for files in outputs:
assert len(files) == 1, 'Multiple or no track files detected.'
assert files[0].endswith('h5'),\
'Track files are not HDF5 files'
outputs = glob.glob('track_1_1_*.h5')
assert len(outputs) == 2, 'Expected two track files.'
def _get_results(self):
"""Digest info in the statepoint and return as a string."""
# Run the track-to-vtk conversion script.
call(['../../scripts/openmc-track-to-vtk', '-o', 'poly'] +
glob.glob(''.join((os.getcwd(), '/track*'))))
glob.glob('track_1_1_*.h5'))
# Make sure the vtk file was created then return it's contents.
poly = os.path.join(os.getcwd(), 'poly.pvtp')
assert os.path.isfile(poly), 'poly.pvtp file not found.'
assert os.path.isfile('poly.pvtp'), 'poly.pvtp file not found.'
with open(poly) as fin:
with open('poly.pvtp', 'r') as fin:
outstr = fin.read()
return outstr
def _cleanup(self):
TestHarness._cleanup(self)
output = glob.glob(os.path.join(os.getcwd(), 'track*'))
output += glob.glob(os.path.join(os.getcwd(), 'poly*'))
output = glob.glob('track*') + glob.glob('poly*')
for f in output:
if os.path.exists(f):
os.remove(f)
@ -54,5 +48,5 @@ if __name__ == '__main__':
print('----------------Skipping test-------------')
shutil.copy('results_true.dat', 'results_test.dat')
exit()
harness = TrackTestHarness('statepoint.2.*')
harness = TrackTestHarness('statepoint.2.h5')
harness.main()

Some files were not shown because too many files have changed in this diff Show more