Major refactoring of MGXS subclasses to eliminate tallies properties

This commit is contained in:
Will Boyd 2016-05-12 21:08:55 -04:00
parent 9e843de1bd
commit 19feb55e6d
13 changed files with 704 additions and 750 deletions

View file

@ -372,6 +372,7 @@
"\n",
"* `TotalXS`\n",
"* `TransportXS`\n",
"* `NuTransportXS`\n",
"* `AbsorptionXS`\n",
"* `CaptureXS`\n",
"* `FissionXS`\n",
@ -409,7 +410,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 26,
"metadata": {
"collapsed": false
},
@ -418,25 +419,27 @@
"data": {
"text/plain": [
"OrderedDict([('flux', Tally\n",
" \tID =\t10000\n",
" \tName =\t\n",
" \tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
" \tNuclides =\ttotal \n",
" \tScores =\t['flux']\n",
" \tEstimator =\ttracklength), ('absorption', Tally\n",
" \tID =\t10001\n",
" \tName =\t\n",
" \tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
" \tNuclides =\ttotal \n",
" \tScores =\t['absorption']\n",
" \tEstimator =\ttracklength)])"
"\tID =\t10012\n",
"\tName =\t\n",
"\tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
"\tNuclides =\ttotal \n",
"\tScores =\t[u'flux']\n",
"\tEstimator =\ttracklength\n",
"), ('absorption', Tally\n",
"\tID =\t10013\n",
"\tName =\t\n",
"\tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
"\tNuclides =\ttotal \n",
"\tScores =\t[u'absorption']\n",
"\tEstimator =\ttracklength\n",
")])"
]
},
"execution_count": 13,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
@ -510,8 +513,8 @@
" Copyright: 2011-2016 Massachusetts Institute of Technology\n",
" License: http://openmc.readthedocs.io/en/latest/license.html\n",
" Version: 0.7.1\n",
" Git SHA1: 502482dcf630ee6e290c15b8535e6e850a351c88\n",
" Date/Time: 2016-05-10 20:52:19\n",
" Git SHA1: ae588276014a905ecc6e0967bf08288ecec5b550\n",
" Date/Time: 2016-05-12 20:41:27\n",
" MPI Processes: 1\n",
"\n",
" ===========================================================================\n",
@ -597,20 +600,20 @@
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 5.3200E-01 seconds\n",
" Reading cross sections = 1.3300E-01 seconds\n",
" Total time in simulation = 2.3438E+01 seconds\n",
" Time in transport only = 2.3419E+01 seconds\n",
" Time in inactive batches = 2.9490E+00 seconds\n",
" Time in active batches = 2.0489E+01 seconds\n",
" Time synchronizing fission bank = 6.0000E-03 seconds\n",
" Sampling source sites = 3.0000E-03 seconds\n",
" SEND/RECV source sites = 1.0000E-03 seconds\n",
" Time accumulating tallies = 0.0000E+00 seconds\n",
" Total time for initialization = 4.7500E-01 seconds\n",
" Reading cross sections = 9.7000E-02 seconds\n",
" Total time in simulation = 1.8074E+01 seconds\n",
" Time in transport only = 1.8055E+01 seconds\n",
" Time in inactive batches = 2.1180E+00 seconds\n",
" Time in active batches = 1.5956E+01 seconds\n",
" Time synchronizing fission bank = 4.0000E-03 seconds\n",
" Sampling source sites = 4.0000E-03 seconds\n",
" SEND/RECV source sites = 0.0000E+00 seconds\n",
" Time accumulating tallies = 2.0000E-03 seconds\n",
" Total time for finalization = 0.0000E+00 seconds\n",
" Total time elapsed = 2.3985E+01 seconds\n",
" Calculation Rate (inactive) = 8477.45 neutrons/second\n",
" Calculation Rate (active) = 4880.67 neutrons/second\n",
" Total time elapsed = 1.8559E+01 seconds\n",
" Calculation Rate (inactive) = 11803.6 neutrons/second\n",
" Calculation Rate (active) = 6267.23 neutrons/second\n",
"\n",
" ============================> RESULTS <============================\n",
"\n",
@ -1121,7 +1124,7 @@
" <td>6.250000e-07</td>\n",
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1</td>\n",
" <td>1.0</td>\n",
" <td>0.007763</td>\n",
" </tr>\n",
" <tr>\n",
@ -1131,7 +1134,7 @@
" <td>2.000000e+01</td>\n",
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1</td>\n",
" <td>1.0</td>\n",
" <td>0.003739</td>\n",
" </tr>\n",
" </tbody>\n",
@ -1178,7 +1181,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
"version": "2.7.6"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -227,29 +227,30 @@ class MGXS(object):
domain_filter = openmc.Filter(self.domain_type, self.domain.id)
# Create each Tally needed to compute the multi group cross section
for score, key, filters in zip(self.scores, self.keys, self.filters):
self.tallies[key] = openmc.Tally(name=self.name)
self.tallies[key].scores = [score]
self.tallies[key].estimator = self.estimator
self.tallies[key].filters = [domain_filter]
tally_metadata = zip(self.scores, self.tally_keys, self.filters)
for score, key, filters in tally_metadata:
self._tallies[key] = openmc.Tally(name=self.name)
self._tallies[key].scores = [score]
self._tallies[key].estimator = self.estimator
self._tallies[key].filters = [domain_filter]
# If a tally trigger was specified, add it to each tally
if self.tally_trigger:
trigger_clone = copy.deepcopy(self.tally_trigger)
trigger_clone.scores = [score]
self.tallies[key].triggers.append(trigger_clone)
self._tallies[key].triggers.append(trigger_clone)
# Add non-domain specific Filters (e.g., 'energy') to the Tally
for add_filter in filters:
self.tallies[key].filters.append(add_filter)
self._tallies[key].filters.append(add_filter)
# If this is a by-nuclide cross-section, add nuclides to Tally
if self.by_nuclide and score != 'flux':
all_nuclides = self.get_all_nuclides()
for nuclide in all_nuclides:
self.tallies[key].nuclides.append(nuclide)
self._tallies[key].nuclides.append(nuclide)
else:
self.tallies[key].nuclides.append('total')
self._tallies[key].nuclides.append('total')
return self._tallies
@ -311,7 +312,7 @@ class MGXS(object):
def filters(self):
group_edges = self.energy_groups.group_edges
energy_filter = openmc.Filter('energy', group_edges)
return [[energy_filter] * len(self.scores)]
return [[energy_filter]] * len(self.scores)
@property
def tally_keys(self):
@ -1544,7 +1545,7 @@ class NuTransportXS(TransportXS):
return ['flux', 'total', 'nu-scatter-1']
@property
def keys(self):
def tally_keys(self):
return ['flux', 'total', 'scatter-1']
@ -1674,50 +1675,38 @@ class ScatterMatrixXS(MGXS):
@property
def scores(self):
return ['flux', 'total', 'nu-scatter-1']
scores = ['flux']
for moment in range(self.legendre_order+1):
scores.append('scatter-{}'.format(moment))
if self.correction == 'P0' and self.legendre_order == 0:
scores.append('scatter-1')
return scores
@property
def keys(self):
return ['flux', 'total', 'scatter-1']
def filters(self):
group_edges = self.energy_groups.group_edges
energy = openmc.Filter('energy', group_edges)
energyout = openmc.Filter('energyout', group_edges)
filters = [[energy]]
for moment in range(self.legendre_order+1):
filters.append([energy, energyout])
if self.correction == 'P0' and self.legendre_order == 0:
filters.append([energyout])
return filters
@property
def tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
def tally_keys(self):
return ['flux', 'scatter-0', 'scatter-1']
This method constructs three analog tallies to compute the 'flux'
and Legendre scattering moment reaction rates in the spatial domain and
energy groups of interest.
"""
# Instantiate tallies if they do not exist
if self._tallies is None:
group_edges = self.energy_groups.group_edges
energy = openmc.Filter('energy', group_edges)
energyout = openmc.Filter('energyout', group_edges)
# Create lists of scores, filters for each Tally to be created
scores = ['flux']
filters = [[energy]]
# Create separate tallies for each moment
for moment in range(self.legendre_order+1):
scores.append('scatter-{}'.format(moment))
filters.append([energy, energyout])
# Append to the lists for the P0 approximation if needed
if self.correction == 'P0' and self.legendre_order == 0:
scores.append('scatter-1')
filters.append([energyout])
estimator = 'analog'
keys = scores
# Initialize the Tallies
self._create_tallies(scores, filters, keys, estimator)
return self._tallies
@property
def estimator(self):
return 'analog'
@property
def rxn_rate_tally(self):
@ -1727,7 +1716,7 @@ class ScatterMatrixXS(MGXS):
# If using P0 correction subtract scatter-1 from the diagonal
if self.correction == 'P0' and self.legendre_order == 0:
scatter_p1 = self.tallies['scatter-1']
scatter_p1 = scatter_p1.get_slice(scores=['scatter-1'])
scatter_p1 = scatter_p1.get_slice(scores=[self.scores[-1]])
energy_filter = self.tallies['scatter-0'].find_filter('energy')
energy_filter = copy.deepcopy(energy_filter)
scatter_p1 = scatter_p1.diagonalize_filter(energy_filter)
@ -1737,8 +1726,7 @@ class ScatterMatrixXS(MGXS):
else:
rxn_rate_tally = self.tallies['scatter-0']
for moment in range(1, self.legendre_order+1):
scatter_key = 'scatter-{}'.format(moment)
scatter_pn = self.tallies[scatter_key]
scatter_pn = self.tallies['scatter-{}'.format(moment)]
rxn_rate_tally = rxn_rate_tally.merge(scatter_pn)
self._rxn_rate_tally = rxn_rate_tally
@ -2188,45 +2176,16 @@ class NuScatterMatrixXS(ScatterMatrixXS):
self._rxn_type = 'nu-scatter matrix'
@property
def tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
def scores(self):
scores = ['flux']
This method constructs three analog tallies to compute the 'flux',
'nu-scatter' and 'scatter-P1' reaction rates in the spatial domain and
energy groups of interest.
for moment in range(self.legendre_order+1):
scores.append('nu-scatter-{}'.format(moment))
"""
if self.correction == 'P0' and self.legendre_order == 0:
scores.append('nu-scatter-1')
# Instantiate tallies if they do not exist
if self._tallies is None:
group_edges = self.energy_groups.group_edges
energy = openmc.Filter('energy', group_edges)
energyout = openmc.Filter('energyout', group_edges)
# Create lists of scores, filters for each Tally to be created
scores = ['flux']
filters = [[energy]]
keys = ['flux']
# Create separate tallies for each moment
for moment in range(self.legendre_order+1):
scores.append('nu-scatter-{}'.format(moment))
filters.append([energy, energyout])
keys.append('scatter-{}'.format(moment))
# Append to the lists for the P0 approximation if needed
if self.correction == 'P0' and self.legendre_order == 0:
scores.append('scatter-1')
filters.append([energyout])
keys.append('scatter-1')
estimator = 'analog'
# Intialize the Tallies
self._create_tallies(scores, filters, keys, estimator)
return self._tallies
return scores
class Chi(MGXS):
@ -2238,33 +2197,24 @@ class Chi(MGXS):
self._rxn_type = 'chi'
@property
def tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
def scores(self):
return ['nu-fission', 'nu-fission']
This method constructs two analog tallies to compute 'nu-fission'
reaction rates with 'energy' and 'energyout' filters in the spatial
domain and energy groups of interest.
@property
def filters(self):
# Create the non-domain specific Filters for the Tallies
group_edges = self.energy_groups.group_edges
energyout = openmc.Filter('energyout', group_edges)
energyin = openmc.Filter('energy', [group_edges[0], group_edges[-1]])
return [[energyin], [energyout]]
"""
@property
def tally_keys(self):
return ['nu-fission-in', 'nu-fission-out']
# Instantiate tallies if they do not exist
if self._tallies is None:
# Create a list of scores for each Tally to be created
scores = ['nu-fission', 'nu-fission']
estimator = 'analog'
keys = ['nu-fission-in', 'nu-fission-out']
# Create the non-domain specific Filters for the Tallies
group_edges = self.energy_groups.group_edges
energyout = openmc.Filter('energyout', group_edges)
energyin = openmc.Filter('energy', [group_edges[0], group_edges[-1]])
filters = [[energyin], [energyout]]
# Intialize the Tallies
self._create_tallies(scores, filters, keys, estimator)
return self._tallies
@property
def estimator(self):
return 'analog'
@property
def rxn_rate_tally(self):

View file

@ -1 +1 @@
e3834da92fc6ae57ce109621e3f692a186a03820b61332fa9ed898bc07fb8a63484ace095713d5b88196b1d2f1430d2e7b27a505944c7c3027f6365801f58146
ee40a2b826dea8323249c7261502f8339c78a5dc236e019842cc5244c048d5978fe66e036b86d46b262260556fbd62b19cbb2f0d70325b92b8c40275e75afe4f

View file

@ -1,7 +1,7 @@
material group in nuclide mean std. dev.
0 1 1 total 0.412084 0.02359 material group in nuclide mean std. dev.
0 1 1 total 0.076425 0.003691 material group in group out nuclide moment mean std. dev. moment
0 1 1 1 total P0 0.345643 0.021487 P0 material group out nuclide mean std. dev.
0 1 1 1 total P0 0.345503 0.021465 P0 material group out nuclide mean std. dev.
0 1 1 total 1.0 0.055333 material group in nuclide mean std. dev.
0 2 1 total 0.241262 0.00841 material group in nuclide mean std. dev.
0 2 1 total 0.0 0.0 material group in group out nuclide moment mean std. dev. moment

View file

@ -1 +1 @@
aadb1e94492741c091bff4b5e17634ee327c718fc9fd1f27aa22fe8406fb70f732750dfdceb30eb40b5e4f406061bea6bd5235ba613c3c81009f5857a9051728
c46381a2d86bd849ca20dc64022ffcf836ba0f236f392bba6335c42559df61d14d09a616bc3a9590d954a5bf099610eb071982296b75b10d1c168cc3e343d383

View file

@ -1 +1 @@
e3834da92fc6ae57ce109621e3f692a186a03820b61332fa9ed898bc07fb8a63484ace095713d5b88196b1d2f1430d2e7b27a505944c7c3027f6365801f58146
ee40a2b826dea8323249c7261502f8339c78a5dc236e019842cc5244c048d5978fe66e036b86d46b262260556fbd62b19cbb2f0d70325b92b8c40275e75afe4f

View file

@ -5,9 +5,9 @@ domain=1 type=nu-fission
[ 0.02178897 0.71407658]
[ 0.00118187 0.04055185]
domain=1 type=nu-scatter matrix
[[ 0.3373971 0.00155945]
[[ 0.33724504 0.00155945]
[ 0. 0.42205129]]
[[ 0.02303884 0.00051015]
[[ 0.02301463 0.00051015]
[ 0. 0.02161702]]
domain=1 type=chi
[ 1. 0.]

View file

@ -1 +1 @@
e3834da92fc6ae57ce109621e3f692a186a03820b61332fa9ed898bc07fb8a63484ace095713d5b88196b1d2f1430d2e7b27a505944c7c3027f6365801f58146
ee40a2b826dea8323249c7261502f8339c78a5dc236e019842cc5244c048d5978fe66e036b86d46b262260556fbd62b19cbb2f0d70325b92b8c40275e75afe4f

View file

@ -3,7 +3,7 @@
0 1 2 total 0.861607 0.032349 material group in nuclide mean std. dev.
1 1 1 total 0.021789 0.001182
0 1 2 total 0.714077 0.040552 material group in group out nuclide moment mean std. dev. moment
3 1 1 1 total P0 0.337397 0.023039 P0
3 1 1 1 total P0 0.337245 0.023015 P0
2 1 1 2 total P0 0.001559 0.000510 P0
1 1 2 1 total P0 0.000000 0.000000 P0
0 1 2 2 total P0 0.422051 0.021617 P0 material group out nuclide mean std. dev.

View file

@ -1 +1 @@
f1c203fb7f0b141ee608d7bb9223aa5f7ab84966b6a80525879df730d19179f6c6a1a4bc7038d84e6b366b360f43a1ca17a0af8d02f96eb23e53b93a2445380e
f4abbd7867b0f0d2d9d93ed089c95904541f970522e1ef3a843373b60094ef4571a64a7b5f68efe9e51fd49754bc9e20a3bcc85c0bde3a8224608f8b97c01b85

View file

@ -138,7 +138,7 @@
102 1 1 1 U-234 P0 0.000000 0.000000 P0
103 1 1 1 U-235 P0 0.003226 0.001139 P0
104 1 1 1 U-236 P0 0.001697 0.000923 P0
105 1 1 1 U-238 P0 0.194620 0.013297 P0
105 1 1 1 U-238 P0 0.194468 0.013279 P0
106 1 1 1 Np-237 P0 0.000000 0.000000 P0
107 1 1 1 Pu-238 P0 0.000000 0.000000 P0
108 1 1 1 Pu-239 P0 0.001005 0.000477 P0