Skip to content

Commit

Permalink
Merge branch 'fission_src' of github.com:bhermanmit/openmc into fissi…
Browse files Browse the repository at this point in the history
…on_src
  • Loading branch information
Bryan Herman committed Sep 5, 2014
2 parents a3df011 + c5a4374 commit b8681fc
Show file tree
Hide file tree
Showing 102 changed files with 8,615 additions and 8,345 deletions.
4 changes: 2 additions & 2 deletions data/get_nndc_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@

# loop around ace directories
for d in ace_dirs:
print('Coverting {0}...'.format(d))
print('Converting {0}...'.format(d))

# get a list of files to convert
ace_files = glob.glob(os.path.join(d, '*.ace*'))

# convert files
for f in ace_files:
print(' Coverting {0}...'.format(os.path.split(f)[1]))
print(' Converting {0}...'.format(os.path.split(f)[1]))
ascii_to_binary(f, f)

# Change cross_sections.xml file
Expand Down
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ foreach(test ${TESTS})
set(RESTART_FILE statepoint.07.h5)
elseif(${test} MATCHES "test_sourcepoint_restart")
set(RESTART_FILE statepoint.07.h5 source.07.h5)
elseif(${test} MATCHES "test_particle_restart")
set(RESTART_FILE particle_12_885.h5)
elseif(${test} MATCHES "test_particle_restart_eigval")
set(RESTART_FILE particle_12_842.h5)
elseif(${test} MATCHES "test_particle_restart_fixed")
set(RESTART_FILE particle_7_6144.h5)
else(${test} MATCHES "test_statepoint_restart")
message(FATAL_ERROR "Restart test ${test} not recognized")
endif(${test} MATCHES "test_statepoint_restart")
Expand All @@ -358,8 +360,10 @@ foreach(test ${TESTS})
set(RESTART_FILE statepoint.07.binary)
elseif(${test} MATCHES "test_sourcepoint_restart")
set(RESTART_FILE statepoint.07.binary source.07.binary)
elseif(${test} MATCHES "test_particle_restart")
set(RESTART_FILE particle_12_885.binary)
elseif(${test} MATCHES "test_particle_restart_eigval")
set(RESTART_FILE particle_12_842.binary)
elseif(${test} MATCHES "test_particle_restart_fixed")
set(RESTART_FILE particle_7_6144.binary)
else(${test} MATCHES "test_statepoint_restart")
message(FATAL_ERROR "Restart test ${test} not recognized")
endif(${test} MATCHES "test_statepoint_restart")
Expand Down
13 changes: 11 additions & 2 deletions src/constants.F90
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,22 @@ 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

! Source spatial distribution types
integer, parameter :: &
SRC_SPACE_BOX = 1, & ! Source in a rectangular prism
SRC_SPACE_POINT = 2 ! Source at a single point
SRC_SPACE_BOX = 1, & ! Source in a rectangular prism
SRC_SPACE_POINT = 2, & ! Source at a single point
SRC_SPACE_FISSION = 3 ! Source in prism filtered by fissionable mats

! Source angular distribution types
integer, parameter :: &
Expand Down
3 changes: 0 additions & 3 deletions src/fixed_source.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ module fixed_source
use tally, only: synchronize_tallies, setup_active_usertallies
use tracking, only: transport

type(Bank), pointer :: source_site => null()
!$omp threadprivate(source_site)

contains

subroutine run_fixedsource()
Expand Down
4 changes: 4 additions & 0 deletions src/global.F90
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ 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
Expand Down
36 changes: 36 additions & 0 deletions src/initialize.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module initialize
use global
use input_xml, only: read_input_xml, read_cross_sections_xml, &
cells_in_univ_dict, read_plots_xml
use material_header, only: Material
use output, only: title, header, write_summary, print_version, &
print_usage, write_xs_summary, print_plot, &
write_message
Expand Down Expand Up @@ -107,6 +108,9 @@ subroutine initialize_run()
! Create linked lists for multiple instances of the same nuclide
call same_nuclide_list()

! Check for fissionable material
call check_mat_fission()

! Construct unionized energy grid from cross-sections
if (grid_method == GRID_UNION) then
call time_unionize % start()
Expand Down Expand Up @@ -897,4 +901,36 @@ subroutine allocate_banks()

end subroutine allocate_banks

!===============================================================================
! CHECK_MAT_FISSION checks material for fissionable nuclides
!===============================================================================

subroutine check_mat_fission()

integer :: i ! Material index counter
integer :: j ! Nuclide index counter
type(Material), pointer :: m => null()

! Loop around material
MAT: do i = 1, n_materials

! Get material
m => materials(i)
m % fissionable = .false.

! Loop around nuclides in material
NUC: do j = 1, m % n_nuclides

! Check for fission in nuclide
if (nuclides(m % nuclide(j)) % fissionable) then
m % fissionable = .true.
exit NUC
end if

end do NUC

end do MAT

end subroutine check_mat_fission

end module initialize
3 changes: 3 additions & 0 deletions src/input_xml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ subroutine read_settings_xml()
case ('box')
external_source % type_space = SRC_SPACE_BOX
coeffs_reqd = 6
case ('fission')
external_source % type_space = SRC_SPACE_FISSION
coeffs_reqd = 6
case ('point')
external_source % type_space = SRC_SPACE_POINT
coeffs_reqd = 3
Expand Down
4 changes: 4 additions & 0 deletions src/material_header.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module material_header
! Temporary names read during initialization
character(12), allocatable :: names(:) ! isotope names
character(12), allocatable :: sab_names(:) ! name of S(a,b) table

! Does this material contain fissionable nuclides?
logical :: fissionable

