mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Added list of filters to TallyObject for use in get_scoring_bins.
This commit is contained in:
parent
99bd108936
commit
34cf649465
4 changed files with 134 additions and 102 deletions
|
|
@ -445,6 +445,14 @@ contains
|
|||
! =======================================================================
|
||||
! WRITE INFORMATION ON TALLY FILTERS
|
||||
|
||||
! Write filters
|
||||
call hdf5_make_integer(temp_group, "n_filters", t % n_filters)
|
||||
if (t % n_filters > 0) then
|
||||
dims(1) = t % n_filters
|
||||
call h5ltmake_dataset_int_f(temp_group, "filters", 1, &
|
||||
dims, t % filters, hdf5_err)
|
||||
end if
|
||||
|
||||
! Write universe_bins if present
|
||||
if (t % n_filter_bins(FILTER_UNIVERSE) > 0) then
|
||||
dims(1) = t % n_filter_bins(FILTER_UNIVERSE)
|
||||
|
|
|
|||
|
|
@ -615,6 +615,8 @@ contains
|
|||
integer :: i_mesh ! index in meshes array
|
||||
integer :: n ! size of arrays in mesh specification
|
||||
integer :: n_words ! number of words read
|
||||
integer :: n_filters ! number of filters
|
||||
integer :: filters(N_FILTER_TYPES) ! temporary list of filters
|
||||
logical :: file_exists ! does tallies.xml file exist?
|
||||
character(MAX_LINE_LEN) :: filename
|
||||
character(MAX_WORD_LEN) :: word
|
||||
|
|
@ -735,6 +737,10 @@ contains
|
|||
t % n_filter_bins = 0
|
||||
t % stride = 0
|
||||
|
||||
! Initialize filters
|
||||
n_filters = 0
|
||||
filters = 0
|
||||
|
||||
! Set tally type to volume by default
|
||||
t % type = TALLY_VOLUME
|
||||
|
||||
|
|
@ -767,6 +773,9 @@ contains
|
|||
t % cell_bins(j) % scalar = int(str_to_int(words(j)),4)
|
||||
end do
|
||||
t % n_filter_bins(FILTER_CELL) = n_words
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_CELL
|
||||
end if
|
||||
|
||||
! Read surface filter bins
|
||||
|
|
@ -777,6 +786,9 @@ contains
|
|||
t % surface_bins(j) % scalar = int(str_to_int(words(j)),4)
|
||||
end do
|
||||
t % n_filter_bins(FILTER_SURFACE) = n_words
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_SURFACE
|
||||
end if
|
||||
|
||||
! Read universe filter bins
|
||||
|
|
@ -787,6 +799,9 @@ contains
|
|||
t % universe_bins(j) % scalar = int(str_to_int(words(j)),4)
|
||||
end do
|
||||
t % n_filter_bins(FILTER_UNIVERSE) = n_words
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_UNIVERSE
|
||||
end if
|
||||
|
||||
! Read material filter bins
|
||||
|
|
@ -797,6 +812,9 @@ contains
|
|||
t % material_bins(j) % scalar = int(str_to_int(words(j)),4)
|
||||
end do
|
||||
t % n_filter_bins(FILTER_MATERIAL) = n_words
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_MATERIAL
|
||||
end if
|
||||
|
||||
! Read mesh filter bins
|
||||
|
|
@ -814,6 +832,9 @@ contains
|
|||
end if
|
||||
|
||||
t % n_filter_bins(FILTER_MESH) = t % n_filter_bins(FILTER_MESH) + product(m % dimension)
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_MESH
|
||||
end if
|
||||
|
||||
! Read birth region filter bins
|
||||
|
|
@ -824,6 +845,9 @@ contains
|
|||
t % cellborn_bins(j) % scalar = int(str_to_int(words(j)),4)
|
||||
end do
|
||||
t % n_filter_bins(FILTER_CELLBORN) = n_words
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_CELLBORN
|
||||
end if
|
||||
|
||||
! Read incoming energy filter bins
|
||||
|
|
@ -834,6 +858,9 @@ contains
|
|||
t % energy_in(j) = str_to_real(words(j))
|
||||
end do
|
||||
t % n_filter_bins(FILTER_ENERGYIN) = n_words - 1
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_ENERGYIN
|
||||
end if
|
||||
|
||||
! Read outgoing energy filter bins
|
||||
|
|
@ -847,8 +874,16 @@ contains
|
|||
|
||||
! Set tally estimator to analog
|
||||
t % estimator = ESTIMATOR_ANALOG
|
||||
|
||||
n_filters = n_filters + 1
|
||||
filters(n_filters) = FILTER_ENERGYOUT
|
||||
end if
|
||||
|
||||
! Allocate and set filters
|
||||
t % n_filters = n_filters
|
||||
allocate(t % filters(n_filters))
|
||||
t % filters = filters(1:n_filters)
|
||||
|
||||
! Read macro reactions
|
||||
if (len_trim(tally_(i) % macros) > 0) then
|
||||
call split_string(tally_(i) % macros, words, n_words)
|
||||
|
|
|
|||
186
src/tally.F90
186
src/tally.F90
|
|
@ -602,11 +602,12 @@ contains
|
|||
|
||||
subroutine get_scoring_bins(p, index_tally, bins, found_bin)
|
||||
|
||||
type(Particle), pointer :: p
|
||||
integer, intent(in) :: index_tally
|
||||
integer, intent(out) :: bins(N_FILTER_TYPES)
|
||||
logical, intent(out) :: found_bin
|
||||
type(Particle), pointer :: p
|
||||
integer, intent(in) :: index_tally
|
||||
integer, intent(out) :: bins(N_FILTER_TYPES)
|
||||
logical, intent(out) :: found_bin
|
||||
|
||||
integer :: i
|
||||
integer :: n
|
||||
integer :: mesh_bin
|
||||
type(TallyObject), pointer :: t => null()
|
||||
|
|
@ -614,114 +615,97 @@ contains
|
|||
|
||||
found_bin = .true.
|
||||
t => tallies(index_tally)
|
||||
bins = 1
|
||||
|
||||
! determine mesh bin
|
||||
if (t % n_filter_bins(FILTER_MESH) > 0) then
|
||||
m => meshes(t % mesh)
|
||||
FILTER_LOOP: do i = 1, t % n_filters
|
||||
|
||||
! Determine if we're in the mesh first
|
||||
call get_mesh_bin(m, p % coord0 % xyz, mesh_bin)
|
||||
if (mesh_bin == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
bins(FILTER_MESH) = mesh_bin
|
||||
else
|
||||
bins(FILTER_MESH) = 1
|
||||
end if
|
||||
select case (t % filters(i))
|
||||
case (FILTER_MESH)
|
||||
! determine mesh bin
|
||||
m => meshes(t % mesh)
|
||||
|
||||
! determine next universe bin
|
||||
! TODO: Account for multiple universes when performing this filter
|
||||
if (t % n_filter_bins(FILTER_UNIVERSE) > 0) then
|
||||
bins(FILTER_UNIVERSE) = get_next_bin(FILTER_UNIVERSE, &
|
||||
p % coord % universe, index_tally)
|
||||
if (bins(FILTER_UNIVERSE) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
else
|
||||
bins(FILTER_UNIVERSE) = 1
|
||||
end if
|
||||
! Determine if we're in the mesh first
|
||||
call get_mesh_bin(m, p % coord0 % xyz, mesh_bin)
|
||||
if (mesh_bin == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
bins(FILTER_MESH) = mesh_bin
|
||||
|
||||
! determine next material bin
|
||||
if (t % n_filter_bins(FILTER_MATERIAL) > 0) then
|
||||
bins(FILTER_MATERIAL) = get_next_bin(FILTER_MATERIAL, &
|
||||
p % material, index_tally)
|
||||
if (bins(FILTER_MATERIAL) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
else
|
||||
bins(FILTER_MATERIAL) = 1
|
||||
end if
|
||||
case (FILTER_UNIVERSE)
|
||||
! determine next universe bin
|
||||
! TODO: Account for multiple universes when performing this filter
|
||||
bins(FILTER_UNIVERSE) = get_next_bin(FILTER_UNIVERSE, &
|
||||
p % coord % universe, index_tally)
|
||||
if (bins(FILTER_UNIVERSE) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! determine next cell bin
|
||||
! TODO: Account for cells in multiple levels when performing this filter
|
||||
if (t % n_filter_bins(FILTER_CELL) > 0) then
|
||||
bins(FILTER_CELL) = get_next_bin(FILTER_CELL, &
|
||||
p % coord % cell, index_tally)
|
||||
if (bins(FILTER_CELL) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
else
|
||||
bins(FILTER_CELL) = 1
|
||||
end if
|
||||
case (FILTER_MATERIAL)
|
||||
bins(FILTER_MATERIAL) = get_next_bin(FILTER_MATERIAL, &
|
||||
p % material, index_tally)
|
||||
if (bins(FILTER_MATERIAL) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! determine next cellborn bin
|
||||
if (t % n_filter_bins(FILTER_CELLBORN) > 0) then
|
||||
bins(FILTER_CELLBORN) = get_next_bin(FILTER_CELLBORN, &
|
||||
p % cell_born, index_tally)
|
||||
if (bins(FILTER_CELLBORN) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
else
|
||||
bins(FILTER_CELLBORN) = 1
|
||||
end if
|
||||
case (FILTER_CELL)
|
||||
! determine next cell bin
|
||||
! TODO: Account for cells in multiple levels when performing this filter
|
||||
bins(FILTER_CELL) = get_next_bin(FILTER_CELL, &
|
||||
p % coord % cell, index_tally)
|
||||
if (bins(FILTER_CELL) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! determine next surface bin
|
||||
if (t % n_filter_bins(FILTER_SURFACE) > 0) then
|
||||
bins(FILTER_SURFACE) = get_next_bin(FILTER_SURFACE, &
|
||||
p % surface, index_tally)
|
||||
if (bins(FILTER_SURFACE) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
else
|
||||
bins(FILTER_SURFACE) = 1
|
||||
end if
|
||||
case (FILTER_CELLBORN)
|
||||
! determine next cellborn bin
|
||||
bins(FILTER_CELLBORN) = get_next_bin(FILTER_CELLBORN, &
|
||||
p % cell_born, index_tally)
|
||||
if (bins(FILTER_CELLBORN) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! determine incoming energy bin
|
||||
n = t % n_filter_bins(FILTER_ENERGYIN)
|
||||
if (n > 0) then
|
||||
! check if energy of the particle is within energy bins
|
||||
if (p % last_E < t % energy_in(1) .or. &
|
||||
p % last_E > t % energy_in(n + 1)) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
case (FILTER_SURFACE)
|
||||
! determine next surface bin
|
||||
bins(FILTER_SURFACE) = get_next_bin(FILTER_SURFACE, &
|
||||
p % surface, index_tally)
|
||||
if (bins(FILTER_SURFACE) == NO_BIN_FOUND) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! search to find incoming energy bin
|
||||
bins(FILTER_ENERGYIN) = binary_search(t % energy_in, n + 1, p % last_E)
|
||||
else
|
||||
bins(FILTER_ENERGYIN) = 1
|
||||
end if
|
||||
case (FILTER_ENERGYIN)
|
||||
! determine incoming energy bin
|
||||
n = t % n_filter_bins(FILTER_ENERGYIN)
|
||||
! check if energy of the particle is within energy bins
|
||||
if (p % last_E < t % energy_in(1) .or. &
|
||||
p % last_E > t % energy_in(n + 1)) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! determine outgoing energy bin
|
||||
n = t % n_filter_bins(FILTER_ENERGYOUT)
|
||||
if (n > 0) then
|
||||
! check if energy of the particle is within energy bins
|
||||
if (p % E < t % energy_out(1) .or. p % E > t % energy_out(n + 1)) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
! search to find incoming energy bin
|
||||
bins(FILTER_ENERGYIN) = binary_search(t % energy_in, n + 1, p % last_E)
|
||||
|
||||
! search to find incoming energy bin
|
||||
bins(FILTER_ENERGYOUT) = binary_search(t % energy_out, n + 1, p % E)
|
||||
else
|
||||
bins(FILTER_ENERGYOUT) = 1
|
||||
end if
|
||||
case (FILTER_ENERGYOUT)
|
||||
! determine outgoing energy bin
|
||||
n = t % n_filter_bins(FILTER_ENERGYOUT)
|
||||
! check if energy of the particle is within energy bins
|
||||
if (p % E < t % energy_out(1) .or. p % E > t % energy_out(n + 1)) then
|
||||
found_bin = .false.
|
||||
return
|
||||
end if
|
||||
|
||||
! search to find incoming energy bin
|
||||
bins(FILTER_ENERGYOUT) = binary_search(t % energy_out, n + 1, p % E)
|
||||
|
||||
end select
|
||||
|
||||
end do FILTER_LOOP
|
||||
|
||||
end subroutine get_scoring_bins
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,12 @@ module tally_header
|
|||
integer :: estimator ! collision, track-length
|
||||
real(8) :: volume ! volume of region
|
||||
|
||||
! Tally bin specifications
|
||||
! Information about what filters should be used
|
||||
|
||||
integer :: n_filters
|
||||
integer, allocatable :: filters(:)
|
||||
|
||||
! Filter bin specifications
|
||||
|
||||
type(TallyFilter), pointer :: universe_bins(:) => null()
|
||||
type(TallyFilter), pointer :: material_bins(:) => null()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue