From 4832f71083c579bbf6e4dadfb1749a6a5f7c9694 Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Wed, 16 Sep 2015 07:02:12 -0400 Subject: [PATCH] Angular implementation updated --- docs/source/usersguide/input.rst | 12 +++++------ src/math.F90 | 3 ++- src/search.F90 | 2 -- src/tally.F90 | 37 ++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 7424121989..e94066a5d6 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -1282,17 +1282,17 @@ The ```` element accepts the following sub-elements: :azimuthal: A monotonically increasing list of bounding particle azimuthal angles - which represents a portion of the possible values of :math:'\[-\pi,\pi\]'. - For example, spanning all of :math:'\[-\pi,\pi\]' with five equi-width + which represents a portion of the possible values of :math:'\[0,2\pi\]'. + For example, spanning all of :math:'\[0,2\pi\]' with two equi-width bins can be specified as: - ```` + ```` Alternatively, if only one value is provided as a bin, OpenMC will - interpret this to mean the complete range of :math:'\[-\pi,\pi\]' should + interpret this to mean the complete range of :math:'\[0,2\pi\]' should be automatically subdivided in to the provided value for the bin. That is, the above example of five equi-width bins spanning - :math:'\[-\pi,\pi\]' can be instead written as: - ````. + :math:'\[0,2\pi\]' can be instead written as: + ````. :mesh: The ``id`` of a structured mesh to be tallied over. diff --git a/src/math.F90 b/src/math.F90 index 826172fa24..cd6f5567f4 100644 --- a/src/math.F90 +++ b/src/math.F90 @@ -181,7 +181,6 @@ contains if (uvw(1) == ZERO) then phi = ZERO else -! phi = atan(uvw(2) / uvw(1)) phi = atan2(uvw(2), uvw(1)) end if @@ -556,6 +555,8 @@ contains rn = ONE end select + ! rn = rn * sin(phi) + end function calc_rn !=============================================================================== diff --git a/src/search.F90 b/src/search.F90 index a6657b71de..dab7fa67ca 100644 --- a/src/search.F90 +++ b/src/search.F90 @@ -34,8 +34,6 @@ contains R = n if (val < array(L) .or. val > array(R)) then -write(*,*) val -write(*,*) array call fatal_error("Value outside of array during binary search") end if diff --git a/src/tally.F90 b/src/tally.F90 index fe9127c30b..28e888a7cd 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -906,6 +906,8 @@ contains logical :: found_bin ! was a scoring bin found? logical :: start_in_mesh ! starting coordinates inside mesh? logical :: end_in_mesh ! ending coordinates inside mesh? + real(8) :: theta + real(8) :: phi type(TallyObject), pointer :: t type(StructuredMesh), pointer :: m type(Material), pointer :: mat @@ -990,6 +992,41 @@ contains matching_bins(i) = binary_search(t % filters(i) % real_bins, & k + 1, p % E) end if + + case (FILTER_POLAR) + ! Get theta value + theta = acos(p % coord(1) % uvw(3)) + + ! determine polar angle bin + k = t % filters(i) % n_bins + + ! check if particle is within polar angle bins + if (theta < t % filters(i) % real_bins(1) .or. & + theta > t % filters(i) % real_bins(k + 1)) then + matching_bins(i) = NO_BIN_FOUND + else + ! search to find polar angle bin + matching_bins(i) = binary_search(t % filters(i) % real_bins, & + k + 1, theta) + end if + + case (FILTER_AZIMUTHAL) + ! make sure the correct direction vector is used + phi = atan2(p % coord(1) % uvw(2), p % coord(1) % uvw(1)) + + ! determine mu bin + k = t % filters(i) % n_bins + + ! check if particle is within azimuthal angle bins + if (phi < t % filters(i) % real_bins(1) .or. & + phi > t % filters(i) % real_bins(k + 1)) then + matching_bins(i) = NO_BIN_FOUND + else + ! search to find azimuthal angle bin + matching_bins(i) = binary_search(t % filters(i) % real_bins, & + k + 1, phi) + end if + end select ! Check if no matching bin was found