mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Ability to write state points at specified batches.
This commit is contained in:
parent
b6e4e9ecb8
commit
d4d1f63e1d
9 changed files with 90 additions and 28 deletions
|
|
@ -69,6 +69,7 @@ fixed_source.o: output.o
|
|||
fixed_source.o: physics.o
|
||||
fixed_source.o: random_lcg.o
|
||||
fixed_source.o: source.o
|
||||
fixed_source.o: state_point.o
|
||||
fixed_source.o: string.o
|
||||
fixed_source.o: tally.o
|
||||
fixed_source.o: timing.o
|
||||
|
|
@ -233,7 +234,7 @@ source.o: random_lcg.o
|
|||
source.o: string.o
|
||||
|
||||
state_point.o: global.o
|
||||
state_point.o: source.o
|
||||
state_point.o: output.o
|
||||
state_point.o: string.o
|
||||
|
||||
string.o: constants.o
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ random_lcg.o \
|
|||
search.o \
|
||||
source.o \
|
||||
source_header.o \
|
||||
state_point.o \
|
||||
string.o \
|
||||
tally.o \
|
||||
tally_header.o \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module criticality
|
|||
count_source_for_ufs
|
||||
use output, only: write_message, header, print_columns
|
||||
use physics, only: transport
|
||||
use source, only: get_source_particle
|
||||
use source, only: get_source_particle, write_source_binary
|
||||
use state_point, only: create_state_point
|
||||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies
|
||||
|
|
@ -120,6 +120,8 @@ contains
|
|||
|
||||
subroutine finalize_batch()
|
||||
|
||||
integer :: i ! loop index for state point batches
|
||||
|
||||
! Collect tallies
|
||||
if (tallies_on) then
|
||||
call timer_start(time_ic_tallies)
|
||||
|
|
@ -133,6 +135,19 @@ contains
|
|||
! Collect results and statistics
|
||||
call calculate_keff()
|
||||
|
||||
! Write out state point if it's been specified for this batch
|
||||
do i = 1, n_state_points
|
||||
if (current_batch == statepoint_batch(i)) then
|
||||
! Create state point file
|
||||
if (master) call create_state_point()
|
||||
|
||||
! Create binary source file
|
||||
call write_source_binary('source.' // &
|
||||
trim(to_str(current_batch)) // '.binary')
|
||||
exit
|
||||
end if
|
||||
end do
|
||||
|
||||
! Turn tallies on once inactive cycles are complete
|
||||
if (current_batch == n_inactive) then
|
||||
tallies_on = .true.
|
||||
|
|
@ -140,8 +155,6 @@ contains
|
|||
call timer_start(time_active)
|
||||
end if
|
||||
|
||||
! TODO: Write out state point if requested
|
||||
|
||||
end subroutine finalize_batch
|
||||
|
||||
end module criticality
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
module fixed_source
|
||||
|
||||
use constants, only: ZERO
|
||||
use constants, only: ZERO
|
||||
use global
|
||||
use output, only: write_message, header
|
||||
use physics, only: transport
|
||||
use random_lcg, only: set_particle_seed
|
||||
use source, only: initialize_particle, sample_external_source, &
|
||||
copy_source_attributes
|
||||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies
|
||||
use timing, only: timer_start, timer_stop
|
||||
use output, only: write_message, header
|
||||
use physics, only: transport
|
||||
use random_lcg, only: set_particle_seed
|
||||
use source, only: initialize_particle, sample_external_source, &
|
||||
copy_source_attributes
|
||||
use state_point, only: create_state_point
|
||||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies
|
||||
use timing, only: timer_start, timer_stop
|
||||
|
||||
type(Bank), pointer :: source_site => null()
|
||||
|
||||
|
|
@ -97,10 +98,23 @@ contains
|
|||
|
||||
subroutine finalize_batch()
|
||||
|
||||
integer :: i ! loop index for state point batches
|
||||
|
||||
! Collect and accumulate tallies
|
||||
call timer_start(time_ic_tallies)
|
||||
call synchronize_tallies()
|
||||
call timer_stop(time_ic_tallies)
|
||||
|
||||
! Write out state point if it's been specified for this batch
|
||||
if (master) then
|
||||
do i = 1, n_state_points
|
||||
if (current_batch == statepoint_batch(i)) then
|
||||
call create_state_point()
|
||||
exit
|
||||
end if
|
||||
end do
|
||||
end if
|
||||
|
||||
end subroutine finalize_batch
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -243,6 +243,10 @@ module global
|
|||
integer :: trace_gen
|
||||
integer(8) :: trace_particle
|
||||
|
||||
! Information about state points to be written
|
||||
integer :: n_state_points = 0
|
||||
integer, allocatable :: statepoint_batch(:)
|
||||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ contains
|
|||
! Copy batch information
|
||||
n_batches = fixed_source_ % batches
|
||||
n_active = fixed_source_ % batches
|
||||
n_inactive = 0
|
||||
gen_per_batch = 1
|
||||
end if
|
||||
|
||||
|
|
@ -457,6 +458,16 @@ contains
|
|||
! Check if the user has specified to write binary source file
|
||||
if (trim(write_source_) == 'on') write_source = .true.
|
||||
|
||||
! Check if the user has specified to write state points
|
||||
if (associated(write_state_point_)) then
|
||||
! Determine number of batches at which to store state points
|
||||
n_state_points = size(write_state_point_)
|
||||
|
||||
! Allocate and store batches
|
||||
allocate(statepoint_batch(n_state_points))
|
||||
statepoint_batch = write_state_point_
|
||||
end if
|
||||
|
||||
! Check if the user has specified to not reduce tallies at the end of every
|
||||
! batch
|
||||
if (trim(no_reduce_) == 'on') reduce_tallies = .false.
|
||||
|
|
|
|||
|
|
@ -239,17 +239,28 @@ contains
|
|||
! can be used as a starting source in a new simulation
|
||||
!===============================================================================
|
||||
|
||||
subroutine write_source_binary()
|
||||
|
||||
subroutine write_source_binary(path)
|
||||
|
||||
character(*), optional :: path
|
||||
|
||||
#ifdef MPI
|
||||
integer :: fh ! file handle
|
||||
integer(MPI_OFFSET_KIND) :: offset ! offset in memory (0=beginning of file)
|
||||
#endif
|
||||
|
||||
! Determine path to binary source file to write
|
||||
if (present(path)) then
|
||||
path_source = path
|
||||
else
|
||||
path_source = 'source.binary'
|
||||
end if
|
||||
|
||||
#ifdef MPI
|
||||
! ==========================================================================
|
||||
! PARALLEL I/O USING MPI-2 ROUTINES
|
||||
|
||||
! Open binary source file for reading
|
||||
call MPI_FILE_OPEN(MPI_COMM_WORLD, 'source.binary', MPI_MODE_CREATE + &
|
||||
call MPI_FILE_OPEN(MPI_COMM_WORLD, path_source, MPI_MODE_CREATE + &
|
||||
MPI_MODE_WRONLY, MPI_INFO_NULL, fh, mpi_err)
|
||||
|
||||
if (master) then
|
||||
|
|
@ -273,7 +284,7 @@ contains
|
|||
! SERIAL I/O USING FORTRAN INTRINSIC ROUTINES
|
||||
|
||||
! Open binary source file for writing
|
||||
open(UNIT=UNIT_SOURCE, FILE='source.binary', STATUS='replace', &
|
||||
open(UNIT=UNIT_SOURCE, FILE=path_source, STATUS='replace', &
|
||||
ACCESS='stream')
|
||||
|
||||
! Write the number of particles
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module state_point
|
||||
|
||||
use global
|
||||
use source, only: write_source_binary
|
||||
use output, only: write_message
|
||||
use string, only: to_str
|
||||
|
||||
implicit none
|
||||
|
|
@ -20,6 +20,10 @@ contains
|
|||
! Set filename for binary state point
|
||||
path_state_point = 'restart.' // trim(to_str(current_batch)) // '.binary'
|
||||
|
||||
! Write message
|
||||
message = "Creating state point " // trim(path_state_point) // "..."
|
||||
call write_message()
|
||||
|
||||
! Open binary state point file for writing
|
||||
open(UNIT=UNIT_STATE, FILE=path_state_point, STATUS='replace', &
|
||||
ACCESS='stream')
|
||||
|
|
@ -37,26 +41,28 @@ contains
|
|||
! Write out current batch number
|
||||
write(UNIT_STATE) current_batch
|
||||
|
||||
! Write out random number seed
|
||||
write(UNIT_STATE) seed
|
||||
|
||||
! 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
|
||||
if (tallies_on) then
|
||||
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
|
||||
end if
|
||||
|
||||
! 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
|
||||
|
|
|
|||
|
|
@ -50,5 +50,6 @@
|
|||
<variable name="trace_" tag="trace" type="integer-array" />
|
||||
<variable name="uniform_fs_" tag="uniform_fs" type="mesh_xml" dimension="1" />
|
||||
<variable name="write_source_" tag="write_source" type="word" length="3" />
|
||||
<variable name="write_state_point_" tag="write_state_point" type="integer-array" />
|
||||
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue