From 1fb0e4fe99a9ebed2c87c90086d2f6cd3718ad4e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 12 Oct 2011 14:44:07 -0400 Subject: [PATCH] Added scattering moment and scattering production macro tallies. --- src/constants.f90 | 17 +++++++++------ src/input_xml.f90 | 8 +++++++ src/particle_header.f90 | 1 + src/physics.f90 | 7 +++++++ src/tally.f90 | 46 ++++++++++++++++++++++++++++++++--------- 5 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/constants.f90 b/src/constants.f90 index 09caced703..06275cf6b8 100644 --- a/src/constants.f90 +++ b/src/constants.f90 @@ -152,13 +152,18 @@ module constants N_DA = 117 ! Tally macro reactions + integer, parameter :: N_MACRO_TYPES = 10 integer, parameter :: & - MACRO_FLUX = -1, & ! flux - MACRO_TOTAL = -2, & ! total reaction rate - MACRO_SCATTER = -3, & ! total scattering rate - MACRO_ABSORPTION = -4, & ! total absorption rate - MACRO_FISSION = -5, & ! total fission rate - MACRO_NU_FISSION = -6 ! total neutron production rate + MACRO_FLUX = -1, & ! flux + MACRO_TOTAL = -2, & ! total reaction rate + MACRO_SCATTER = -3, & ! scattering rate + MACRO_NU_SCATTER = -4, & ! scattering production rate + MACRO_SCATTER_1 = -5, & ! first scattering moment + MACRO_SCATTER_2 = -6, & ! second scattering moment + MACRO_SCATTER_3 = -7, & ! third scattering moment + MACRO_ABSORPTION = -8, & ! absorption rate + MACRO_FISSION = -9, & ! fission rate + MACRO_NU_FISSION = -10 ! neutron production rate ! Tally map bin finding integer, parameter :: NO_BIN_FOUND = -1 diff --git a/src/input_xml.f90 b/src/input_xml.f90 index e07318969d..2cdacf7ac4 100644 --- a/src/input_xml.f90 +++ b/src/input_xml.f90 @@ -748,6 +748,14 @@ contains t % macro_bins(j) % scalar = MACRO_TOTAL case ('scatter') t % macro_bins(j) % scalar = MACRO_SCATTER + case ('nu-scatter') + t % macro_bins(j) % scalar = MACRO_NU_SCATTER + case ('scatter-1') + t % macro_bins(j) % scalar = MACRO_SCATTER_1 + case ('scatter-2') + t % macro_bins(j) % scalar = MACRO_SCATTER_2 + case ('scatter-3') + t % macro_bins(j) % scalar = MACRO_SCATTER_3 case ('absorption') t % macro_bins(j) % scalar = MACRO_ABSORPTION case ('fission') diff --git a/src/particle_header.f90 b/src/particle_header.f90 index 4bf53c470e..b39670e685 100644 --- a/src/particle_header.f90 +++ b/src/particle_header.f90 @@ -20,6 +20,7 @@ module particle_header real(8) :: uvw(3) ! directional cosines real(8) :: wgt ! particle weight real(8) :: E ! energy + real(8) :: mu ! angle of scatter logical :: alive ! is particle alive? ! Pre-collision physical data diff --git a/src/physics.f90 b/src/physics.f90 index 0b53048e4b..5bfd00fccb 100644 --- a/src/physics.f90 +++ b/src/physics.f90 @@ -574,11 +574,15 @@ contains E = vx*vx + vy*vy + vz*vz vel = sqrt(E) + ! Set energy and direction of particle in LAB frame p % E = E p % uvw(1) = vx/vel p % uvw(2) = vy/vel p % uvw(3) = vz/vel + ! Copy scattering cosine for tallies + p % mu = mu + end subroutine elastic_scatter !=============================================================================== @@ -836,6 +840,9 @@ contains ! change energy of particle p % E = E + ! Copy scattering cosine for tallies + p % mu = mu + ! change weight of particle based on multiplicity n_secondary = abs(rxn % TY) p % wgt = n_secondary * p % wgt diff --git a/src/tally.f90 b/src/tally.f90 index 7005fa81f1..efcd8833a0 100644 --- a/src/tally.f90 +++ b/src/tally.f90 @@ -269,17 +269,21 @@ contains integer :: n integer :: bins(TALLY_TYPES) integer :: score_index + integer :: macro_bin real(8) :: score real(8) :: last_wgt real(8) :: wgt + real(8) :: mu logical :: in_mesh logical :: has_outgoing_energy + logical :: has_outgoing_angle type(TallyObject), pointer :: t type(StructuredMesh), pointer :: m - ! Copy particle's pre- and post-collision weight + ! Copy particle's pre- and post-collision weight and angle last_wgt = p % last_wgt wgt = p % wgt + mu = p % mu ! A loop over all tallies is necessary because we need to simultaneously ! determine different filter bins for the same tally in order to score to it @@ -378,7 +382,16 @@ contains ! Determine score for each bin do j = 1, t % n_macro_bins - if (has_outgoing_energy) then + ! determine what type of macro bin + macro_bin = t % macro_bins(j) % scalar + + ! determine if we need outgoing angle + has_outgoing_angle = (macro_bin == MACRO_NU_SCATTER .or. & + macro_bin == MACRO_SCATTER_1 .or. & + macro_bin == MACRO_SCATTER_2 .or. & + macro_bin == MACRO_SCATTER_3) + + if (has_outgoing_energy .or. has_outgoing_angle) then ! If this tally has an outgoing energy filter, the only supported ! reaction is scattering. For all other reactions, about @@ -388,16 +401,25 @@ contains ! occured, we do not need to multiply by the scattering cross ! section - if (t % macro_bins(j) % scalar == MACRO_SCATTER) then + select case (macro_bin) + case (MACRO_SCATTER) score = last_wgt - else + case (MACRO_NU_SCATTER) + score = wgt + case (MACRO_SCATTER_1) + score = last_wgt * mu + case (MACRO_SCATTER_2) + score = last_wgt * 0.5*(3.0*mu*mu - ONE) + case (MACRO_SCATTER_3) + score = last_wgt * 0.5*(5.0*mu*mu*mu - 3.0*mu) + case default ! call fatal_error - end if + end select else ! For tallies with no outgoing energy filter, the score is ! calculated normally depending on the quantity specified - select case(t % macro_bins(j) % scalar) + select case (macro_bin) case (MACRO_FLUX) score = last_wgt / material_xs % total case (MACRO_TOTAL) @@ -558,10 +580,10 @@ contains integer :: score_index ! index in scores array for filters logical :: file_exists ! does tallies.out file already exists? logical :: has_filter(TALLY_TYPES) ! does tally have this filter? - character(MAX_LINE_LEN) :: filename ! name of output file - character(15) :: filter_name(TALLY_TYPES) ! names of tally filters - character(20) :: macro_name(6) ! names of macro scores - character(80) :: space = " " ! spaces + character(MAX_LINE_LEN) :: filename ! name of output file + character(15) :: filter_name(TALLY_TYPES) ! names of tally filters + character(27) :: macro_name(N_MACRO_TYPES) ! names of macro scores + character(80) :: space = " " ! spaces type(TallyObject), pointer :: t ! Skip if there are no tallies @@ -581,6 +603,10 @@ contains macro_name(abs(MACRO_FLUX)) = "Flux" macro_name(abs(MACRO_TOTAL)) = "Total Reaction Rate" macro_name(abs(MACRO_SCATTER)) = "Scattering Rate" + macro_name(abs(MACRO_NU_SCATTER)) = "Scattering Production Rate" + macro_name(abs(MACRO_SCATTER_1)) = "First Scattering Moment" + macro_name(abs(MACRO_SCATTER_2)) = "Second Scattering Moment" + macro_name(abs(MACRO_SCATTER_3)) = "Third Scattering Moment" macro_name(abs(MACRO_ABSORPTION)) = "Absorption Rate" macro_name(abs(MACRO_FISSION)) = "Fission Rate" macro_name(abs(MACRO_NU_FISSION)) = "Nu-Fission Rate"