mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Fixes per @wbinventor comments
This commit is contained in:
parent
6e3f6bf8b1
commit
54b65c8bda
10 changed files with 453 additions and 831 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -520,8 +520,8 @@
|
|||
" Copyright | 2011-2017 Massachusetts Institute of Technology\n",
|
||||
" License | http://openmc.readthedocs.io/en/latest/license.html\n",
|
||||
" Version | 0.8.0\n",
|
||||
" Git SHA1 | 2bf05f281e566a81e181ee0e9c699138b37b57b4\n",
|
||||
" Date/Time | 2017-01-19 13:31:59\n",
|
||||
" Git SHA1 | 6e3f6bf8b11cb3f6f171f1c351ddcaf85dd515ec\n",
|
||||
" Date/Time | 2017-02-11 14:02:54\n",
|
||||
" OpenMP Threads | 8\n",
|
||||
"\n",
|
||||
" ===========================================================================\n",
|
||||
|
|
@ -607,20 +607,20 @@
|
|||
"\n",
|
||||
" =======================> TIMING STATISTICS <=======================\n",
|
||||
"\n",
|
||||
" Total time for initialization = 3.1727E-01 seconds\n",
|
||||
" Reading cross sections = 2.4380E-01 seconds\n",
|
||||
" Total time in simulation = 2.3160E+00 seconds\n",
|
||||
" Time in transport only = 2.2082E+00 seconds\n",
|
||||
" Time in inactive batches = 2.4914E-01 seconds\n",
|
||||
" Time in active batches = 2.0669E+00 seconds\n",
|
||||
" Time synchronizing fission bank = 2.7438E-03 seconds\n",
|
||||
" Sampling source sites = 2.0106E-03 seconds\n",
|
||||
" SEND/RECV source sites = 6.9831E-04 seconds\n",
|
||||
" Time accumulating tallies = 4.9308E-05 seconds\n",
|
||||
" Total time for finalization = 4.0687E-04 seconds\n",
|
||||
" Total time elapsed = 2.6419E+00 seconds\n",
|
||||
" Calculation Rate (inactive) = 1.00345E+05 neutrons/second\n",
|
||||
" Calculation Rate (active) = 48381.7 neutrons/second\n",
|
||||
" Total time for initialization = 3.8572E-01 seconds\n",
|
||||
" Reading cross sections = 2.6254E-01 seconds\n",
|
||||
" Total time in simulation = 4.0095E+00 seconds\n",
|
||||
" Time in transport only = 3.1037E+00 seconds\n",
|
||||
" Time in inactive batches = 7.2398E-01 seconds\n",
|
||||
" Time in active batches = 3.2855E+00 seconds\n",
|
||||
" Time synchronizing fission bank = 2.9057E-03 seconds\n",
|
||||
" Sampling source sites = 2.1033E-03 seconds\n",
|
||||
" SEND/RECV source sites = 7.5640E-04 seconds\n",
|
||||
" Time accumulating tallies = 7.2906E-05 seconds\n",
|
||||
" Total time for finalization = 7.4175E-04 seconds\n",
|
||||
" Total time elapsed = 4.4039E+00 seconds\n",
|
||||
" Calculation Rate (inactive) = 34531.2 neutrons/second\n",
|
||||
" Calculation Rate (active) = 30436.6 neutrons/second\n",
|
||||
"\n",
|
||||
" ============================> RESULTS <============================\n",
|
||||
"\n",
|
||||
|
|
@ -739,8 +739,8 @@
|
|||
"\tDomain Type =\tcell\n",
|
||||
"\tDomain ID =\t1\n",
|
||||
"\tCross Sections [cm^-1]:\n",
|
||||
" Group 1 [0.625 - 20000000.0eV]:\t2.69e-01 +/- 2.69e-01%\n",
|
||||
" Group 2 [0.0 - 0.625 eV]:\t5.93e-01 +/- 5.93e-01%\n",
|
||||
" Group 1 [0.625 - 20000000.0eV]:\t6.81e-01 +/- 2.69e-01\n",
|
||||
" Group 2 [0.0 - 0.625 eV]:\t1.40e+00 +/- 5.93e-01\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n"
|
||||
|
|
@ -901,7 +901,7 @@
|
|||
" <td>6.250000e-01</td>\n",
|
||||
" <td>total</td>\n",
|
||||
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
|
||||
" <td>-2.442491e-15</td>\n",
|
||||
" <td>-2.664535e-15</td>\n",
|
||||
" <td>0.011292</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
|
|
@ -911,7 +911,7 @@
|
|||
" <td>2.000000e+07</td>\n",
|
||||
" <td>total</td>\n",
|
||||
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
|
||||
" <td>-5.551115e-16</td>\n",
|
||||
" <td>-8.881784e-16</td>\n",
|
||||
" <td>0.002570</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
|
|
@ -924,8 +924,8 @@
|
|||
"1 1 6.25e-01 2.00e+07 total \n",
|
||||
"\n",
|
||||
" score mean std. dev. \n",
|
||||
"0 (((total / flux) - (absorption / flux)) - (sca... -2.44e-15 1.13e-02 \n",
|
||||
"1 (((total / flux) - (absorption / flux)) - (sca... -5.55e-16 2.57e-03 "
|
||||
"0 (((total / flux) - (absorption / flux)) - (sca... -2.66e-15 1.13e-02 \n",
|
||||
"1 (((total / flux) - (absorption / flux)) - (sca... -8.88e-16 2.57e-03 "
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1008,7 +1008,7 @@ class EnergyFilter(RealFilter):
|
|||
# them as necessary to account for other filters.
|
||||
lo_bins = np.repeat(self.bins[:-1], self.stride)
|
||||
hi_bins = np.repeat(self.bins[1:], self.stride)
|
||||
tile_factor = data_size / len(lo_bins)
|
||||
tile_factor = int(data_size / len(lo_bins))
|
||||
lo_bins = np.tile(lo_bins, tile_factor)
|
||||
hi_bins = np.tile(hi_bins, tile_factor)
|
||||
|
||||
|
|
|
|||
|
|
@ -1151,14 +1151,12 @@ class Library(object):
|
|||
xsdata._absorption[i] = \
|
||||
np.subtract(xsdata._total[i], np.sum(np.sum(
|
||||
xsdata._scatter_matrix[i][:, :, :],
|
||||
axis=2),
|
||||
axis=1))
|
||||
axis=2), axis=1))
|
||||
elif representation == 'angle':
|
||||
xsdata._absorption[i] = \
|
||||
np.subtract(xsdata._total[i], np.sum(np.sum(
|
||||
xsdata._scatter_matrix[i][:, :, :, :, :],
|
||||
axis=4),
|
||||
axis=3))
|
||||
axis=4), axis=3))
|
||||
|
||||
return xsdata
|
||||
|
||||
|
|
|
|||
|
|
@ -175,13 +175,23 @@ class MDGXS(MGXS):
|
|||
else:
|
||||
return existing
|
||||
|
||||
@property
|
||||
def _dont_squeeze(self):
|
||||
"""Create a tuple of axes which should not be removed during the get_xs
|
||||
process
|
||||
"""
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
return (0, 1, 3, 4)
|
||||
else:
|
||||
return (1, 2)
|
||||
|
||||
@property
|
||||
def delayed_groups(self):
|
||||
return self._delayed_groups
|
||||
|
||||
@property
|
||||
def num_delayed_groups(self):
|
||||
if self.delayed_groups == None:
|
||||
if self.delayed_groups is None:
|
||||
return 1
|
||||
else:
|
||||
return len(self.delayed_groups)
|
||||
|
|
@ -189,7 +199,7 @@ class MDGXS(MGXS):
|
|||
@delayed_groups.setter
|
||||
def delayed_groups(self, delayed_groups):
|
||||
|
||||
if delayed_groups != None:
|
||||
if delayed_groups is not None:
|
||||
|
||||
cv.check_type('delayed groups', delayed_groups, list, int)
|
||||
cv.check_greater_than('num delayed groups', len(delayed_groups), 0)
|
||||
|
|
@ -431,18 +441,7 @@ class MDGXS(MGXS):
|
|||
if squeeze:
|
||||
# We want to squeeze out everything but the polar, azimuthal,
|
||||
# delayed group, and energy group data.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
dont_squeeze = (0, 1, 3, 4)
|
||||
else:
|
||||
dont_squeeze = (1, 2)
|
||||
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
|
||||
return xs
|
||||
|
||||
|
|
@ -681,7 +680,7 @@ class MDGXS(MGXS):
|
|||
string += '\t' + template.format('', group,
|
||||
bounds[0],
|
||||
bounds[1])
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[pol, azi, group - 1],
|
||||
rel_err_xs[pol, azi, group - 1])
|
||||
string += '\n'
|
||||
|
|
@ -691,7 +690,7 @@ class MDGXS(MGXS):
|
|||
for group in range(1, self.num_groups+1):
|
||||
bounds = self.energy_groups.get_group_bounds(group)
|
||||
string += template.format('', group, bounds[0], bounds[1])
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[group - 1], rel_err_xs[group - 1])
|
||||
string += '\n'
|
||||
string += '\n'
|
||||
|
|
@ -830,7 +829,6 @@ class MDGXS(MGXS):
|
|||
if self.by_nuclide and nuclides == 'sum':
|
||||
|
||||
# Use tally summation to sum across all nuclides
|
||||
query_nuclides = [nuclides]
|
||||
xs_tally = self.xs_tally.summation(nuclides=self.get_nuclides())
|
||||
df = xs_tally.get_pandas_dataframe(
|
||||
distribcell_paths=distribcell_paths)
|
||||
|
|
@ -858,45 +856,9 @@ class MDGXS(MGXS):
|
|||
else:
|
||||
df = df.drop('score', axis=1)
|
||||
|
||||
# Override polar and azimuthal bounds with indices
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
# First for polar
|
||||
del df['polar high']
|
||||
df.rename(columns={'polar low': 'polar bin'}, inplace=True)
|
||||
df_bins = df['polar bin']
|
||||
polar_bins = np.linspace(0., np.pi, num=self.num_polar + 1,
|
||||
endpoint=True)
|
||||
df['polar bin'] = np.searchsorted(polar_bins, df_bins) + 1
|
||||
|
||||
# Second for azimuthal
|
||||
del df['azimuthal high']
|
||||
df.rename(columns={'azimuthal low': 'azimuthal bin'},
|
||||
inplace=True)
|
||||
df_bins = df['azimuthal bin']
|
||||
azimuthal_bins = np.linspace(-np.pi, np.pi,
|
||||
num=self.num_azimuthal + 1,
|
||||
endpoint=True)
|
||||
df['azimuthal bin'] = np.searchsorted(azimuthal_bins, df_bins) + 1
|
||||
columns = ['polar bin', 'azimuthal bin']
|
||||
else:
|
||||
columns = []
|
||||
|
||||
# Override energy groups bounds with indices
|
||||
if 'energy low [eV]' in df:
|
||||
df.rename(columns={'energy low [eV]': 'group in'}, inplace=True)
|
||||
df_bins = df['group in']
|
||||
df['group in'] = self.energy_groups.num_groups - \
|
||||
np.searchsorted(self.energy_groups.group_edges, df_bins)
|
||||
del df['energy high [eV]']
|
||||
columns += ['group in']
|
||||
if 'energyout low [eV]' in df:
|
||||
df.rename(columns={'energyout low [eV]': 'group out'},
|
||||
inplace=True)
|
||||
df_bins = df['group out']
|
||||
df['group out'] = self.energy_groups.num_groups - \
|
||||
np.searchsorted(self.energy_groups.group_edges, df_bins)
|
||||
del df['energyout high [eV]']
|
||||
columns += ['group out']
|
||||
# Convert azimuthal, polar, energy in and energy out bin values in to
|
||||
# bin indices
|
||||
columns = self._df_convert_columns_to_bins(df)
|
||||
|
||||
# Select out those groups the user requested
|
||||
if not isinstance(groups, string_types):
|
||||
|
|
@ -912,7 +874,7 @@ class MDGXS(MGXS):
|
|||
else:
|
||||
densities = self.get_nuclide_densities('sum')
|
||||
densities = np.repeat(densities, len(self.rxn_rate_tally.scores))
|
||||
tile_factor = df.shape[0] / len(densities)
|
||||
tile_factor = int(df.shape[0] / len(densities))
|
||||
df['mean'] /= np.tile(densities, tile_factor)
|
||||
df['std. dev.'] /= np.tile(densities, tile_factor)
|
||||
|
||||
|
|
@ -1439,17 +1401,7 @@ class ChiDelayed(MDGXS):
|
|||
if squeeze:
|
||||
# We want to squeeze out everything but the polar, azimuthal,
|
||||
# and energy group data.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
dont_squeeze = (0, 1, 3, 4)
|
||||
else:
|
||||
dont_squeeze = (1, 2)
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
|
||||
return xs
|
||||
|
||||
|
|
@ -2069,6 +2021,16 @@ class MatrixMDGXS(MDGXS):
|
|||
|
||||
"""
|
||||
|
||||
@property
|
||||
def _dont_squeeze(self):
|
||||
"""Create a tuple of axes which should not be removed during the get_xs
|
||||
process
|
||||
"""
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
return (0, 1, 3, 4, 5)
|
||||
else:
|
||||
return (1, 2, 3)
|
||||
|
||||
@property
|
||||
def filters(self):
|
||||
# Create the non-domain specific Filters for the Tallies
|
||||
|
|
@ -2268,17 +2230,7 @@ class MatrixMDGXS(MDGXS):
|
|||
if squeeze:
|
||||
# We want to squeeze out everything but the polar, azimuthal,
|
||||
# and in/out energy group data.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
dont_squeeze = (0, 1, 3, 4, 5)
|
||||
else:
|
||||
dont_squeeze = (1, 2, 3)
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
|
||||
return xs
|
||||
|
||||
|
|
@ -2466,7 +2418,7 @@ class MatrixMDGXS(MDGXS):
|
|||
for out_group in range(1, self.num_groups + 1):
|
||||
string += '\t' + template.format(
|
||||
'', in_group, out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[pol, azi, in_group - 1,
|
||||
out_group - 1],
|
||||
rel_err_xs[pol, azi, in_group - 1,
|
||||
|
|
@ -2480,7 +2432,7 @@ class MatrixMDGXS(MDGXS):
|
|||
for out_group in range(1, self.num_groups + 1):
|
||||
string += template.format(
|
||||
'', in_group, out_group)
|
||||
string += '{:.2e} +/- {:.2e}%'.format(
|
||||
string += '{:.2e} +/- {:.2e}'.format(
|
||||
average_xs[in_group-1, out_group-1],
|
||||
rel_err_xs[in_group-1, out_group-1])
|
||||
string += '\n'
|
||||
|
|
@ -2512,7 +2464,7 @@ class MatrixMDGXS(MDGXS):
|
|||
for out_group in range(1, self.num_groups + 1):
|
||||
string += '\t' + template.format(
|
||||
'', in_group, out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[pol, azi, in_group - 1,
|
||||
out_group - 1],
|
||||
rel_err_xs[pol, azi, in_group - 1,
|
||||
|
|
@ -2526,7 +2478,7 @@ class MatrixMDGXS(MDGXS):
|
|||
for out_group in range(1, self.num_groups + 1):
|
||||
string += template.format('', in_group,
|
||||
out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[in_group - 1, out_group - 1],
|
||||
rel_err_xs[in_group - 1, out_group - 1])
|
||||
string += '\n'
|
||||
|
|
|
|||
|
|
@ -65,6 +65,39 @@ MU_TREATMENTS = ('legendre', 'histogram')
|
|||
_MAX_LEGENDRE = 10
|
||||
|
||||
|
||||
def _df_column_convert_to_bin(df, current_name, new_name, values_to_bin,
|
||||
reverse_order=False):
|
||||
"""Convert a Pandas DataFrame column from the bin edges to an index for
|
||||
each bin. This method operates on the DataFrame, df, in-place.
|
||||
"""
|
||||
|
||||
# Get the current values
|
||||
df_bins = np.asarray(df[current_name])
|
||||
new_vals = np.zeros_like(df_bins, dtype=int)
|
||||
# Replace the values with the index of the closest entry in values_to_bin
|
||||
# The closest is used because it is expected that the values in df could
|
||||
# have lost precision along the way
|
||||
for i, df_val in enumerate(df_bins):
|
||||
idx = np.searchsorted(values_to_bin, df_val)
|
||||
# Check to make sure if the value is just above the search result
|
||||
if idx > 0 and np.isclose(values_to_bin[idx - 1], df_val):
|
||||
idx -= 1
|
||||
# If it is just below the search result then we are done
|
||||
new_vals[i] = idx
|
||||
# Switch to a one-based indexing
|
||||
new_vals += 1
|
||||
|
||||
# Reverse the ordering if requested (this is for energy group ordering)
|
||||
if reverse_order:
|
||||
new_vals = (len(values_to_bin) - 1) - new_vals + 1
|
||||
|
||||
# Assign the values
|
||||
df[current_name] = new_vals[:]
|
||||
|
||||
# And rename the column
|
||||
df.rename(columns={current_name: new_name}, inplace=True)
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class MGXS(object):
|
||||
"""An abstract multi-group cross section for some energy group structure
|
||||
|
|
@ -232,7 +265,10 @@ class MGXS(object):
|
|||
return existing
|
||||
|
||||
def _add_angle_filters(self, filters):
|
||||
# Add the azimuthal and polar bins if needed.
|
||||
"""Add the azimuthal and polar bins to the MGXS filters if needed.
|
||||
Filters will be provided as a ragged 2D list of openmc.Filter objects.
|
||||
"""
|
||||
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
# Then the user has requested angular data, so create the bins
|
||||
pol_bins = np.linspace(0., np.pi, num=self.num_polar + 1,
|
||||
|
|
@ -246,6 +282,75 @@ class MGXS(object):
|
|||
|
||||
return filters
|
||||
|
||||
def _squeeze_xs(self, xs):
|
||||
"""Remove dimensions which are not needed from a cross section array
|
||||
due to user options. This is used by the openmc.Mgxs.get_xs(...) method
|
||||
"""
|
||||
|
||||
# numpy.squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, to avoid this we will try each axis one at a
|
||||
# time to preclude the ValueError.
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in self._dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
return xs
|
||||
|
||||
def _df_convert_columns_to_bins(self, df):
|
||||
"""This method converts all relevant and present DataFrame columns from
|
||||
their bin boundaries to the index for each bin. This method operates on
|
||||
the DataFrame, df, in place. The method returns a list of the columns
|
||||
in which it has operated on.
|
||||
"""
|
||||
# Override polar and azimuthal bounds with indices
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
# First for polar
|
||||
bins = np.linspace(0., np.pi, self.num_polar + 1, True)
|
||||
_df_column_convert_to_bin(df, 'polar low', 'polar bin', bins)
|
||||
del df['polar high']
|
||||
|
||||
# Second for azimuthal
|
||||
bins = np.linspace(-np.pi, np.pi, self.num_azimuthal + 1, True)
|
||||
_df_column_convert_to_bin(df, 'azimuthal low', 'azimuthal bin',
|
||||
bins)
|
||||
del df['azimuthal high']
|
||||
columns = ['polar bin', 'azimuthal bin']
|
||||
else:
|
||||
columns = []
|
||||
|
||||
# Override energy groups bounds with indices
|
||||
if 'energy low [eV]' in df:
|
||||
_df_column_convert_to_bin(df, 'energy low [eV]', 'group in',
|
||||
self.energy_groups.group_edges,
|
||||
reverse_order=True)
|
||||
del df['energy high [eV]']
|
||||
columns += ['group in']
|
||||
if 'energyout low [eV]' in df:
|
||||
_df_column_convert_to_bin(df, 'energyout low [eV]', 'group out',
|
||||
self.energy_groups.group_edges,
|
||||
reverse_order=True)
|
||||
del df['energyout high [eV]']
|
||||
columns += ['group out']
|
||||
|
||||
if 'mu low' in df and hasattr(self, 'histogram_bins'):
|
||||
# Only the ScatterMatrix class has the histogram_bins attribute
|
||||
bins = np.linspace(-1., 1., self.histogram_bins + 1, True)
|
||||
_df_column_convert_to_bin(df, 'mu low', 'mu bin', bins)
|
||||
del df['mu high']
|
||||
columns += ['mu bin']
|
||||
|
||||
return columns
|
||||
|
||||
@property
|
||||
def _dont_squeeze(self):
|
||||
"""Create a tuple of axes which should not be removed during the get_xs
|
||||
process
|
||||
"""
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
return (0, 1, 3)
|
||||
else:
|
||||
return (1, )
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
|
@ -936,17 +1041,7 @@ class MGXS(object):
|
|||
if squeeze:
|
||||
# We want to squeeze out everything but the polar, azimuthal,
|
||||
# and energy group data.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
dont_squeeze = (0, 1, 3)
|
||||
else:
|
||||
dont_squeeze = (1, )
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
|
||||
return xs
|
||||
|
||||
|
|
@ -1452,7 +1547,7 @@ class MGXS(object):
|
|||
bounds[0],
|
||||
bounds[1])
|
||||
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[pol, azi, group - 1],
|
||||
rel_err_xs[pol, azi, group - 1])
|
||||
string += '\n'
|
||||
|
|
@ -1463,7 +1558,7 @@ class MGXS(object):
|
|||
bounds = self.energy_groups.get_group_bounds(group)
|
||||
string += template.format('', group, bounds[0],
|
||||
bounds[1])
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[group - 1], rel_err_xs[group - 1])
|
||||
string += '\n'
|
||||
string += '\n'
|
||||
|
|
@ -1758,44 +1853,9 @@ class MGXS(object):
|
|||
else:
|
||||
df = df.drop('score', axis=1)
|
||||
|
||||
# Override polar and azimuthal bounds with indices
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
# First for polar
|
||||
del df['polar high']
|
||||
df.rename(columns={'polar low': 'polar bin'}, inplace=True)
|
||||
df_bins = df['polar bin']
|
||||
pol_bins = np.linspace(0., np.pi, num=self.num_polar + 1,
|
||||
endpoint=True)
|
||||
df['polar bin'] = np.searchsorted(pol_bins, df_bins) + 1
|
||||
|
||||
# Second for azimuthal
|
||||
del df['azimuthal high']
|
||||
df.rename(columns={'azimuthal low': 'azimuthal bin'},
|
||||
inplace=True)
|
||||
df_bins = df['azimuthal bin']
|
||||
azi_bins = np.linspace(-np.pi, np.pi, num=self.num_azimuthal + 1,
|
||||
endpoint=True)
|
||||
df['azimuthal bin'] = np.searchsorted(azi_bins, df_bins) + 1
|
||||
columns = ['polar bin', 'azimuthal bin']
|
||||
else:
|
||||
columns = []
|
||||
|
||||
# Override energy groups bounds with indices
|
||||
if 'energy low [eV]' in df:
|
||||
df.rename(columns={'energy low [eV]': 'group in'}, inplace=True)
|
||||
df_bins = df['group in']
|
||||
df['group in'] = self.energy_groups.num_groups - \
|
||||
np.searchsorted(self.energy_groups.group_edges, df_bins)
|
||||
del df['energy high [eV]']
|
||||
columns += ['group in']
|
||||
if 'energyout low [eV]' in df:
|
||||
df.rename(columns={'energyout low [eV]': 'group out'},
|
||||
inplace=True)
|
||||
df_bins = df['group out']
|
||||
df['group out'] = self.energy_groups.num_groups - \
|
||||
np.searchsorted(self.energy_groups.group_edges, df_bins)
|
||||
del df['energyout high [eV]']
|
||||
columns += ['group out']
|
||||
# Convert azimuthal, polar, energy in and energy out bin values in to
|
||||
# bin indices
|
||||
columns = self._df_convert_columns_to_bins(df)
|
||||
|
||||
# Select out those groups the user requested
|
||||
if not isinstance(groups, string_types):
|
||||
|
|
@ -1811,7 +1871,7 @@ class MGXS(object):
|
|||
else:
|
||||
densities = self.get_nuclide_densities('sum')
|
||||
densities = np.repeat(densities, len(self.rxn_rate_tally.scores))
|
||||
tile_factor = df.shape[0] / len(densities)
|
||||
tile_factor = int(df.shape[0] / len(densities))
|
||||
df['mean'] /= np.tile(densities, tile_factor)
|
||||
df['std. dev.'] /= np.tile(densities, tile_factor)
|
||||
|
||||
|
|
@ -1949,6 +2009,16 @@ class MatrixMGXS(MGXS):
|
|||
The key used to index multi-group cross sections in an HDF5 data store
|
||||
|
||||
"""
|
||||
@property
|
||||
def _dont_squeeze(self):
|
||||
"""Create a tuple of axes which should not be removed during the get_xs
|
||||
process
|
||||
"""
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
return (0, 1, 3, 4)
|
||||
else:
|
||||
return (1, 2)
|
||||
|
||||
@property
|
||||
def filters(self):
|
||||
# Create the non-domain specific Filters for the Tallies
|
||||
|
|
@ -2127,17 +2197,7 @@ class MatrixMGXS(MGXS):
|
|||
if squeeze:
|
||||
# We want to squeeze out everything but the polar, azimuthal,
|
||||
# and in/out energy group data.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
dont_squeeze = (0, 1, 3, 4)
|
||||
else:
|
||||
dont_squeeze = (1, 2)
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
|
||||
return xs
|
||||
|
||||
|
|
@ -2309,7 +2369,7 @@ class MatrixMGXS(MGXS):
|
|||
string += '\t' + template.format('',
|
||||
in_group,
|
||||
out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[pol, azi, in_group - 1,
|
||||
out_group - 1],
|
||||
rel_err_xs[pol, azi, in_group - 1,
|
||||
|
|
@ -2322,7 +2382,7 @@ class MatrixMGXS(MGXS):
|
|||
for in_group in range(1, self.num_groups + 1):
|
||||
for out_group in range(1, self.num_groups + 1):
|
||||
string += template.format('', in_group, out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[in_group - 1, out_group - 1],
|
||||
rel_err_xs[in_group - 1, out_group - 1])
|
||||
string += '\n'
|
||||
|
|
@ -3797,6 +3857,22 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
clone._histogram_bins = self.histogram_bins
|
||||
return clone
|
||||
|
||||
@property
|
||||
def _dont_squeeze(self):
|
||||
"""Create a tuple of axes which should not be removed during the get_xs
|
||||
process
|
||||
"""
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
if self.scatter_format == 'histogram':
|
||||
return (0, 1, 3, 4, 5)
|
||||
else:
|
||||
return (0, 1, 3, 4)
|
||||
else:
|
||||
if self.scatter_format == 'histogram':
|
||||
return (1, 2, 3)
|
||||
else:
|
||||
return (1, 2)
|
||||
|
||||
@property
|
||||
def correction(self):
|
||||
return self._correction
|
||||
|
|
@ -4247,24 +4323,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
# out_groups, and, if needed, num_mu_bins dimension. These must
|
||||
# not be squeezed so 1-group, 1-angle problems have the correct
|
||||
# shape.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
if self.scatter_format == 'histogram':
|
||||
dont_squeeze = (0, 1, 3, 4, 5)
|
||||
else:
|
||||
dont_squeeze = (0, 1, 3, 4)
|
||||
else:
|
||||
if self.scatter_format == 'histogram':
|
||||
dont_squeeze = (1, 2, 3)
|
||||
else:
|
||||
dont_squeeze = (1, 2)
|
||||
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
return xs
|
||||
|
||||
def get_pandas_dataframe(self, groups='all', nuclides='all', moment='all',
|
||||
|
|
@ -4342,15 +4401,6 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
'moment', moment, self.legendre_order, equality=True)
|
||||
df = df[df['moment'] == 'P{}'.format(moment)]
|
||||
|
||||
elif self.scatter_format == 'histogram':
|
||||
# Replace the mu low and mu high columns with a single mu bin
|
||||
df.rename(columns={'mu low': 'mu bins'}, inplace=True)
|
||||
df_bins = df['mu bins']
|
||||
mu_bins = np.linspace(-1., 1., num=self.histogram_bins + 1,
|
||||
endpoint=True)
|
||||
df['mu bins'] = np.searchsorted(mu_bins, df_bins) + 1
|
||||
del df['mu high']
|
||||
|
||||
return df
|
||||
|
||||
def print_xs(self, subdomains='all', nuclides='all',
|
||||
|
|
@ -4476,7 +4526,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
string += '\t' + template.format('',
|
||||
in_group,
|
||||
out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[pol, azi, in_group - 1,
|
||||
out_group - 1],
|
||||
rel_err_xs[pol, azi, in_group - 1,
|
||||
|
|
@ -4489,7 +4539,7 @@ class ScatterMatrixXS(MatrixMGXS):
|
|||
for in_group in range(1, self.num_groups + 1):
|
||||
for out_group in range(1, self.num_groups + 1):
|
||||
string += template.format('', in_group, out_group)
|
||||
string += '{1:.2e} +/- {1:.2e}%'.format(
|
||||
string += '{0:.2e} +/- {1:.2e}'.format(
|
||||
average_xs[in_group - 1, out_group - 1],
|
||||
rel_err_xs[in_group - 1, out_group - 1])
|
||||
string += '\n'
|
||||
|
|
@ -5047,6 +5097,16 @@ class Chi(MGXS):
|
|||
self._estimator = 'analog'
|
||||
self._valid_estimators = ['analog']
|
||||
|
||||
@property
|
||||
def _dont_squeeze(self):
|
||||
"""Create a tuple of axes which should not be removed during the get_xs
|
||||
process
|
||||
"""
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
return (0, 1, 3)
|
||||
else:
|
||||
return (1,)
|
||||
|
||||
@property
|
||||
def scores(self):
|
||||
return ['nu-fission', 'nu-fission']
|
||||
|
|
@ -5378,17 +5438,7 @@ class Chi(MGXS):
|
|||
if squeeze:
|
||||
# We want to squeeze out everything but the polar, azimuthal,
|
||||
# and energy group data.
|
||||
if self.num_polar > 1 or self.num_azimuthal > 1:
|
||||
dont_squeeze = (0, 1, 3)
|
||||
else:
|
||||
dont_squeeze = (1,)
|
||||
# Squeeze will return a ValueError if the axis has a size
|
||||
# greater than 1, so try each axis in axes one at a time,
|
||||
# and do our own check to preclude the ValueError
|
||||
initial_shape = len(xs.shape)
|
||||
for axis in range(initial_shape - 1, -1, -1):
|
||||
if axis not in dont_squeeze and xs.shape[axis] == 1:
|
||||
xs = np.squeeze(xs, axis=axis)
|
||||
xs = self._squeeze_xs(xs)
|
||||
|
||||
return xs
|
||||
|
||||
|
|
@ -5443,7 +5493,7 @@ class Chi(MGXS):
|
|||
densities = self.get_nuclide_densities(nuclides)
|
||||
else:
|
||||
densities = self.get_nuclide_densities('sum')
|
||||
tile_factor = df.shape[0] / len(densities)
|
||||
tile_factor = int(df.shape[0] / len(densities))
|
||||
df['mean'] *= np.tile(densities, tile_factor)
|
||||
df['std. dev.'] *= np.tile(densities, tile_factor)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue