mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
added new run mode for particle restart, restart files are read in
This commit is contained in:
parent
98a4105a59
commit
42c1159aa5
7 changed files with 113 additions and 17 deletions
|
|
@ -265,8 +265,11 @@ output.o: tally_header.o
|
|||
|
||||
particle_header.o: constants.o
|
||||
|
||||
particle_restart.o: bank_header.o
|
||||
particle_restart.o: constants.o
|
||||
particle_restart.o: geometry_header.o
|
||||
particle_restart.o: global.o
|
||||
particle_restart.o: particle_header.o
|
||||
|
||||
physics.o: ace_header.o
|
||||
physics.o: constants.o
|
||||
|
|
|
|||
|
|
@ -346,7 +346,8 @@ module constants
|
|||
MODE_FIXEDSOURCE = 1, & ! Fixed source mode
|
||||
MODE_EIGENVALUE = 2, & ! K eigenvalue mode
|
||||
MODE_PLOTTING = 3, & ! Plotting mode
|
||||
MODE_TALLIES = 4 ! Tally results mode
|
||||
MODE_TALLIES = 4, & ! Tally results mode
|
||||
MODE_PARTICLE = 5 ! Particle restart mode
|
||||
|
||||
! Unit numbers
|
||||
integer, parameter :: UNIT_SUMMARY = 11 ! unit # for writing summary file
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ contains
|
|||
! Start finalization timer
|
||||
call time_finalize % start()
|
||||
|
||||
if (run_mode /= MODE_PLOTTING) then
|
||||
if (run_mode /= MODE_PLOTTING .and. run_mode /= MODE_PARTICLE) then
|
||||
! Calculate statistics for tallies and write to tallies.out
|
||||
if (master) call tally_statistics()
|
||||
if (output_tallies) then
|
||||
|
|
@ -46,7 +46,8 @@ contains
|
|||
call time_finalize % stop()
|
||||
call time_total % stop()
|
||||
if (master .and. (run_mode /= MODE_PLOTTING .and. &
|
||||
run_mode /= MODE_TALLIES)) then
|
||||
run_mode /= MODE_TALLIES .and. &
|
||||
run_mode /= MODE_PARTICLE)) then
|
||||
call print_runtime()
|
||||
call print_results()
|
||||
end if
|
||||
|
|
|
|||
|
|
@ -254,10 +254,11 @@ module global
|
|||
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_state_point ! Path to binary state point
|
||||
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_state_point ! Path to binary state point
|
||||
character(MAX_FILE_LEN) :: path_particle_restart ! Path to particle restart
|
||||
|
||||
! Message used in message/warning/fatal_error
|
||||
character(MAX_LINE_LEN) :: message
|
||||
|
|
@ -275,6 +276,9 @@ module global
|
|||
integer :: trace_gen
|
||||
integer(8) :: trace_particle
|
||||
|
||||
! Particle restart run
|
||||
logical :: particle_restart_run = .false.
|
||||
|
||||
! ============================================================================
|
||||
! CMFD VARIABLES
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,9 @@ contains
|
|||
end if
|
||||
end if
|
||||
|
||||
! check for particle restart run
|
||||
if (particle_restart_run) run_mode = MODE_PARTICLE
|
||||
|
||||
! Stop initialization timer
|
||||
call time_initialize % stop()
|
||||
|
||||
|
|
@ -303,6 +306,11 @@ contains
|
|||
case ('-eps_tol', '-ksp_gmres_restart')
|
||||
! Handle options that would be based to PETSC
|
||||
i = i + 1
|
||||
case ('-partcle','--particle')
|
||||
! Read in path for particle restart
|
||||
i = i + 1
|
||||
path_particle_restart = argv(i)
|
||||
particle_restart_run = .true.
|
||||
case default
|
||||
message = "Unknown command line option: " // argv(i)
|
||||
call fatal_error()
|
||||
|
|
|
|||
13
src/main.F90
13
src/main.F90
|
|
@ -1,12 +1,13 @@
|
|||
program main
|
||||
|
||||
use constants
|
||||
use eigenvalue, only: run_eigenvalue
|
||||
use finalize, only: finalize_run
|
||||
use fixed_source, only: run_fixedsource
|
||||
use eigenvalue, only: run_eigenvalue
|
||||
use finalize, only: finalize_run
|
||||
use fixed_source, only: run_fixedsource
|
||||
use global
|
||||
use initialize, only: initialize_run
|
||||
use plot, only: run_plot
|
||||
use initialize, only: initialize_run
|
||||
use particle_restart, only: run_particle_restart
|
||||
use plot, only: run_plot
|
||||
|
||||
implicit none
|
||||
|
||||
|
|
@ -24,6 +25,8 @@ program main
|
|||
case (MODE_TALLIES)
|
||||
! For tallies-only mode, we just skip straight to finalize_run to write out
|
||||
! the tally results
|
||||
case (MODE_PARTICLE)
|
||||
call run_particle_restart()
|
||||
end select
|
||||
|
||||
! finalize run
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
module particle_restart
|
||||
|
||||
use bank_header, only: Bank
|
||||
use bank_header, only: Bank
|
||||
use constants
|
||||
use geometry_header, only: BASE_UNIVERSE
|
||||
use global
|
||||
use particle_header, only: deallocate_coord
|
||||
|
||||
#ifdef HDF5
|
||||
use hdf5
|
||||
use h5lt
|
||||
use, intrinsic :: ISO_C_BINDING
|
||||
#endif
|
||||
|
||||
implicit none
|
||||
private
|
||||
public :: write_particle_restart
|
||||
public :: write_particle_restart, run_particle_restart
|
||||
|
||||
integer(HID_T) :: hdf5_particle_file
|
||||
|
||||
|
|
@ -59,7 +61,35 @@ contains
|
|||
! READ_PARTICLE_RESTART
|
||||
!===============================================================================
|
||||
|
||||
subroutine read_particle_restart
|
||||
subroutine read_particle_restart()
|
||||
|
||||
integer(HSIZE_T) :: dims1(1)
|
||||
|
||||
! open hdf5 file
|
||||
call h5fopen_f(path_particle_restart, H5F_ACC_RDONLY_F, hdf5_particle_file,&
|
||||
hdf5_err)
|
||||
|
||||
! read data from file
|
||||
call hdf5_read_integer(hdf5_particle_file, 'current_batch', current_batch)
|
||||
call hdf5_read_integer(hdf5_particle_file, 'gen_per_batch', gen_per_batch)
|
||||
call hdf5_read_integer(hdf5_particle_file, 'current_gen', current_gen)
|
||||
call hdf5_read_long(hdf5_particle_file, 'n_particles', n_particles)
|
||||
call hdf5_read_long(hdf5_particle_file, 'id', p % id)
|
||||
call hdf5_read_double(hdf5_particle_file, 'weight', p % wgt)
|
||||
call hdf5_read_double(hdf5_particle_file, 'energy', p % E)
|
||||
dims1 = (/3/)
|
||||
call h5ltread_dataset_double_f(hdf5_particle_file, 'xyz', p % coord % xyz, &
|
||||
dims1, hdf5_err)
|
||||
call h5ltread_dataset_double_f(hdf5_particle_file, 'uvw', p % coord % uvw, &
|
||||
dims1, hdf5_err)
|
||||
|
||||
! set particle last attributes
|
||||
p % last_wgt = p % wgt
|
||||
p % last_xyz = p % coord % xyz
|
||||
p % last_E = p % E
|
||||
|
||||
! close hdf5 file
|
||||
call h5fclose_f(hdf5_particle_file, hdf5_err)
|
||||
|
||||
end subroutine read_particle_restart
|
||||
|
||||
|
|
@ -67,10 +97,56 @@ contains
|
|||
! RUN_PARTICLE_RESTART
|
||||
!===============================================================================
|
||||
|
||||
subroutine run_particle_restart
|
||||
subroutine run_particle_restart()
|
||||
|
||||
! initialize the particle to be tracked
|
||||
call initialize_particle()
|
||||
|
||||
! read in the restart information
|
||||
call read_particle_restart()
|
||||
|
||||
! set all tallies to 0 for now (just tracking errors)
|
||||
n_tallies = 0
|
||||
|
||||
! compute seed
|
||||
|
||||
end subroutine run_particle_restart
|
||||
|
||||
!===============================================================================
|
||||
! INITIALIZE_PARTICLE
|
||||
!===============================================================================
|
||||
|
||||
subroutine initialize_particle()
|
||||
|
||||
! Allocate particle
|
||||
allocate(p)
|
||||
|
||||
! Set particle to neutron that's alive
|
||||
p % type = NEUTRON
|
||||
p % alive = .true.
|
||||
|
||||
! clear attributes
|
||||
p % surface = NONE
|
||||
p % cell_born = NONE
|
||||
p % material = NONE
|
||||
p % last_material = NONE
|
||||
p % wgt = ONE
|
||||
p % last_wgt = ONE
|
||||
p % absorb_wgt = ZERO
|
||||
p % n_bank = 0
|
||||
p % wgt_bank = ZERO
|
||||
p % n_collision = 0
|
||||
|
||||
! remove any original coordinates
|
||||
call deallocate_coord(p % coord0)
|
||||
|
||||
! Set up base level coordinates
|
||||
allocate(p % coord0)
|
||||
p % coord0 % universe = BASE_UNIVERSE
|
||||
p % coord => p % coord0
|
||||
|
||||
end subroutine initialize_particle
|
||||
|
||||
!===============================================================================
|
||||
! HDF5_WRITE_INTEGER
|
||||
!===============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue