Ability to create state point.

This commit is contained in:
Paul Romano 2012-07-31 13:01:44 -04:00
parent af25e7932e
commit b6e4e9ecb8
6 changed files with 101 additions and 13 deletions

View file

@ -23,11 +23,13 @@ cross_section.o: random_lcg.o
cross_section.o: search.o
criticality.o: constants.o
criticality.o: finalize.o
criticality.o: global.o
criticality.o: intercycle.o
criticality.o: output.o
criticality.o: physics.o
criticality.o: source.o
criticality.o: state_point.o
criticality.o: string.o
criticality.o: tally.o
criticality.o: timing.o
@ -230,6 +232,10 @@ source.o: physics.o
source.o: random_lcg.o
source.o: string.o
state_point.o: global.o
state_point.o: source.o
state_point.o: string.o
string.o: constants.o
string.o: error.o
string.o: global.o

View file

@ -5,10 +5,15 @@ module constants
! ============================================================================
! VERSIONING NUMBERS
! OpenMC major, minor, and release numbers
integer, parameter :: VERSION_MAJOR = 0
integer, parameter :: VERSION_MINOR = 4
integer, parameter :: VERSION_RELEASE = 3
! Revision numbers for binary files
integer, parameter :: REVISION_SOURCE = 1
integer, parameter :: REVISION_STATEPOINT = 1
! ============================================================================
! ADJUSTABLE PARAMETERS
@ -350,5 +355,6 @@ module constants
integer, parameter :: UNIT_PLOT = 13 ! unit # for writing plot file
integer, parameter :: UNIT_XS = 14 ! unit # for writing xs summary file
integer, parameter :: UNIT_SOURCE = 15 ! unit # for writing source file
integer, parameter :: UNIT_STATE = 16 ! unit # for writing state point
end module constants

View file

@ -1,15 +1,16 @@
module criticality
use constants, only: ZERO
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, print_columns
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
use intercycle, only: shannon_entropy, calculate_keff, synchronize_bank, &
count_source_for_ufs
use output, only: write_message, header, print_columns
use physics, only: transport
use source, only: get_source_particle
use state_point, only: create_state_point
use string, only: to_str
use tally, only: synchronize_tallies
use timing, only: timer_start, timer_stop
contains
@ -139,6 +140,8 @@ contains
call timer_start(time_active)
end if
! TODO: Write out state point if requested
end subroutine finalize_batch
end module criticality

View file

@ -64,9 +64,7 @@ contains
! Accumulate time for transport
call timer_stop(time_transport)
call timer_start(time_ic_tallies)
call synchronize_tallies()
call timer_stop(time_ic_tallies)
call finalize_batch()
end do BATCH_LOOP
@ -93,6 +91,18 @@ contains
end subroutine initialize_batch
!===============================================================================
! FINALIZE_BATCH
!===============================================================================
subroutine finalize_batch()
call timer_start(time_ic_tallies)
call synchronize_tallies()
call timer_stop(time_ic_tallies)
end subroutine finalize_batch
!===============================================================================
! SAMPLE_SOURCE_PARTICLE
!===============================================================================

View file

@ -224,7 +224,8 @@ module global
character(MAX_FILE_LEN) :: path_input ! Path to input file
character(MAX_FILE_LEN) :: path_cross_sections ! Path to cross_sections.xml
character(MAX_FILE_LEN) :: path_source ! Path to source file
character(MAX_FILE_LEN) :: path_source ! Path to binary source
character(MAX_FILE_LEN) :: path_state_point ! Path to binary state point
! Message used in message/warning/fatal_error
character(MAX_LINE_LEN) :: message

62
src/state_point.F90 Normal file
View file

@ -0,0 +1,62 @@
module state_point
use global
use source, only: write_source_binary
use string, only: to_str
implicit none
contains
!===============================================================================
! CREATE_STATE_POINT creates a state point binary file that can be used for
! restarting a run
!===============================================================================
subroutine create_state_point()
integer :: i ! loop index
! Set filename for binary state point
path_state_point = 'restart.' // trim(to_str(current_batch)) // '.binary'
! Open binary state point file for writing
open(UNIT=UNIT_STATE, FILE=path_state_point, STATUS='replace', &
ACCESS='stream')
! Write revision number for state point file
write(UNIT_STATE) REVISION_STATEPOINT
! Write OpenMC version
write(UNIT_STATE) VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE
! Write run information
write(UNIT_STATE) run_mode, n_particles, n_batches, &
n_inactive, gen_per_batch
! Write out current batch number
write(UNIT_STATE) current_batch
! Write out global tallies sum and sum_sq
write(UNIT_STATE) N_GLOBAL_TALLIES
write(UNIT_STATE) global_tallies(:) % sum
write(UNIT_STATE) global_tallies(:) % sum_sq
! Write out tallies sum and sum_sq
write(UNIT_STATE) n_tallies
do i = 1, n_tallies
write(UNIT_STATE) size(tallies(i) % scores, 1)
write(UNIT_STATE) size(tallies(i) % scores, 2)
write(UNIT_STATE) tallies(i) % scores(:,:) % sum
write(UNIT_STATE) tallies(i) % scores(:,:) % sum_sq
end do
! Close binary state point file
close(UNIT_STATE)
! For a criticality simulation, write the source file
if (run_mode == MODE_CRITICALITY) call write_source_binary()
end subroutine create_state_point
end module state_point