From a0193b13a5c7409f5231a4457a996d28d3d4d5b2 Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Fri, 23 Oct 2015 17:27:28 -0400 Subject: [PATCH] fixed merging of tallies with delayedgroup filters in python API and other small issues --- docs/source/usersguide/input.rst | 2 +- openmc/filter.py | 2 +- openmc/statepoint.py | 6 ++---- openmc/tallies.py | 15 +++++++++++++++ src/ace.F90 | 6 +++--- src/fission.F90 | 6 +++--- src/input_xml.F90 | 2 +- src/particle_header.F90 | 1 - src/physics.F90 | 1 - src/tally.F90 | 29 ++++++++++------------------- src/tracking.F90 | 1 - 11 files changed, 36 insertions(+), 35 deletions(-) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 0c10756ba1..f89e951576 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -1355,7 +1355,7 @@ The ```` element accepts the following sub-elements: -:nuclides: + :nuclides: If specified, the scores listed will be for particular nuclides, not the summation of reactions from all nuclides. The format for nuclides should be [Atomic symbol]-[Mass number], e.g. "U-235". The reaction rate for all diff --git a/openmc/filter.py b/openmc/filter.py index bd42039ed8..6c4377ff34 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -271,7 +271,7 @@ class Filter(object): merged_filter = copy.deepcopy(self) # Merge unique filter bins - merged_bins = list(set(self.bins + filter.bins)) + merged_bins = list(set(np.concatenate((self.bins, filter.bins)))) merged_filter.bins = merged_bins merged_filter.num_bins = len(merged_bins) diff --git a/openmc/statepoint.py b/openmc/statepoint.py index e7e8d8e089..56b6eaf348 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -432,10 +432,8 @@ class StatePoint(object): score = score.decode() # If this is a moment, use generic moment order - regexp = re.compile(r'-n$|-pn$|-yn$') - if regexp.search(score) is not None: - score = score.strip(regexp.findall(score)[0]) - score += '-' + moments[j].decode() + pattern = r'-n$|-pn$|-yn$' + score = re.sub(pattern, '-' + moments[j].decode(), score) tally.add_score(score) diff --git a/openmc/tallies.py b/openmc/tallies.py index a0f617d08c..610b6689ce 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -565,6 +565,21 @@ class Tally(object): if len(self.filters) != len(tally.filters): return False + # Check if only one tally contains a delayed group filter + tally1_dg = False + for filter1 in self.filters: + if filter1.type == 'delayedgroup': + tally1_dg = True + + tally2_dg = False + for filter2 in tally.filters: + if filter2.type == 'delayedgroup': + tally2_dg = True + + # Return False if only one tally has a delayed group filter + if (tally1_dg or tally2_dg) and not (tally1_dg and tally2_dg): + return False + # Look to see if all filters are the same, or one or more can be merged for filter1 in self.filters: mergeable_filter = False diff --git a/src/ace.F90 b/src/ace.F90 index d70c50259f..f7d4bec69f 100644 --- a/src/ace.F90 +++ b/src/ace.F90 @@ -640,8 +640,8 @@ contains ! of delayed groups if (NPCR > MAX_DELAYED_GROUPS) then call fatal_error("Encountered nuclide with " // trim(to_str(NPCR)) & - &// " delayed groups while the maximum number of delayed groups " & - &// "set in constants.F90 is " // trim(to_str(MAX_DELAYED_GROUPS))) + // " delayed groups while the maximum number of delayed groups & + &set in constants.F90 is " // trim(to_str(MAX_DELAYED_GROUPS))) end if nuc % n_precursor = NPCR @@ -681,7 +681,7 @@ contains else nuc % nu_d_type = NU_NONE - nuc % n_precursor = ZERO + nuc % n_precursor = 0 end if end subroutine read_nu_data diff --git a/src/fission.F90 b/src/fission.F90 index f69ffc9628..7b2911997b 100644 --- a/src/fission.F90 +++ b/src/fission.F90 @@ -89,9 +89,9 @@ contains function nu_delayed(nuc, E) result(nu) - type(Nuclide), pointer :: nuc ! nuclide from which to find nu - real(8), intent(in) :: E ! energy of incoming neutron - real(8) :: nu ! number of delayed neutrons emitted per fission + type(Nuclide), intent(in) :: nuc ! nuclide from which to find nu + real(8), intent(in) :: E ! energy of incoming neutron + real(8) :: nu ! number of delayed neutrons emitted per fission if (nuc % nu_d_type == NU_NONE) then ! since no prompt or delayed data is present, this means all neutron diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 528ea40f51..e36dc60213 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -2937,7 +2937,7 @@ contains ! Check if delayed group filter is used with any score besides ! delayed-nu-fission - if (trim(score_name) /= 'delayed-nu-fission' .and. & + if (score_name /= 'delayed-nu-fission' .and. & t % find_filter(FILTER_DELAYEDGROUP) > 0) then call fatal_error("Cannot tally " // trim(score_name) // " with a & &delayedgroup filter.") diff --git a/src/particle_header.F90 b/src/particle_header.F90 index b2f6c579e0..0b9b251ee5 100644 --- a/src/particle_header.F90 +++ b/src/particle_header.F90 @@ -106,7 +106,6 @@ contains subroutine initialize_particle(this) class(Particle) :: this - integer :: d ! Clear coordinate lists call this % clear() diff --git a/src/physics.F90 b/src/physics.F90 index 569b89bb09..52e65a4c5b 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -1063,7 +1063,6 @@ contains integer, intent(in) :: i_nuclide integer, intent(in) :: i_reaction - integer :: d ! delayed group index integer :: nu_d(MAX_DELAYED_GROUPS) ! number of delayed neutrons born integer :: i ! loop index integer :: nu ! actual number of neutrons produced diff --git a/src/tally.F90 b/src/tally.F90 index 7ad174c9bc..c997d3e371 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -485,14 +485,8 @@ contains cycle SCORE_LOOP else - score = ZERO - - ! Loop over all delayed groups and accumulate the contribution - ! from each group - do d = 1, nuclides(p % event_nuclide) % n_precursor - score = score + keff * p % wgt_bank / p % n_bank * & - p % n_delayed_bank(d) - end do + ! Add the contribution from all delayed groups + score = keff * p % wgt_bank / p % n_bank * sum(p % n_delayed_bank) end if end if else @@ -579,12 +573,9 @@ contains ! Get index in nuclides array i_nuc = mat % nuclide(l) - ! Get the current nuclide - nuc => nuclides(i_nuc) - ! Accumulate the contribution from each nuclide score = score + micro_xs(i_nuc) % fission & - * nu_delayed(nuc, p % E) * atom_density_ * flux + * nu_delayed(nuclides(i_nuc), p % E) * atom_density_ * flux end do end if end if @@ -1049,9 +1040,9 @@ contains subroutine score_fission_delayed_eout(p, t, i_score) - type(Particle), intent(in) :: p - type(TallyObject), intent(in) :: t - integer, intent(in) :: i_score ! index for score + type(Particle), intent(in) :: p + type(TallyObject), intent(inout) :: t + integer, intent(in) :: i_score ! index for score integer :: i ! index of outgoing energy filter integer :: j ! index of delayedgroup filter @@ -1063,7 +1054,7 @@ contains integer :: bin_energyout ! original outgoing energy bin real(8) :: score ! actual score real(8) :: E_out ! energy of fission bank site - logical :: d_found = .FALSE. ! bool to inidicate if delayed group was found + logical :: d_found = .false. ! bool to inidicate if delayed group was found ! save original outgoing energy and delayed group bins i = t % find_filter(FILTER_ENERGYOUT) @@ -1132,9 +1123,9 @@ contains subroutine score_fission_delayed_dg(t, d_bin, score, score_index) - type(TallyObject) :: t - integer, intent(in) :: score_index ! index for score - integer, intent(in) :: d_bin ! delayed group bin index + type(TallyObject), intent(inout) :: t + integer, intent(in) :: score_index ! index for score + integer, intent(in) :: d_bin ! delayed group bin index integer :: bin_original ! original bin index integer :: filter_index ! index for matching filter bin combination diff --git a/src/tracking.F90 b/src/tracking.F90 index 391199bc08..2e4503e139 100644 --- a/src/tracking.F90 +++ b/src/tracking.F90 @@ -29,7 +29,6 @@ contains type(Particle), intent(inout) :: p - integer :: d ! delayed group index integer :: j ! coordinate level integer :: next_level ! next coordinate level to check integer :: surface_crossed ! surface which particle is on