Merge pull request #869 from samuelshaner/tally_align_fix

Tally alignment fix for swapping filters
This commit is contained in:
Will Boyd 2017-04-26 13:58:27 -04:00 committed by GitHub
commit 1509b7573d
3 changed files with 80 additions and 72 deletions

View file

@ -1343,7 +1343,7 @@ class Tally(object):
# If a user-requested Filter, get the user-requested bins
for j, test_filter in enumerate(filters):
if isinstance(self_filter, test_filter):
if type(self_filter) is test_filter:
bins = filter_bins[j]
user_filter = True
break
@ -2121,7 +2121,6 @@ class Tally(object):
----------
filter1 : Filter
The filter to swap with filter2
filter2 : Filter
The filter to swap with filter1
@ -2148,15 +2147,6 @@ class Tally(object):
'does not contain such a filter'.format(filter2.type, self.id)
raise ValueError(msg)
# Swap the filters in the copied version of this Tally
filter1_index = self.filters.index(filter1)
filter2_index = self.filters.index(filter2)
self.filters[filter1_index] = filter2
self.filters[filter2_index] = filter1
# Update the tally's filter strides
self._update_filter_strides()
# Construct lists of tuples for the bins in each of the two filters
filters = [type(filter1), type(filter2)]
if isinstance(filter1, openmc.DistribcellFilter):
@ -2173,23 +2163,41 @@ class Tally(object):
else:
filter2_bins = [filter2.get_bin(i) for i in range(filter2.num_bins)]
# Adjust the mean data array to relect the new filter order
if self.mean is not None:
for bin1, bin2 in itertools.product(filter1_bins, filter2_bins):
filter_bins = [(bin1,), (bin2,)]
data = self.get_values(
filters=filters, filter_bins=filter_bins, value='mean')
indices = self.get_filter_indices(filters, filter_bins)
self.mean[indices, :, :] = data
# Create variables to store views of data in the misaligned structure
mean = {}
std_dev = {}
# Adjust the std_dev data array to relect the new filter order
if self.std_dev is not None:
for bin1, bin2 in itertools.product(filter1_bins, filter2_bins):
filter_bins = [(bin1,), (bin2,)]
data = self.get_values(
# Store the data from the misaligned structure
for i, (bin1, bin2) in enumerate(itertools.product(filter1_bins, filter2_bins)):
filter_bins = [(bin1,), (bin2,)]
if self.mean is not None:
mean[i] = self.get_values(
filters=filters, filter_bins=filter_bins, value='mean')
if self.std_dev is not None:
std_dev[i] = self.get_values(
filters=filters, filter_bins=filter_bins, value='std_dev')
indices = self.get_filter_indices(filters, filter_bins)
self.std_dev[indices, :, :] = data
# Swap the filters in the copied version of this Tally
filter1_index = self.filters.index(filter1)
filter2_index = self.filters.index(filter2)
self.filters[filter1_index] = filter2
self.filters[filter2_index] = filter1
# Update the tally's filter strides
self._update_filter_strides()
# Realign the data
for i, (bin1, bin2) in enumerate(itertools.product(filter1_bins, filter2_bins)):
filter_bins = [(bin1,), (bin2,)]
indices = self.get_filter_indices(filters, filter_bins)
if self.mean is not None:
self.mean[indices, :, :] = mean[i]
if self.std_dev is not None:
self.std_dev[indices, :, :] = std_dev[i]
def _swap_nuclides(self, nuclide1, nuclide2):
"""Reverse the ordering of two nuclides in this tally

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

@ -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