Add test cases

This commit is contained in:
Shikhar Kumar 2021-02-09 16:13:55 -05:00
parent ee077b4d61
commit b4e00b7324
9 changed files with 825 additions and 1 deletions

View file

@ -141,6 +141,31 @@ def test_cmfd_feed():
harness = CMFDTestHarness('statepoint.20.h5', cmfd_run)
harness.main()
def test_cmfd_feed_rectlin():
"""Test 1 group CMFD solver with CMFD feedback"""
# Initialize and set CMFD mesh
cmfd_mesh = cmfd.CMFDMesh()
cmfd_mesh.mesh_type = 'rectilinear'
x_grid = np.linspace(-10, 10, 11)
y_grid = [-1., 1.]
z_grid = [-1., 1.]
cmfd_mesh.grid = [x_grid, y_grid, z_grid]
cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0)
# Initialize and run CMFDRun object
cmfd_run = cmfd.CMFDRun()
cmfd_run.mesh = cmfd_mesh
cmfd_run.tally_begin = 5
cmfd_run.solver_begin = 5
cmfd_run.display = {'dominance': True}
cmfd_run.feedback = True
cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20]
cmfd_run.run()
# Initialize and run CMFD test harness
harness = CMFDTestHarness('statepoint.20.h5', cmfd_run)
harness.main()
def test_cmfd_multithread():
"""Test 1 group CMFD solver with all available threads"""
# Initialize and set CMFD mesh

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<geometry>
<!-- Definition of Cells -->
<cell id="1">
<universe>0</universe>
<region>-1 2 -3 4 -5 6</region>
<material>1</material>
</cell>
<!-- Defition of Surfaces -->
<surface id="1">
<type>x-plane</type>
<coeffs>10</coeffs>
<boundary> vacuum </boundary>
</surface>
<surface id="2">
<type>x-plane</type>
<coeffs>-10</coeffs>
<boundary> vacuum </boundary>
</surface>
<surface id="3">
<type>y-plane</type>
<coeffs>1</coeffs>
<boundary>reflective</boundary>
</surface>
<surface id="4">
<type>y-plane</type>
<coeffs>-1</coeffs>
<boundary>reflective</boundary>
</surface>
<surface id="5">
<type>z-plane</type>
<coeffs>1</coeffs>
<boundary>reflective</boundary>
</surface>
<surface id="6">
<type>z-plane</type>
<coeffs>-1</coeffs>
<boundary>reflective</boundary>
</surface>
</geometry>

View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<materials>
<!-- Definition of materials -->
<material id="1">
<density value="19" units="g/cc" />
<nuclide name="U235" wo="0.21" />
<nuclide name="U238" wo="0.68" />
<nuclide name="O16" wo="0.11" />
</material>
</materials>

View file

@ -0,0 +1,636 @@
k-combined:
1.157187E+00 1.636299E-02
tally 1:
1.105119E+01
1.225764E+01
2.005562E+01
4.044077E+01
2.763651E+01
7.659204E+01
3.350385E+01
1.124748E+02
3.708973E+01
1.378980E+02
3.819687E+01
1.461904E+02
3.563815E+01
1.272689E+02
2.951618E+01
8.720253E+01
2.110567E+01
4.462562E+01
1.177125E+01
1.391704E+01
tally 2:
8.413458E+00
3.600701E+00
5.811221E+00
1.720423E+00
3.152237E+01
4.997128E+01
2.209153E+01
2.455911E+01
2.181469E+01
2.395139E+01
1.541498E+01
1.196916E+01
5.445894E+01
1.490652E+02
3.866629E+01
7.523403E+01
3.282600E+01
5.400949E+01
2.342806E+01
2.753117E+01
7.081101E+01
2.514150E+02
5.036626E+01
1.272409E+02
3.737870E+01
7.016018E+01
2.659096E+01
3.553255E+01
3.782640E+01
7.182993E+01
2.699064E+01
3.660686E+01
7.361578E+01
2.717788E+02
5.234377E+01
1.374393E+02
3.428621E+01
5.895928E+01
2.449124E+01
3.009739E+01
5.922017E+01
1.756748E+02
4.200257E+01
8.838800E+01
2.336382E+01
2.740967E+01
1.658498E+01
1.382335E+01
3.297049E+01
5.456989E+01
2.339783E+01
2.749345E+01
8.828373E+00
3.943974E+00
6.102413E+00
1.883966E+00
tally 3:
5.596852E+00
1.598537E+00
3.522058E-01
6.713731E-03
2.126148E+01
2.274990E+01
1.422059E+00
1.023184E-01
1.486366E+01
1.113118E+01
9.672994E-01
4.841756E-02
3.718151E+01
6.959813E+01
2.434965E+00
2.992672E-01
2.255899E+01
2.552453E+01
1.400193E+00
9.974367E-02
4.850275E+01
1.180150E+02
3.030061E+00
4.650085E-01
2.561202E+01
3.297554E+01
1.660808E+00
1.399354E-01
2.603551E+01
3.406292E+01
1.644980E+00
1.378019E-01
5.041383E+01
1.274936E+02
3.230209E+00
5.274516E-01
2.357275E+01
2.788910E+01
1.519553E+00
1.172908E-01
4.043162E+01
8.190810E+01
2.584619E+00
3.376865E-01
1.598070E+01
1.283439E+01
1.032328E+00
5.432257E-02
2.254607E+01
2.553039E+01
1.449211E+00
1.061279E-01
5.871759E+00
1.744573E+00
3.943129E-01
8.103936E-03
tally 4:
3.066217E+00
4.730450E-01
0.000000E+00
0.000000E+00
1.360953E+00
9.533513E-02
4.308283E+00
9.334136E-01
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
4.308283E+00
9.334136E-01
1.360953E+00
9.533513E-02
3.783652E+00
7.238359E-01
6.291955E+00
1.990579E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
6.291955E+00
1.990579E+00
3.783652E+00
7.238359E-01
4.885573E+00
1.200082E+00
7.106830E+00
2.535661E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
7.106830E+00
2.535661E+00
4.885573E+00
1.200082E+00
6.866283E+00
2.371554E+00
8.503237E+00
3.630917E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
8.503237E+00
3.630917E+00
6.866283E+00
2.371554E+00
7.768902E+00
3.027583E+00
9.082457E+00
4.135990E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
9.082457E+00
4.135990E+00
7.768902E+00
3.027583E+00
8.769969E+00
3.865147E+00
9.319943E+00
4.358847E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
9.319943E+00
4.358847E+00
8.769969E+00
3.865147E+00
9.325939E+00
4.366610E+00
9.435739E+00
4.466600E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
9.435739E+00
4.466600E+00
9.325939E+00
4.366610E+00
9.542810E+00
4.573627E+00
9.199847E+00
4.247714E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
9.199847E+00
4.247714E+00
9.542810E+00
4.573627E+00
9.374166E+00
4.404055E+00
8.192575E+00
3.370018E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
8.192575E+00
3.370018E+00
9.374166E+00
4.404055E+00
8.889272E+00
3.956143E+00
7.298067E+00
2.671190E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
7.298067E+00
2.671190E+00
8.889272E+00
3.956143E+00
7.459052E+00
2.787818E+00
5.208762E+00
1.362339E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
5.208762E+00
1.362339E+00
7.459052E+00
2.787818E+00
6.514105E+00
2.127726E+00
3.935834E+00
7.791845E-01
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
3.935834E+00
7.791845E-01
6.514105E+00
2.127726E+00
4.382888E+00
9.637493E-01
1.398986E+00
9.904821E-02
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
1.398986E+00
9.904821E-02
4.382888E+00
9.637493E-01
3.080536E+00
4.769864E-01
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
0.000000E+00
tally 5:
5.593947E+00
1.596885E+00
8.106566E-01
3.664721E-02
2.125531E+01
2.273647E+01
3.065490E+00
4.787394E-01
1.486069E+01
1.112690E+01
1.949973E+00
1.949146E-01
3.717221E+01
6.956205E+01
5.001200E+00
1.267587E+00
2.255049E+01
2.550506E+01
2.899016E+00
4.325940E-01
4.849423E+01
1.179738E+02
6.528348E+00
2.152826E+00
2.561091E+01
3.297274E+01
3.488550E+00
6.229290E-01
2.603063E+01
3.405034E+01
3.601295E+00
6.558219E-01
5.040479E+01
1.274480E+02
6.786233E+00
2.323774E+00
2.357068E+01
2.788373E+01
2.889115E+00
4.258034E-01
4.042343E+01
8.187501E+01
5.332998E+00
1.439867E+00
1.597773E+01
1.282957E+01
1.942949E+00
1.954364E-01
2.254116E+01
2.551921E+01
3.104316E+00
4.901972E-01
5.869140E+00
1.742897E+00
9.010904E-01
4.316080E-02
cmfd indices
1.400000E+01
1.000000E+00
1.000000E+00
1.000000E+00
k cmfd
1.175888E+00
1.173169E+00
1.178686E+00
1.169259E+00
1.159624E+00
1.161905E+00
1.150366E+00
1.156936E+00
1.152230E+00
1.158120E+00
1.151832E+00
1.156090E+00
1.156076E+00
1.159749E+00
1.159483E+00
1.159617E+00
cmfd entropy
3.585755E+00
3.588829E+00
3.591601E+00
3.596486E+00
3.598552E+00
3.600536E+00
3.606024E+00
3.602025E+00
3.603625E+00
3.601073E+00
3.602144E+00
3.601031E+00
3.603146E+00
3.603878E+00
3.602530E+00
3.603442E+00
cmfd balance
5.69096E-03
5.82028E-03
5.54245E-03
3.56776E-03
2.86949E-03
2.55946E-03
2.27787E-03
2.58567E-03
1.98573E-03
2.01270E-03
2.15386E-03
1.88029E-03
1.65172E-03
1.50711E-03
1.28653E-03
1.19687E-03
cmfd dominance ratio
6.039E-01
6.045E-01
6.026E-01
6.050E-01
6.067E-01
6.071E-01
6.097E-01
6.060E-01
6.067E-01
6.060E-01
6.069E-01
6.056E-01
6.064E-01
6.066E-01
6.050E-01
6.052E-01
cmfd openmc source comparison
6.220816E-03
6.181852E-03
4.920765E-03
5.006176E-03
4.717371E-03
5.049855E-03
2.182449E-03
3.301480E-03
3.408666E-03
2.012317E-03
1.751563E-03
1.934989E-03
1.827288E-03
1.055350E-03
1.321006E-03
1.220975E-03
cmfd source
1.501950E-02
6.088975E-02
4.178034E-02
1.057740E-01
6.080482E-02
1.314338E-01
7.208400E-02
7.138769E-02
1.400772E-01
6.569802E-02
1.114779E-01
4.436863E-02
6.224041E-02
1.696388E-02

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<!-- Parameters for criticality calculation -->
<run_mode>eigenvalue</run_mode>
<batches>20</batches>
<inactive>10</inactive>
<particles>1000</particles>
<!-- Starting source -->
<source>
<space>
<type>box</type>
<parameters>-10 -1 -1 10 1 1</parameters>
</space>
</source>
<!-- Shannon Entropy -->
<mesh id="10">
<dimension> 10 1 1 </dimension>
<lower_left> -10.0 -1.0 -1.0 </lower_left>
<upper_right> 10.0 1.0 1.0 </upper_right>
</mesh>
<entropy_mesh>10</entropy_mesh>
</settings>

View file

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<tallies>
<mesh id="1">
<type>regular</type>
<lower_left>-10 -1 -1 </lower_left>
<upper_right>10 1 1</upper_right>
<dimension>10 1 1</dimension>
</mesh>
<filter id="1">
<type>mesh</type>
<bins>1</bins>
</filter>
<tally id="1">
<filters>1</filters>
<scores>flux</scores>
</tally>
</tallies>

View file

@ -0,0 +1,30 @@
from tests.testing_harness import CMFDTestHarness
from openmc import cmfd
import numpy as np
import scipy.sparse
def test_cmfd_feed_rectlin():
"""Test 1 group CMFD solver with CMFD feedback"""
# Initialize and set CMFD mesh
cmfd_mesh = cmfd.CMFDMesh()
cmfd_mesh.mesh_type = 'rectilinear'
x_grid = [-10., -9., -7., -6., -4., -3., -1., 0., 1., 3., 4., 6., 7., 9., 10.]
y_grid = [-1., 1.]
z_grid = [-1., 1.]
cmfd_mesh.grid = [x_grid, y_grid, z_grid]
cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0)
# Initialize and run CMFDRun object
cmfd_run = cmfd.CMFDRun()
cmfd_run.mesh = cmfd_mesh
cmfd_run.tally_begin = 5
cmfd_run.solver_begin = 5
cmfd_run.display = {'dominance': True}
cmfd_run.feedback = True
cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20]
cmfd_run.run()
# Initialize and run CMFD test harness
harness = CMFDTestHarness('statepoint.20.h5', cmfd_run)
harness.main()

View file

@ -442,7 +442,7 @@ def test_find_material(lib_init):
assert mat is openmc.lib.materials[2]
def test_mesh(lib_init):
def test_regular_mesh(lib_init):
mesh = openmc.lib.RegularMesh()
mesh.dimension = (2, 3, 4)
assert mesh.dimension == (2, 3, 4)
@ -477,6 +477,37 @@ def test_mesh(lib_init):
assert msf.mesh == mesh
def test_rectilinear_mesh(lib_init):
mesh = openmc.lib.RectilinearMesh()
x_grid = [-10., 0., 10.]
y_grid = [0., 10., 20.]
z_grid = [10., 20., 30.]
mesh.set_grid(x_grid, y_grid, z_grid)
assert np.all(mesh.lower_left == (-10., 0., 10.))
assert np.all(mesh.upper_right == (10., 20., 30.))
assert np.all(mesh.dimension == (2, 2, 2))
for i, diff_x in enumerate(np.diff(x_grid)):
for j, diff_y in enumerate(np.diff(y_grid)):
for k, diff_z in enumerate(np.diff(z_grid)):
assert np.all(mesh.width[i, j, k, :] == (10, 10, 10))
with pytest.raises(exc.AllocationError):
mesh2 = openmc.lib.RectilinearMesh(mesh.id)
meshes = openmc.lib.meshes
assert isinstance(meshes, Mapping)
assert len(meshes) == 2
mesh = meshes[mesh.id]
assert isinstance(mesh, openmc.lib.RectilinearMesh)
mf = openmc.lib.MeshFilter(mesh)
assert mf.mesh == mesh
msf = openmc.lib.MeshSurfaceFilter(mesh)
assert msf.mesh == mesh
def test_restart(lib_init, mpi_intracomm):
# Finalize and re-init to make internal state consistent with XML.
openmc.lib.hard_reset()