From 67f9cfe1c70005b78ea82122d4074ca2066f2fe7 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 22 Mar 2016 14:53:57 -0400 Subject: [PATCH] Distribcell paths now handled by StatePoint.link_with_summary(...) routine in Python API --- openmc/filter.py | 13 +++++++++++++ openmc/statepoint.py | 10 ++++++++-- openmc/summary.py | 5 +++++ src/summary.F90 | 10 +++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/openmc/filter.py b/openmc/filter.py index 2ae8eeb626..3d67052ea7 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -45,6 +45,9 @@ class Filter(object): stride : Integral The number of filter, nuclide and score bins within each of this filter's bins. + distribcell_paths : list of str + The paths traversed through the CSG tree to reach each distribcell + instance (for 'distribcell' filters only) """ @@ -56,6 +59,7 @@ class Filter(object): self._bins = None self._mesh = None self._stride = None + self._distribcell_paths = None if type is not None: self.type = type @@ -152,6 +156,10 @@ class Filter(object): def stride(self): return self._stride + @property + def distribcell_paths(self): + return self._distribcell_paths + @type.setter def type(self, type): if type is None: @@ -246,6 +254,11 @@ class Filter(object): self._stride = stride + @distribcell_paths.setter + def distribcell_paths(self, distribcell_paths): + cv.check_iterable_type('distribcell_paths', distribcell_paths, str) + self._distribcell_paths = distribcell_paths + def can_merge(self, other): """Determine if filter can be merged with another. diff --git a/openmc/statepoint.py b/openmc/statepoint.py index dcf544ccb1..1644e44ab4 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -609,11 +609,13 @@ class StatePoint(object): raise ValueError(msg) for tally_id, tally in self.tallies.items(): - # Get the Tally name from the summary file - tally.name = summary.tallies[tally_id].name + summary_tally = summary.tallies[tally_id] + tally.name = summary_tally.name tally.with_summary = True for tally_filter in tally.filters: + summary_filter = summary_tally.find_filter(tally_filter.type) + if tally_filter.type == 'surface': surface_ids = [] for bin in tally_filter.bins: @@ -626,6 +628,10 @@ class StatePoint(object): distribcell_ids.append(summary.cells[bin].id) tally_filter.bins = distribcell_ids + if tally_filter.type == 'distribcell': + tally_filter.distribcell_paths = \ + summary_filter.distribcell_paths + if tally_filter.type == 'universe': universe_ids = [] for bin in tally_filter.bins: diff --git a/openmc/summary.py b/openmc/summary.py index 119a870bff..f17c0c8f93 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -562,6 +562,11 @@ class Summary(object): new_filter = openmc.Filter(filter_type, bins) new_filter.num_bins = num_bins + # Read in distribcell paths + if filter_type == 'distribcell': + new_filter.distribcell_paths = \ + self._f['{0}/paths'.format(subsubbase)][...] + # Add Filter to the Tally tally.filters.append(new_filter) diff --git a/src/summary.F90 b/src/summary.F90 index 3431595280..9597bbb0d1 100644 --- a/src/summary.F90 +++ b/src/summary.F90 @@ -595,11 +595,15 @@ contains t%filters(j)%type == FILTER_POLAR .or. & t%filters(j)%type == FILTER_AZIMUTHAL) then call write_dataset(filter_group, "bins", t%filters(j)%real_bins) + else + call write_dataset(filter_group, "bins", t%filters(j)%int_bins) + end if ! Write paths to reach each distribcell instance - else if (t%filters(j)%type == FILTER_DISTRIBCELL) then + if (t%filters(j)%type == FILTER_DISTRIBCELL) then ! Allocate array of strings for each distribcell path allocate(paths(t % filters(j) % n_bins)) + ! Store path for each distribcell instance do k = 1, t % filters(j) % n_bins path = '' @@ -608,10 +612,10 @@ contains universes(BASE_UNIVERSE), k, offset, path) paths(k) = path end do + + ! Write array of distribcell paths to summary file call write_dataset(filter_group, "paths", paths) deallocate(paths) - else - call write_dataset(filter_group, "bins", t%filters(j)%int_bins) end if ! Write name of type