diff --git a/src/cmfd_data.F90 b/src/cmfd_data.F90 index 4cd8d5cc1c..86f3bac42b 100644 --- a/src/cmfd_data.F90 +++ b/src/cmfd_data.F90 @@ -81,6 +81,7 @@ contains ! set flux object and source distribution to all zeros cmfd % flux = 0.0_8 + cmfd % openmc_cycle_src = 0.0_8 cmfd % openmc_src = 0.0_8 ! associate tallies and mesh @@ -113,6 +114,9 @@ contains end if end if + ! extract accumulated fission source + if (ital == 1) call extract_accum_fsrc(i,j,k) + ! loop around energy groups OUTGROUP: do h = 1,ng @@ -168,7 +172,7 @@ contains bins = 1 ! set ijk as mesh indices - ijk = (/ i, j, k /) + ijk = (/ i, j, k /) ! get bin number for mesh indices bins(FILTER_MESH) = mesh_indices_to_bin(m,ijk) @@ -176,7 +180,6 @@ contains ! apply energy in filter bins(FILTER_ENERGYIN) = ng - h + 1 - ! set energy out bin bins(FILTER_ENERGYOUT) = ng - g + 1 @@ -192,7 +195,7 @@ contains & cmfd % flux(h,i,j,k) ! bank source - cmfd % openmc_src(g,i,j,k) = cmfd % openmc_src(g,i,j,k) + & + cmfd % openmc_cycle_src(g,i,j,k) = cmfd % openmc_cycle_src(g,i,j,k) + & & t % scores(score_index,2) % sum end do INGROUP @@ -271,6 +274,7 @@ contains ! normalize openmc source distribution cmfd % openmc_src = cmfd % openmc_src/sum(cmfd % openmc_src)*cmfd%norm + cmfd % openmc_cycle_src = cmfd % openmc_cycle_src/sum(cmfd % openmc_cycle_src)*cmfd%norm end subroutine compute_xs @@ -703,4 +707,55 @@ contains end subroutine fix_2_grp +!============================================================================== +! EXTRACT_ACCUM_FSRC +!============================================================================== + + subroutine extract_accum_fsrc(i,j,k) + + use global + use mesh, only: mesh_indices_to_bin + use mesh_header, only: StructuredMesh + use tally_header, only: TallyObject, TallyScore + + integer :: nx ! number of mesh cells in x direction + integer :: ny ! number of mesh cells in y direction + integer :: nz ! number of mesh cells in z direction + integer :: ng ! number of energy groups + integer :: i ! iteration counter for x + integer :: j ! iteration counter for y + integer :: k ! iteration counter for z + integer :: g ! iteration counter for g + integer :: h ! iteration counter for outgoing groups + integer :: ital ! tally object index + integer :: ijk(3) ! indices for mesh cell + integer :: score_index ! index to pull from tally object + integer :: bins(N_FILTER_TYPES) ! bins for filters + + real(8) :: flux ! temp variable for flux + + type(TallyObject), pointer :: t ! pointer for tally object + type(StructuredMesh), pointer :: m ! pointer for mesh object + + ! associate tallies and mesh + t => tallies(1) + m => meshes(t % mesh) + + ! reset all bins to 1 + bins = 1 + + ! set ijk as mesh indices + ijk = (/ i, j, k /) + + ! get bin number for mesh indices + bins(FILTER_MESH) = mesh_indices_to_bin(m,ijk) + + ! calculate score index from bins + score_index = sum((bins - 1) * t%stride) + 1 + + ! bank source + cmfd % openmc_src(i,j,k) = t % scores(score_index,1) % sum + + end subroutine extract_accum_fsrc + end module cmfd_data diff --git a/src/cmfd_header.F90 b/src/cmfd_header.F90 index d5d58c0e8a..9f66a86c84 100644 --- a/src/cmfd_header.F90 +++ b/src/cmfd_header.F90 @@ -68,7 +68,8 @@ module cmfd_header real(8) :: entropy = 0.0_8 ! openmc source - real(8), allocatable :: openmc_src(:,:,:,:) + real(8), allocatable :: openmc_src(:,:,:) + real(8), allocatable :: openmc_cycle_src(:,:,:,:) ! openmc source normalization factor real(8) :: norm = 1.0_8 @@ -119,7 +120,8 @@ contains if (.not. allocated(this % current)) allocate(this % current(12,ng,nx,ny,nz)) ! allocate openmc source distribution - if (.not. allocated(this % openmc_src)) allocate(this % openmc_src(ng,nx,ny,nz)) + if (.not. allocated(this % openmc_src)) allocate(this % openmc_src(nx,ny,nz)) + if (.not. allocated(this % openmc_cycle_src)) allocate(this % openmc_cycle_src(ng,nx,ny,nz)) end subroutine allocate_cmfd @@ -151,6 +153,7 @@ contains if (allocated(this % sourcecounts)) deallocate(this % sourcecounts) if (allocated(this % weightfactors)) deallocate(this % weightfactors) if (allocated(this % openmc_src)) deallocate(this % openmc_src) + if (allocated(this % openmc_cycle_src)) deallocate(this % openmc_cycle_src) end subroutine deallocate_cmfd diff --git a/src/cmfd_output.F90 b/src/cmfd_output.F90 index 57a88d37c2..f61a68febc 100644 --- a/src/cmfd_output.F90 +++ b/src/cmfd_output.F90 @@ -130,7 +130,7 @@ contains integer(HID_T) :: dataspace_id ! Data space identifier integer(HID_T) :: dataset_id ! Dataset identifier integer(HSIZE_T), dimension(1) :: dim1 ! vector for hdf5 dimensions -! integer(HSIZE_T), dimension(3) :: dim3 ! vector for hdf5 dimensions + integer(HSIZE_T), dimension(3) :: dim3 ! vector for hdf5 dimensions integer(HSIZE_T), dimension(4) :: dim4 ! vector for hdf5 dimensions integer(HSIZE_T), dimension(5) :: dim5 ! vector for hdf5 dimensions @@ -354,11 +354,20 @@ contains call h5dclose_f(dataset_id,hdf5_err) ! write out openmc source vector - dim4 = (/ng,nx,ny,nz/) - call h5screate_simple_f(4,dim4,dataspace_id,hdf5_err) + dim3 = (/nx,ny,nz/) + call h5screate_simple_f(3,dim4,dataspace_id,hdf5_err) call h5dcreate_f(hdf5_output_file,trim(cycname)//"/openmc_src", & & H5T_NATIVE_DOUBLE,dataspace_id,dataset_id,hdf5_err) - call h5dwrite_f(dataset_id,H5T_NATIVE_DOUBLE,cmfd%openmc_src,dim4,hdf5_err) + call h5dwrite_f(dataset_id,H5T_NATIVE_DOUBLE,cmfd%openmc_src,dim3,hdf5_err) + call h5sclose_f(dataspace_id,hdf5_err) + call h5dclose_f(dataset_id,hdf5_err) + + ! write out openmc source vector + dim4 = (/ng,nx,ny,nz/) + call h5screate_simple_f(4,dim4,dataspace_id,hdf5_err) + call h5dcreate_f(hdf5_output_file,trim(cycname)//"/openmc_cycle_src", & + & H5T_NATIVE_DOUBLE,dataspace_id,dataset_id,hdf5_err) + call h5dwrite_f(dataset_id,H5T_NATIVE_DOUBLE,cmfd%openmc_cycle_src,dim4,hdf5_err) call h5sclose_f(dataspace_id,hdf5_err) call h5dclose_f(dataset_id,hdf5_err)