From 7c3e2b9953564cabc78f8c270e9b2bad0f76588d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Nov 2011 21:14:22 -0500 Subject: [PATCH] Fixed surface currents with multiple mesh bins. --- src/constants.f90 | 5 ++++- src/geometry.f90 | 15 +++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/constants.f90 b/src/constants.f90 index 106a38b0a4..7fec731d69 100644 --- a/src/constants.f90 +++ b/src/constants.f90 @@ -5,7 +5,7 @@ module constants ! Versioning numbers integer, parameter :: VERSION_MAJOR = 0 integer, parameter :: VERSION_MINOR = 3 - integer, parameter :: VERSION_RELEASE = 2 + integer, parameter :: VERSION_RELEASE = 3 ! Physical constants real(8), parameter :: & @@ -70,6 +70,9 @@ module constants & SENSE_POSITIVE = 1, & & SENSE_NEGATIVE = -1 + ! Used for surface current tallies + real(8), parameter :: TINY_BIT = 1e-8 + ! Codes for read errors -- better hope these numbers are never used in an ! input file! integer, parameter :: ERROR_INT = -huge(0) diff --git a/src/geometry.f90 b/src/geometry.f90 index 9d5d4f7bd6..387fea4af6 100644 --- a/src/geometry.f90 +++ b/src/geometry.f90 @@ -215,7 +215,7 @@ contains ! TODO: Find a better solution to score surface currents than physically ! moving the particle forward slightly - p % xyz = p % xyz + 1e-6 * p % uvw + p % xyz = p % xyz + TINY_BIT * p % uvw call score_surface_current(p) ! Display message @@ -229,6 +229,13 @@ contains ! ======================================================================= ! PARTICLE REFLECTS FROM SURFACE + ! Score surface currents since reflection causes the direction of the + ! particle to change -- artificially move the particle slightly back in + ! case the surface crossing in coincident with a mesh boundary + p % xyz = p % xyz - TINY_BIT * p % uvw + call score_surface_current(p) + p % xyz = p % xyz + TINY_BIT * p % uvw + ! Copy particle's direction cosines u = p % uvw(1) v = p % uvw(2) @@ -321,12 +328,8 @@ contains p % cell = last_cell p % surface = -p % surface - ! Score surface currents since reflection causes the direction of the - ! particle to change - call score_surface_current(p) - ! Set previous coordinate going slightly past surface crossing - p % last_xyz = p % xyz + 1e-6 * p % uvw + p % last_xyz = p % xyz + TINY_BIT * p % uvw ! Diagnostic message if (verbosity >= 10) then