update mutipole tests

This commit is contained in:
liangjg 2018-08-17 14:22:25 -04:00
parent 60a88b9cab
commit 63032ba40a
3 changed files with 57 additions and 75 deletions

View file

@ -209,10 +209,6 @@ class WindowedMultipole(EqualityMixin):
def data(self):
return self._data
@property
def l_value(self):
return self._l_value
@property
def windows(self):
return self._windows
@ -228,35 +224,35 @@ class WindowedMultipole(EqualityMixin):
@spacing.setter
def spacing(self, spacing):
if spacing is not None:
check_type('spacing', spacing, Real)
check_greater_than('spacing', spacing, 0.0, equality=False)
cv.check_type('spacing', spacing, Real)
cv.check_greater_than('spacing', spacing, 0.0, equality=False)
self._spacing = spacing
@sqrtAWR.setter
def sqrtAWR(self, sqrtAWR):
if sqrtAWR is not None:
check_type('sqrtAWR', sqrtAWR, Real)
check_greater_than('sqrtAWR', sqrtAWR, 0.0, equality=False)
cv.check_type('sqrtAWR', sqrtAWR, Real)
cv.check_greater_than('sqrtAWR', sqrtAWR, 0.0, equality=False)
self._sqrtAWR = sqrtAWR
@E_min.setter
def E_min(self, E_min):
if E_min is not None:
check_type('E_min', E_min, Real)
check_greater_than('E_min', E_min, 0.0, equality=True)
cv.check_type('E_min', E_min, Real)
cv.check_greater_than('E_min', E_min, 0.0, equality=True)
self._E_min = E_min
@E_max.setter
def E_max(self, E_max):
if E_max is not None:
check_type('E_max', E_max, Real)
check_greater_than('E_max', E_max, 0.0, equality=False)
cv.check_type('E_max', E_max, Real)
cv.check_greater_than('E_max', E_max, 0.0, equality=False)
self._E_max = E_max
@data.setter
def data(self, data):
if data is not None:
check_type('data', data, np.ndarray)
cv.check_type('data', data, np.ndarray)
if len(data.shape) != 2:
raise ValueError('Multipole data arrays must be 2D')
if data.shape[1] not in (3, 4):
@ -271,7 +267,7 @@ class WindowedMultipole(EqualityMixin):
@windows.setter
def windows(self, windows):
if windows is not None:
check_type('windows', windows, np.ndarray)
cv.check_type('windows', windows, np.ndarray)
if len(windows.shape) != 2:
raise ValueError('Multipole windows arrays must be 2D')
if not np.issubdtype(windows.dtype, int):
@ -282,7 +278,7 @@ class WindowedMultipole(EqualityMixin):
@broaden_poly.setter
def broaden_poly(self, broaden_poly):
if broaden_poly is not None:
check_type('broaden_poly', broaden_poly, np.ndarray)
cv.check_type('broaden_poly', broaden_poly, np.ndarray)
if len(broaden_poly.shape) != 1:
raise ValueError('Multipole broaden_poly arrays must be 1D')
if not np.issubdtype(broaden_poly.dtype, bool):
@ -293,7 +289,7 @@ class WindowedMultipole(EqualityMixin):
@curvefit.setter
def curvefit(self, curvefit):
if curvefit is not None:
check_type('curvefit', curvefit, np.ndarray)
cv.check_type('curvefit', curvefit, np.ndarray)
if len(curvefit.shape) != 3:
raise ValueError('Multipole curvefit arrays must be 3D')
if curvefit.shape[2] not in (2, 3): # sig_s, sig_a (maybe sig_f)

View file

@ -1,36 +1,36 @@
k-combined:
1.363786E+00 1.103929E-02
1.342579E+00 1.221176E-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
3.839794E+00
2.951721E+00
2.785273E+00
1.554128E+00
5.349716E-01
5.732174E-02
4.499834E-01
4.055011E-02
0.000000E+00
0.000000E+00
2.254165E+01
1.016444E+02
2.258507E+01
1.020294E+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
6.862242E-04
9.421377E-08
2.256396E+01
1.018388E+02
1.146136E-04
3.296980E-09
3.624627E+02
2.628739E+04
2.785273E+00
1.554128E+00
2.176478E+00
9.480405E-01
3.574110E+02
2.555993E+04
1.146136E-04
3.296980E-09
Cell
ID = 11
Name =

View file

@ -3,8 +3,6 @@ import os
import numpy as np
import pytest
import openmc.data
pytestmark = pytest.mark.skipif(
'OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable must be set')
@ -18,44 +16,32 @@ def u235():
@pytest.fixture(scope='module')
def u234():
def b10():
directory = os.environ['OPENMC_MULTIPOLE_LIBRARY']
filename = os.path.join(directory, '092234.h5')
filename = os.path.join(directory, '005010.h5')
return openmc.data.WindowedMultipole.from_hdf5(filename)
@pytest.fixture(scope='module')
def fe56():
directory = os.environ['OPENMC_MULTIPOLE_LIBRARY']
filename = os.path.join(directory, '026056.h5')
return openmc.data.WindowedMultipole.from_hdf5(filename)
def test_evaluate_rm(u235):
"""Make sure a Reich-Moore multipole object can be called."""
def test_evaluate(u235):
"""Test the cross section evaluation of a library."""
energies = [1e-3, 1.0, 10.0, 50.]
total, absorption, fission = u235(energies, 0.0)
assert total[1] == pytest.approx(90.64895383)
total, absorption, fission = u235(energies, 300.0)
assert total[1] == pytest.approx(91.12534964)
scattering, absorption, fission = u235(energies, 0.0)
assert (scattering[1], absorption[1], fission[1]) == \
pytest.approx((13.09, 77.56, 67.36), rel=1e-3)
scattering, absorption, fission = u235(energies, 300.0)
assert (scattering[2], absorption[2], fission[2]) == \
pytest.approx((11.24, 21.26, 15.50), rel=1e-3)
def test_evaluate_mlbw(u234):
"""Make sure a Multi-Level Breit-Wigner multipole object can be called."""
energies = [1e-3, 1.0, 10.0, 50.]
total, absorption, fission = u234(energies, 0.0)
assert total[3] == pytest.approx(15.02827953)
total, absorption, fission = u234(energies, 300.0)
assert total[3] == pytest.approx(15.08269143)
def test_high_l(fe56):
"""Test a nuclide (Fe56) with a high l-value (4)."""
def test_evaluate_none_poles(b10):
"""Test a library with no poles, i.e., purely polynomials."""
energies = [1e-3, 1.0, 10.0, 1e3, 1e5]
total, absorption, fission = fe56(energies, 0.0)
assert total[0] == pytest.approx(25.072619556789267)
total, absorption, fission = fe56(energies, 300.0)
assert total[0] == pytest.approx(27.85535792368082)
scattering, absorption, fission = b10(energies, 0.0)
assert (scattering[0], absorption[0], fission[0]) == \
pytest.approx((2.201, 19330., 0.), rel=1e-3)
scattering, absorption, fission = b10(energies, 300.0)
assert (scattering[-1], absorption[-1], fission[-1]) == \
pytest.approx((2.878, 1.982, 0.), rel=1e-3)
def test_export_to_hdf5(tmpdir, u235):