Merge branch 'develop' into separate_filters

* develop: (91 commits)
  Update resonance scattering test result
  removed additional unnecessary modifications
  removed unnecessary modifications
  updated to only modify the _swap_filters method
  Check for elastic scattering with isotropic mu.
  changed == to is
  fixed issue in tallies.py in making sure static copy of other filter gets updated and updated tests
  fixed bug for misaligned energy and energyout filters
  When 1 temp is available, revert to nearest temp on all processes
  added other_old to _swap_filter method
  fixed tally alignment method in tallies.py
  Make sure get_pandas_dataframe() works with 1D mesh filter
  Fix bug with SurfaceFilter bin ordering
  Check for void materials in tracklength tallies
  Make sure source is in geometry before fiss. check
  Make parent class for filters with IDed objects
  Allow objects in addition to ids in Filters
  Cleaned up rxn_rate_tally property for consistent scattering matrices
  Simplified code for xs_tally property for consistent scattering matrices
  Update inputs for test_diff_tally
  ...

Conflicts:
	openmc/filter.py
	src/output.F90
This commit is contained in:
amandalund 2017-04-30 17:41:38 -05:00
commit 375125c603
230 changed files with 16397 additions and 11457 deletions

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

@ -184,8 +184,8 @@ class Test(object):
build_str += "-Ddebug=ON "
if self.optimize:
build_str += "-Doptimize=ON "
if self.openmp:
build_str += "-Dopenmp=ON "
if not self.openmp:
build_str += "-Dopenmp=OFF "
if self.coverage:
build_str += "-Dcoverage=ON "
self.build_opts = build_str

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" />
@ -306,7 +306,7 @@
<parameters>-160 -160 -183 160 160 183</parameters>
</space>
</source>
<temperature_multipole>True</temperature_multipole>
<temperature_multipole>true</temperature_multipole>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>

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,91 @@ 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_filter = openmc.MaterialFilter(model.materials)
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

@ -105,18 +105,18 @@ domain=10000 type=prompt-nu-fission matrix
[[3.14909051e-03 0.00000000e+00]
[2.86750878e-02 0.00000000e+00]]
domain=10000 type=delayed-nu-fission
[[2.29808266e-05 1.06974147e-04]
[1.43606354e-04 5.52167849e-04]
[1.51382232e-04 5.27147626e-04]
[7.42603126e-05 2.22017986e-04]
[4.14908415e-05 9.10244168e-05]
[1.70015984e-05 3.81298021e-05]]
[[1.66363187e-06 9.49155601e-06]
[1.05907827e-05 4.89925095e-05]
[1.12671254e-05 4.67725251e-05]
[5.22610330e-06 1.87563055e-05]
[2.99830756e-06 7.68983466e-06]
[1.22654681e-06 3.22124422e-06]]
[[4.31687649e-06 1.06974147e-04]
[2.69760050e-05 5.52167849e-04]
[2.84366794e-05 5.27147626e-04]
[7.42603126e-05 1.18190938e-03]
[4.14908415e-05 4.84567103e-04]
[1.70015984e-05 2.02983423e-04]]
[[2.89748553e-07 9.49155601e-06]
[1.85003751e-06 4.89925095e-05]
[1.97097930e-06 4.67725251e-05]
[5.22610330e-06 1.04867938e-04]
[2.99830756e-06 4.29944539e-05]
[1.22654681e-06 1.80102228e-05]]
domain=10000 type=chi-delayed
[[0.00000000e+00 0.00000000e+00]
[1.00000000e+00 0.00000000e+00]
@ -131,18 +131,18 @@ domain=10000 type=chi-delayed
[0.00000000e+00 0.00000000e+00]
[0.00000000e+00 0.00000000e+00]]
domain=10000 type=beta
[[4.89188226e-05 2.27713711e-04]
[3.05691952e-04 1.17538858e-03]
[3.22244307e-04 1.12212853e-03]
[3.82159878e-03 1.14255332e-02]
[2.13520982e-03 4.68431640e-03]
[8.74939593e-04 1.96224336e-03]]
[[4.67388636e-06 2.46946655e-05]
[2.95223864e-05 1.27466313e-04]
[3.12884979e-05 1.21690467e-04]
[3.21434953e-04 1.09939768e-03]
[1.82980531e-04 4.50738369e-04]
[7.48900067e-05 1.88812689e-04]]
[[2.22155945e-04 2.27713711e-04]
[1.38824446e-03 1.17538858e-03]
[1.46341397e-03 1.12212853e-03]
[3.82159878e-03 2.51590670e-03]
[2.13520982e-03 1.03148823e-03]
[8.74939593e-04 4.32086725e-04]]
[[1.80847602e-05 2.46946655e-05]
[1.14688936e-04 1.27466313e-04]
[1.21787672e-04 1.21690467e-04]
[3.21434953e-04 2.72840272e-04]
[1.82980531e-04 1.11860871e-04]
[7.48900067e-05 4.68581181e-05]]
domain=10000 type=decay-rate
[[1.34450193e-02 1.33360001e-02]
[3.20638663e-02 3.27389978e-02]
@ -167,7 +167,7 @@ domain=10000 type=delayed-nu-fission matrix
[1.18579136e-03 0.00000000e+00]]
[[0.00000000e+00 0.00000000e+00]
[8.59786782e-04 0.00000000e+00]]
[4.82335163e-03 0.00000000e+00]]
[[0.00000000e+00 0.00000000e+00]
[0.00000000e+00 0.00000000e+00]]
@ -184,7 +184,7 @@ domain=10000 type=delayed-nu-fission matrix
[1.18610370e-03 0.00000000e+00]]
[[0.00000000e+00 0.00000000e+00]
[2.22194557e-04 0.00000000e+00]]
[1.23402593e-03 0.00000000e+00]]
[[0.00000000e+00 0.00000000e+00]
[0.00000000e+00 0.00000000e+00]]

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

@ -128,19 +128,19 @@
2 10000 1 2 total 0.000000 0.000000
1 10000 2 1 total 0.445819 0.028675
0 10000 2 2 total 0.000000 0.000000
material delayedgroup group in nuclide mean std. dev.
1 10000 1 1 total 0.000023 0.000002
3 10000 2 1 total 0.000144 0.000011
5 10000 3 1 total 0.000151 0.000011
7 10000 4 1 total 0.000074 0.000005
9 10000 5 1 total 0.000041 0.000003
11 10000 6 1 total 0.000017 0.000001
0 10000 1 2 total 0.000107 0.000009
2 10000 2 2 total 0.000552 0.000049
4 10000 3 2 total 0.000527 0.000047
6 10000 4 2 total 0.000222 0.000019
8 10000 5 2 total 0.000091 0.000008
10 10000 6 2 total 0.000038 0.000003
material delayedgroup group in nuclide mean std. dev.
1 10000 1 1 total 0.000004 2.897486e-07
3 10000 2 1 total 0.000027 1.850038e-06
5 10000 3 1 total 0.000028 1.970979e-06
7 10000 4 1 total 0.000074 5.226103e-06
9 10000 5 1 total 0.000041 2.998308e-06
11 10000 6 1 total 0.000017 1.226547e-06
0 10000 1 2 total 0.000107 9.491556e-06
2 10000 2 2 total 0.000552 4.899251e-05
4 10000 3 2 total 0.000527 4.677253e-05
6 10000 4 2 total 0.001182 1.048679e-04
8 10000 5 2 total 0.000485 4.299445e-05
10 10000 6 2 total 0.000203 1.801022e-05
material delayedgroup group out nuclide mean std. dev.
1 10000 1 1 total 0.0 0.000000
3 10000 2 1 total 1.0 0.869128
@ -155,18 +155,18 @@
8 10000 5 2 total 0.0 0.000000
10 10000 6 2 total 0.0 0.000000
material delayedgroup group in nuclide mean std. dev.
1 10000 1 1 total 0.000049 0.000005
3 10000 2 1 total 0.000306 0.000030
5 10000 3 1 total 0.000322 0.000031
1 10000 1 1 total 0.000222 0.000018
3 10000 2 1 total 0.001388 0.000115
5 10000 3 1 total 0.001463 0.000122
7 10000 4 1 total 0.003822 0.000321
9 10000 5 1 total 0.002135 0.000183
11 10000 6 1 total 0.000875 0.000075
0 10000 1 2 total 0.000228 0.000025
2 10000 2 2 total 0.001175 0.000127
4 10000 3 2 total 0.001122 0.000122
6 10000 4 2 total 0.011426 0.001099
8 10000 5 2 total 0.004684 0.000451
10 10000 6 2 total 0.001962 0.000189
6 10000 4 2 total 0.002516 0.000273
8 10000 5 2 total 0.001031 0.000112
10 10000 6 2 total 0.000432 0.000047
material delayedgroup group in nuclide mean std. dev.
1 10000 1 1 total 0.013445 0.001084
3 10000 2 1 total 0.032064 0.002658
@ -196,7 +196,7 @@
1 10000 1 2 1 total 0.000000 0.000000
5 10000 2 2 1 total 0.002538 0.001561
9 10000 3 2 1 total 0.001186 0.001186
13 10000 4 2 1 total 0.000860 0.000222
13 10000 4 2 1 total 0.004823 0.001234
17 10000 5 2 1 total 0.000000 0.000000
21 10000 6 2 1 total 0.000000 0.000000
0 10000 1 2 2 total 0.000000 0.000000

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

