summaryrefslogtreecommitdiff
path: root/Dragon/src/MCGCOEF.f
blob: 298bf04ab6f9edd295ebc9238d2244654d78095e (plain)
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
*DECK MCGCOEF
      SUBROUTINE MCGCOEF(NFUNL,NMU,ZMU,WZMU,NANGL,CAZ1,CAZ2,COEFI)
*
*-----------------------------------------------------------------------
*
*Purpose:
* Find MOC coefficients for DD1 approximation up to P3 scattering order
* using a Gauss-Chebyshev or Leonard-McDaniel-Chebyshev quadrature.
*
*Copyright:
* Copyright (C) 2015 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*Author(s): A. Hebert
*
*Parameters: input
* NFUNL   number of spherical harmonics components.
* NMU     number of polar angles.
* ZMU     polar quadrature set in 2D.
* WZMU    polar quadrature set in 2D.
* NANGL   number of azimuthal angles.
* CAZ1    first azimuthal cosines.
* CAZ2    second azimuthal cosines.
*
*Parameters: output
* COEFI   Gram-Schmidt MOC coefficients.
*
*Reference:
* A. Hebert, "High-Order Diamond Differencing Along Finite
* Characteristics," Nucl. Sci. Eng., 169, 81-97 (2011).
*
*-----------------------------------------------------------------------
*
      IMPLICIT DOUBLE PRECISION(A-H,O-Z)
*----
*  SUBROUTINE ARGUMENTS
*----
      INTEGER NFUNL,NMU
      REAL ZMU(NMU),WZMU(NMU)
      DOUBLE PRECISION CAZ1(NANGL),CAZ2(NANGL),COEFI(2*NFUNL,2*NFUNL)
*----
*  LOCAL VARIABLES
*----
      DOUBLE PRECISION, DIMENSION(:,:), ALLOCATABLE :: COEF,COEF2,COEF3
      DOUBLE PRECISION, DIMENSION(2,2) :: M
      INTEGER, DIMENSION(10), PARAMETER :: 
     >                        LL=(/ 0, 1, 1, 2, 2, 2, 3, 3, 3, 3 /)
      INTEGER, DIMENSION(10), PARAMETER ::
     >                        MM=(/ 0, -1, 1, -2, 0, 2, -3, -1, 1, 3 /)
*
      ALLOCATE(COEF(2*NFUNL,2*NFUNL))
      DO I=1,NFUNL
        IL=LL(I) ; IM=MM(I) ;
        DO J=1,NFUNL
          ILP=LL(J) ; IMP=MM(J) ;
          CALL MCGDYA(NMU,ZMU,WZMU,NANGL,CAZ1,CAZ2,IL,IM,ILP,IMP,M) ;
          COEF(I,J)=M(1,1) ; COEF(I,NFUNL+J)=M(1,2) ;
          COEF(NFUNL+I,J)=M(2,1) ; COEF(NFUNL+I,NFUNL+J)=M(2,2) ;
        ENDDO
      ENDDO
      IF(NFUNL == 1) THEN
        CALL ALPINVD(2*NFUNL,2*NFUNL,COEF,COEFI(1,1)) ;
      ELSEIF(NFUNL == 3) THEN
        ALLOCATE(COEF2(2*NFUNL+1,2*NFUNL), COEF3(2*NFUNL,2*NFUNL+1))
        COEF2=0.0D0 ; COEF2(1:2*NFUNL,:)=COEF ;
        COEF2(2*NFUNL+1,2)=1.0D0 ; COEF2(2*NFUNL+1,NFUNL+3)=-1.0D0 ;
        CALL ALPINVD(2*NFUNL+1,2*NFUNL,COEF2,COEF3(1,1)) ;
        COEFI=COEF3(:,1:2*NFUNL) ;
        DEALLOCATE(COEF2, COEF3)
      ELSEIF(NFUNL == 6) THEN
        ALLOCATE(COEF2(2*NFUNL+3,2*NFUNL), COEF3(2*NFUNL,2*NFUNL+3))
        COEF2=0.0D0 ; COEF2(1:2*NFUNL,:)=COEF ;
        COEF2(2*NFUNL+1,2)=1.0D0 ; COEF2(2*NFUNL+1,NFUNL+3)=-1.0D0 ;
        COEF2(2*NFUNL+2,5)=SQRT(3.0D0) ; COEF2(2*NFUNL+2,6)=1.0D0 ;
        COEF2(2*NFUNL+2,NFUNL+4)=1.0D0 ;
        COEF2(2*NFUNL+3,NFUNL+5)=SQRT(3.0D0) ;
        COEF2(2*NFUNL+3,NFUNL+6)=-1.0D0 ; COEF2(2*NFUNL+3,4)=1.0D0 ;
        CALL ALPINVD(2*NFUNL+3,2*NFUNL,COEF2,COEF3(1,1)) ;
        COEFI=COEF3(:,1:2*NFUNL) ;
        DEALLOCATE(COEF2, COEF3)
      ELSEIF(NFUNL == 10) THEN
        ALLOCATE(COEF2(2*NFUNL+6,2*NFUNL), COEF3(2*NFUNL,2*NFUNL+6))
        COEF2=0.0D0 ; COEF2(1:2*NFUNL,:)=COEF ;
        COEF2(2*NFUNL+1,2)=1.0D0 ; COEF2(2*NFUNL+1,NFUNL+3)=-1.0D0 ;
        COEF2(2*NFUNL+2,5)=SQRT(3.0D0) ; COEF2(2*NFUNL+2,6)=1.0D0 ;
        COEF2(2*NFUNL+2,NFUNL+4)=1.0D0 ;
        COEF2(2*NFUNL+3,NFUNL+5)=SQRT(3.0D0) ;
        COEF2(2*NFUNL+3,NFUNL+6)=-1.0D0 ; COEF2(2*NFUNL+3,4)=1.0D0 ;
        COEF2(2*NFUNL+4,8)=1.0D0 ; COEF2(2*NFUNL+4,NFUNL+9)=-1.0D0 ;
        COEF2(2*NFUNL+5,7)=1.0D0 ; COEF2(2*NFUNL+5,NFUNL+10)=-1.0D0 ;
        COEF2(2*NFUNL+6,10)=1.0D0 ;
        COEF2(2*NFUNL+6,9)=SQRT(5.0D0/3.0D0) ;
        COEF2(2*NFUNL+6,NFUNL+8)=-SQRT(5.0D0/3.0D0) ;
        COEF2(2*NFUNL+6,NFUNL+7)=1.0D0 ;
        CALL ALPINVD(2*NFUNL+6,2*NFUNL,COEF2,COEF3(1,1)) ;
        COEFI=COEF3(:,1:2*NFUNL) ;
        DEALLOCATE(COEF2, COEF3)
      ELSE
        CALL XABORT('MCGCOEF: NFUNL MUST BE = 1, 3, 6 OR 10')
      ENDIF
      DEALLOCATE(COEF)
      RETURN
      END