mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Change fixed source simulations to use source_bank rather than dummy source
site. This makes fixed source and eigenvalue modes more similar.
This commit is contained in:
parent
3d1af11b6c
commit
2c8c771998
10 changed files with 44 additions and 88 deletions
|
|
@ -317,7 +317,7 @@ foreach(test ${TESTS})
|
|||
elseif(${test} MATCHES "test_particle_restart_eigval")
|
||||
set(RESTART_FILE particle_12_616.h5)
|
||||
elseif(${test} MATCHES "test_particle_restart_fixed")
|
||||
set(RESTART_FILE particle_7_6144.h5)
|
||||
set(RESTART_FILE particle_7_928.h5)
|
||||
else(${test} MATCHES "test_statepoint_restart")
|
||||
message(FATAL_ERROR "Restart test ${test} not recognized")
|
||||
endif(${test} MATCHES "test_statepoint_restart")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module eigenvalue
|
|||
use particle_header, only: Particle
|
||||
use random_lcg, only: prn, set_particle_seed, prn_skip
|
||||
use search, only: binary_search
|
||||
use source, only: get_source_particle
|
||||
use source, only: get_source_particle, initialize_source
|
||||
use state_point, only: write_state_point, write_source_point
|
||||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies, setup_active_usertallies, &
|
||||
|
|
@ -44,6 +44,8 @@ contains
|
|||
type(Particle) :: p
|
||||
integer(8) :: i_work
|
||||
|
||||
if (.not. restart_run) call initialize_source()
|
||||
|
||||
if (master) call header("K EIGENVALUE SIMULATION", level=1)
|
||||
|
||||
! Display column titles
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module fixed_source
|
|||
use output, only: write_message, header
|
||||
use particle_header, only: Particle
|
||||
use random_lcg, only: set_particle_seed
|
||||
use source, only: sample_external_source, copy_source_attributes
|
||||
use source, only: initialize_source, get_source_particle
|
||||
use state_point, only: write_state_point
|
||||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies, setup_active_usertallies
|
||||
|
|
@ -22,16 +22,13 @@ contains
|
|||
|
||||
subroutine run_fixedsource()
|
||||
|
||||
integer(8) :: i ! index over histories in single cycle
|
||||
type(Particle) :: p
|
||||
integer(8) :: i_work ! index over histories in single cycle
|
||||
|
||||
if (.not. restart_run) call initialize_source()
|
||||
|
||||
if (master) call header("FIXED SOURCE TRANSPORT SIMULATION", level=1)
|
||||
|
||||
! Allocate particle and dummy source site
|
||||
!$omp parallel
|
||||
allocate(source_site)
|
||||
!$omp end parallel
|
||||
|
||||
! Turn timer and tallies on
|
||||
tallies_on = .true.
|
||||
!$omp parallel
|
||||
|
|
@ -50,6 +47,7 @@ contains
|
|||
end if
|
||||
|
||||
call initialize_batch()
|
||||
overall_gen = current_batch
|
||||
|
||||
! Start timer for transport
|
||||
call time_transport % start()
|
||||
|
|
@ -57,21 +55,11 @@ contains
|
|||
! =======================================================================
|
||||
! LOOP OVER PARTICLES
|
||||
!$omp parallel do schedule(static) firstprivate(p)
|
||||
PARTICLE_LOOP: do i = 1, work
|
||||
|
||||
! Set unique particle ID
|
||||
p % id = (current_batch - 1)*n_particles + work_index(rank) + i
|
||||
|
||||
! set particle trace
|
||||
trace = .false.
|
||||
if (current_batch == trace_batch .and. current_gen == trace_gen .and. &
|
||||
work_index(rank) + i == trace_particle) trace = .true.
|
||||
|
||||
! set random number seed
|
||||
call set_particle_seed(p % id)
|
||||
PARTICLE_LOOP: do i_work = 1, work
|
||||
current_work = i_work
|
||||
|
||||
! grab source particle from bank
|
||||
call sample_source_particle(p)
|
||||
call get_source_particle(p, current_work)
|
||||
|
||||
! transport particle
|
||||
call transport(p)
|
||||
|
|
@ -151,26 +139,4 @@ contains
|
|||
|
||||
end subroutine finalize_batch
|
||||
|
||||
!===============================================================================
|
||||
! SAMPLE_SOURCE_PARTICLE
|
||||
!===============================================================================
|
||||
|
||||
subroutine sample_source_particle(p)
|
||||
|
||||
type(Particle), intent(inout) :: p
|
||||
|
||||
! Set particle
|
||||
call p % initialize()
|
||||
|
||||
! Sample the external source distribution
|
||||
call sample_external_source(source_site)
|
||||
|
||||
! Copy source attributes to the particle
|
||||
call copy_source_attributes(p, source_site)
|
||||
|
||||
! Determine whether to create track file
|
||||
if (write_all_tracks) p % write_track = .true.
|
||||
|
||||
end subroutine sample_source_particle
|
||||
|
||||
end module fixed_source
|
||||
|
|
|
|||
|
|
@ -283,10 +283,6 @@ module global
|
|||
! Mode to run in (fixed source, eigenvalue, plotting, etc)
|
||||
integer :: run_mode = NONE
|
||||
|
||||
! Fixed source particle bank
|
||||
type(Bank), pointer :: source_site => null()
|
||||
!$omp threadprivate(source_site)
|
||||
|
||||
! Restart run
|
||||
logical :: restart_run = .false.
|
||||
integer :: restart_batch
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ module initialize
|
|||
write_message
|
||||
use output_interface
|
||||
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
|
||||
use tally_header, only: TallyObject, TallyResult, TallyFilter
|
||||
|
|
@ -141,13 +140,9 @@ contains
|
|||
! Determine how much work each processor should do
|
||||
call calculate_work()
|
||||
|
||||
! Allocate banks and create source particles -- for a fixed source
|
||||
! calculation, the external source distribution is sampled during the
|
||||
! run, not at initialization
|
||||
if (run_mode == MODE_EIGENVALUE) then
|
||||
call allocate_banks()
|
||||
if (.not. restart_run) call initialize_source()
|
||||
end if
|
||||
! Allocate source bank, and for eigenvalu simulations also allocate the
|
||||
! fission bank
|
||||
call allocate_banks()
|
||||
|
||||
! If this is a restart run, load the state point data and binary source
|
||||
! file
|
||||
|
|
@ -904,31 +899,33 @@ contains
|
|||
call fatal_error("Failed to allocate source bank.")
|
||||
end if
|
||||
|
||||
if (run_mode == MODE_EIGENVALUE) then
|
||||
#ifdef _OPENMP
|
||||
! If OpenMP is being used, each thread needs its own private fission
|
||||
! bank. Since the private fission banks need to be combined at the end of a
|
||||
! generation, there is also a 'master_fission_bank' that is used to collect
|
||||
! the sites from each thread.
|
||||
! If OpenMP is being used, each thread needs its own private fission
|
||||
! bank. Since the private fission banks need to be combined at the end of
|
||||
! a generation, there is also a 'master_fission_bank' that is used to
|
||||
! collect the sites from each thread.
|
||||
|
||||
n_threads = omp_get_max_threads()
|
||||
n_threads = omp_get_max_threads()
|
||||
|
||||
!$omp parallel
|
||||
thread_id = omp_get_thread_num()
|
||||
thread_id = omp_get_thread_num()
|
||||
|
||||
if (thread_id == 0) then
|
||||
allocate(fission_bank(3*work))
|
||||
else
|
||||
allocate(fission_bank(3*work/n_threads))
|
||||
end if
|
||||
if (thread_id == 0) then
|
||||
allocate(fission_bank(3*work))
|
||||
else
|
||||
allocate(fission_bank(3*work/n_threads))
|
||||
end if
|
||||
!$omp end parallel
|
||||
allocate(master_fission_bank(3*work), STAT=alloc_err)
|
||||
allocate(master_fission_bank(3*work), STAT=alloc_err)
|
||||
#else
|
||||
allocate(fission_bank(3*work), STAT=alloc_err)
|
||||
allocate(fission_bank(3*work), STAT=alloc_err)
|
||||
#endif
|
||||
|
||||
! Check for allocation errors
|
||||
if (alloc_err /= 0) then
|
||||
call fatal_error("Failed to allocate fission bank.")
|
||||
! Check for allocation errors
|
||||
if (alloc_err /= 0) then
|
||||
call fatal_error("Failed to allocate fission bank.")
|
||||
end if
|
||||
end if
|
||||
|
||||
end subroutine allocate_banks
|
||||
|
|
|
|||
|
|
@ -43,12 +43,7 @@ contains
|
|||
call pr % file_create(filename)
|
||||
|
||||
! Get information about source particle
|
||||
select case (run_mode)
|
||||
case (MODE_EIGENVALUE)
|
||||
src => source_bank(current_work)
|
||||
case (MODE_FIXEDSOURCE)
|
||||
src => source_site
|
||||
end select
|
||||
src => source_bank(current_work)
|
||||
|
||||
! Write data to file
|
||||
call pr % write_data(FILETYPE_PARTICLE_RESTART, 'filetype')
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ contains
|
|||
|
||||
! Write out initial source
|
||||
if (write_initial_source) then
|
||||
call write_message('Writing out initial source guess...', 1)
|
||||
call write_message('Writing out initial source...', 1)
|
||||
#ifdef HDF5
|
||||
filename = trim(path_output) // 'initial_source.h5'
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
tally 1:
|
||||
4.483337E+02
|
||||
2.017057E+04
|
||||
4.538791E+02
|
||||
2.073271E+04
|
||||
leakage:
|
||||
9.820000E+00
|
||||
9.648000E+00
|
||||
9.830000E+00
|
||||
9.663900E+00
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ current batch:
|
|||
current gen:
|
||||
0.000000E+00
|
||||
particle id:
|
||||
6.144000E+03
|
||||
9.280000E+02
|
||||
run mode:
|
||||
1.000000E+00
|
||||
particle weight:
|
||||
1.000000E+00
|
||||
particle energy:
|
||||
5.749729E+00
|
||||
4.412022E+00
|
||||
particle xyz:
|
||||
8.754675E+00 2.551620E+00 4.394350E-01
|
||||
5.572639E+00 -9.139472E+00 -1.974824E+00
|
||||
particle uvw:
|
||||
-5.971721E-01 -4.845709E-01 6.391999E-01
|
||||
1.410422E-01 5.330426E-01 -8.342498E-01
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ from testing_harness import ParticleRestartTestHarness
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = ParticleRestartTestHarness('particle_7_6144.*')
|
||||
harness = ParticleRestartTestHarness('particle_7_928.*')
|
||||
harness.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue