mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Added user input option entropy_box and fixed bug in shannon_entropy subroutine.
This commit is contained in:
parent
de24c7e8ed
commit
69f8f9bd46
3 changed files with 39 additions and 7 deletions
|
|
@ -142,6 +142,30 @@ contains
|
|||
trace_particle = trace_(2)
|
||||
end if
|
||||
|
||||
! Entropy box
|
||||
if (associated(entropy_box_)) then
|
||||
! Check to make sure enough values were supplied
|
||||
if (size(entropy_box_) /= 6) then
|
||||
message = "Need to supply lower-left and upper-right coordinates " &
|
||||
// "for Shannon entropy box."
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
! Copy values
|
||||
entropy_lower_left = entropy_box_(1:3)
|
||||
entropy_upper_right = entropy_box_(4:6)
|
||||
|
||||
! Check on values provided
|
||||
if (.not. all(entropy_upper_right > entropy_lower_left)) then
|
||||
message = "Upper-right coordinate must be greater than lower-left " &
|
||||
// "coordinate for Shannon entropy box."
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
! Turn on Shannon entropy calculation
|
||||
entropy_on = .true.
|
||||
end if
|
||||
|
||||
end subroutine read_settings_xml
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@ contains
|
|||
|
||||
subroutine shannon_entropy()
|
||||
|
||||
integer :: i_bank ! index for bank sites
|
||||
integer :: m ! index for bank sites
|
||||
integer :: i ! x-index for entropy mesh
|
||||
integer :: j ! y-index for entropy mesh
|
||||
integer :: k ! z-index for entropy mesh
|
||||
integer, save :: n_box ! total # of boxes on mesh
|
||||
integer, save :: n ! # of boxes in each dimension
|
||||
real(8), save :: width(3) ! width of box in each dimension
|
||||
logical :: outside_box ! were there sites outside entropy box?
|
||||
|
||||
! On the first pass through this subroutine, we need to determine how big
|
||||
! the entropy mesh should be in each direction and then allocate a
|
||||
|
|
@ -43,19 +44,19 @@ contains
|
|||
|
||||
! initialize p
|
||||
entropy_p = ZERO
|
||||
outside_box = .false.
|
||||
|
||||
! loop over fission sites and count how many are in each mesh box
|
||||
FISSION_SITES: do i_bank = 1, n_bank
|
||||
FISSION_SITES: do m = 1, n_bank
|
||||
! determine indices for entropy mesh box
|
||||
i = (fission_bank(i_bank) % xyz(1) - entropy_lower_left(1))/n
|
||||
j = (fission_bank(i_bank) % xyz(2) - entropy_lower_left(2))/n
|
||||
k = (fission_bank(i_bank) % xyz(3) - entropy_lower_left(3))/n
|
||||
i = (fission_bank(m) % xyz(1) - entropy_lower_left(1))/width(1) + 1
|
||||
j = (fission_bank(m) % xyz(2) - entropy_lower_left(2))/width(2) + 1
|
||||
k = (fission_bank(m) % xyz(3) - entropy_lower_left(3))/width(3) + 1
|
||||
|
||||
! if outside mesh, skip particle
|
||||
if (i < 1 .or. i > n .or. j < 1 .or. &
|
||||
j > n .or. k < 1 .or. k > n) then
|
||||
message = "Fission source site outside of entropy box."
|
||||
call warning()
|
||||
outside_box = .true.
|
||||
cycle
|
||||
end if
|
||||
|
||||
|
|
@ -63,6 +64,12 @@ contains
|
|||
entropy_p(i,j,k) = entropy_p(i,j,k) + 1
|
||||
end do FISSION_SITES
|
||||
|
||||
! display warning message if there were sites outside entropy box
|
||||
if (outside_box) then
|
||||
message = "Fission source site(s) outside of entropy box."
|
||||
call warning()
|
||||
end if
|
||||
|
||||
! normalize to number of fission sites
|
||||
entropy_p = entropy_p/n
|
||||
|
||||
|
|
|
|||
|
|
@ -26,5 +26,6 @@
|
|||
<variable name="cutoff_" tag="cutoff" type="cutoff_xml" dimension="1" />
|
||||
<variable name="cross_sections_" tag="cross_sections" type="word" length="255" />
|
||||
<variable name="trace_" tag="trace" type="integer-array" />
|
||||
<variable name="entropy_box_" tag="entropy_box" type="double-array" />
|
||||
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue