Fixed issue where both P0 and P1 moments were displayed in the diffusion coefficient results. With this fix, the Legendre filter is successfully sliced. Also, there was previously concern that get_condensed_xs needed to be specially catered toward DiffusionCoefficient. However, since the MGXS get_condensed_xs method condenses the tallies before calculating the cross section, that should work great for DiffusionCoefficient as well. Tests updated.

This commit is contained in:
Miriam Rathbun 2021-11-16 13:58:40 -07:00
parent c8003e0243
commit e131e07948
7 changed files with 76 additions and 204 deletions

View file

@ -3127,6 +3127,32 @@ class DiffusionCoefficient(TransportXS):
@property
def rxn_rate_tally(self):
if self._rxn_rate_tally is None:
# Switch EnergyoutFilter to EnergyFilter.
p1_tally = self.tallies['scatter-1']
old_filt = p1_tally.filters[-2]
new_filt = openmc.EnergyFilter(old_filt.values)
p1_tally.filters[-2] = new_filt
# Slice Legendre expansion filter and change name of score
p1_tally = p1_tally.get_slice(filters=[openmc.LegendreFilter],
filter_bins=[('P1',)],
squeeze=True)
p1_tally._scores = ['scatter-1']
transport = self.tallies['total'] - p1_tally
self._rxn_rate_tally = transport**(-1) / 3.0
self._rxn_rate_tally.sparse = self.sparse
return self._rxn_rate_tally
@property
def xs_tally(self):
if self._xs_tally is None:
if self.tallies is None:
msg = 'Unable to get xs_tally since tallies have ' \
'not been loaded from a statepoint'
raise ValueError(msg)
# Switch EnergyoutFilter to EnergyFilter
p1_tally = self.tallies['scatter-1']
old_filt = p1_tally.filters[-2]
@ -3143,136 +3169,16 @@ class DiffusionCoefficient(TransportXS):
total_xs = self.tallies['total'] / self.tallies['flux (tracklength)']
# Compute transport correction term
trans_corr = self.tallies['scatter-1'] / self.tallies['flux (analog)']
trans_corr = p1_tally / self.tallies['flux (analog)']
# Compute the diffusion coefficient
transport = total_xs - trans_corr
dif_coef = transport**(-1) / 3.0
self._rxn_rate_tally = dif_coef * self.tallies['flux (tracklength)']
self._rxn_rate_tally.sparse = self.sparse
return self._rxn_rate_tally
@property
def xs_tally(self):
if self._xs_tally is None:
if self.tallies is None:
msg = 'Unable to get xs_tally since tallies have ' \
'not been loaded from a statepoint'
raise ValueError(msg)
self._xs_tally = self.rxn_rate_tally / self.tallies['flux (tracklength)']
diff_coef = transport**(-1) / 3.0
self._xs_tally = diff_coef
self._compute_xs()
return self._xs_tally
def get_condensed_xs(self, coarse_groups):
"""Construct an energy-condensed version of this cross section.
Parameters
----------
coarse_groups : openmc.mgxs.EnergyGroups
The coarse energy group structure of interest
Returns
-------
MGXS
A new MGXS condensed to the group structure of interest
"""
cv.check_type('coarse_groups', coarse_groups, EnergyGroups)
cv.check_less_than('coarse groups', coarse_groups.num_groups,
self.num_groups, equality=True)
cv.check_value('upper coarse energy', coarse_groups.group_edges[-1],
[self.energy_groups.group_edges[-1]])
cv.check_value('lower coarse energy', coarse_groups.group_edges[0],
[self.energy_groups.group_edges[0]])
# Clone this MGXS to initialize the condensed version
condensed_xs = copy.deepcopy(self)
if self._rxn_rate_tally is None:
p1_tally = self.tallies['scatter-1']
old_filt = p1_tally.filters[-2]
new_filt = openmc.EnergyFilter(old_filt.values)
p1_tally.filters[-2] = new_filt
# Slice Legendre expansion filter and change name of score
p1_tally = p1_tally.get_slice(filters=[openmc.LegendreFilter],
filter_bins=[('P1',)],
squeeze=True)
p1_tally._scores = ['scatter-1']
total = self.tallies['total'] / self.tallies['flux (tracklength)']
trans_corr = p1_tally / self.tallies['flux (analog)']
transport = (total - trans_corr)
dif_coef = transport**(-1) / 3.0
dif_coef *= self.tallies['flux (tracklength)']
else:
dif_coef = self.rxn_rate_tally
flux_tally = condensed_xs.tallies['flux (tracklength)']
condensed_xs._tallies = OrderedDict()
condensed_xs._tallies[self._rxn_type] = dif_coef
condensed_xs._tallies['flux (tracklength)'] = flux_tally
condensed_xs._rxn_rate_tally = dif_coef
condensed_xs._xs_tally = None
condensed_xs._sparse = False
condensed_xs._energy_groups = coarse_groups
# Build energy indices to sum across
energy_indices = []
for group in range(coarse_groups.num_groups, 0, -1):
low, high = coarse_groups.get_group_bounds(group)
low_index = np.where(self.energy_groups.group_edges == low)[0][0]
energy_indices.append(low_index)
fine_edges = self.energy_groups.group_edges
# Condense each of the tallies to the coarse group structure
for tally in condensed_xs.tallies.values():
# Make condensed tally derived and null out sum, sum_sq
tally._derived = True
tally._sum = None
tally._sum_sq = None
# Get tally data arrays reshaped with one dimension per filter
mean = tally.get_reshaped_data(value='mean')
std_dev = tally.get_reshaped_data(value='std_dev')
# Sum across all applicable fine energy group filters
for i, tally_filter in enumerate(tally.filters):
if not isinstance(tally_filter,
(openmc.EnergyFilter,
openmc.EnergyoutFilter)):
continue
elif len(tally_filter.bins) != len(fine_edges):
continue
elif not np.allclose(tally_filter.bins, fine_edges):
continue
else:
tally_filter.bins = coarse_groups.group_edges
mean = np.add.reduceat(mean, energy_indices, axis=i)
std_dev = np.add.reduceat(std_dev**2, energy_indices,
axis=i)
std_dev = np.sqrt(std_dev)
# Reshape condensed data arrays with one dimension for all filters
mean = np.reshape(mean, tally.shape)
std_dev = np.reshape(std_dev, tally.shape)
# Override tally's data with the new condensed data
tally._mean = mean
tally._std_dev = std_dev
# Compute the energy condensed multi-group cross section
condensed_xs.sparse = self.sparse
return condensed_xs
class AbsorptionXS(MGXS):
r"""An absorption multi-group cross section.

View file

@ -214,24 +214,16 @@
28 2 2 y-min out 1 total 4.548 0.156691
mesh 1 group in nuclide mean std. dev.
x y z
1 1 1 1 0 total 1.039567 0.052248
0 1 1 1 1 total 0.289572 0.043864
5 1 2 1 0 total 1.079961 0.085600
4 1 2 1 1 total 0.304543 0.038994
3 2 1 1 0 total 1.088126 0.082813
2 2 1 1 1 total 0.304326 0.051269
7 2 2 1 0 total 1.037036 0.121171
6 2 2 1 1 total 0.308008 0.027855
0 1 1 1 1 total 0.757948 0.035459
2 1 2 1 1 total 0.779112 0.047034
1 2 1 1 1 total 0.787475 0.050368
3 2 2 1 1 total 0.769656 0.058065
mesh 1 group in nuclide mean std. dev.
x y z
1 1 1 1 0 total 1.039567 0.052248
0 1 1 1 1 total 0.289572 0.043864
5 1 2 1 0 total 1.079555 0.085584
4 1 2 1 1 total 0.304543 0.038994
3 2 1 1 0 total 1.088126 0.082813
2 2 1 1 1 total 0.304326 0.051269
7 2 2 1 0 total 1.037036 0.121171
6 2 2 1 1 total 0.308008 0.027855
0 1 1 1 1 total 0.757948 0.035459
2 1 2 1 1 total 0.778934 0.047027
1 2 1 1 1 total 0.787475 0.050368
3 2 2 1 1 total 0.769656 0.058065
mesh 1 delayedgroup group in nuclide mean std. dev.
x y z
0 1 1 1 1 1 total 0.000006 3.699363e-07

View file

@ -54,12 +54,10 @@
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.088451 0.003512
sum(distribcell) group in group out nuclide mean std. dev.
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.082789 0.005683
sum(distribcell) group in legendre nuclide mean std. dev.
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 P0 total 5.212993 1.398847
1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 P1 total 0.806252 0.027980
sum(distribcell) group in legendre nuclide mean std. dev.
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 P0 total 5.226298 1.407011
1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 P1 total 0.806564 0.028011
sum(distribcell) group in nuclide mean std. dev.
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.806252 0.022131
sum(distribcell) group in nuclide mean std. dev.
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 total 0.806564 0.022166
sum(distribcell) delayedgroup group in nuclide mean std. dev.
0 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 1 1 total 0.000020 8.047454e-07
1 ((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...),) 2 1 total 0.000108 4.184372e-06

View file

@ -144,15 +144,11 @@ domain=1 type=current
[2.08326667e-02 3.48425028e-02 0.00000000e+00 0.00000000e+00
7.95361553e-02 6.66783323e-02 0.00000000e+00 0.00000000e+00]]]
domain=1 type=diffusion-coefficient
[[2.89572488e-01 6.04647594e+01]
[1.03956656e+00 1.39871892e+01]]
[[4.38638506e-02 2.26850956e+03]
[5.22481383e-02 1.22780818e+01]]
[1.03956656e+00 2.89572488e-01]
[4.66257756e-02 3.47571359e-02]
domain=1 type=nu-diffusion-coefficient
[[2.89572488e-01 6.04647594e+01]
[1.03956656e+00 1.39871892e+01]]
[[4.38638506e-02 2.26850956e+03]
[5.22481383e-02 1.22780818e+01]]
[1.03956656e+00 2.89572488e-01]
[4.66257756e-02 3.47571359e-02]
domain=1 type=delayed-nu-fission
[[1.37840363e-06 3.03296462e-05]
[8.45663047e-06 1.56552364e-04]

View file

@ -212,26 +212,18 @@
30 2 2 y-max out 1 total 0.0244 0.024400
29 2 2 y-min in 1 total 0.2326 0.042782
28 2 2 y-min out 1 total 0.1778 0.009484
mesh 1 group in legendre nuclide mean std. dev.
x y z
0 1 1 1 1 P0 total 26.352505 16.110503
1 1 1 1 1 P1 total 4.600555 0.424935
4 1 2 1 1 P0 total 32.890094 15.569252
5 1 2 1 1 P1 total 4.572518 0.218792
2 2 1 1 1 P0 total 27.128188 17.388447
3 2 1 1 1 P1 total 4.493168 0.383445
6 2 2 1 1 P0 total 21.584163 5.964683
7 2 2 1 1 P1 total 4.489908 0.236773
mesh 1 group in legendre nuclide mean std. dev.
x y z
0 1 1 1 1 P0 total 26.352505 16.110503
1 1 1 1 1 P1 total 4.600555 0.424935
4 1 2 1 1 P0 total 32.996545 15.690979
5 1 2 1 1 P1 total 4.571696 0.218502
2 2 1 1 1 P0 total 27.434506 17.764465
3 2 1 1 1 P1 total 4.496020 0.383903
6 2 2 1 1 P0 total 21.761315 6.095339
7 2 2 1 1 P1 total 4.492825 0.237270
mesh 1 group in nuclide mean std. dev.
x y z
0 1 1 1 1 total 4.600555 0.368212
2 1 2 1 1 total 4.572518 0.204129
1 2 1 1 1 total 4.493168 0.329560
3 2 2 1 1 total 4.489908 0.228574
mesh 1 group in nuclide mean std. dev.
x y z
0 1 1 1 1 total 4.600555 0.368212
2 1 2 1 1 total 4.571696 0.203824
1 2 1 1 1 total 4.496020 0.330019
3 2 2 1 1 total 4.492825 0.229077
mesh 1 delayedgroup group in nuclide mean std. dev.
x y z
0 1 1 1 1 1 total 0.000007 4.371033e-07

View file

@ -151,17 +151,13 @@ prompt-nu-fission matrix
1 1 2 1 total 0.495450 0.012592
0 1 2 2 total 0.000000 0.000000
diffusion-coefficient
material group in legendre nuclide mean std. dev.
2 1 1 P0 total 13.267434 9.377780
3 1 1 P1 total 0.881035 0.050823
0 1 2 P0 total 1.242844 0.316720
1 1 2 P1 total 0.519910 0.064395
material group in nuclide mean std. dev.
1 1 1 total 0.881035 0.038500
0 1 2 total 0.519910 0.049301
nu-diffusion-coefficient
material group in legendre nuclide mean std. dev.
2 1 1 P0 total 13.360612 9.496523
3 1 1 P1 total 0.880816 0.050843
0 1 2 P0 total 1.242844 0.316720
1 1 2 P1 total 0.519910 0.064395
material group in nuclide mean std. dev.
1 1 1 total 0.880816 0.038534
0 1 2 total 0.519910 0.049301
(n,elastic)
material group in nuclide mean std. dev.
1 1 1 total 0.361427 0.011879
@ -457,17 +453,13 @@ prompt-nu-fission matrix
1 2 2 1 total 0.0 0.0
0 2 2 2 total 0.0 0.0
diffusion-coefficient
material group in legendre nuclide mean std. dev.
2 2 1 P0 total 133.637358 904.804108
3 2 1 P1 total 1.210594 0.082668
0 2 2 P0 total 34.754997 241.483530
1 2 2 P1 total 1.110491 0.131041
material group in nuclide mean std. dev.
1 2 1 total 1.210594 0.070439
0 2 2 total 1.110491 0.099580
nu-diffusion-coefficient
material group in legendre nuclide mean std. dev.
2 2 1 P0 total 133.637358 904.804108
3 2 1 P1 total 1.210594 0.082668
0 2 2 P0 total 34.754997 241.483530
1 2 2 P1 total 1.110491 0.131041
material group in nuclide mean std. dev.
1 2 1 total 1.210594 0.070439
0 2 2 total 1.110491 0.099580
(n,elastic)
material group in nuclide mean std. dev.
1 2 1 total 0.301494 0.009403
@ -763,17 +755,13 @@ prompt-nu-fission matrix
1 3 2 1 total 0.0 0.0
0 3 2 2 total 0.0 0.0
diffusion-coefficient
material group in legendre nuclide mean std. dev.
2 3 1 P0 total 11.244053 8.794903
3 3 1 P1 total 1.141761 0.081143
0 3 2 P0 total -2.888333 3.736106
1 3 2 P1 total 0.227648 0.021613
material group in nuclide mean std. dev.
1 3 1 total 1.141761 0.074641
0 3 2 total 0.227648 0.018035
nu-diffusion-coefficient
material group in legendre nuclide mean std. dev.
2 3 1 P0 total 11.244053 8.794903
3 3 1 P1 total 1.141761 0.081143
0 3 2 P0 total -2.888333 3.736106
1 3 2 P1 total 0.227648 0.021613
material group in nuclide mean std. dev.
1 3 1 total 1.141761 0.074641
0 3 2 total 0.227648 0.018035
(n,elastic)
material group in nuclide mean std. dev.
1 3 1 total 0.683777 0.015496

View file

@ -1 +1 @@
bf460584607a2a7b2f3fca008762839f5b3a5bbc85721a990eb568df5d0417c4f4eca3e0c2c12380c0761e15faeccc662af1876171ff8de0102ba86c81b4bd04
b8706c9586aeeb5ee558829c28772f7f6e18a0d3fe4e30a2059b6e74564d1ebbbd0ab5473965c4e6156dff8b8178ce76c74d8db1d63f032c3d4da5f7eb9eae2c