@ -1 +1 @@
107576b21fa8ed72f71ac65866e4ad1100cc62df527f6f4e6bb8a6318f3694614b6ba1c72634b2e97474a75ea1b3112dcb9b4b36e58f0417e5b04aee5d3c7570
ea1c7567cb5399ab26297b5df0c1c21b52863303746d04f1698760d88b1aafb625d5743969ad30b194c353d106ed4287a8bc755ea6404c2f5dafb2ea930444a7

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,22 +43,13 @@
<parameters>-1 -1 -1 1 1 1</parameters>
</space>
</source>
<output>
<summary>true</summary>
</output>
<temperature_multipole>True</temperature_multipole>
<temperature_multipole>true</temperature_multipole>
<temperature_tolerance>1000</temperature_tolerance>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<plots>
<plot basis="xy" color_by="cell" filename="cellplot" id="1" type="slice">
<origin>0 0 0</origin>
<width>7 7</width>
<pixels>400 400</pixels>
</plot>
<plot basis="xy" color_by="material" filename="matplot" id="2" type="slice">
<origin>0 0 0</origin>
<width>7 7</width>
<pixels>400 400</pixels>
</plot>
</plots>
<tallies>
<tally id="10000">
<nuclides>U235 O16 total</nuclides>
<scores>total fission (n,gamma) elastic (n,p)</scores>
</tally>
</tallies>

View file

@ -1,5 +1,36 @@
k-combined:
1.363786E+00 1.103929E-02
tally 1:
3.960375E+00
3.138356E+00
2.875799E+00
1.655329E+00
5.521904E-01
6.105083E-02
4.617974E-01
4.274130E-02
0.000000E+00
0.000000E+00
2.254165E+01
1.016444E+02
0.000000E+00
0.000000E+00
6.839351E-04
9.359599E-08
2.251829E+01
1.014341E+02
4.903575E-05
1.199780E-09
3.595002E+02
2.586079E+04
2.875799E+00
1.655329E+00
2.174747E+00
9.465589E-01
3.543564E+02
2.512619E+04
4.903575E-05
1.199780E-09
Cell
ID = 11
Name =

View file

