Added criticality module.

This commit is contained in:
Paul Romano 2012-04-07 11:27:05 -04:00
parent f4f2a85b6f
commit 3ffbd80efd
4 changed files with 149 additions and 140 deletions

View file

@ -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

View file

@ -3,6 +3,7 @@ ace.o \
ace_header.o \
bank_header.o \
cross_section.o \
criticality.o \
datatypes.o \
datatypes_header.o \
doppler.o \

130
src/criticality.F90 Normal file
View file

@ -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

View file

@ -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