mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Ability to restart from state point. Works in serial.
This commit is contained in:
parent
d4d1f63e1d
commit
013df94b2e
8 changed files with 128 additions and 4 deletions
|
|
@ -120,6 +120,7 @@ initialize.o: input_xml.o
|
|||
initialize.o: output.o
|
||||
initialize.o: random_lcg.o
|
||||
initialize.o: source.o
|
||||
initialize.o: state_point.o
|
||||
initialize.o: string.o
|
||||
initialize.o: tally.o
|
||||
initialize.o: tally_header.o
|
||||
|
|
@ -233,6 +234,7 @@ source.o: physics.o
|
|||
source.o: random_lcg.o
|
||||
source.o: string.o
|
||||
|
||||
state_point.o: error.o
|
||||
state_point.o: global.o
|
||||
state_point.o: output.o
|
||||
state_point.o: string.o
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ contains
|
|||
! LOOP OVER BATCHES
|
||||
BATCH_LOOP: do current_batch = 1, n_batches
|
||||
|
||||
! In a restart run, skip any batches that have already been simulated
|
||||
if (restart_run .and. current_batch <= restart_batch) then
|
||||
if (current_batch == n_inactive) tallies_on = .true.
|
||||
if (current_batch > n_inactive) n_realizations = n_realizations + 1
|
||||
cycle BATCH_LOOP
|
||||
end if
|
||||
|
||||
call initialize_batch()
|
||||
|
||||
! =======================================================================
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ contains
|
|||
! LOOP OVER BATCHES
|
||||
BATCH_LOOP: do current_batch = 1, n_batches
|
||||
|
||||
! In a restart run, skip any batches that have already been simulated
|
||||
if (restart_run .and. current_batch <= restart_batch) then
|
||||
if (current_batch > n_inactive) n_realizations = n_realizations + 1
|
||||
cycle BATCH_LOOP
|
||||
end if
|
||||
|
||||
call initialize_batch()
|
||||
|
||||
! Start timer for transport
|
||||
|
|
|
|||
|
|
@ -222,9 +222,13 @@ module global
|
|||
! Mode to run in (fixed source, criticality, plotting, etc)
|
||||
integer :: run_mode = MODE_CRITICALITY
|
||||
|
||||
! Restart run
|
||||
logical :: restart_run = .false.
|
||||
integer :: restart_batch
|
||||
|
||||
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 binary source
|
||||
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
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ module initialize
|
|||
create_xs_summary_file, print_version
|
||||
use random_lcg, only: initialize_prng
|
||||
use source, only: initialize_source
|
||||
use state_point, only: load_state_point
|
||||
use string, only: to_str, str_to_int, starts_with, ends_with, &
|
||||
lower_case
|
||||
use tally, only: create_tally_map
|
||||
|
|
@ -125,6 +126,10 @@ contains
|
|||
call allocate_banks()
|
||||
call initialize_source()
|
||||
end if
|
||||
|
||||
! If this is a restart run, load the state point data and binary source
|
||||
! file
|
||||
if (restart_run) call load_state_point()
|
||||
end if
|
||||
|
||||
! stop timer for initialization
|
||||
|
|
@ -260,6 +265,14 @@ contains
|
|||
" command-line flag."
|
||||
call fatal_error()
|
||||
end if
|
||||
case ('-r', '-restart', '--restart')
|
||||
i = i + 1
|
||||
! Read path for state point
|
||||
path_state_point = argv(i)
|
||||
restart_run = .true.
|
||||
|
||||
! Set path for binary source file
|
||||
path_source = 'source.' // path_state_point(9:10) // '.binary'
|
||||
case ('-?', '-help', '--help')
|
||||
call print_usage()
|
||||
stop
|
||||
|
|
|
|||
|
|
@ -327,9 +327,6 @@ contains
|
|||
allocate(external_source % params_energy(2))
|
||||
external_source % params_energy = (/ 0.988_8, 2.249_8 /)
|
||||
end if
|
||||
|
||||
! Set null path for source file
|
||||
path_source = ""
|
||||
end if
|
||||
|
||||
! Survival biasing
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ contains
|
|||
write(OUTPUT_UNIT,*)
|
||||
write(OUTPUT_UNIT,*) 'Options:'
|
||||
write(OUTPUT_UNIT,*) ' -p, --plot Run in plotting mode'
|
||||
write(OUTPUT_UNIT,*) ' -r, --restart Restart a previous run'
|
||||
write(OUTPUT_UNIT,*) ' -v, --version Show version information'
|
||||
write(OUTPUT_UNIT,*) ' -?, --help Show this message'
|
||||
end if
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module state_point
|
||||
|
||||
use error, only: warning, fatal_error
|
||||
use global
|
||||
use output, only: write_message
|
||||
use string, only: to_str
|
||||
|
|
@ -44,6 +45,9 @@ contains
|
|||
! Write out random number seed
|
||||
write(UNIT_STATE) seed
|
||||
|
||||
! Write out keff information
|
||||
write(UNIT_STATE) keff, keff_std
|
||||
|
||||
! Write out global tallies sum and sum_sq
|
||||
write(UNIT_STATE) N_GLOBAL_TALLIES
|
||||
write(UNIT_STATE) global_tallies(:) % sum
|
||||
|
|
@ -65,4 +69,94 @@ contains
|
|||
|
||||
end subroutine create_state_point
|
||||
|
||||
!===============================================================================
|
||||
! LOAD_STATE_POINT
|
||||
!===============================================================================
|
||||
|
||||
subroutine load_state_point()
|
||||
|
||||
integer :: i ! loop index
|
||||
integer :: temp(3) ! temporary variable
|
||||
|
||||
! Write message
|
||||
message = "Loading 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='old', &
|
||||
ACCESS='stream')
|
||||
|
||||
! Raad revision number for state point file and make sure it matches with
|
||||
! current version
|
||||
read(UNIT_STATE) temp(1)
|
||||
if (temp(1) /= REVISION_STATEPOINT) then
|
||||
message = "State point binary version does not match current version " &
|
||||
// "in OpenMC."
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
! Read OpenMC version
|
||||
read(UNIT_STATE) temp(1:3)
|
||||
if (temp(1) /= VERSION_MAJOR .or. temp(2) /= VERSION_MINOR &
|
||||
.or. temp(3) /= VERSION_RELEASE) then
|
||||
message = "State point file was created with a different version " // &
|
||||
"of OpenMC."
|
||||
call warning()
|
||||
end if
|
||||
|
||||
! Read and overwrite run information
|
||||
read(UNIT_STATE) run_mode, n_particles, n_batches, &
|
||||
n_inactive, gen_per_batch
|
||||
|
||||
! Read batch number to restart at
|
||||
read(UNIT_STATE) restart_batch
|
||||
|
||||
! Read and overwrite random number seed
|
||||
read(UNIT_STATE) seed
|
||||
|
||||
! Write out keff information
|
||||
read(UNIT_STATE) keff, keff_std
|
||||
|
||||
if (master) then
|
||||
! Read number of global tallies and make sure it matches
|
||||
read(UNIT_STATE) temp(1)
|
||||
if (temp(1) /= N_GLOBAL_TALLIES) then
|
||||
message = "Number of global tallies does not match in state point."
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
! Read global tally data
|
||||
read(UNIT_STATE) global_tallies(:) % sum
|
||||
read(UNIT_STATE) global_tallies(:) % sum_sq
|
||||
|
||||
! Read tally data
|
||||
if (current_batch > n_inactive) then
|
||||
! Read number of tallies and make sure it matches
|
||||
read(UNIT_STATE) temp(1)
|
||||
if (temp(1) /= n_tallies) then
|
||||
message = "Number of tallies does not match in state point."
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
do i = 1, n_tallies
|
||||
! Make sure dimensions match for tally filters and scores
|
||||
read(UNIT_STATE) temp(1:2)
|
||||
if (temp(1) /= size(tallies(i) % scores, 1) .or. &
|
||||
temp(2) /= size(tallies(i) % scores, 2)) then
|
||||
message = "Tally dimensions do not match in state point."
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
! Read sum and sum squared
|
||||
read(UNIT_STATE) tallies(i) % scores(:,:) % sum
|
||||
read(UNIT_STATE) tallies(i) % scores(:,:) % sum_sq
|
||||
end do
|
||||
end if
|
||||
end if
|
||||
|
||||
! Close binary state point file
|
||||
close(UNIT_STATE)
|
||||
|
||||
end subroutine load_state_point
|
||||
|
||||
end module state_point
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue