mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Merge pull request #393 from wbinventor/pandas
Pandas DataFrames for tally data
This commit is contained in:
commit
1ce3ec24ea
10 changed files with 996 additions and 422 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -61,5 +61,4 @@ data/nndc
|
|||
|
||||
# PyCharm project configuration files
|
||||
.idea
|
||||
.idea/*
|
||||
|
||||
.idea/*
|
||||
|
|
@ -129,7 +129,6 @@ contains
|
|||
type(Particle), intent(inout) :: p
|
||||
logical, intent(inout) :: found
|
||||
integer, optional :: search_cells(:)
|
||||
|
||||
integer :: i ! index over cells
|
||||
integer :: i_xyz(3) ! indices in lattice
|
||||
integer :: n ! number of cells to search
|
||||
|
|
@ -583,7 +582,6 @@ contains
|
|||
|
||||
type(Particle), intent(inout) :: p
|
||||
integer, intent(in) :: lattice_translation(3)
|
||||
|
||||
integer :: i_xyz(3) ! indices in lattice
|
||||
logical :: found ! particle found in cell?
|
||||
class(Lattice), pointer :: lat
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class Filter(object):
|
|||
self._type = type
|
||||
|
||||
elif not type in FILTER_TYPES.values():
|
||||
msg = 'Unable to set Filter type to {0} since it is not one ' \
|
||||
msg = 'Unable to set Filter type to "{0}" since it is not one ' \
|
||||
'of the supported types'.format(type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ class Filter(object):
|
|||
self.num_bins = 0
|
||||
|
||||
elif self._type is None:
|
||||
msg = 'Unable to set bins for Filter to {0} since ' \
|
||||
msg = 'Unable to set bins for Filter to "{0}" since ' \
|
||||
'the Filter type has not yet been set'.format(bins)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -136,12 +136,12 @@ class Filter(object):
|
|||
for edge in bins:
|
||||
|
||||
if not is_integer(edge):
|
||||
msg = 'Unable to add bin {0} to a {1} Filter since ' \
|
||||
msg = 'Unable to add bin "{0}" to a {1} Filter since ' \
|
||||
'it is a non-integer'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif edge < 0:
|
||||
msg = 'Unable to add bin {0} to a {1} Filter since ' \
|
||||
msg = 'Unable to add bin "{0}" to a {1} Filter since ' \
|
||||
'it is a negative integer'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -151,22 +151,22 @@ class Filter(object):
|
|||
for edge in bins:
|
||||
|
||||
if not is_integer(edge) and not is_float(edge):
|
||||
msg = 'Unable to add bin edge {0} to {1} Filter since ' \
|
||||
'it is a non-integer or floating point ' \
|
||||
msg = 'Unable to add bin edge "{0}" to a {1} Filter ' \
|
||||
'since it is a non-integer or floating point ' \
|
||||
'value'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif edge < 0.:
|
||||
msg = 'Unable to add bin edge {0} to {1} Filter since it ' \
|
||||
'is a negative value'.format(edge, self._type)
|
||||
msg = 'Unable to add bin edge "{0}" to a {1} Filter ' \
|
||||
'since it is a negative value'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Check that bin edges are monotonically increasing
|
||||
for index in range(len(bins)):
|
||||
|
||||
if index > 0 and bins[index] < bins[index-1]:
|
||||
msg = 'Unable to add bin edges {0} to {1} Filter since ' \
|
||||
'they are not monotonically ' \
|
||||
msg = 'Unable to add bin edges "{0}" to a {1} Filter ' \
|
||||
'since they are not monotonically ' \
|
||||
'increasing'.format(bins, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -175,17 +175,17 @@ class Filter(object):
|
|||
elif self._type == 'mesh':
|
||||
|
||||
if not len(bins) == 1:
|
||||
msg = 'Unable to add bins {0} to a mesh Filter since ' \
|
||||
msg = 'Unable to add bins "{0}" to a mesh Filter since ' \
|
||||
'only a single mesh can be used per tally'.format(bins)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not is_integer(bins[0]):
|
||||
msg = 'Unable to add bin {0} to mesh Filter since it ' \
|
||||
msg = 'Unable to add bin "{0}" to mesh Filter since it ' \
|
||||
'is a non-integer'.format(bins[0])
|
||||
raise ValueError(msg)
|
||||
|
||||
elif bins[0] < 0:
|
||||
msg = 'Unable to add bin {0} to mesh Filter since it ' \
|
||||
msg = 'Unable to add bin "{0}" to mesh Filter since it ' \
|
||||
'is a negative integer'.format(bins[0])
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ class Filter(object):
|
|||
def num_bins(self, num_bins):
|
||||
|
||||
if not is_integer(num_bins) or num_bins < 0:
|
||||
msg = 'Unable to set the number of bins {0} for a {1} Filter ' \
|
||||
msg = 'Unable to set the number of bins "{0}" for a {1} Filter ' \
|
||||
'since it is not a positive ' \
|
||||
'integer'.format(num_bins, self._type)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -210,7 +210,7 @@ class Filter(object):
|
|||
def mesh(self, mesh):
|
||||
|
||||
if not isinstance(mesh, Mesh):
|
||||
msg = 'Unable to set Mesh to {0} for Filter since it is not a ' \
|
||||
msg = 'Unable to set Mesh to "{0}" for Filter since it is not a ' \
|
||||
'Mesh object'.format(mesh)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ class Filter(object):
|
|||
def offset(self, offset):
|
||||
|
||||
if not is_integer(offset):
|
||||
msg = 'Unable to set offset {0} for a {1} Filter since it is a ' \
|
||||
msg = 'Unable to set offset "{0}" for a {1} Filter since it is a ' \
|
||||
'non-integer value'.format(offset, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -234,12 +234,12 @@ class Filter(object):
|
|||
def stride(self, stride):
|
||||
|
||||
if not is_integer(stride):
|
||||
msg = 'Unable to set stride {0} for a {1} Filter since it is a ' \
|
||||
msg = 'Unable to set stride "{0}" for a {1} Filter since it is a ' \
|
||||
'non-integer value'.format(stride, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
if stride < 0:
|
||||
msg = 'Unable to set stride {0} for a {1} Filter since it is a ' \
|
||||
msg = 'Unable to set stride "{0}" for a {1} Filter since it is a ' \
|
||||
'negative value'.format(stride, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -288,17 +288,67 @@ class Filter(object):
|
|||
return merged_filter
|
||||
|
||||
|
||||
def get_bin_index(self, bin):
|
||||
def get_bin_index(self, filter_bin):
|
||||
"""Returns the index in the Filter for some bin.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
filter_bin : int, tuple
|
||||
The bin is the integer ID for 'material', 'surface', 'cell',
|
||||
'cellborn', and 'universe' Filters. The bin is an integer for
|
||||
the cell instance ID for 'distribcell' Filters. The bin is
|
||||
a 2-tuple of floats for 'energy' and 'energyout' filters
|
||||
corresponding to the energy boundaries of the bin of interest.
|
||||
The bin is a (x,y,z) 3-tuple for 'mesh' filters corresponding to
|
||||
the mesh cell of interest.
|
||||
|
||||
Returns
|
||||
-------
|
||||
The index in the Tally data array for this filter bin.
|
||||
"""
|
||||
|
||||
|
||||
# FIXME: This does not work for distribcells!!!
|
||||
|
||||
try:
|
||||
index = self._bins.index(bin)
|
||||
# Filter bins for a mesh are an (x,y,z) tuple
|
||||
if self.type == 'mesh':
|
||||
|
||||
# Convert (x,y,z) to a single bin -- this is similar to
|
||||
# subroutine mesh_indices_to_bin in openmc/src/mesh.F90.
|
||||
if (len(self.mesh.dimension) == 3):
|
||||
nx, ny, nz = self.mesh.dimension
|
||||
val = (filter_bin[0] - 1) * ny * nz + \
|
||||
(filter_bin[1] - 1) * nz + \
|
||||
(filter_bin[2] - 1)
|
||||
else:
|
||||
nx, ny = self.mesh.dimension
|
||||
val = (filter_bin[0] - 1) * ny + \
|
||||
(filter_bin[1] - 1)
|
||||
|
||||
filter_index = val
|
||||
|
||||
# Use lower energy bound to find index for energy Filters
|
||||
elif self.type in ['energy', 'energyout']:
|
||||
val = self.bins.index(filter_bin[0])
|
||||
filter_index = val
|
||||
|
||||
# Filter bins for distribcell are the "IDs" of each unique placement
|
||||
# of the Cell in the Geometry (integers starting at 0)
|
||||
elif self._type == 'distribcell':
|
||||
filter_index = filter_bin
|
||||
|
||||
# Use ID for all other Filters (e.g., material, cell, etc.)
|
||||
else:
|
||||
val = self.bins.index(filter_bin)
|
||||
filter_index = val
|
||||
|
||||
except ValueError:
|
||||
msg = 'Unable to get the bin index for Filter since {0} ' \
|
||||
'is not one of the bins'.format(bin)
|
||||
msg = 'Unable to get the bin index for Filter since "{0}" ' \
|
||||
'is not one of the bins'.format(filter_bin)
|
||||
raise ValueError(msg)
|
||||
|
||||
return index
|
||||
return filter_index
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
|||
|
|
@ -332,9 +332,6 @@ class StatePoint(object):
|
|||
|
||||
subbase = '{0}{1}/filter '.format(base, tally_key)
|
||||
|
||||
# Initialize the stride
|
||||
stride = 1
|
||||
|
||||
# Initialize all Filters
|
||||
for j in range(1, n_filters+1):
|
||||
|
||||
|
|
@ -359,7 +356,6 @@ class StatePoint(object):
|
|||
bins = self._get_double(
|
||||
n_bins+1, path='{0}{1}/bins'.format(subbase, j))
|
||||
|
||||
# FIXME
|
||||
elif FILTER_TYPES[filter_type] in ['mesh', 'distribcell']:
|
||||
bins = self._get_int(
|
||||
path='{0}{1}/bins'.format(subbase, j))[0]
|
||||
|
|
@ -371,7 +367,6 @@ class StatePoint(object):
|
|||
# Create Filter object
|
||||
filter = openmc.Filter(FILTER_TYPES[filter_type], bins)
|
||||
filter.offset = offset
|
||||
filter.stride = stride
|
||||
filter.num_bins = n_bins
|
||||
|
||||
if FILTER_TYPES[filter_type] == 'mesh':
|
||||
|
|
@ -381,9 +376,6 @@ class StatePoint(object):
|
|||
# Add Filter to the Tally
|
||||
tally.add_filter(filter)
|
||||
|
||||
# Update the stride for the next Filter
|
||||
stride *= n_bins
|
||||
|
||||
# Read Nuclide bins
|
||||
n_nuclides = self._get_int(
|
||||
path='{0}{1}/n_nuclides'.format(base, tally_key))[0]
|
||||
|
|
@ -406,6 +398,14 @@ class StatePoint(object):
|
|||
n_user_scores = self._get_int(
|
||||
path='{0}{1}/n_user_score_bins'.format(base, tally_key))[0]
|
||||
|
||||
# Compute and set the filter strides
|
||||
for i in range(n_filters):
|
||||
filter = tally.filters[i]
|
||||
filter.stride = n_score_bins * n_nuclides
|
||||
|
||||
for j in range(i+1, n_filters):
|
||||
filter.stride *= tally.filters[j].num_bins
|
||||
|
||||
# Read scattering moment order strings (e.g., P3, Y-1,2, etc.)
|
||||
moments = []
|
||||
subbase = '{0}{1}/moments/'.format(base, tally_key)
|
||||
|
|
@ -435,7 +435,7 @@ class StatePoint(object):
|
|||
tally.add_score(score)
|
||||
|
||||
# Add Tally to the global dictionary of all Tallies
|
||||
self._tallies[tally_key] = tally
|
||||
self.tallies[tally_key] = tally
|
||||
|
||||
|
||||
def read_results(self):
|
||||
|
|
@ -574,76 +574,108 @@ class StatePoint(object):
|
|||
|
||||
|
||||
# Calculate sample mean and standard deviation for user-defined Tallies
|
||||
for tally_id, tally in self._tallies.items():
|
||||
for tally_id, tally in self.tallies.items():
|
||||
tally.compute_std_dev(t_value)
|
||||
|
||||
|
||||
def get_tally(self, score, filters, nuclides,
|
||||
name='', estimator='tracklength'):
|
||||
def get_tally(self, scores=[], filters=[], nuclides=[],
|
||||
name=None, id=None, estimator=None):
|
||||
"""Finds and returns a Tally object with certain properties.
|
||||
|
||||
This routine searches the list of Tallies and returns the first Tally
|
||||
found it finds which satisfieds all of the input parameters.
|
||||
NOTE: The input parameters do not need to match the complete Tally
|
||||
specification and may only represent a subset of the Tallies properties.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
score : str
|
||||
The score string
|
||||
scores : list
|
||||
A list of one or more score strings (default is []).
|
||||
|
||||
filters : list
|
||||
A list of Filter objects
|
||||
A list of Filter objects (default is []).
|
||||
|
||||
nuclides : list
|
||||
A list of Nuclide objects
|
||||
A list of Nuclide objects (default is []).
|
||||
|
||||
name : str
|
||||
The name specified for the Tally (default is '')
|
||||
The name specified for the Tally (default is None).
|
||||
|
||||
id : int
|
||||
The id specified for the Tally (default is None).
|
||||
|
||||
estimator: str
|
||||
The type of estimator ('tracklength' (default) or 'analog')
|
||||
The type of estimator ('tracklength', 'analog'; default is None).
|
||||
|
||||
Returns
|
||||
-------
|
||||
A Tally object.
|
||||
|
||||
Raises
|
||||
------
|
||||
LookupError : An error when a Tally meeting all of the input
|
||||
parameters cannot be found in the statepoint.
|
||||
"""
|
||||
|
||||
# Loop over the domain-to-tallies mapping to find the Tally
|
||||
tally = None
|
||||
|
||||
# Iterate over all tallies to find the appropriate one
|
||||
for tally_id, test_tally in self._tallies.items():
|
||||
for tally_id, test_tally in self.tallies.items():
|
||||
|
||||
# Determine if the queried Tally name is the same as this Tally
|
||||
if not name == test_tally._name:
|
||||
# Determine if Tally has queried name
|
||||
if name and name != test_tally.name:
|
||||
continue
|
||||
|
||||
# Determine if the queried Tally estimator is the same as this Tally
|
||||
if not estimator == test_tally._estimator:
|
||||
# Determine if Tally has queried id
|
||||
if id and id != test_tally.id:
|
||||
continue
|
||||
|
||||
# Determine if the queried Tally scores are the same as this Tally
|
||||
if not score in test_tally._scores:
|
||||
# Determine if Tally has queried estimator
|
||||
if estimator and not estimator == test_tally.estimator:
|
||||
continue
|
||||
|
||||
# Determine if queried Tally filters is same length as this Tally
|
||||
if len(filters) != len(test_tally._filters):
|
||||
continue
|
||||
# Determine if Tally has the queried score(s)
|
||||
if scores:
|
||||
contains_scores = True
|
||||
|
||||
# Determine if the queried Tally filters are the same as this Tally
|
||||
contains_filters = True
|
||||
# Iterate over the scores requested by the user
|
||||
for score in scores:
|
||||
if not score in test_tally.scores:
|
||||
contains_scores = False
|
||||
break
|
||||
|
||||
# Iterate over the filters requested by the user
|
||||
for filter in filters:
|
||||
if not filter in test_tally._filters:
|
||||
contains_filters = False
|
||||
break
|
||||
if not contains_scores:
|
||||
continue
|
||||
|
||||
# Determine if the queried Nuclide is in this Tally
|
||||
contains_nuclides = True
|
||||
# Determine if Tally has the queried Filter(s)
|
||||
if filters:
|
||||
contains_filters = True
|
||||
|
||||
# Iterate over the Nuclides requested by the user
|
||||
for nuclide in nuclides:
|
||||
if not nuclide in test_tally._nuclides:
|
||||
contains_nuclides = False
|
||||
break
|
||||
# Iterate over the Filters requested by the user
|
||||
for filter in filters:
|
||||
if not filter in test_tally.filters:
|
||||
contains_filters = False
|
||||
break
|
||||
|
||||
# If the Tally contained all Filters and Nuclides, return the Tally
|
||||
if contains_filters and contains_nuclides:
|
||||
tally = test_tally
|
||||
break
|
||||
if not contains_filters:
|
||||
continue
|
||||
|
||||
# Determine if Tally has the queried Nuclide(s)
|
||||
if nuclides:
|
||||
contains_nuclides = True
|
||||
|
||||
# Iterate over the Nuclides requested by the user
|
||||
for nuclide in nuclides:
|
||||
if not nuclide in test_tally.nuclides:
|
||||
contains_nuclides = False
|
||||
break
|
||||
|
||||
if not contains_nuclides:
|
||||
continue
|
||||
|
||||
# If the current Tally met user's request, break loop and return it
|
||||
tally = test_tally
|
||||
break
|
||||
|
||||
# If we did not find the Tally, return an error message
|
||||
if tally is None:
|
||||
|
|
@ -652,41 +684,37 @@ class StatePoint(object):
|
|||
return tally
|
||||
|
||||
|
||||
def get_tally_id(self, score, filters, name='', estimator='tracklength'):
|
||||
"""Retrieve the Tally ID for a given list of filters and score(s).
|
||||
def link_with_summary(self, summary):
|
||||
"""Links Tallies and Filters with Summary model information.
|
||||
|
||||
This routine retrieves model information (materials, geometry) from a
|
||||
Summary object populated with an HDF5 'summary.h5' file and inserts
|
||||
it into the Tally objects. This can be helpful when viewing and
|
||||
manipulating large scale Tally data.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
score : str
|
||||
The score string
|
||||
summary : Summary
|
||||
A Summary object.
|
||||
|
||||
filters : list
|
||||
A list of Filter objects
|
||||
|
||||
name : str
|
||||
The name specified for the Tally (default is '')
|
||||
|
||||
estimator: str
|
||||
The type of estimator ('tracklength' (default) or 'analog')
|
||||
Raises
|
||||
------
|
||||
ValueError : An error when the argument passed to the 'summary'
|
||||
parameter is not an openmc.Summary object.
|
||||
"""
|
||||
|
||||
tally = self.get_tally(score, filters, name, estimator)
|
||||
return tally._id
|
||||
|
||||
|
||||
def link_with_summary(self, summary):
|
||||
|
||||
if not isinstance(summary, openmc.summary.Summary):
|
||||
msg = 'Unable to link statepoint with {0} which ' \
|
||||
'is not a Summary object'.format(summary)
|
||||
raise ValueError(msg)
|
||||
|
||||
for tally_id, tally in self._tallies.items():
|
||||
for tally_id, tally in self.tallies.items():
|
||||
|
||||
# Get the Tally name from the summary file
|
||||
tally.name = summary.tallies[tally_id].name
|
||||
tally.with_summary = True
|
||||
|
||||
nuclide_zaids = copy.deepcopy(tally._nuclides)
|
||||
nuclide_zaids = copy.deepcopy(tally.nuclides)
|
||||
|
||||
for nuclide_zaid in nuclide_zaids:
|
||||
|
||||
|
|
@ -696,32 +724,32 @@ class StatePoint(object):
|
|||
else:
|
||||
tally.add_nuclide(summary.nuclides[nuclide_zaid])
|
||||
|
||||
for filter in tally._filters:
|
||||
for filter in tally.filters:
|
||||
|
||||
if filter._type == 'surface':
|
||||
if filter.type == 'surface':
|
||||
surface_ids = []
|
||||
for bin in filter._bins:
|
||||
surface_ids.append(summary.surfaces[bin]._id)
|
||||
for bin in filter.bins:
|
||||
surface_ids.append(summary.surfaces[bin].id)
|
||||
filter.bins = surface_ids
|
||||
|
||||
if filter._type in ['cell', 'distribcell']:
|
||||
if filter.type in ['cell', 'distribcell']:
|
||||
distribcell_ids = []
|
||||
for bin in filter._bins:
|
||||
distribcell_ids.append(summary.cells[bin]._id)
|
||||
for bin in filter.bins:
|
||||
distribcell_ids.append(summary.cells[bin].id)
|
||||
filter.bins = distribcell_ids
|
||||
|
||||
if filter._type == 'universe':
|
||||
if filter.type == 'universe':
|
||||
universe_ids = []
|
||||
for bin in filter._bins:
|
||||
universe_ids.append(summary.universes[bin]._id)
|
||||
for bin in filter.bins:
|
||||
universe_ids.append(summary.universes[bin].id)
|
||||
filter.bins = universe_ids
|
||||
|
||||
if filter._type == 'material':
|
||||
if filter.type == 'material':
|
||||
material_ids = []
|
||||
for bin in filter._bins:
|
||||
material_ids.append(summary.materials[bin]._id)
|
||||
for bin in filter.bins:
|
||||
material_ids.append(summary.materials[bin].id)
|
||||
filter.bins = material_ids
|
||||
|
||||
|
||||
self._with_summary = True
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -491,6 +491,10 @@ class Summary(object):
|
|||
self.tallies = {}
|
||||
|
||||
# Read the number of tallies
|
||||
if not 'tallies' in self._f.keys():
|
||||
self.n_tallies = 0
|
||||
return
|
||||
|
||||
self.n_tallies = self._f['tallies/n_tallies'][0]
|
||||
|
||||
# OpenMC Tally keys
|
||||
|
|
@ -532,15 +536,16 @@ class Summary(object):
|
|||
|
||||
subsubbase = '{0}/filter {1}'.format(subbase, j)
|
||||
|
||||
# Read filter type (e.g., "cell", "energy", etc.) integer code
|
||||
filter_type = self._f['{0}/type'.format(subsubbase)][0]
|
||||
# Read filter type (e.g., "cell", "energy", etc.)
|
||||
filter_type_code = self._f['{0}/type'.format(subsubbase)][0]
|
||||
filter_type = openmc.FILTER_TYPES[filter_type_code]
|
||||
|
||||
# Read the filter bins
|
||||
num_bins = self._f['{0}/n_bins'.format(subsubbase)][0]
|
||||
bins = self._f['{0}/bins'.format(subsubbase)][...]
|
||||
|
||||
# Create Filter object
|
||||
filter = openmc.Filter(openmc.FILTER_TYPES[filter_type], bins)
|
||||
filter = openmc.Filter(filter_type, bins)
|
||||
filter.num_bins = num_bins
|
||||
|
||||
# Add Filter to the Tally
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -57,7 +57,7 @@ class Trigger(object):
|
|||
|
||||
if not trigger_type in ['variance', 'std_dev', 'rel_err']:
|
||||
msg = 'Unable to create a tally trigger with ' \
|
||||
'type {0}'.format(trigger_type)
|
||||
'type "{0}"'.format(trigger_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._trigger_type = trigger_type
|
||||
|
|
@ -68,7 +68,7 @@ class Trigger(object):
|
|||
|
||||
if not is_float(threshold):
|
||||
msg = 'Unable to set a tally trigger threshold with ' \
|
||||
'threshold {0}'.format(threshold)
|
||||
'threshold "{0}"'.format(threshold)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._threshold = threshold
|
||||
|
|
@ -77,7 +77,7 @@ class Trigger(object):
|
|||
def add_score(self, score):
|
||||
|
||||
if not is_string(score):
|
||||
msg = 'Unable to add score {0} to tally trigger since ' \
|
||||
msg = 'Unable to add score "{0}" to tally trigger since ' \
|
||||
'it is not a string'.format(score)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ else:
|
|||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally1 = sp.get_tally('flux', [openmc.Filter('mesh', [1])], \
|
||||
[-1], estimator='tracklength')
|
||||
tally2 = sp.get_tally('flux', [openmc.Filter('mesh', [2])], \
|
||||
[-1], estimator='analog')
|
||||
tally3 = sp.get_tally('nu-fission', [openmc.Filter('mesh', [2])], \
|
||||
[-1], estimator='analog')
|
||||
tally4 = sp.get_tally('current', [openmc.Filter('mesh', [2]), \
|
||||
tally1 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [1])], \
|
||||
estimator='tracklength')
|
||||
tally2 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [2])], \
|
||||
estimator='analog')
|
||||
tally3 = sp.get_tally(scores=['nu-fission'], \
|
||||
filters=[openmc.Filter('mesh', [2])], estimator='analog')
|
||||
tally4 = sp.get_tally(scores=['current'], filters=[openmc.Filter('mesh', [2]), \
|
||||
openmc.Filter('surface', [1,2,3,4,5,6])], \
|
||||
[-1], estimator='analog')
|
||||
estimator='analog')
|
||||
|
||||
results1 = np.zeros((tally1.sum.size + tally1.sum.size, ))
|
||||
results1[0::2] = tally1.sum.ravel()
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ else:
|
|||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally1 = sp.get_tally('flux', [openmc.Filter('mesh', [1])], \
|
||||
[-1], estimator='tracklength')
|
||||
tally2 = sp.get_tally('flux', [openmc.Filter('mesh', [2])], \
|
||||
[-1], estimator='analog')
|
||||
tally3 = sp.get_tally('nu-fission', [openmc.Filter('mesh', [2])], \
|
||||
[-1], estimator='analog')
|
||||
tally4 = sp.get_tally('current', [openmc.Filter('mesh', [2]), \
|
||||
tally1 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [1])], \
|
||||
estimator='tracklength')
|
||||
tally2 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [2])], \
|
||||
estimator='analog')
|
||||
tally3 = sp.get_tally(scores=['nu-fission'], \
|
||||
filters=[openmc.Filter('mesh', [2])], estimator='analog')
|
||||
tally4 = sp.get_tally(scores=['current'], filters=[openmc.Filter('mesh', [2]), \
|
||||
openmc.Filter('surface', [1,2,3,4,5,6])], \
|
||||
[-1], estimator='analog')
|
||||
estimator='analog')
|
||||
|
||||
results1 = np.zeros((tally1.sum.size + tally1.sum.size, ))
|
||||
results1[0::2] = tally1.sum.ravel()
|
||||
|
|
|
|||
|
|
@ -21,89 +21,74 @@ sp3.compute_stdev()
|
|||
|
||||
# analyze sp1
|
||||
# compare distrib sum to cell
|
||||
sp1_t1 = sp1._tallies[1]
|
||||
sp1_t2 = sp1._tallies[2]
|
||||
sp1_t1 = sp1.tallies[1]
|
||||
sp1_t2 = sp1.tallies[2]
|
||||
|
||||
distribcell_filter = sp1_t1.find_filter(filter_type='distribcell', bins=[2])
|
||||
sp1_t1_d1 = sp1_t1.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[0], value='mean')
|
||||
sp1_t1_d2 = sp1_t1.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[1], value='mean')
|
||||
sp1_t1_d3 = sp1_t1.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[2], value='mean')
|
||||
sp1_t1_d4 = sp1_t1.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[3], value='mean')
|
||||
sp1_t1_d1 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(0,)], value='mean')
|
||||
sp1_t1_d2 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(1,)], value='mean')
|
||||
sp1_t1_d3 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(2,)], value='mean')
|
||||
sp1_t1_d4 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(3,)], value='mean')
|
||||
sp1_t1_sum = sp1_t1_d1 + sp1_t1_d2 + sp1_t1_d3 + sp1_t1_d4
|
||||
|
||||
cell_filter = sp1_t2.find_filter(filter_type='cell', bins=[2])
|
||||
sp1_t2_c201 = sp1_t2.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[2], value='mean')
|
||||
cell_filter = sp1_t2.find_filter(filter_type='cell')
|
||||
sp1_t2_c201 = sp1_t2.get_values(scores=['total'], value='mean')
|
||||
|
||||
|
||||
# analyze sp2
|
||||
sp2_t1 = sp2._tallies[1]
|
||||
cell_filter = sp2_t1.find_filter(filter_type='cell', bins=[2,4,6,8])
|
||||
sp2_t1_c201 = sp2_t1.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[2], value='mean')
|
||||
sp2_t1_c203 = sp2_t1.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[4], value='mean')
|
||||
sp2_t1_c205 = sp2_t1.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[6], value='mean')
|
||||
sp2_t1_c207 = sp2_t1.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[8], value='mean')
|
||||
sp2_t1 = sp2.tallies[1]
|
||||
sp2_t1_c201 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(2,)], value='mean')
|
||||
sp2_t1_c203 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(4,)], value='mean')
|
||||
sp2_t1_c205 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(6,)], value='mean')
|
||||
sp2_t1_c207 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(8,)], value='mean')
|
||||
|
||||
|
||||
# analyze sp3
|
||||
sp3_t1 = sp3._tallies[1]
|
||||
sp3_t2 = sp3._tallies[2]
|
||||
sp3_t3 = sp3._tallies[3]
|
||||
sp3_t4 = sp3._tallies[4]
|
||||
sp3_t5 = sp3._tallies[5]
|
||||
sp3_t6 = sp3._tallies[6]
|
||||
sp3_t1 = sp3.tallies[1]
|
||||
sp3_t2 = sp3.tallies[2]
|
||||
sp3_t3 = sp3.tallies[3]
|
||||
sp3_t4 = sp3.tallies[4]
|
||||
sp3_t5 = sp3.tallies[5]
|
||||
sp3_t6 = sp3.tallies[6]
|
||||
|
||||
cell_filter = sp3_t1.find_filter(filter_type='cell', bins=[1])
|
||||
distribcell_filter = sp3_t2.find_filter(filter_type='distribcell', bins=[1])
|
||||
sp3_t1_c1 = sp3_t1.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[1], value='mean')
|
||||
sp3_t2_d1 = sp3_t2.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[0], value='mean')
|
||||
sp3_t1_c1 = sp3_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(1,)], value='mean')
|
||||
sp3_t2_d1 = sp3_t2.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(0,)], value='mean')
|
||||
|
||||
cell_filter = sp3_t3.find_filter(filter_type='cell', bins=[26])
|
||||
distribcell_filter = sp3_t4.find_filter(filter_type='distribcell', bins=[26])
|
||||
sp3_t3_c60 = sp3_t3.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[26], value='mean')
|
||||
sp3_t4_d = 0
|
||||
for i in range(241):
|
||||
sp3_t4_d += sp3_t4.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[i], value='mean')
|
||||
sp3_t3_c60 = sp3_t3.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(26,)], value='mean')
|
||||
sp3_t4_d = sum(sp3_t4.get_values(scores=['total'], value='mean'))
|
||||
|
||||
cell_filter = sp3_t5.find_filter(filter_type='cell', bins=[19])
|
||||
distribcell_filter = sp3_t6.find_filter(filter_type='distribcell', bins=[19])
|
||||
sp3_t5_c27 = sp3_t5.get_value(score='total', filters=[cell_filter],
|
||||
filter_bins=[19], value='mean')
|
||||
sp3_t6_d = 0
|
||||
for i in range(63624):
|
||||
sp3_t6_d += sp3_t6.get_value(score='total', filters=[distribcell_filter],
|
||||
filter_bins=[i], value='mean')
|
||||
sp3_t5_c27 = sp3_t5.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(19,)], value='mean')
|
||||
sp3_t6_d = sum(sp3_t6.get_values(scores=['total'], value='mean'))
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_sum)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t2_c201)
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c201)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d4)
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c203)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d1)
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c205)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d3)
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c207)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d2)
|
||||
outstr += "{0:12.6E}\n".format(sp3_t1_c1)
|
||||
outstr += "{0:12.6E}\n".format(sp3_t2_d1)
|
||||
outstr += "{0:12.6E}\n".format(sp3_t3_c60)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t2_c201[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c201[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d4[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c203[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d1[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c205[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d3[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c207[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d2[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t1_c1[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t2_d1[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t3_c60[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t4_d)
|
||||
outstr += "{0:12.6E}\n".format(sp3_t5_c27)
|
||||
outstr += "{0:12.6E}\n".format(sp3_t5_c27[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t6_d)
|
||||
|
||||
# write results to file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue