From 8a94f1b8c7994873df40376e8f5e99516874fc1e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 11 Aug 2017 09:32:39 -0500 Subject: [PATCH] Move CMFD-related variables to cmfd_header --- src/cmfd_data.F90 | 16 ++++------- src/cmfd_execute.F90 | 14 ++++----- src/cmfd_header.F90 | 58 ++++++++++++++++++++++++++++++++++++++ src/cmfd_input.F90 | 4 +-- src/cmfd_loss_operator.F90 | 2 +- src/cmfd_prod_operator.F90 | 2 +- src/cmfd_solver.F90 | 23 +++++++-------- src/global.F90 | 56 ------------------------------------ 8 files changed, 83 insertions(+), 92 deletions(-) diff --git a/src/cmfd_data.F90 b/src/cmfd_data.F90 index e66c89457f..d1db7c509d 100644 --- a/src/cmfd_data.F90 +++ b/src/cmfd_data.F90 @@ -5,6 +5,8 @@ module cmfd_data ! parameters for CMFD calculation. !============================================================================== + use cmfd_header, only: allocate_cmfd, cmfd, cmfd_coremap, & + cmfd_downscatter, cmfd_tallies, dhat_reset use constants use tally_filter_mesh, only: MeshFilter @@ -20,9 +22,7 @@ contains subroutine set_up_cmfd() - use cmfd_header, only: allocate_cmfd use constants, only: CMFD_NOACCEL - use global, only: cmfd, cmfd_coremap, cmfd_downscatter ! Check for core map and set it up if ((cmfd_coremap) .and. (cmfd%mat_dim == CMFD_NOACCEL)) call set_coremap() @@ -50,17 +50,16 @@ contains subroutine compute_xs() - use cmfd_header, only: cmfd_tallies use constants, only: FILTER_MESH, FILTER_ENERGYIN, FILTER_ENERGYOUT, & FILTER_SURFACE, OUT_LEFT, OUT_RIGHT, OUT_BACK, & OUT_FRONT, OUT_BOTTOM, OUT_TOP, IN_LEFT, IN_RIGHT, & IN_BACK, IN_FRONT, IN_BOTTOM, IN_TOP, CMFD_NOACCEL, & ZERO, ONE, TINY_BIT use error, only: fatal_error - use global, only: cmfd, meshes, filters, filter_matches - use mesh_header, only: RegularMesh + use mesh_header, only: RegularMesh, meshes use string, only: to_str use tally_header, only: TallyObject + use tally_filter_header, only: filters, filter_matches integer :: nx ! number of mesh cells in x direction integer :: ny ! number of mesh cells in y direction @@ -335,7 +334,6 @@ contains subroutine set_coremap() use constants, only: CMFD_NOACCEL - use global, only: cmfd integer :: counter=1 ! counter for unique fuel assemblies integer :: nx ! number of mesh cells in x direction @@ -396,7 +394,7 @@ contains subroutine neutron_balance() use constants, only: ONE, ZERO, CMFD_NOACCEL, CMFD_NORES - use global, only: cmfd, keff, current_batch + use global, only: keff, current_batch integer :: nx ! number of mesh cells in x direction integer :: ny ! number of mesh cells in y direction @@ -505,7 +503,6 @@ contains subroutine compute_dtilde() use constants, only: CMFD_NOACCEL, ZERO_FLUX, TINY_BIT - use global, only: cmfd, cmfd_coremap integer :: nx ! maximum number of cells in x direction integer :: ny ! maximum number of cells in y direction @@ -647,7 +644,6 @@ contains subroutine compute_dhat() use constants, only: CMFD_NOACCEL, ZERO - use global, only: cmfd, cmfd_coremap, dhat_reset use output, only: write_message use string, only: to_str @@ -797,7 +793,6 @@ contains function get_reflector_albedo(l, g, i, j, k) use constants, only: ONE - use global, only: cmfd real(8) :: get_reflector_albedo ! reflector albedo integer, intent(in) :: i ! iteration counter for x @@ -836,7 +831,6 @@ contains subroutine compute_effective_downscatter() use constants, only: ZERO, CMFD_NOACCEL - use global, only: cmfd integer :: nx ! number of mesh cells in x direction integer :: ny ! number of mesh cells in y direction diff --git a/src/cmfd_execute.F90 b/src/cmfd_execute.F90 index 89e763187c..2edc8b08f3 100644 --- a/src/cmfd_execute.F90 +++ b/src/cmfd_execute.F90 @@ -5,6 +5,8 @@ module cmfd_execute ! cross section generation, diffusion calculation, and source re-weighting !============================================================================== + use cmfd_header, only: cmfd_begin, cmfd_on, cmfd_reset, cmfd, cmfd_coremap, & + cmfd_mesh use global implicit none @@ -63,9 +65,7 @@ contains subroutine cmfd_init_batch() - use global, only: cmfd_begin, cmfd_on, & - cmfd_reset, cmfd_run, & - current_batch + use global, only: cmfd_run, current_batch ! Check to activate CMFD diffusion and possible feedback ! this guarantees that when cmfd begins at least one batch of tallies are @@ -91,7 +91,7 @@ contains subroutine calc_fission_source() use constants, only: CMFD_NOACCEL, ZERO, TWO - use global, only: cmfd, cmfd_coremap, entropy_on, current_batch + use global, only: entropy_on, current_batch use message_passing use string, only: to_str @@ -214,10 +214,9 @@ contains subroutine cmfd_reweight(new_weights) use algorithm, only: binary_search - use cmfd_header, only: cmfd_mesh use constants, only: ZERO, ONE use error, only: warning, fatal_error - use global, only: source_bank, work, cmfd + use global, only: source_bank, work use mesh_header, only: RegularMesh use mesh, only: count_bank_sites use message_passing @@ -328,8 +327,6 @@ contains function get_matrix_idx(g, i, j, k, ng, nx, ny) result (matidx) - use global, only: cmfd, cmfd_coremap - integer :: matidx ! the index location in matrix integer, intent(in) :: i ! current x index integer, intent(in) :: j ! current y index @@ -360,7 +357,6 @@ contains subroutine cmfd_tally_reset() - use cmfd_header, only: cmfd_tallies use output, only: write_message integer :: i ! loop counter diff --git a/src/cmfd_header.F90 b/src/cmfd_header.F90 index 0a8e5ae9fa..1d1056f4de 100644 --- a/src/cmfd_header.F90 +++ b/src/cmfd_header.F90 @@ -2,7 +2,9 @@ module cmfd_header use constants, only: CMFD_NOACCEL, ZERO, ONE use mesh_header, only: RegularMesh + use set_header, only: SetInt use tally_header, only: TallyObject + use timer_header, only: Timer implicit none private @@ -90,11 +92,67 @@ module cmfd_header end type cmfd_type + ! Main object + type(cmfd_type), public :: cmfd + type(RegularMesh), public, pointer :: cmfd_mesh => null() ! Pointers for different tallies type(TallyObject), public, pointer :: cmfd_tallies(:) => null() + ! Timing objects + type(Timer), public :: time_cmfd ! timer for whole cmfd calculation + type(Timer), public :: time_cmfdbuild ! timer for matrix build + type(Timer), public :: time_cmfdsolve ! timer for solver + + ! Flag for active core map + logical, public :: cmfd_coremap = .false. + + ! Flag to reset dhats to zero + logical, public :: dhat_reset = .false. + + ! Flag to activate neutronic feedback via source weights + logical, public :: cmfd_feedback = .false. + + ! Adjoint method type + character(len=10), public :: cmfd_adjoint_type = 'physical' + + ! Number of incomplete ilu factorization levels + integer, public :: cmfd_ilu_levels = 1 + + ! Batch to begin cmfd + integer, public :: cmfd_begin = 1 + + ! Tally reset list + integer, public :: n_cmfd_resets + type(SetInt), public :: cmfd_reset + + ! Compute effective downscatter cross section + logical, public :: cmfd_downscatter = .false. + + ! Convergence monitoring + logical, public :: cmfd_power_monitor = .false. + + ! Cmfd output + logical, public :: cmfd_write_matrices = .false. + + ! Run an adjoint calculation (last batch only) + logical, public :: cmfd_run_adjoint = .false. + + ! CMFD run logicals + logical, public :: cmfd_on = .false. + + ! CMFD display info + character(len=25), public :: cmfd_display = 'balance' + + ! Estimate of spectral radius of CMFD matrices and tolerances + real(8), public :: cmfd_spectral = ZERO + real(8), public :: cmfd_shift = 1.e6 + real(8), public :: cmfd_ktol = 1.e-8_8 + real(8), public :: cmfd_stol = 1.e-8_8 + real(8), public :: cmfd_atoli = 1.e-10_8 + real(8), public :: cmfd_rtoli = 1.e-5_8 + contains !============================================================================== diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90 index 0208855286..67341ae953 100644 --- a/src/cmfd_input.F90 +++ b/src/cmfd_input.F90 @@ -2,6 +2,7 @@ module cmfd_input use, intrinsic :: ISO_C_BINDING + use cmfd_header use global implicit none @@ -16,7 +17,6 @@ contains subroutine configure_cmfd() - use cmfd_header, only: allocate_cmfd use message_passing, only: master integer :: color ! color group of processor @@ -49,7 +49,6 @@ contains use constants, only: ZERO, ONE use error, only: fatal_error, warning - use global use output, only: write_message use string, only: to_lower use xml_interface @@ -248,7 +247,6 @@ contains subroutine create_cmfd_tally(root) - use cmfd_header, only: cmfd_mesh, cmfd_tallies use constants, only: MAX_LINE_LEN use error, only: fatal_error, warning use mesh_header, only: RegularMesh, openmc_extend_meshes diff --git a/src/cmfd_loss_operator.F90 b/src/cmfd_loss_operator.F90 index 7dfeed1dbd..50a75e52d5 100644 --- a/src/cmfd_loss_operator.F90 +++ b/src/cmfd_loss_operator.F90 @@ -1,7 +1,7 @@ module cmfd_loss_operator use constants, only: CMFD_NOACCEL, ZERO - use global, only: cmfd, cmfd_coremap + use cmfd_header, only: cmfd, cmfd_coremap use matrix_header, only: Matrix implicit none diff --git a/src/cmfd_prod_operator.F90 b/src/cmfd_prod_operator.F90 index 7779c24551..91ce43b359 100644 --- a/src/cmfd_prod_operator.F90 +++ b/src/cmfd_prod_operator.F90 @@ -1,7 +1,7 @@ module cmfd_prod_operator use constants, only: CMFD_NOACCEL - use global, only: cmfd, cmfd_coremap + use cmfd_header, only: cmfd, cmfd_coremap use matrix_header, only: Matrix implicit none diff --git a/src/cmfd_solver.F90 b/src/cmfd_solver.F90 index fb687d10b4..42d93f02f4 100644 --- a/src/cmfd_solver.F90 +++ b/src/cmfd_solver.F90 @@ -53,7 +53,7 @@ contains subroutine cmfd_solver_execute(adjoint) - use global, only: cmfd_adjoint_type, time_cmfdbuild, time_cmfdsolve + use cmfd_header, only: cmfd_adjoint_type, time_cmfdbuild, time_cmfdsolve logical, optional, intent(in) :: adjoint ! adjoint calc @@ -100,8 +100,8 @@ contains subroutine init_data(adjoint) use constants, only: ONE, ZERO - use global, only: cmfd_shift, keff, cmfd_ktol, cmfd_stol, & - cmfd_write_matrices + use cmfd_header, only: cmfd_shift, cmfd_ktol, cmfd_stol, cmfd_write_matrices + use global, only: keff logical, intent(in) :: adjoint @@ -167,7 +167,7 @@ contains subroutine compute_adjoint() use error, only: fatal_error - use global, only: cmfd_write_matrices + use cmfd_header, only: cmfd_write_matrices ! Transpose matrices loss = loss % transpose() @@ -190,7 +190,7 @@ contains use constants, only: ONE use error, only: fatal_error - use global, only: cmfd, cmfd_atoli, cmfd_rtoli + use cmfd_header, only: cmfd, cmfd_atoli, cmfd_rtoli integer :: i ! iteration counter integer :: innerits ! # of inner iterations @@ -304,7 +304,7 @@ contains use, intrinsic :: ISO_FORTRAN_ENV use constants, only: ONE, ZERO - use global, only: cmfd_power_monitor + use cmfd_header, only: cmfd_power_monitor use message_passing, only: master integer, intent(in) :: iter ! outer iteration number @@ -346,7 +346,7 @@ contains use constants, only: ONE, ZERO use error, only: fatal_error - use global, only: cmfd, cmfd_spectral + use cmfd_header, only: cmfd, cmfd_spectral type(Matrix), intent(inout) :: A ! coefficient matrix type(Vector), intent(inout) :: b ! right hand side vector @@ -452,7 +452,7 @@ contains use constants, only: ONE, ZERO use error, only: fatal_error - use global, only: cmfd, cmfd_spectral + use cmfd_header, only: cmfd, cmfd_spectral type(Matrix), intent(inout) :: A ! coefficient matrix type(Vector), intent(inout) :: b ! right hand side vector @@ -597,7 +597,7 @@ contains use constants, only: ONE, ZERO use error, only: fatal_error - use global, only: cmfd, cmfd_spectral + use cmfd_header, only: cmfd, cmfd_spectral type(Matrix), intent(inout) :: A ! coefficient matrix type(Vector), intent(inout) :: b ! right hand side vector @@ -693,7 +693,8 @@ contains subroutine extract_results() - use global, only: cmfd, cmfd_write_matrices, current_batch + use cmfd_header, only: cmfd, cmfd_write_matrices + use global, only: current_batch character(len=25) :: filename ! name of file to write data integer :: n ! problem size @@ -750,7 +751,7 @@ contains subroutine matrix_to_indices(irow, g, i, j, k, ng, nx, ny, nz) - use global, only: cmfd, cmfd_coremap + use cmfd_header, only: cmfd, cmfd_coremap integer, intent(out) :: i ! iteration counter for x integer, intent(out) :: j ! iteration counter for y diff --git a/src/global.F90 b/src/global.F90 index baac4638a4..e080e95155 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -236,65 +236,9 @@ module global ! ============================================================================ ! CMFD VARIABLES - ! Main object - type(cmfd_type) :: cmfd - ! Is CMFD active logical :: cmfd_run = .false. - ! Timing objects - type(Timer) :: time_cmfd ! timer for whole cmfd calculation - type(Timer) :: time_cmfdbuild ! timer for matrix build - type(Timer) :: time_cmfdsolve ! timer for solver - - ! Flag for active core map - logical :: cmfd_coremap = .false. - - ! Flag to reset dhats to zero - logical :: dhat_reset = .false. - - ! Flag to activate neutronic feedback via source weights - logical :: cmfd_feedback = .false. - - ! Adjoint method type - character(len=10) :: cmfd_adjoint_type = 'physical' - - ! Number of incomplete ilu factorization levels - integer :: cmfd_ilu_levels = 1 - - ! Batch to begin cmfd - integer :: cmfd_begin = 1 - - ! Tally reset list - integer :: n_cmfd_resets - type(SetInt) :: cmfd_reset - - ! Compute effective downscatter cross section - logical :: cmfd_downscatter = .false. - - ! Convergence monitoring - logical :: cmfd_power_monitor = .false. - - ! Cmfd output - logical :: cmfd_write_matrices = .false. - - ! Run an adjoint calculation (last batch only) - logical :: cmfd_run_adjoint = .false. - - ! CMFD run logicals - logical :: cmfd_on = .false. - - ! CMFD display info - character(len=25) :: cmfd_display = 'balance' - - ! Estimate of spectral radius of CMFD matrices and tolerances - real(8) :: cmfd_spectral = ZERO - real(8) :: cmfd_shift = 1.e6 - real(8) :: cmfd_ktol = 1.e-8_8 - real(8) :: cmfd_stol = 1.e-8_8 - real(8) :: cmfd_atoli = 1.e-10_8 - real(8) :: cmfd_rtoli = 1.e-5_8 - ! Information about state points to be written integer :: n_state_points = 0 type(SetInt) :: statepoint_batch