mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Moved tally names from statepoint to summary files
This commit is contained in:
parent
615724a686
commit
ef9e51a2c0
4 changed files with 82 additions and 29 deletions
|
|
@ -547,6 +547,14 @@ contains
|
|||
! Get pointer to tally
|
||||
t => tallies(i)
|
||||
|
||||
! Write the name for this tally
|
||||
call su % write_data(len(t % name), "name_size", &
|
||||
group="tallies/tally " // trim(to_str(t % id)))
|
||||
if (len(t % name) > 0) then
|
||||
call su % write_data(t % name, "name", &
|
||||
group="tallies/tally " // trim(to_str(t % id)))
|
||||
endif
|
||||
|
||||
! Write size of each tally
|
||||
call su % write_data(t % total_score_bins, "total_score_bins", &
|
||||
group="tallies/tally " // trim(to_str(t % id)))
|
||||
|
|
|
|||
|
|
@ -236,13 +236,6 @@ contains
|
|||
! Get pointer to tally
|
||||
tally => tallies(i)
|
||||
|
||||
call sp % write_data(len(tally % name), "name_size", &
|
||||
group="tallies/tally " // trim(to_str(tally % id)))
|
||||
if (len(tally % name) > 0) then
|
||||
call sp % write_data(tally % name, "name", &
|
||||
group="tallies/tally " // trim(to_str(tally % id)))
|
||||
endif
|
||||
|
||||
call sp % write_data(tally % estimator, "estimator", &
|
||||
group="tallies/tally " // trim(to_str(tally % id)))
|
||||
call sp % write_data(tally % n_realizations, "n_realizations", &
|
||||
|
|
@ -826,13 +819,6 @@ contains
|
|||
tally => tallies(i)
|
||||
curr_key = key_array(id_array(i))
|
||||
|
||||
call sp % read_data(j, "name_size", group="tallies/tally " // &
|
||||
trim(to_str(curr_key)))
|
||||
if (j > 0) then
|
||||
call sp % read_data(name, "name", group="tallies/tally " // &
|
||||
trim(to_str(curr_key)))
|
||||
end if
|
||||
|
||||
call sp % read_data(tally % estimator, "estimator", &
|
||||
group="tallies/tally " // trim(to_str(curr_key)))
|
||||
call sp % read_data(tally % n_realizations, "n_realizations", &
|
||||
|
|
|
|||
|
|
@ -298,18 +298,6 @@ class StatePoint(object):
|
|||
# Iterate over all Tallies
|
||||
for tally_key in self._tally_keys:
|
||||
|
||||
# Read user-specified Tally name (if specified)
|
||||
name_size = self._get_int(
|
||||
path='{0}{1}/name_size'.format(base, tally_key))[0]
|
||||
|
||||
if name_size > 0:
|
||||
name = self._get_string(
|
||||
name_size, path='{0}{1}/name'.format(base, tally_key))
|
||||
|
||||
# Remove leading and trailing characters from string name
|
||||
name = name.lstrip('[\'')
|
||||
name = name.rstrip('\']')
|
||||
|
||||
# Read integer Tally estimator type code (analog or tracklength)
|
||||
estimator_type = self._get_int(
|
||||
path='{0}{1}/estimator'.format(base, tally_key))[0]
|
||||
|
|
@ -319,7 +307,7 @@ class StatePoint(object):
|
|||
path='{0}{1}/n_realizations'.format(base, tally_key))[0]
|
||||
|
||||
# Create Tally object and assign basic properties
|
||||
tally = openmc.Tally(tally_key, name)
|
||||
tally = openmc.Tally(tally_key)
|
||||
tally.estimator = ESTIMATOR_TYPES[estimator_type]
|
||||
tally.num_realizations = n_realizations
|
||||
|
||||
|
|
@ -674,6 +662,9 @@ class StatePoint(object):
|
|||
|
||||
for tally_id, tally in self._tallies.items():
|
||||
|
||||
# Get the Tally name from the summary file
|
||||
tally.name = summary.tallies[tally_id].name
|
||||
|
||||
nuclide_zaids = copy.deepcopy(tally._nuclides)
|
||||
|
||||
for nuclide_zaid in nuclide_zaids:
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class Summary(object):
|
|||
|
||||
self._read_metadata()
|
||||
self._read_geometry()
|
||||
self._read_tallies()
|
||||
|
||||
|
||||
def _read_metadata(self):
|
||||
|
|
@ -398,8 +399,8 @@ class Summary(object):
|
|||
self.lattices[index] = lattice
|
||||
|
||||
if lattice_type == 'hexagonal':
|
||||
n_rings = self._f['geometry/latties'][key]['n_rings'][0]
|
||||
n_axial = self._f['geometry/latties'][key]['n_axial'][0]
|
||||
n_rings = self._f['geometry/lattices'][key]['n_rings'][0]
|
||||
n_axial = self._f['geometry/lattices'][key]['n_axial'][0]
|
||||
center = self._f['geometry/lattices'][key]['center'][...]
|
||||
pitch = self._f['geometry/lattices'][key]['pitch'][...]
|
||||
outer = self._f['geometry/lattices'][key]['outer'][0]
|
||||
|
|
@ -464,6 +465,73 @@ class Summary(object):
|
|||
self.openmc_geometry.root_universe = root_universe
|
||||
|
||||
|
||||
def _read_tallies(self):
|
||||
|
||||
# Initialize dictionaries for the Tallies
|
||||
# Keys - Tally IDs
|
||||
# Values - Tally objects
|
||||
self.tallies = {}
|
||||
|
||||
# Read the number of tallies
|
||||
self.n_tallies = self._f['tallies/n_tallies'][0]
|
||||
|
||||
# OpenMC Tally keys
|
||||
all_keys = self._f['tallies/'].keys()
|
||||
tally_keys = [key for key in all_keys if 'tally' in key]
|
||||
|
||||
base = 'tallies/tally '
|
||||
|
||||
# Iterate over all Tallies
|
||||
for tally_key in tally_keys:
|
||||
|
||||
tally_id = int(tally_key.strip('tally '))
|
||||
subbase = '{0}{1}'.format(base, tally_id)
|
||||
|
||||
# Read Tally name metadata
|
||||
name_size = self._f['{0}/name_size'.format(subbase)][0]
|
||||
if (name_size > 0):
|
||||
tally_name = self._f['{0}/name'.format(subbase)][0]
|
||||
tally_name = tally_name.lstrip('[\'')
|
||||
tally_name = tally_name.rstrip('\']')
|
||||
else:
|
||||
tally_name = ''
|
||||
|
||||
# Create Tally object and assign basic properties
|
||||
tally = openmc.Tally(tally_id, tally_name)
|
||||
|
||||
# Read score metadata
|
||||
score_bins = self._f['{0}/score_bins'.format(subbase)][...]
|
||||
for score_bin in score_bins:
|
||||
tally.add_score(openmc.SCORE_TYPES[score_bin])
|
||||
num_score_bins = self._f['{0}/n_score_bins'.format(subbase)][...]
|
||||
tally.num_score_bins = num_score_bins
|
||||
|
||||
# Read filter metadata
|
||||
num_filters = self._f['{0}/n_filters'.format(subbase)][0]
|
||||
|
||||
# Initialize all Filters
|
||||
for j in range(1, num_filters+1):
|
||||
|
||||
subsubbase = '{0}/filter {1}'.format(subbase, j)
|
||||
|
||||
# Read filter type (e.g., "cell", "energy", etc.)
|
||||
filter_type = self._f['{0}/type_name'.format(subsubbase)][0]
|
||||
|
||||
# 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(filter_type, bins)
|
||||
filter.num_bins = num_bins
|
||||
|
||||
# Add Filter to the Tally
|
||||
tally.add_filter(filter)
|
||||
|
||||
# Add Tally to the global dictionary of all Tallies
|
||||
self.tallies[tally_id] = tally
|
||||
|
||||
|
||||
def make_opencg_geometry(self):
|
||||
if self.opencg_geometry is None:
|
||||
self.opencg_geometry = get_opencg_geometry(self.openmc_geometry)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue