mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Use different stream for source sampling
This commit makes it easier for eigenvalue and fixed source runs to use the same seeds when sampling sources.
This commit is contained in:
parent
884fcac846
commit
f1fc8c7f5e
6 changed files with 20 additions and 14 deletions
|
|
@ -348,6 +348,14 @@ module constants
|
|||
K_TRACKLENGTH = 3, &
|
||||
LEAKAGE = 4
|
||||
|
||||
! ============================================================================
|
||||
! RANDOM NUMBER STREAM CONSTANTS
|
||||
|
||||
integer, parameter :: N_STREAMS = 3
|
||||
integer, parameter :: STREAM_TRACKING = 1
|
||||
integer, parameter :: STREAM_TALLIES = 2
|
||||
integer, parameter :: STREAM_SOURCE = 3
|
||||
|
||||
! ============================================================================
|
||||
! EXTERNAL SOURCE PARAMETERS
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ module fixed_source
|
|||
use tally, only: synchronize_tallies, setup_active_usertallies
|
||||
use tracking, only: transport
|
||||
|
||||
!$omp threadprivate(source_site)
|
||||
|
||||
contains
|
||||
|
||||
subroutine run_fixedsource()
|
||||
|
|
@ -68,11 +66,6 @@ contains
|
|||
! grab source particle from bank
|
||||
call sample_source_particle(p)
|
||||
|
||||
! Reset random number seed (it was changed during source sampling and
|
||||
! it should be set before transport is called to make it consistent
|
||||
! with eigenvalue and particle_restart).
|
||||
call set_particle_seed(p % id)
|
||||
|
||||
! transport particle
|
||||
call transport(p)
|
||||
|
||||
|
|
|
|||
|
|
@ -258,6 +258,8 @@ module global
|
|||
|
||||
! Fixed source particle bank
|
||||
type(Bank), pointer :: source_site => null()
|
||||
!$omp threadprivate(source_site)
|
||||
|
||||
|
||||
! Restart run
|
||||
logical :: restart_run = .false.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module particle_restart
|
|||
use output, only: write_message, print_particle
|
||||
use output_interface, only: BinaryOutput
|
||||
use particle_header, only: Particle
|
||||
use random_lcg, only: set_particle_seed, prn
|
||||
use random_lcg, only: set_particle_seed
|
||||
use tracking, only: transport
|
||||
|
||||
implicit none
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
module random_lcg
|
||||
|
||||
use constants
|
||||
|
||||
implicit none
|
||||
|
||||
private
|
||||
save
|
||||
|
||||
! Random number streams
|
||||
integer, parameter :: N_STREAMS = 2
|
||||
integer, parameter :: STREAM_TRACKING = 1
|
||||
integer, parameter :: STREAM_TALLIES = 2
|
||||
|
||||
integer(8) :: prn_seed0 ! original seed
|
||||
integer(8) :: prn_seed(N_STREAMS) ! current seed
|
||||
integer(8) :: prn_mult ! multiplication factor, g
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module source
|
|||
use output, only: write_message
|
||||
use output_interface, only: BinaryOutput
|
||||
use particle_header, only: Particle
|
||||
use random_lcg, only: prn, set_particle_seed
|
||||
use random_lcg, only: prn, set_particle_seed, prn_set_stream
|
||||
use string, only: to_str
|
||||
|
||||
#ifdef MPI
|
||||
|
|
@ -101,6 +101,9 @@ contains
|
|||
! Set weight to one by default
|
||||
site % wgt = ONE
|
||||
|
||||
! Set the random number generator to the source stream.
|
||||
call prn_set_stream(STREAM_SOURCE)
|
||||
|
||||
! Sample position
|
||||
select case (external_source % type_space)
|
||||
case (SRC_SPACE_BOX)
|
||||
|
|
@ -189,6 +192,9 @@ contains
|
|||
call fatal_error()
|
||||
end select
|
||||
|
||||
! Set the random number generator back to the tracking stream.
|
||||
call prn_set_stream(STREAM_TRACKING)
|
||||
|
||||
end subroutine sample_external_source
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue