Merge pull request #1947 from pshriwise/ww-final-tests

Weight windows final push
This commit is contained in:
Paul Romano 2022-01-19 09:13:07 -06:00 committed by GitHub
commit 72af700ffd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 2244 additions and 18 deletions

View file

@ -1,13 +1,23 @@
from contextlib import contextmanager
import os
from shutil import copy
import tempfile
@contextmanager
def cdtemp():
"""Context manager to change to/return from a tmpdir."""
def cdtemp(files=None):
"""Context manager to change to/return from a tmpdir.
Parameters
----------
files : Iterable of str or Path-like
Set of files to copy into the temporary directory
"""
with tempfile.TemporaryDirectory() as tmpdir:
cwd = os.getcwd()
if files:
for file in files:
copy(file, tmpdir, follow_symlinks=True)
try:
os.chdir(tmpdir)
yield

View file

@ -0,0 +1 @@

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
c77af605fb23bc3f03bb304b82cc2d0d9efe7826167f43202fa0ecba17e6a77fc1a91bf9f4b23f175ae98c04c69067bffb96d7d68e30a126f5fa7c0080ea8367

View file

@ -0,0 +1,110 @@
from copy import deepcopy
import pytest
import numpy as np
import openmc
from openmc.stats import Discrete, Point
from tests.testing_harness import HashedPyAPITestHarness
@pytest.fixture
def model():
model = openmc.Model()
# materials (M4 steel alloy)
m4 = openmc.Material()
m4.set_density('g/cc', 2.3)
m4.add_nuclide('H1', 0.168018676)
m4.add_nuclide("H2", 1.93244e-05)
m4.add_nuclide("O16", 0.561814465)
m4.add_nuclide("O17", 0.00021401)
m4.add_nuclide("Na23", 0.021365)
m4.add_nuclide("Al27", 0.021343)
m4.add_nuclide("Si28", 0.187439342)
m4.add_nuclide("Si29", 0.009517714)
m4.add_nuclide("Si30", 0.006273944)
m4.add_nuclide("Ca40", 0.018026179)
m4.add_nuclide("Ca42", 0.00012031)
m4.add_nuclide("Ca43", 2.51033e-05)
m4.add_nuclide("Ca44", 0.000387892)
m4.add_nuclide("Ca46", 7.438e-07)
m4.add_nuclide("Ca48", 3.47727e-05)
m4.add_nuclide("Fe54", 0.000248179)
m4.add_nuclide("Fe56", 0.003895875)
m4.add_nuclide("Fe57", 8.99727e-05)
m4.add_nuclide("Fe58", 1.19737e-05)
s0 = openmc.Sphere(r=240)
s1 = openmc.Sphere(r=250, boundary_type='vacuum')
c0 = openmc.Cell(fill=m4, region=-s0)
c1 = openmc.Cell(region=+s0 & -s1)
model.geometry = openmc.Geometry([c0, c1])
# settings
settings = model.settings
settings.run_mode = 'fixed source'
settings.particles = 200
settings.batches = 2
settings.max_splits = 200
settings.photon_transport = True
space = Point((0.001, 0.001, 0.001))
energy = Discrete([14E6], [1.0])
settings.source = openmc.Source(space=space, energy=energy)
# tally
mesh = openmc.RegularMesh()
mesh.lower_left = (-240, -240, -240)
mesh.upper_right = (240, 240, 240)
mesh.dimension = (5, 10, 15)
mesh_filter = openmc.MeshFilter(mesh)
e_bnds = [0.0, 0.5, 2E7]
energy_filter = openmc.EnergyFilter(e_bnds)
particle_filter = openmc.ParticleFilter(['neutron', 'photon'])
tally = openmc.Tally()
tally.filters = [mesh_filter, energy_filter, particle_filter]
tally.scores = ['flux']
model.tallies.append(tally)
# weight windows
# load pre-generated weight windows
# (created using the same tally as above)
ww_n_lower_bnds = np.loadtxt('ww_n.txt')
ww_p_lower_bnds = np.loadtxt('ww_p.txt')
# create a mesh matching the one used
# to generate the weight windows
ww_mesh = openmc.RegularMesh()
ww_mesh.lower_left = (-240, -240, -240)
ww_mesh.upper_right = (240, 240, 240)
ww_mesh.dimension = (5, 6, 7)
ww_n = openmc.WeightWindows(ww_mesh,
ww_n_lower_bnds,
None,
10.0,
e_bnds)
ww_p = openmc.WeightWindows(ww_mesh,
ww_p_lower_bnds,
None,
10.0,
e_bnds)
model.settings.weight_windows = [ww_n, ww_p]
return model
def test_weightwindows(model):
test = HashedPyAPITestHarness('statepoint.2.h5', model)
test.main()

View file

@ -0,0 +1,420 @@
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
7.695031155172815952e-14
-1.000000000000000000e+00
7.476545089278482294e-06
-1.000000000000000000e+00
2.161215042522170282e-06
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.136040178434497494e-18
-1.000000000000000000e+00
1.345534130616238158e-05
-1.000000000000000000e+00
3.353295403842037074e-05
-1.000000000000000000e+00
3.016075845432365699e-07
-1.000000000000000000e+00
1.026243155073153453e-13
-1.000000000000000000e+00
1.685921961405802360e-19
-1.000000000000000000e+00
3.853097455417877125e-06
-1.000000000000000000e+00
4.354946981329799215e-05
-1.000000000000000000e+00
7.002861620919231721e-08
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.620506488302619488e-11
-1.000000000000000000e+00
1.704166922479738429e-09
-1.000000000000000000e+00
1.874782466747863741e-14
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
5.619835883512352867e-14
-1.000000000000000000e+00
1.951356547084204088e-15
-1.000000000000000000e+00
8.481761456712739755e-10
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.450826207325665860e-13
-1.000000000000000000e+00
4.109066205029878035e-05
-1.000000000000000000e+00
2.057318145024078612e-04
-1.000000000000000000e+00
2.124999182004654892e-05
-1.000000000000000000e+00
5.537915413446233643e-08
-1.000000000000000000e+00
1.555045595917848555e-06
-1.000000000000000000e+00
7.213722022489493227e-04
-1.000000000000000000e+00
7.673145137236566868e-03
-1.000000000000000000e+00
8.175033526488423340e-04
-1.000000000000000000e+00
1.008394964750946906e-06
-1.000000000000000000e+00
6.848642863465584904e-07
-1.000000000000000000e+00
1.073708183250235556e-03
-1.000000000000000000e+00
7.197662162700776967e-03
-1.000000000000000000e+00
7.151459162818185784e-04
-1.000000000000000000e+00
2.253382683081525085e-06
-1.000000000000000000e+00
1.318156235244509166e-10
-1.000000000000000000e+00
1.938470818929409920e-05
-1.000000000000000000e+00
4.602961711512755646e-04
-1.000000000000000000e+00
2.562906833044621533e-05
-1.000000000000000000e+00
5.504813693036932910e-12
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
3.316482534950376351e-16
-1.000000000000000000e+00
3.937160538176268057e-07
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.517291205731239772e-14
-1.000000000000000000e+00
6.315154082213375425e-07
-1.000000000000000000e+00
3.855884234344844889e-06
-1.000000000000000000e+00
1.777013641125591191e-05
-1.000000000000000000e+00
1.642149199375171522e-11
-1.000000000000000000e+00
5.976538141107809983e-06
-1.000000000000000000e+00
1.959411999677113103e-03
-1.000000000000000000e+00
1.333061985337931354e-02
-1.000000000000000000e+00
1.795061316935990395e-03
-1.000000000000000000e+00
2.430637569372220458e-06
-1.000000000000000000e+00
6.922231352729155390e-05
-1.000000000000000000e+00
8.657573566388353237e-02
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
8.356487100743359431e-02
-1.000000000000000000e+00
1.641903115049591277e-04
-1.000000000000000000e+00
9.031085518264690009e-05
-1.000000000000000000e+00
8.488729673818780352e-02
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
8.288806458368344621e-02
-1.000000000000000000e+00
5.694959706678497628e-05
-1.000000000000000000e+00
8.037131813528500897e-07
-1.000000000000000000e+00
1.663712654332187308e-03
-1.000000000000000000e+00
1.664109232689093068e-02
-1.000000000000000000e+00
1.832759343760799985e-03
-1.000000000000000000e+00
6.542700644645626997e-07
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
6.655926357459274907e-08
-1.000000000000000000e+00
5.783974359937856763e-06
-1.000000000000000000e+00
2.679340942769232109e-06
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.104060901286513389e-05
-1.000000000000000000e+00
2.928209794781622450e-05
-1.000000000000000000e+00
1.284759166582201940e-05
-1.000000000000000000e+00
1.009290508315880392e-11
-1.000000000000000000e+00
1.322801376552501482e-05
-1.000000000000000000e+00
7.136750029575815620e-03
-1.000000000000000000e+00
6.539005235506369085e-02
-1.000000000000000000e+00
6.480331412016533503e-03
-1.000000000000000000e+00
2.601178739391680563e-06
-1.000000000000000000e+00
8.887234042637683843e-05
-1.000000000000000000e+00
5.000000000000000000e-01
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
4.877856021170283163e-01
-1.000000000000000000e+00
1.769985835774446302e-04
-1.000000000000000000e+00
1.670700632870335029e-04
-1.000000000000000000e+00
4.899999304038166192e-01
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
4.857384221387814338e-01
-1.000000000000000000e+00
2.153456869915780514e-04
-1.000000000000000000e+00
7.842896894949250204e-06
-1.000000000000000000e+00
6.379065450759913505e-03
-1.000000000000000000e+00
6.550426960512012453e-02
-1.000000000000000000e+00
6.639379668946672301e-03
-1.000000000000000000e+00
7.754700849337902260e-06
-1.000000000000000000e+00
2.720743316579670241e-11
-1.000000000000000000e+00
5.985108617124988932e-06
-1.000000000000000000e+00
3.634644995026691954e-05
-1.000000000000000000e+00
3.932389299316284718e-06
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.271128669411294917e-07
-1.000000000000000000e+00
8.846493399850662704e-06
-1.000000000000000000e+00
2.499931357628383163e-07
-1.000000000000000000e+00
8.533030345699353466e-17
-1.000000000000000000e+00
1.669925427773410862e-06
-1.000000000000000000e+00
1.754138009689378778e-03
-1.000000000000000000e+00
1.514897842827161306e-02
-1.000000000000000000e+00
1.627979455242757438e-03
-1.000000000000000000e+00
2.380955631371225994e-06
-1.000000000000000000e+00
2.164891804046736287e-05
-1.000000000000000000e+00
8.339317973815890683e-02
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
8.285899874014539257e-02
-1.000000000000000000e+00
2.762955748645507000e-05
-1.000000000000000000e+00
5.116174051620571477e-05
-1.000000000000000000e+00
8.095280568305474045e-02
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
8.636569925236790846e-02
-1.000000000000000000e+00
3.452537179033895228e-05
-1.000000000000000000e+00
3.598103176641614321e-06
-1.000000000000000000e+00
1.570829313580840913e-03
-1.000000000000000000e+00
1.621821782442112170e-02
-1.000000000000000000e+00
1.544782399547004175e-03
-1.000000000000000000e+00
7.989579285134733983e-06
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.594951085377587857e-06
-1.000000000000000000e+00
4.323138781337962887e-05
-1.000000000000000000e+00
6.948292975998465777e-07
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.446945600849361415e-09
-1.000000000000000000e+00
9.041149893307805599e-07
-1.000000000000000000e+00
2.206099258062212484e-11
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.681305446488883933e-11
-1.000000000000000000e+00
7.091263906557290927e-05
-1.000000000000000000e+00
2.746424406288768276e-04
-1.000000000000000000e+00
1.285845570921339974e-05
-1.000000000000000000e+00
2.029521362171670568e-09
-1.000000000000000000e+00
1.291182719850037242e-08
-1.000000000000000000e+00
9.127050763987511325e-04
-1.000000000000000000e+00
7.385384405891665810e-03
-1.000000000000000000e+00
1.001943240150808675e-03
-1.000000000000000000e+00
1.080711295768550941e-05
-1.000000000000000000e+00
8.020767115181573972e-07
-1.000000000000000000e+00
9.252532821720597109e-04
-1.000000000000000000e+00
7.188410694198127913e-03
-1.000000000000000000e+00
7.245451610090619275e-04
-1.000000000000000000e+00
2.515735579020177281e-07
-1.000000000000000000e+00
1.482521919913335348e-12
-1.000000000000000000e+00
4.756872959630257218e-05
-1.000000000000000000e+00
2.668579837809080925e-04
-1.000000000000000000e+00
2.822627694453269613e-05
-1.000000000000000000e+00
5.182269672663266089e-10
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.936268747135548187e-14
-1.000000000000000000e+00
2.544728124173036570e-07
-1.000000000000000000e+00
3.898416671385980035e-08
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.639268952045578987e-10
-1.000000000000000000e+00
3.705151822008388643e-06
-1.000000000000000000e+00
1.133362760482367266e-09
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.229674726063540458e-06
-1.000000000000000000e+00
7.962899789920809096e-06
-1.000000000000000000e+00
8.211982683649991481e-09
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.563965686625045276e-06
-1.000000000000000000e+00
2.248761782893832567e-05
-1.000000000000000000e+00
3.279904588337207471e-06
-1.000000000000000000e+00
4.076762579823379031e-17
-1.000000000000000000e+00
1.547676923757129466e-14
-1.000000000000000000e+00
1.030567269874565733e-11
-1.000000000000000000e+00
1.957092814065688094e-05
-1.000000000000000000e+00
3.852324755037881526e-12
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.769723317139941641e-13
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00

View file

@ -0,0 +1,420 @@
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
5.447493368067179064e-10
-1.000000000000000000e+00
4.040462614734400249e-13
-1.000000000000000000e+00
9.382800796426366364e-17
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
5.752120832330885919e-11
-1.000000000000000000e+00
3.520674728719278012e-05
-1.000000000000000000e+00
8.760419353035269667e-05
-1.000000000000000000e+00
3.136829920007008993e-05
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
4.233410073487771971e-06
-1.000000000000000000e+00
2.551963224311764450e-04
-1.000000000000000000e+00
4.777967757842694024e-04
-1.000000000000000000e+00
3.598354799974066488e-04
-1.000000000000000000e+00
4.625859206051786618e-07
-1.000000000000000000e+00
4.587143797469485258e-08
-1.000000000000000000e+00
1.291843367759397518e-04
-1.000000000000000000e+00
4.695895684632649786e-04
-1.000000000000000000e+00
8.862760180332873163e-05
-1.000000000000000000e+00
3.279091474401153391e-06
-1.000000000000000000e+00
1.151457911727229161e-10
-1.000000000000000000e+00
2.295071617064146262e-05
-1.000000000000000000e+00
6.922962992428139458e-05
-1.000000000000000000e+00
2.160655073217069276e-05
-1.000000000000000000e+00
2.617878055106949035e-16
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.722191123879781983e-08
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.123498061876322157e-13
-1.000000000000000000e+00
1.462884795971722476e-05
-1.000000000000000000e+00
2.777791741571173956e-05
-1.000000000000000000e+00
9.533806586698390583e-06
-1.000000000000000000e+00
1.078687446476880940e-14
-1.000000000000000000e+00
3.057105085570708401e-06
-1.000000000000000000e+00
8.231482263927564300e-04
-1.000000000000000000e+00
3.881102561422505696e-03
-1.000000000000000000e+00
1.229730308180539307e-03
-1.000000000000000000e+00
4.684235088236766580e-05
-1.000000000000000000e+00
1.675799759004882713e-04
-1.000000000000000000e+00
1.172471437684818700e-02
-1.000000000000000000e+00
6.827568359008943932e-02
-1.000000000000000000e+00
1.144038101286408600e-02
-1.000000000000000000e+00
3.782322077390032930e-04
-1.000000000000000000e+00
5.098747893974247782e-05
-1.000000000000000000e+00
1.208261392046878005e-02
-1.000000000000000000e+00
6.428782790571178907e-02
-1.000000000000000000e+00
1.129470856680416663e-02
-1.000000000000000000e+00
8.168081568291806404e-05
-1.000000000000000000e+00
2.347504827875979927e-05
-1.000000000000000000e+00
8.787411098754914583e-04
-1.000000000000000000e+00
5.151329213225949548e-03
-1.000000000000000000e+00
1.102802039050768210e-03
-1.000000000000000000e+00
1.088201101868485208e-06
-1.000000000000000000e+00
1.058825762372267240e-07
-1.000000000000000000e+00
2.704481717610955638e-05
-1.000000000000000000e+00
2.621123924679610439e-05
-1.000000000000000000e+00
2.070764852974689408e-06
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.380657778513517658e-06
-1.000000000000000000e+00
1.007700972669126494e-04
-1.000000000000000000e+00
4.313097771132341687e-04
-1.000000000000000000e+00
1.335621430311087867e-04
-1.000000000000000000e+00
3.792209399652395984e-06
-1.000000000000000000e+00
2.205797076162476780e-04
-1.000000000000000000e+00
1.884234453311008084e-02
-1.000000000000000000e+00
1.151012001392641704e-01
-1.000000000000000000e+00
1.825795827020864834e-02
-1.000000000000000000e+00
2.084830922016203648e-04
-1.000000000000000000e+00
1.333255443748032664e-03
-1.000000000000000000e+00
4.931708164307664344e-01
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
4.899952354672477139e-01
-1.000000000000000000e+00
1.495703328116801227e-03
-1.000000000000000000e+00
1.550036616828060930e-03
-1.000000000000000000e+00
4.897735047310072254e-01
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
5.000000000000000000e-01
-1.000000000000000000e+00
1.107679609210218599e-03
-1.000000000000000000e+00
2.792896409558744781e-04
-1.000000000000000000e+00
1.721806295736377085e-02
-1.000000000000000000e+00
1.189125124490693353e-01
-1.000000000000000000e+00
1.904070707116530328e-02
-1.000000000000000000e+00
1.732952862815292309e-04
-1.000000000000000000e+00
4.670673837764873805e-08
-1.000000000000000000e+00
1.263753469561097525e-04
-1.000000000000000000e+00
2.705205429838525473e-04
-1.000000000000000000e+00
1.497958445994315019e-04
-1.000000000000000000e+00
3.247830168002185438e-08
-1.000000000000000000e+00
7.239087311622818554e-08
-1.000000000000000000e+00
4.669378458601891341e-04
-1.000000000000000000e+00
1.537590300149361015e-03
-1.000000000000000000e+00
2.368681880710174145e-04
-1.000000000000000000e+00
8.616027294555461632e-07
-1.000000000000000000e+00
2.362355168421952122e-04
-1.000000000000000000e+00
5.708498338352203244e-02
-1.000000000000000000e+00
4.237271368372501623e-01
-1.000000000000000000e+00
5.490281661912204542e-02
-1.000000000000000000e+00
3.000232638838324392e-04
-1.000000000000000000e+00
2.329540159600531311e-03
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.784732930735042255e-03
-1.000000000000000000e+00
3.432919201293736875e-03
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
2.672923773363389179e-03
-1.000000000000000000e+00
3.182108781955477806e-04
-1.000000000000000000e+00
5.639071613735578692e-02
-1.000000000000000000e+00
4.346984808472855177e-01
-1.000000000000000000e+00
5.500108683629956891e-02
-1.000000000000000000e+00
2.417599813822804812e-04
-1.000000000000000000e+00
2.774067049392004042e-07
-1.000000000000000000e+00
3.257646134837451210e-04
-1.000000000000000000e+00
1.264833388398999524e-03
-1.000000000000000000e+00
2.981891705231208794e-04
-1.000000000000000000e+00
4.986698316296506713e-06
-1.000000000000000000e+00
3.419181071650815928e-06
-1.000000000000000000e+00
1.081445276486055809e-04
-1.000000000000000000e+00
6.934466049804711161e-04
-1.000000000000000000e+00
2.510674100806631662e-04
-1.000000000000000000e+00
5.515522196186722918e-06
-1.000000000000000000e+00
1.424205319552986396e-04
-1.000000000000000000e+00
1.854111290797000322e-02
-1.000000000000000000e+00
1.236406932635011752e-01
-1.000000000000000000e+00
1.760297107458398680e-02
-1.000000000000000000e+00
2.130582646223859260e-04
-1.000000000000000000e+00
1.501650004537408200e-03
-1.000000000000000000e+00
4.903495510314233030e-01
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
4.952432605379828989e-01
-1.000000000000000000e+00
1.769327994909421784e-03
-1.000000000000000000e+00
9.304497896205120647e-04
-1.000000000000000000e+00
4.873897581604286766e-01
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
4.981497862127627907e-01
-1.000000000000000000e+00
1.127334097206107765e-03
-1.000000000000000000e+00
1.412615360326509664e-04
-1.000000000000000000e+00
1.729816946709781048e-02
-1.000000000000000000e+00
1.181916566651922268e-01
-1.000000000000000000e+00
1.780262484403568810e-02
-1.000000000000000000e+00
1.319677450153934042e-04
-1.000000000000000000e+00
2.210707325798542070e-07
-1.000000000000000000e+00
1.728787338791035720e-04
-1.000000000000000000e+00
5.197081842709918220e-04
-1.000000000000000000e+00
9.256616392487857544e-05
-1.000000000000000000e+00
1.032520710502734699e-08
-1.000000000000000000e+00
2.027381220364608057e-16
-1.000000000000000000e+00
1.225736024671247218e-05
-1.000000000000000000e+00
3.856169633708643398e-05
-1.000000000000000000e+00
1.806455099029475317e-05
-1.000000000000000000e+00
7.691527781829036254e-17
-1.000000000000000000e+00
1.298062961617926916e-05
-1.000000000000000000e+00
1.178616843705955963e-03
-1.000000000000000000e+00
4.441328419270368887e-03
-1.000000000000000000e+00
8.919466185572301909e-04
-1.000000000000000000e+00
5.272021975060514019e-06
-1.000000000000000000e+00
1.607976851421854571e-04
-1.000000000000000000e+00
1.112842419638761758e-02
-1.000000000000000000e+00
6.433819434431045647e-02
-1.000000000000000000e+00
1.095563748531924904e-02
-1.000000000000000000e+00
8.370896020975688591e-05
-1.000000000000000000e+00
2.223447159544331337e-04
-1.000000000000000000e+00
1.102706140784315975e-02
-1.000000000000000000e+00
6.684484191345574366e-02
-1.000000000000000000e+00
1.111302464121833623e-02
-1.000000000000000000e+00
1.255887947410807431e-04
-1.000000000000000000e+00
1.004439072885827748e-05
-1.000000000000000000e+00
8.081009012754719698e-04
-1.000000000000000000e+00
5.384625561469683769e-03
-1.000000000000000000e+00
1.146714816952060971e-03
-1.000000000000000000e+00
3.574060778841494232e-06
-1.000000000000000000e+00
2.251232708364186507e-10
-1.000000000000000000e+00
6.717625881826167172e-05
-1.000000000000000000e+00
6.949587369646497293e-05
-1.000000000000000000e+00
2.909334597507522605e-05
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
8.582011716859218622e-15
-1.000000000000000000e+00
8.304845400451923449e-08
-1.000000000000000000e+00
4.575723837205823402e-11
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
1.311680713303003522e-15
-1.000000000000000000e+00
2.686689485248190559e-05
-1.000000000000000000e+00
4.316605279989737501e-05
-1.000000000000000000e+00
6.401055165502384025e-06
-1.000000000000000000e+00
5.726152701849347207e-16
-1.000000000000000000e+00
8.541606727879512040e-07
-1.000000000000000000e+00
2.029396545382813118e-04
-1.000000000000000000e+00
4.299195570308034968e-04
-1.000000000000000000e+00
8.544159282151438236e-05
-1.000000000000000000e+00
1.099532245627738225e-06
-1.000000000000000000e+00
1.289814511028014912e-06
-1.000000000000000000e+00
1.104204785730725317e-04
-1.000000000000000000e+00
6.870228272606287295e-04
-1.000000000000000000e+00
1.399807456616496116e-04
-1.000000000000000000e+00
4.279460329782799377e-09
-1.000000000000000000e+00
1.290717169529484602e-13
-1.000000000000000000e+00
1.925724800911436302e-05
-1.000000000000000000e+00
9.332371598523186474e-05
-1.000000000000000000e+00
1.310633551813380206e-05
-1.000000000000000000e+00
6.574706543646946099e-16
-1.000000000000000000e+00
-1.000000000000000000e+00
-1.000000000000000000e+00
3.827053602579980514e-15
-1.000000000000000000e+00
2.101790478097516960e-09
-1.000000000000000000e+00
9.904481358675477728e-13
-1.000000000000000000e+00
-1.000000000000000000e+00

