From 3ffbd80efd2738078737848825f03e07ec216a6a Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 7 Apr 2012 11:27:05 -0400 Subject: [PATCH] Added criticality module. --- src/DEPENDENCIES | 19 +++--- src/OBJECTS | 1 + src/criticality.F90 | 130 +++++++++++++++++++++++++++++++++++++++++ src/main.F90 | 139 ++------------------------------------------ 4 files changed, 149 insertions(+), 140 deletions(-) create mode 100644 src/criticality.F90 diff --git a/src/DEPENDENCIES b/src/DEPENDENCIES index 7d70c783ef..08f362792e 100644 --- a/src/DEPENDENCIES +++ b/src/DEPENDENCIES @@ -22,6 +22,16 @@ cross_section.o: material_header.o cross_section.o: random_lcg.o cross_section.o: search.o +criticality.o: constants.o +criticality.o: global.o +criticality.o: intercycle.o +criticality.o: output.o +criticality.o: physics.o +criticality.o: source.o +criticality.o: string.o +criticality.o: tally.o +criticality.o: timing.o + datatypes.o: datatypes_header.o doppler.o: constants.o @@ -138,16 +148,11 @@ interpolation.o: search.o interpolation.o: string.o main.o: constants.o +main.o: criticality.o +main.o: finalize.o main.o: global.o main.o: initialize.o -main.o: intercycle.o -main.o: output.o -main.o: physics.o main.o: plot.o -main.o: source.o -main.o: string.o -main.o: tally.o -main.o: timing.o mesh.o: constants.o mesh.o: global.o diff --git a/src/OBJECTS b/src/OBJECTS index e78fcd0c62..69229e1819 100644 --- a/src/OBJECTS +++ b/src/OBJECTS @@ -3,6 +3,7 @@ ace.o \ ace_header.o \ bank_header.o \ cross_section.o \ +criticality.o \ datatypes.o \ datatypes_header.o \ doppler.o \ diff --git a/src/criticality.F90 b/src/criticality.F90 new file mode 100644 index 0000000000..92f3c95b04 --- /dev/null +++ b/src/criticality.F90 @@ -0,0 +1,130 @@ +module criticality + + use constants, only: ZERO + use global + use intercycle, only: shannon_entropy, calculate_keff, synchronize_bank, & + count_source_for_ufs + use output, only: write_message, header + use physics, only: transport + use source, only: get_source_particle + use string, only: to_str + use tally, only: synchronize_tallies + use timing, only: timer_start, timer_stop + +contains + +!=============================================================================== +! RUN_CRITICALITY encompasses all the main logic where iterations are performed +! over the cycles and histories. +!=============================================================================== + + subroutine run_criticality() + + integer(8) :: i ! index over histories in single cycle + + if (master) call header("BEGIN SIMULATION", level=1) + + tallies_on = .false. + call timer_start(time_inactive) + + ! Allocate particle + allocate(p) + + ! Display column titles + if (entropy_on) then + message = " Batch k(batch) Entropy Average k" + call write_message(1) + message = " ===== ======== ======= ===================" + call write_message(1) + else + message = " Batch k(batch) Average k" + call write_message(1) + message = " ===== ======== ===================" + call write_message(1) + end if + + ! ========================================================================== + ! LOOP OVER BATCHES + BATCH_LOOP: do current_batch = 1, n_batches + + message = "Simulating batch " // trim(to_str(current_batch)) // "..." + call write_message(8) + + ! Reset total starting weight + total_weight = ZERO + + ! ======================================================================= + ! LOOP OVER GENERATIONS + GENERATION_LOOP: do current_gen = 1, gen_per_batch + + ! Set all tallies to zero + n_bank = 0 + + ! Count source sites if using uniform fission source weighting + if (ufs) call count_source_for_ufs() + + ! ==================================================================== + ! LOOP OVER HISTORIES + + ! Start timer for transport + call timer_start(time_transport) + + HISTORY_LOOP: do i = 1, work + + ! grab source particle from bank + call get_source_particle(i) + + ! transport particle + call transport() + + end do HISTORY_LOOP + + ! Accumulate time for transport + call timer_stop(time_transport) + + ! ==================================================================== + ! WRAP UP FISSION BANK AND COMPUTE TALLIES, KEFF, ETC + + ! Start timer for inter-cycle synchronization + call timer_start(time_intercycle) + + ! Distribute fission bank across processors evenly + call synchronize_bank() + + ! Stop timer for inter-cycle synchronization + call timer_stop(time_intercycle) + + end do GENERATION_LOOP + + ! Collect tallies + if (tallies_on) then + call timer_start(time_ic_tallies) + call synchronize_tallies() + call timer_stop(time_ic_tallies) + end if + + ! Calculate shannon entropy + if (entropy_on) call shannon_entropy() + + ! Collect results and statistics + call calculate_keff() + + ! Turn tallies on once inactive cycles are complete + if (current_batch == n_inactive) then + tallies_on = .true. + call timer_stop(time_inactive) + call timer_start(time_active) + end if + + end do BATCH_LOOP + + call timer_stop(time_active) + + ! ========================================================================== + ! END OF RUN WRAPUP + + if (master) call header("SIMULATION FINISHED", level=1) + + end subroutine run_criticality + +end module criticality diff --git a/src/main.F90 b/src/main.F90 index dba439b0d9..5de70d8f5d 100644 --- a/src/main.F90 +++ b/src/main.F90 @@ -1,22 +1,11 @@ program main - use constants - use global - use finalize, only: finalize_run - use initialize, only: initialize_run - use intercycle, only: shannon_entropy, calculate_keff, synchronize_bank, & - count_source_for_ufs - use output, only: write_message, header - use plotter, only: run_plot - use physics, only: transport - use source, only: get_source_particle - use string, only: to_str - use tally, only: synchronize_tallies - use timing, only: timer_start, timer_stop - -#ifdef MPI - use mpi -#endif + use constants, only: MODE_CRITICALITY, MODE_PLOTTING + use criticality, only: run_criticality + use finalize, only: finalize_run + use global, only: run_mode + use initialize, only: initialize_run + use plotter, only: run_plot implicit none @@ -34,120 +23,4 @@ program main ! finalize run call finalize_run() -contains - -!=============================================================================== -! RUN_CRITICALITY encompasses all the main logic where iterations are performed -! over the cycles and histories. -!=============================================================================== - - subroutine run_criticality() - - integer(8) :: i ! index over histories in single cycle - - if (master) call header("BEGIN SIMULATION", level=1) - - tallies_on = .false. - call timer_start(time_inactive) - - ! Allocate particle - allocate(p) - - ! Display column titles - if (entropy_on) then - message = " Batch k(batch) Entropy Average k" - call write_message(1) - message = " ===== ======== ======= ===================" - call write_message(1) - else - message = " Batch k(batch) Average k" - call write_message(1) - message = " ===== ======== ===================" - call write_message(1) - end if - - ! ========================================================================== - ! LOOP OVER BATCHES - BATCH_LOOP: do current_batch = 1, n_batches - - message = "Simulating batch " // trim(to_str(current_batch)) // "..." - call write_message(8) - - ! Reset total starting weight - total_weight = ZERO - - ! ======================================================================= - ! LOOP OVER GENERATIONS - GENERATION_LOOP: do current_gen = 1, gen_per_batch - - ! Set all tallies to zero - n_bank = 0 - - ! Count source sites if using uniform fission source weighting - if (ufs) call count_source_for_ufs() - - ! ==================================================================== - ! LOOP OVER HISTORIES - - ! Start timer for transport - call timer_start(time_transport) - - HISTORY_LOOP: do i = 1, work - - ! grab source particle from bank - call get_source_particle(i) - - ! transport particle - call transport() - - end do HISTORY_LOOP - - ! Accumulate time for transport - call timer_stop(time_transport) - - ! ==================================================================== - ! WRAP UP FISSION BANK AND COMPUTE TALLIES, KEFF, ETC - - ! Start timer for inter-cycle synchronization - call timer_start(time_intercycle) - - ! Distribute fission bank across processors evenly - call synchronize_bank() - - ! Stop timer for inter-cycle synchronization - call timer_stop(time_intercycle) - - end do GENERATION_LOOP - - ! Collect tallies - if (tallies_on) then - call timer_start(time_ic_tallies) - call synchronize_tallies() - call timer_stop(time_ic_tallies) - end if - - ! Calculate shannon entropy - if (entropy_on) call shannon_entropy() - - ! Collect results and statistics - call calculate_keff() - - ! Turn tallies on once inactive cycles are complete - if (current_batch == n_inactive) then - tallies_on = .true. - call timer_stop(time_inactive) - call timer_start(time_active) - end if - - end do BATCH_LOOP - - call timer_stop(time_active) - - ! ========================================================================== - ! END OF RUN WRAPUP - - if (master) call header("SIMULATION FINISHED", level=1) - - end subroutine run_criticality - end program main