-
Notifications
You must be signed in to change notification settings - Fork 12
/
collapse_fluxes.f90
executable file
·105 lines (85 loc) · 3.52 KB
/
collapse_fluxes.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
!begin rubric
!****************************************************************************** *
!* Original Author: Mark Gilbert *
!* copyright, 2015 (first version), 2018 (first git repository), UKAEA *
!******************************************************************************
!end rubric
SUBROUTINE collapse_fluxes(fluxx,ninput_groups,noutput_groups,output_energies,input_energies)
use globals
IMPLICIT NONE
! 12/3/2018 - corrects to memory leaks due to input arrays being one less in size than groups+1
INTEGER, INTENT (in) :: ninput_groups,noutput_groups
REAL(KIND=DBL), INTENT (inout) :: fluxx(MAX(noutput_groups,ninput_groups))
REAL(KIND=DBL), INTENT (in) :: output_energies(noutput_groups),input_energies(ninput_groups)
INTEGER :: ii,jj,kk
REAL(KIND=DBL) :: fluxx_rounded(MAX(noutput_groups,ninput_groups))
integer :: nd1,ni
logical :: split
REAL (KIND=DBL) :: frac,frac2,ebottom,due,dud
!30/6/2016 modified from CEM's grpconvert routine in FISPACT-II - itself based on routines written by N.P.Taylor.
IF(do_outputs) WRITE(log_unit,*) 'collapsing fluxes'
! 11/7/2016 but in this routine we will always be using a grid where the value in ii corresponds to
! the energy bin from ii-1 to ii
fluxx_rounded=0.0
nd1=noutput_groups
! check for overlap of groups - shouldn't be a problem here.
! 11/7/2016 - in fact all the output groups with energies below the
! first input group bound get a proportion of the total in the first group
! so we want to start from ni=1
!ni = 0
!do kk = 1,nd1
! ni = kk
! if(input_energies(1).lt.output_energies(kk)) exit
!end do
!print *,ni
ni = 1
jj=0
split=.false.
outer: do kk=ni,nd1
ii = kk !- 1
inner: do
if(.not.split) then
jj = jj + 1
if(jj>ninput_groups) exit outer
frac = 1.0
end if
!IF(kk/=1) THEN
if(input_energies(jj)>real(output_energies(ii))) exit inner
!END IF
!if(kk/=1) then
fluxx_rounded(ii) = fluxx_rounded(ii) + fluxx(jj) * frac
!end if
split = .false.
if(input_energies(jj) == real(output_energies(ii))) cycle outer
end do inner
IF(jj/=1) THEN
ebottom = input_energies(jj-1)
ELSE
ebottom=0._DBL
END IF
if(split) THEN
IF( ii/=1) THEN
ebottom = output_energies(ii-1)
ELSE
ebottom = 0._DBL
END IF
END IF
!lethargy method
!due = log(ebottom/real(output_energies(ii+1)))
!dud = log(ebottom/input_energies(jj+1))
!flat weight method
due = output_energies(ii)-ebottom
dud = input_energies(jj) -ebottom
frac2 = frac * due / dud
!if(kk/=1) then
fluxx_rounded(ii) = fluxx_rounded(ii) + fluxx(jj) * frac2
!end if
frac = frac * (1.0 - due / dud)
split = .true.
end do outer
IF(do_outputs) WRITE(log_unit,*) "finished"
fluxx=0._DBL
fluxx(1:noutput_groups)=fluxx_rounded(1:noutput_groups)
IF(do_outputs) WRITE(log_unit,*) 'sent results to matrix'
END SUBROUTINE collapse_fluxes