@ -4,99 +4,69 @@ 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
import openmc.model
def make_model():
model = openmc.model.Model()
# Materials
moderator = openmc.Material(material_id=1)
moderator.set_density('g/cc', 1.0)
moderator.add_nuclide('H1', 2.0)
moderator.add_nuclide('O16', 1.0)
moderator.add_s_alpha_beta('c_H_in_H2O')
dense_fuel = openmc.Material(material_id=2)
dense_fuel.set_density('g/cc', 4.5)
dense_fuel.add_nuclide('U235', 1.0)
model.materials += [moderator, dense_fuel]
# Geometry
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, fill=dense_fuel, region=-r0)
c11.temperature = [500, 0, 700, 800]
c12 = openmc.Cell(cell_id=12, fill=moderator, region=+r0)
fuel_univ = openmc.Universe(universe_id=11, cells=(c11, c12))
lat = openmc.RectLattice(lattice_id=101)
lat.dimension = [2, 2]
lat.lower_left = [-2.0, -2.0]
lat.pitch = [2.0, 2.0]
lat.universes = [[fuel_univ]*2]*2
lat.outer = mod_univ
x0 = openmc.XPlane(x0=-3.0)
x1 = openmc.XPlane(x0=3.0)
y0 = openmc.YPlane(y0=-3.0)
y1 = openmc.YPlane(y0=3.0)
for s in [x0, x1, y0, y1]:
s.boundary_type = 'reflective'
c101 = openmc.Cell(cell_id=101, fill=lat, region=+x0 & -x1 & +y0 & -y1)
model.geometry.root_universe = openmc.Universe(universe_id=0, cells=(c101,))
# Settings
model.settings.batches = 5
model.settings.inactive = 0
model.settings.particles = 1000
model.settings.source = openmc.Source(space=openmc.stats.Box(
[-1, -1, -1], [1, 1, 1]))
model.settings.temperature = {'tolerance': 1000, 'multipole': True}
# Tallies
tally = openmc.Tally()
tally.nuclides = ['U235', 'O16', 'total']
tally.scores = ['total', 'fission', '(n,gamma)', 'elastic', '(n,p)']
model.tallies.append(tally)
return model
class MultipoleTestHarness(PyAPITestHarness):
def _build_inputs(self):
####################
# Materials
####################
moderator = openmc.Material(material_id=1)
moderator.set_density('g/cc', 1.0)
moderator.add_nuclide('H1', 2.0)
moderator.add_nuclide('O16', 1.0)
moderator.add_s_alpha_beta('c_H_in_H2O')
dense_fuel = openmc.Material(material_id=2)
dense_fuel.set_density('g/cc', 4.5)
dense_fuel.add_nuclide('U235', 1.0)
mats_file = openmc.Materials([moderator, dense_fuel])
mats_file.export_to_xml()
####################
# Geometry
####################
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, fill=dense_fuel, region=-r0)
c11.temperature = [500, 0, 700, 800]
c12 = openmc.Cell(cell_id=12, fill=moderator, region=+r0)
fuel_univ = openmc.Universe(universe_id=11, cells=(c11, c12))
lat = openmc.RectLattice(lattice_id=101)
lat.dimension = [2, 2]
lat.lower_left = [-2.0, -2.0]
lat.pitch = [2.0, 2.0]
lat.universes = [[fuel_univ]*2]*2
lat.outer = mod_univ
x0 = openmc.XPlane(x0=-3.0)
x1 = openmc.XPlane(x0=3.0)
y0 = openmc.YPlane(y0=-3.0)
y1 = openmc.YPlane(y0=3.0)
for s in [x0, x1, y0, y1]:
s.boundary_type = 'reflective'
c101 = openmc.Cell(cell_id=101, fill=lat, region=+x0 & -x1 & +y0 & -y1)
root_univ = openmc.Universe(universe_id=0, cells=(c101,))
geometry = openmc.Geometry(root_univ)
geometry.export_to_xml()
####################
# Settings
####################
sets_file = openmc.Settings()
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.temperature = {'tolerance': 1000, 'multipole': True}
sets_file.export_to_xml()
####################
# Plots
####################
plots_file = openmc.Plots()
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)
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()
def execute_test(self):
if not 'OPENMC_MULTIPOLE_LIBRARY' in os.environ:
raise RuntimeError("The 'OPENMC_MULTIPOLE_LIBRARY' environment "
@ -110,13 +80,8 @@ 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')
model = make_model()
harness = MultipoleTestHarness('statepoint.5.h5', model)
harness.main()

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

@ -25,23 +25,10 @@
</space>
</source>
<resonance_scattering>
<scatterer>
<nuclide>U238</nuclide>
<method>DBRC</method>
<E_min>1.0</E_min>
<E_max>210.0</E_max>
</scatterer>
<scatterer>
<nuclide>U235</nuclide>
<method>WCM</method>
<E_min>1.0</E_min>
<E_max>210.0</E_max>
</scatterer>
<scatterer>
<nuclide>Pu239</nuclide>
<method>ARES</method>
<E_min>1.0</E_min>
<E_max>210.0</E_max>
</scatterer>
<enable>true</enable>
<method>ares</method>
<energy_min>1.0</energy_min>
<energy_max>210.0</energy_max>
<nuclides>U238 U235 Pu239</nuclides>
</resonance_scattering>
</settings>

View file

@ -1,2 +1,2 @@
k-combined:
1.440556E+00 6.383274E-02
1.432684E+00 1.233834E-02

View file

@ -9,54 +9,43 @@ import openmc
class ResonanceScatteringTestHarness(PyAPITestHarness):
def _build_inputs(self):
# Nuclides
u238 = openmc.Nuclide('U238')
u235 = openmc.Nuclide('U235')
pu239 = openmc.Nuclide('Pu239')
h1 = openmc.Nuclide('H1')
# Materials
mat = openmc.Material(material_id=1)
mat.set_density('g/cc', 1.0)
mat.add_nuclide(u238, 1.0)
mat.add_nuclide(u235, 0.02)
mat.add_nuclide(pu239, 0.02)
mat.add_nuclide(h1, 20.0)
mat.add_nuclide('U238', 1.0)
mat.add_nuclide('U235', 0.02)
mat.add_nuclide('Pu239', 0.02)
mat.add_nuclide('H1', 20.0)
mats_file = openmc.Materials([mat])
mats_file.export_to_xml()
# Geometry
dumb_surface = openmc.XPlane(x0=100)
dumb_surface.boundary_type = 'reflective'
c1 = openmc.Cell(cell_id=1)
c1.fill = mat
c1.region = -dumb_surface
root_univ = openmc.Universe(universe_id=0)
root_univ.add_cell(c1)
geometry = openmc.Geometry()
geometry.root_universe = root_univ
dumb_surface = openmc.XPlane(x0=100, boundary_type='reflective')
c1 = openmc.Cell(cell_id=1, fill=mat, region=-dumb_surface)
root_univ = openmc.Universe(universe_id=0, cells=[c1])
geometry = openmc.Geometry(root_univ)
geometry.export_to_xml()
# Settings
res_scatt_dbrc = openmc.ResonanceScattering(u238, 'DBRC', 1.0, 210.0)
res_scatt_wcm = openmc.ResonanceScattering(u235, 'WCM', 1.0, 210.0)
res_scatt_ares = openmc.ResonanceScattering(pu239, 'ARES', 1.0, 210.0)
# Resonance elastic scattering settings
res_scat_settings = {
'enable': True,
'energy_min': 1.0,
'energy_max': 210.0,
'method': 'ares',
'nuclides': ['U238', 'U235', 'Pu239']
}
sets_file = openmc.Settings()
sets_file.batches = 10
sets_file.inactive = 5
sets_file.particles = 1000
sets_file.source = openmc.source.Source(
settings = openmc.Settings()
settings.batches = 10
settings.inactive = 5
settings.particles = 1000
settings.source = openmc.source.Source(
space=openmc.stats.Box([-4, -4, -4], [4, 4, 4]))
sets_file.resonance_scattering = [res_scatt_dbrc, res_scatt_wcm,
res_scatt_ares]
sets_file.export_to_xml()
settings.resonance_scattering = res_scat_settings
settings.export_to_xml()
if __name__ == '__main__':
harness = ResonanceScatteringTestHarness('statepoint.10.*')
harness = ResonanceScatteringTestHarness('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,179 @@ 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((model.geometry.get_all_cells()[10],
model.geometry.get_all_cells()[21],
22, 23))] # Test both Cell objects and ids
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((model.geometry.get_materials_by_name('UOX fuel')[0],
model.geometry.get_materials_by_name('Zircaloy')[0],
3, 4))] # Test both Material objects and ids
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((model.geometry.get_all_universes()[1],
model.geometry.get_all_universes()[2],
3, 4, 6, 8))] # Test both Universe objects and ids
universe_tally.scores = ['total']
cell_filter = CellFilter((model.geometry.get_all_cells()[10],
model.geometry.get_all_cells()[21],
22, 23, 60)) # Test both Cell objects and ids
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()

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.15.*', True)
harness = TestHarness('statepoint.15.h5')
harness.main()

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