clebsch.f 4.04 KB
Newer Older
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
      MODULE m_clebsch
      CONTAINS
      REAL FUNCTION clebsch(aj,bj,am,bm,cj,cm)
******************************************************************
*     Program calculates Clebsch-Gordan coefficients                 *
*     See: Landau and Lifshitz, Vol.3                                *
*     cj,cm                                                     *
*     C                                                          *
*     aj,am,bj,bm                                               *
*     Written by A.Soldatov (IAE)                                    *
******************************************************************
      IMPLICIT NONE

      REAL, INTENT (IN) :: aj,bj,am,bm,cj,cm

      INTEGER n,k,i,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10
      REAL    x,s,c,e
      REAL    f(100)
      INTRINSIC sqrt,exp,min0,max0

      n = 100
      k =   0
      x = 2.0
      f(1)=0.e0 ; f(2)=0.e0

      IF ( k <= 0 ) THEN
         k=1
         DO i = 3,n
            f(i)=f(i-1)+log(x)
            x=x+1.e0
         ENDDO
      ENDIF

      i = am + bm - cm + .1e0
      IF (( i < 0 ).OR.( i > 0 )) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i1 = aj + bj - cj + 1.1e0
      IF ( i1 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i2 = aj - bj + cj + 1.1e0
      IF ( i2 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i3 = bj + cj - aj + 1.1e0
      IF ( i3 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      x  = aj + bj + cj + 2.1e0
      i4 = x
      i  = x + .6e0
      i  = i4 - i
      IF (( i < 0 ).OR.( i > 0 )) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      x = aj + am + 1.1e0
      i5 = x
      IF (i5 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i = x + .6e0
      i = i - I5
      IF (( i < 0 ).OR.( i > 0 )) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i6 = aj - am + 1.1e0
      IF (i6 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      x = bj + bm + 1.1e0
      i7=X
      IF (i7 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i = x + .6e0
      i = i - i7
      IF (( i < 0 ).OR.( i > 0 )) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i8 = bj - bm + 1.1e0
      IF (i8 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      x = cj + cm + 1.1e0
      i9 = x
      IF (i9 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i = x + .6e0
      i = i - i9
      IF (( i < 0 ).OR.( i > 0 )) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      i10 = cj - cm + 1.1e0
      IF (i10 <= 0 ) THEN
         clebsch = 0.e0
         RETURN
      ENDIF

      x = f(i1) + f(i2) + f(i3) - f(i4)
      i = i5 - i6
      IF ( i == 0 ) THEN
         i = i7 - i8
         IF ( i == 0 ) THEN
            i  = i4/2
            i5 = i4*0.5e0 + 0.6e0
            i = i - i5
            IF (( i < 0 ).OR.( i > 0 )) THEN
               clebsch = 0.e0
               RETURN
            ENDIF

            i6 = i5 - i6 + 1
            i7 = i5 - i8 + 1
            i8 = i5 - i10 + 1
            s = x*0.5e0 + f(i5) - f(i6) - f(i7) - f(i8)
            s = exp(s)
            i5 = i8/2
            i6 = i8*0.5e0 + 0.6e0
            i5 = i5 - I6
            IF ( i5 == 0 ) THEN
               s = 1.e0 - s - 1.e0
            ENDIF
            
            clebsch = s*SQRT( cj + cj + 1.e0 )
            return
         ENDIF
      ENDIF
      
      x = x + f(i5) + f(i6) + f(i7) + f(i8) + f(i9) + f(i10)
      x = x*0.5e0
      i10 = MIN0(i1,i6,i7)
      i2 = i1 - i5
      i3 = i1 - i8
      i9 = MAX0(0,i2,i3) + 1
      i1 = i1 + 1
      i6 = i6 + 1
      i7 = i7 + 1
      i8 = i9/2
      e  = 1.e0
      i5 = i9*0.5e0 + 0.6e0
      i8 = i8 - i5

      IF ( i8 == 0 ) THEN
         e  = -1.e0
      ENDIF
      S = 0.e0
      DO i = i9, i10
         c = x-f(i)-f(i1-i)-f(i6-i)-f(i7-i)-f(i-i2)-f(i-i3)
         s = s + e*exp(c)
         e = 1.e0 - e - 1.e0
      ENDDO
      clebsch = SQRT( cj + cj + 1.e0 )*s
      RETURN

      

      END FUNCTION clebsch
      END MODULE m_clebsch