View file

@ -0,0 +1,194 @@
import os
from pathlib import Path
import numpy as np
import pytest
from uncertainties import ufloat
import openmc
from openmc.stats import Discrete, Point
from tests import cdtemp
@pytest.fixture
def model():
openmc.reset_auto_ids()
model = openmc.Model()
# materials (M4 steel alloy)
m4 = openmc.Material()
m4.set_density('g/cc', 2.3)
m4.add_nuclide('H1', 0.168018676)
m4.add_nuclide("H2", 1.93244e-05)
m4.add_nuclide("O16", 0.561814465)
m4.add_nuclide("O17", 0.00021401)
m4.add_nuclide("Na23", 0.021365)
m4.add_nuclide("Al27", 0.021343)
m4.add_nuclide("Si28", 0.187439342)
m4.add_nuclide("Si29", 0.009517714)
m4.add_nuclide("Si30", 0.006273944)
m4.add_nuclide("Ca40", 0.018026179)
m4.add_nuclide("Ca42", 0.00012031)
m4.add_nuclide("Ca43", 2.51033e-05)
m4.add_nuclide("Ca44", 0.000387892)
m4.add_nuclide("Ca46", 7.438e-07)
m4.add_nuclide("Ca48", 3.47727e-05)
m4.add_nuclide("Fe54", 0.000248179)
m4.add_nuclide("Fe56", 0.003895875)
m4.add_nuclide("Fe57", 8.99727e-05)
m4.add_nuclide("Fe58", 1.19737e-05)
s0 = openmc.Sphere(r=240)
s1 = openmc.Sphere(r=250, boundary_type='vacuum')
c0 = openmc.Cell(fill=m4, region=-s0)
c1 = openmc.Cell(region=+s0 & -s1)
model.geometry = openmc.Geometry([c0, c1])
# settings
settings = model.settings
settings.run_mode = 'fixed source'
settings.particles = 500
settings.batches = 2
settings.max_splits = 100
settings.photon_transport = True
space = Point((0.001, 0.001, 0.001))
energy = Discrete([14E6], [1.0])
settings.source = openmc.Source(space=space, energy=energy)
# tally
mesh = openmc.RegularMesh()
mesh.lower_left = (-240, -240, -240)
mesh.upper_right = (240, 240, 240)
mesh.dimension = (3, 5, 7)
mesh_filter = openmc.MeshFilter(mesh)
e_bnds = [0.0, 0.5, 2E7]
energy_filter = openmc.EnergyFilter(e_bnds)
particle_filter = openmc.ParticleFilter(['neutron', 'photon'])
tally = openmc.Tally()
tally.filters = [mesh_filter, energy_filter, particle_filter]
tally.scores = ['flux']
model.tallies.append(tally)
return model
def test_weightwindows(model):
ww_files = ('ww_n.txt', 'ww_p.txt')
cwd = Path(__file__).parent.absolute()
filepaths = [cwd / Path(f) for f in ww_files]
with cdtemp(filepaths):
# run once with variance reduction off
model.settings.weight_windows_on = False
analog_sp = model.run()
os.rename(analog_sp, 'statepoint.analog.h5')
# weight windows
# load pre-generated weight windows
# (created using the same tally as above)
ww_n_lower_bnds = np.loadtxt('ww_n.txt')
ww_p_lower_bnds = np.loadtxt('ww_p.txt')
# create a mesh matching the one used
# to generate the weight windows
ww_mesh = openmc.RegularMesh()
ww_mesh.lower_left = (-240, -240, -240)
ww_mesh.upper_right = (240, 240, 240)
ww_mesh.dimension = (5, 6, 7)
# energy bounds matching those of the
# generated weight windows
e_bnds = [0.0, 0.5, 2E7]
ww_n = openmc.WeightWindows(ww_mesh,
ww_n_lower_bnds,
None,
10.0,
e_bnds,
survival_ratio=1.01)
ww_p = openmc.WeightWindows(ww_mesh,
ww_p_lower_bnds,
None,
10.0,
e_bnds,
survival_ratio=1.01)
model.settings.weight_windows = [ww_n, ww_p]
# run again with variance reduction on
model.settings.weight_windows_on = True
ww_sp = model.run()
os.rename(ww_sp, 'statepoint.ww.h5')
# load both statepoints and examine results
asp = openmc.StatePoint('statepoint.analog.h5')
wsp = openmc.StatePoint('statepoint.ww.h5')
analog_tally = asp.tallies[1]
ww_tally = wsp.tallies[1]
def compare_results(particle, analog_tally, ww_tally):
# get values from each of the tallies
an_mean = analog_tally.get_values(filters=[openmc.ParticleFilter],
filter_bins=[(particle,)])
ww_mean = ww_tally.get_values(filters=[openmc.ParticleFilter],
filter_bins=[(particle,)])
# expect that more bins were scored with weight windows than
# the analog run
assert np.count_nonzero(an_mean) < np.count_nonzero(ww_mean)
an_rel_err = analog_tally.get_values(filters=[openmc.ParticleFilter],
filter_bins=[(particle,)],
value='rel_err')
ww_rel_err = ww_tally.get_values(filters=[openmc.ParticleFilter],
filter_bins=[(particle,)],
value='rel_err')
an_rel_err[an_mean == 0.0] = 1.0
ww_rel_err[ww_mean == 0.0] = 1.0
an_avg_rel_err = np.mean(an_rel_err)
ww_avg_rel_err = np.mean(ww_rel_err)
# expect that the average relative error in the tally
# decreases
assert an_avg_rel_err > ww_avg_rel_err
# ensure that the value of the mesh bin containing the
# source is statistically similar in both runs
an_std_dev = analog_tally.get_values(filters=[openmc.ParticleFilter],
filter_bins=[(particle,)],
value='std_dev')
ww_std_dev = ww_tally.get_values(filters=[openmc.ParticleFilter],
filter_bins=[(particle,)],
value='std_dev')
# index of the mesh bin containing the source for the higher
# energy group
source_bin_idx = (an_mean.shape[0]//2, 0, 0)
an_source_bin = ufloat(an_mean[source_bin_idx],
an_std_dev[source_bin_idx])
ww_source_bin = ufloat(ww_mean[source_bin_idx],
ww_std_dev[source_bin_idx])
diff = an_source_bin - ww_source_bin
# check that values are within two combined standard deviations
assert abs(diff.nominal_value) / diff.std_dev < 2.0
compare_results('neutron', analog_tally, ww_tally)
compare_results('photon', analog_tally, ww_tally)

View file

@ -0,0 +1 @@
../../regression_tests/weightwindows/ww_n.txt

View file

@ -0,0 +1 @@
../../regression_tests/weightwindows/ww_p.txt