end type Material

end module material_header
17 changes: 13 additions & 4 deletions src/particle_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module particle_restart
subroutine run_particle_restart()

integer(8) :: particle_seed
integer :: previous_run_mode
type(Particle) :: p

! Set verbosity high
Expand All @@ -37,14 +38,20 @@ subroutine run_particle_restart()
call p % initialize()

! Read in the restart information
call read_particle_restart(p)
call read_particle_restart(p, previous_run_mode)

! Set all tallies to 0 for now (just tracking errors)
n_tallies = 0

! Compute random number seed
particle_seed = ((current_batch - 1)*gen_per_batch + &
current_gen - 1)*n_particles + p % id
select case (previous_run_mode)
case (MODE_EIGENVALUE)
particle_seed = ((current_batch - 1)*gen_per_batch + &
current_gen - 1)*n_particles + p % id
case (MODE_FIXEDSOURCE)
particle_seed = p % id
end select

call set_particle_seed(particle_seed)

! Transport neutron
Expand All @@ -59,9 +66,10 @@ end subroutine run_particle_restart
! READ_PARTICLE_RESTART reads the particle restart file
!===============================================================================

subroutine read_particle_restart(p)
subroutine read_particle_restart(p, previous_run_mode)

integer :: int_scalar
integer, intent(inout) :: previous_run_mode
type(Particle), intent(inout) :: p

! Write meessage
Expand All @@ -79,6 +87,7 @@ subroutine read_particle_restart(p)
call pr % read_data(gen_per_batch, 'gen_per_batch')
call pr % read_data(current_gen, 'current_gen')
call pr % read_data(n_particles, 'n_particles')
call pr % read_data(previous_run_mode, 'run_mode')
call pr % read_data(p % id, 'id')
call pr % read_data(p % wgt, 'weight')
call pr % read_data(p % E, 'energy')
Expand Down
8 changes: 7 additions & 1 deletion src/particle_restart_write.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ subroutine write_particle_restart(p)
call pr % file_create(filename)

! Get information about source particle
src => source_bank(current_work)
select case (run_mode)
case (MODE_EIGENVALUE)
src => source_bank(current_work)
case (MODE_FIXEDSOURCE)
src => source_site
end select

! Write data to file
call pr % write_data(FILETYPE_PARTICLE_RESTART, 'filetype')
Expand All @@ -52,6 +57,7 @@ subroutine write_particle_restart(p)
call pr % write_data(gen_per_batch, 'gen_per_batch')
call pr % write_data(current_gen, 'current_gen')
call pr % write_data(n_particles, 'n_particles')
call pr % write_data(run_mode, 'run_mode')
call pr % write_data(p % id, 'id')
call pr % write_data(src % wgt, 'weight')
call pr % write_data(src % E, 'energy')
Expand Down
13 changes: 6 additions & 7 deletions src/random_lcg.F90
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,7 +18,7 @@ module random_lcg
real(8) :: prn_norm ! 2^(-M)
integer :: stream ! current RNG stream

!$omp threadprivate(prn_seed)
!$omp threadprivate(prn_seed, stream)

public :: prn
public :: initialize_prng
Expand Down Expand Up @@ -63,11 +60,13 @@ subroutine initialize_prng()

integer :: i

stream = STREAM_TRACKING
prn_seed0 = seed
!$omp parallel
do i = 1, N_STREAMS
prn_seed(i) = prn_seed0 + i - 1
end do
stream = STREAM_TRACKING
!$omp end parallel
prn_mult = 2806196910506780709_8
prn_add = 1_8
prn_bits = 63
Expand Down
41 changes: 40 additions & 1 deletion src/source.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -101,6 +101,9 @@ subroutine sample_external_source(site)
! 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)
Expand Down Expand Up @@ -132,6 +135,39 @@ subroutine sample_external_source(site)
end do
call p % clear()

case (SRC_SPACE_FISSION)
! Set particle defaults
call p % initialize()
! Repeat sampling source location until a good site has been found
found = .false.
do while (.not.found)
! Coordinates sampled uniformly over a box
p_min = external_source % params_space(1:3)
p_max = external_source % params_space(4:6)
r = (/ (prn(), i = 1,3) /)
site % xyz = p_min + r*(p_max - p_min)

! Fill p with needed data
p % coord0 % xyz = site % xyz
p % coord0 % uvw = [ ONE, ZERO, ZERO ]

! Now search to see if location exists in geometry
call find_cell(p, found)
if (.not. found) then
num_resamples = num_resamples + 1
if (num_resamples == MAX_EXTSRC_RESAMPLES) then
message = "Maximum number of external source spatial resamples &
&reached!"
call fatal_error()
end if
cycle
end if
if (.not. materials(p % material) % fissionable) then
found = .false.
call p % initialize()
end if
end do

case (SRC_SPACE_POINT)
! Point source
site % xyz = external_source % params_space
Expand Down Expand Up @@ -189,6 +225,9 @@ subroutine sample_external_source(site)
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

!===============================================================================
Expand Down
1 change: 1 addition & 0 deletions src/utils/particle_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def _read_data(self):
self.gen_per_batch = self._get_int(path='gen_per_batch')[0]
self.current_gen = self._get_int(path='current_gen')[0]
self.n_particles = self._get_long(path='n_particles')[0]
self.run_mode = self._get_int(path='run_mode')[0]

# Read particle properties
self.id = self._get_long(path='id')[0]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic/results_true.dat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
k-combined:
3.037840E-01 4.395585E-03
3.011726E-01 1.841644E-03
Loading

0 comments on commit b8681fc

Please sign in to comment.