From fec5a1a9b5bb7d397a3ec49467d1ec808c5c5753 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Sat, 24 Dec 2011 17:32:18 -0800 Subject: [PATCH] added neutron balance output file --- src/DEPENDENCIES | 1 + src/cmfd_execute.F90 | 5 +++- src/cmfd_utils.F90 | 63 ++++++++++++++++++++++++++++++++++++++++++-- src/constants.F90 | 1 + 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/DEPENDENCIES b/src/DEPENDENCIES index 8d606c924f..c8237effb1 100644 --- a/src/DEPENDENCIES +++ b/src/DEPENDENCIES @@ -5,6 +5,7 @@ cmfd_execute.o: mesh_header.o cmfd_execute.o: tally_header.o cmfd_execute.o: timing.o +cmfd_utils.o: constants.o cmfd_utils.o: datatypes.o cmfd_utils.o: global.o cmfd_utils.o: mesh.o diff --git a/src/cmfd_execute.F90 b/src/cmfd_execute.F90 index e6700bc2a6..93d41031f6 100644 --- a/src/cmfd_execute.F90 +++ b/src/cmfd_execute.F90 @@ -1,6 +1,6 @@ module cmfd_execute - use cmfd_utils, only: get_matrix_idx + use cmfd_utils, only: get_matrix_idx,neutron_balance use global use mesh, only: mesh_indices_to_bin use mesh_header, only: StructuredMesh @@ -31,6 +31,9 @@ contains write(105,*) cmfd % hxyz write(106,*) cmfd % current + ! write out neutron balance + call neutron_balance() + ! compute dtilde terms call compute_diffcoef() diff --git a/src/cmfd_utils.F90 b/src/cmfd_utils.F90 index 6ec5fbe704..201d6c0c89 100644 --- a/src/cmfd_utils.F90 +++ b/src/cmfd_utils.F90 @@ -1,12 +1,13 @@ module cmfd_utils use cmfd_header + use constants use datatypes, only: dict_add_key, dict_get_key use error, only: fatal_error, warning use global use mesh, only: mesh_indices_to_bin use mesh_header, only: StructuredMesh - use string, only: lower_case, str_to_real, split_string + use string use tally_header, only: TallyObject, TallyScore implicit none @@ -333,6 +334,20 @@ contains integer :: k ! iteration counter for z integer :: g ! iteration counter for g integer :: h ! iteration counter for outgoing groups + integer :: l ! iteration counter for leakage + integer :: io_error ! error for opening file unit + real(8) :: leakage ! leakage term in neutron balance + real(8) :: interactions ! total number of interactions in balance + real(8) :: scattering ! scattering term in neutron balance + real(8) :: fission ! fission term in neutron balance + real(8) :: res ! residual of neutron balance + character(MAX_FILE_LEN) :: filename + character(30) :: label + + ! open cmfd file for output + filename = "cmfd.out" + open(FILE=filename, UNIT=UNIT_CMFD, STATUS='replace', ACTION='write', & + IOSTAT=io_error) ! extract spatial and energy indices from object nx = cmfd % indices(1) @@ -353,6 +368,50 @@ contains leakage = 0.0 LEAK: do l = 1,3 - leakage = leakage + ((cmfd % current(4) - cmfd % current(3)) + leakage = leakage + ((cmfd % current(4*l,g,i,j,k) - & + & cmfd % current(4*l-1,g,i,j,k))) - & + & ((cmfd % current(4*l-2,g,i,j,k) - & + & cmfd % current(4*l-3,g,i,j,k))) + + end do LEAK + + ! interactions + interactions = cmfd % totalxs(g,i,j,k) * cmfd % flux(g,i,j,k) + + ! get scattering and fission + scattering = 0.0 + fission = 0.0 + GROUPH: do h = 1,ng + + scattering = scattering + cmfd % scattxs(h,g,i,j,k) * & + & cmfd % flux(g,i,j,k) + + fission = fission + cmfd % nfissxs(h,g,i,j,k) * & + & cmfd % flux(g,i,j,k) + + end do GROUPH + + ! compute residual + res = leakage + interactions - scattering - (ONE/keff)*fission + + ! write output + label = "MESH (" // trim(int_to_str(i)) // ". " // & + & trim(int_to_str(j)) // ", " // trim(int_to_str(k)) // & + & ") GROUP " // trim(int_to_str(g)) + write(UNIT=UNIT_CMFD, FMT='(A,T35,A)') label, & + & trim(real_to_str(res)) + + end do GROUPG + + end do XLOOP + + end do YLOOP + + end do ZLOOP + + ! close file + close(UNIT=UNIT_CMFD) + end subroutine neutron_balance + end module cmfd_utils diff --git a/src/constants.F90 b/src/constants.F90 index eba9786d66..5b7013b1f5 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -283,6 +283,7 @@ module constants integer, parameter :: UNIT_LOG = 11 ! unit # for writing log file integer, parameter :: UNIT_TALLY = 12 ! unit # for writing tally file integer, parameter :: UNIT_PLOT = 13 ! unit # for writing plot file + integer, parameter :: UNIT_CMFD = 14 ! unit # for writing cmfd file end module constants