-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathangle.f90
439 lines (426 loc) · 10.8 KB
/
angle.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
SUBROUTINE angle(iexit)
!-------------------------------------------------------------
!
! Prepares the angular quadrature with directions from input
!
!-------------------------------------------------------------
USE invar
IMPLICIT NONE
INTEGER, INTENT(INOUT) :: iexit
REAL*8, DIMENSION(:), ALLOCATABLE :: cs
REAL*8 :: tmp, cons, wtsum
INTEGER :: qdhalf, l, n, i, j
! Check that the type is now 0 or 1 -- 2 has been ruled out already
IF (qdtyp /= 0 .AND. qdtyp /= 1) THEN
WRITE(8,'(/,3X,A)') "ERROR: Illegal value for the quadrature type."
iexit = iexit + 1
END IF
! Prepare the cs array that temporarily holds info
ALLOCATE(cs(qdord/2))
! If qdtyp is 0, use the TWOTRAN formalism
! Completely symmetric angular quadrature
IF (qdtyp == 0) THEN
! Set up the first values to initialize
! No degrees of freedom for N=2
IF (qdord == 2) THEN
cs(1) = 0.57735027d0
! mu_1 selected. TWOTRAN values used
ELSE IF (qdord == 4) THEN
cs(1) = 0.30163878d0
ELSE IF (qdord == 6) THEN
cs(1) = 0.23009194d0
ELSE IF (qdord == 8) THEN
cs(1) = 0.19232747d0
ELSE
WRITE(8,'(/,3X,A)') "ERROR: Illegal value for TWOTRAN qdord (N). Must be 2, 4, 6, or 8."
iexit = iexit + 1
END IF
! Compute the set of distinct direction cosines
cons = REAL(qdord-2)
qdhalf = qdord/2
IF (qdord > 2) THEN
cons = 2.0d0*(1.0d0-3.0d0*cs(1)**2)/cons
DO i = 2, qdhalf
tmp = REAL(i-1)
tmp = cs(1)**2+tmp*cons
cs(i) = SQRT(tmp)
END DO
END IF
! Finish by placing these in the ang matrix
l=0
DO i = 1, qdhalf
n = qdhalf+1-i
DO j = 1, n
l = l+1
ang(l,1) = cs(i)
ang(l,2) = cs(j)
ang(l,3) = cs(n+1-j)
END DO
END DO
! Compute the angular weights
! N=2 and N=4 ordinates all have equal weights
! N=6 and N=8 have weights determined more rigorously
! Weights are normalized that sum is 0.25 per octant/quadrant
IF (qdord == 2 .OR. qdord == 4) THEN
tmp = 0.125d0/REAL(l)
DO i = 1, l
w(i) = tmp
END DO
ELSE IF (qdord == 6) THEN
w(1) = 0.04236164d0
w(2) = 0.040971693d0
w(3) = w(1)
w(4) = w(2)
w(5) = w(2)
w(6) = w(1)
ELSE
DO i = 1, l
w(i) = 0.0233138d0
END DO
w(1) = 0.0291971d0
w(4) = w(1)
w(10) = w(1)
w(6) = 0.0225257d0
END IF
! If quadrature type is EQN, jump to here
ELSE
IF (qdord == 2) THEN
l = 1
ang(1,1) = 0.57735027d0
ang(1,2) = ang(1,1)
ang(1,3) = ang(1,1)
ELSE IF (qdord == 4) THEN
l = 3
ang(1,1) = 0.3500212d0
ang(1,2) = ang(1,1)
ang(1,3) = 0.8688903d0
ang(2,1) = ang(1,1)
ang(2,2) = ang(1,3)
ang(2,3) = ang(1,1)
ang(3,1) = ang(1,3)
ang(3,2) = ang(1,1)
ang(3,3) = ang(1,1)
ELSE IF (qdord == 6) THEN
l = 6
ang(1,1) = 0.2666355d0
ang(1,2) = ang(1,1)
ang(1,3) = 0.9261808d0
ang(2,1) = ang(1,1)
ang(2,2) = 0.6815076d0
ang(2,3) = ang(2,2)
ang(3,1) = ang(1,1)
ang(3,2) = ang(1,3)
ang(3,3) = ang(1,1)
ang(4,1) = ang(2,2)
ang(4,2) = ang(1,1)
ang(4,3) = ang(2,2)
ang(5,1) = ang(2,2)
ang(5,2) = ang(2,2)
ang(5,3) = ang(1,1)
ang(6,1) = ang(1,3)
ang(6,2) = ang(1,1)
ang(6,3) = ang(1,1)
ELSE IF (qdord == 8) THEN
l=10
ang(1,1) = 0.2182179d0
ang(1,2) = ang(1,1)
ang(1,3) = 0.9511897d0
ang(2,1) = ang(1,1)
ang(2,2) = 0.5773503d0
ang(2,3) = 0.7867958d0
ang(3,1) = ang(1,1)
ang(3,2) = ang(2,3)
ang(3,3) = ang(2,2)
ang(4,1) = ang(1,1)
ang(4,2) = ang(1,3)
ang(4,3) = ang(1,1)
ang(5,1) = ang(2,2)
ang(5,2) = ang(1,1)
ang(5,3) = ang(2,3)
ang(6,1) = ang(2,2)
ang(6,2) = ang(2,2)
ang(6,3) = ang(2,2)
ang(7,1) = ang(2,2)
ang(7,2) = ang(2,3)
ang(7,3) = ang(1,1)
ang(8,1) = ang(2,3)
ang(8,2) = ang(1,1)
ang(8,3) = ang(2,2)
ang(9,1) = ang(2,3)
ang(9,2) = ang(2,2)
ang(9,3) = ang(1,1)
ang(10,1)= ang(1,3)
ang(10,2)= ang(1,1)
ang(10,3)= ang(1,1)
ELSE IF (qdord == 12) THEN
l = 21
ang(1,1) = 0.1672126d0
ang(1,2) = ang(1,1)
ang(1,3) = 0.9716377d0
ang(2,1) = ang(1,1)
ang(2,2) = 0.4595476d0
ang(2,3) = 0.8722706d0
ang(3,1) = ang(1,1)
ang(3,2) = 0.6280191d0
ang(3,3) = 0.7600210d0
ang(4,1) = ang(1,1)
ang(4,2) = ang(3,3)
ang(4,3) = ang(3,2)
ang(5,1) = ang(1,1)
ang(5,2) = ang(2,3)
ang(5,3) = ang(2,2)
ang(6,1) = ang(1,1)
ang(6,2) = ang(1,3)
ang(6,3) = ang(1,1)
ang(7,1) = ang(2,2)
ang(7,2) = ang(1,1)
ang(7,3) = ang(2,3)
ang(8,1) = ang(2,2)
ang(8,2) = ang(2,2)
ang(8,3) = ang(3,3)
ang(9,1) = ang(2,2)
ang(9,2) = ang(3,2)
ang(9,3) = ang(3,2)
ang(10,1) = ang(2,2)
ang(10,2) = ang(3,3)
ang(10,3) = ang(2,2)
ang(11,1) = ang(2,2)
ang(11,2) = ang(2,3)
ang(11,3) = ang(1,1)
ang(12,1) = ang(3,2)
ang(12,2) = ang(1,1)
ang(12,3) = ang(3,3)
ang(13,1) = ang(3,2)
ang(13,2) = ang(2,2)
ang(13,3) = ang(3,2)
ang(14,1) = ang(3,2)
ang(14,2) = ang(3,2)
ang(14,3) = ang(2,2)
ang(15,1) = ang(3,2)
ang(15,2) = ang(3,3)
ang(15,3) = ang(1,1)
ang(16,1) = ang(3,3)
ang(16,2) = ang(1,1)
ang(16,3) = ang(3,2)
ang(17,1) = ang(3,3)
ang(17,2) = ang(2,2)
ang(17,3) = ang(2,2)
ang(18,1) = ang(3,3)
ang(18,2) = ang(3,2)
ang(18,3) = ang(1,1)
ang(19,1) = ang(2,3)
ang(19,2) = ang(1,1)
ang(19,3) = ang(2,2)
ang(20,1) = ang(2,3)
ang(20,2) = ang(2,2)
ang(20,3) = ang(1,1)
ang(21,1) = ang(1,3)
ang(21,2) = ang(1,1)
ang(21,3) = ang(1,1)
ELSE IF (qdord == 16) THEN
l=36
ang(1,1) = 0.1389568d0
ang(1,2) = ang(1,1)
ang(1,3) = 0.9805009d0
ang(2,1) = ang(1,1)
ang(2,2) = 0.3922893d0
ang(2,3) = 0.9092855d0
ang(3,1) = ang(1,1)
ang(3,2) = 0.5370966d0
ang(3,3) = 0.8319966d0
ang(4,1) = ang(1,1)
ang(4,2) = 0.6504264d0
ang(4,3) = 0.7467506d0
ang(5,1) = ang(1,1)
ang(5,2) = ang(4,3)
ang(5,3) = ang(4,2)
ang(6,1) = ang(1,1)
ang(6,2) = ang(3,3)
ang(6,3) = ang(3,2)
ang(7,1) = ang(1,1)
ang(7,2) = ang(2,3)
ang(7,3) = ang(2,2)
ang(8,1) = ang(1,1)
ang(8,2) = ang(1,3)
ang(8,3) = ang(1,1)
ang(9,1) = ang(2,2)
ang(9,2) = ang(1,1)
ang(9,3) = ang(2,3)
ang(10,1) = ang(2,2)
ang(10,2) = ang(2,2)
ang(10,3) = ang(3,3)
ang(11,1) = ang(2,2)
ang(11,2) = ang(3,2)
ang(11,3) = ang(4,3)
ang(12,1) = ang(2,2)
ang(12,2) = ang(4,2)
ang(12,3) = ang(4,2)
ang(13,1) = ang(2,2)
ang(13,2) = ang(4,3)
ang(13,3) = ang(3,2)
ang(14,1) = ang(2,2)
ang(14,2) = ang(3,3)
ang(14,3) = ang(2,2)
ang(15,1) = ang(2,2)
ang(15,2) = ang(2,3)
ang(15,3) = ang(1,1)
ang(16,1) = ang(3,2)
ang(16,2) = ang(1,1)
ang(16,3) = ang(3,3)
ang(17,1) = ang(3,2)
ang(17,2) = ang(2,2)
ang(17,3) = ang(4,3)
ang(18,1) = ang(3,2)
ang(18,2) = ang(3,2)
ang(18,3) = ang(4,2)
ang(19,1) = ang(3,2)
ang(19,2) = ang(4,2)
ang(19,3) = ang(3,2)
ang(20,1) = ang(3,2)
ang(20,2) = ang(4,3)
ang(20,3) = ang(2,2)
ang(21,1) = ang(3,2)
ang(21,2) = ang(3,3)
ang(21,3) = ang(1,1)
ang(22,1) = ang(4,2)
ang(22,2) = ang(1,1)
ang(22,3) = ang(4,3)
ang(23,1) = ang(4,2)
ang(23,2) = ang(2,2)
ang(23,3) = ang(4,2)
ang(24,1) = ang(4,2)
ang(24,2) = ang(3,2)
ang(24,3) = ang(3,2)
ang(25,1) = ang(4,2)
ang(25,2) = ang(4,2)
ang(25,3) = ang(2,2)
ang(26,1) = ang(4,2)
ang(26,2) = ang(4,3)
ang(26,3) = ang(1,1)
ang(27,1) = ang(4,3)
ang(27,2) = ang(1,1)
ang(27,3) = ang(4,2)
ang(28,1) = ang(4,3)
ang(28,2) = ang(2,2)
ang(28,3) = ang(3,2)
ang(29,1) = ang(4,3)
ang(29,2) = ang(3,2)
ang(29,3) = ang(2,2)
ang(30,1) = ang(4,3)
ang(30,2) = ang(4,2)
ang(30,3) = ang(1,1)
ang(31,1) = ang(3,3)
ang(31,2) = ang(1,1)
ang(31,3) = ang(3,2)
ang(32,1) = ang(3,3)
ang(32,2) = ang(2,2)
ang(32,3) = ang(2,2)
ang(33,1) = ang(3,3)
ang(33,2) = ang(3,2)
ang(33,3) = ang(1,1)
ang(34,1) = ang(2,3)
ang(34,2) = ang(1,1)
ang(34,3) = ang(2,2)
ang(35,1) = ang(2,3)
ang(35,2) = ang(2,2)
ang(35,3) = ang(1,1)
ang(36,1) = ang(1,3)
ang(36,2) = ang(1,1)
ang(36,3) = ang(1,1)
ELSE
WRITE(8,'(/,3X,A)') "ERROR: Illegal value for EQN qdord (N). Must be 2, 4, 6, 8, 12, or 16."
iexit = iexit + 1
END IF
! Enter weights for EQN type quadrature
IF (qdord == 2 .OR. qdord == 4) THEN
tmp = 1.0d0/REAL(l)
DO i = 1, l
w(i) = tmp
END DO
ELSE IF (qdord == 6) THEN
w(1) = 0.1761263d0
w(2) = 0.1572071d0
w(3) = w(1)
w(4) = w(2)
w(5) = w(2)
w(6) = w(1)
ELSE IF (qdord == 8) THEN
w(1) = 0.1209877d0
w(2) = 0.0907407d0
w(3) = w(2)
w(4) = w(1)
w(5) = w(2)
w(6) = 0.0925926d0
w(7) = w(2)
w(8) = w(2)
w(9) = w(2)
w(10)= w(1)
ELSE IF (qdord == 12) THEN
w(1) = 0.0707626d0
w(2) = 0.0558811d0
w(3) = 0.0373377d0
w(4) = w(3)
w(5) = w(2)
w(6) = w(1)
w(7) = w(2)
w(8) = 0.0502819d0
w(9) = 0.0258513d0
w(10) = w(8)
w(11) = w(2)
w(12) = w(3)
w(13) = w(9)
w(14) = w(9)
w(15) = w(3)
w(16) = w(3)
w(17) = w(8)
w(18) = w(3)
w(19) = w(2)
w(20) = w(2)
w(21) = w(1)
ELSE IF (qdord == 16) THEN
w(1) = 0.0489872d0
w(2) = 0.0413296d0
w(3) = 0.0212326d0
w(4) = 0.0256207d0
w(5) = w(4)
w(6) = w(3)
w(7) = w(2)
w(8) = w(1)
w(9) = w(2)
w(10) = 0.0360486d0
w(11) = 0.0144589d0
w(12) = 0.0344958d0
w(13) = w(11)
w(14) = w(10)
w(15) = w(2)
w(16) = w(3)
w(17) = w(11)
w(18) = 0.0085179d0
w(19) = w(18)
w(20) = w(11)
w(21) = w(3)
w(22) = w(4)
w(23) = w(12)
w(24) = w(18)
w(25) = w(12)
w(26) = w(4)
w(27) = w(4)
w(28) = w(11)
w(29) = w(11)
w(30) = w(4)
w(31) = w(3)
w(32) = w(10)
w(33) = w(3)
w(34) = w(2)
w(35) = w(2)
w(36) = w(1)
END IF
END IF
! Renormalize all the weights
wtsum = SUM(w)
DO n = 1, apo
w(n) = w(n) * 0.125d0/wtsum
END DO
DEALLOCATE(cs)
RETURN
END SUBROUTINE angle