rc6j.f 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. *DECK RC6J
  2. SUBROUTINE RC6J (L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF, NDIM,
  3. + IER)
  4. C***BEGIN PROLOGUE RC6J
  5. C***PURPOSE Evaluate the 6j symbol h(L1) = {L1 L2 L3}
  6. C {L4 L5 L6}
  7. C for all allowed values of L1, the other parameters
  8. C being held fixed.
  9. C***LIBRARY SLATEC
  10. C***CATEGORY C19
  11. C***TYPE SINGLE PRECISION (RC6J-S, DRC6J-D)
  12. C***KEYWORDS 6J COEFFICIENTS, 6J SYMBOLS, CLEBSCH-GORDAN COEFFICIENTS,
  13. C RACAH COEFFICIENTS, VECTOR ADDITION COEFFICIENTS,
  14. C WIGNER COEFFICIENTS
  15. C***AUTHOR Gordon, R. G., Harvard University
  16. C Schulten, K., Max Planck Institute
  17. C***DESCRIPTION
  18. C
  19. C *Usage:
  20. C
  21. C REAL L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF(NDIM)
  22. C INTEGER NDIM, IER
  23. C
  24. C CALL RC6J(L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF, NDIM, IER)
  25. C
  26. C *Arguments:
  27. C
  28. C L2 :IN Parameter in 6j symbol.
  29. C
  30. C L3 :IN Parameter in 6j symbol.
  31. C
  32. C L4 :IN Parameter in 6j symbol.
  33. C
  34. C L5 :IN Parameter in 6j symbol.
  35. C
  36. C L6 :IN Parameter in 6j symbol.
  37. C
  38. C L1MIN :OUT Smallest allowable L1 in 6j symbol.
  39. C
  40. C L1MAX :OUT Largest allowable L1 in 6j symbol.
  41. C
  42. C SIXCOF :OUT Set of 6j coefficients generated by evaluating the
  43. C 6j symbol for all allowed values of L1. SIXCOF(I)
  44. C will contain h(L1MIN+I-1), I=1,2,...,L1MAX-L1MIN+1.
  45. C
  46. C NDIM :IN Declared length of SIXCOF in calling program.
  47. C
  48. C IER :OUT Error flag.
  49. C IER=0 No errors.
  50. C IER=1 L2+L3+L5+L6 or L4+L2+L6 not an integer.
  51. C IER=2 L4, L2, L6 triangular condition not satisfied.
  52. C IER=3 L4, L5, L3 triangular condition not satisfied.
  53. C IER=4 L1MAX-L1MIN not an integer.
  54. C IER=5 L1MAX less than L1MIN.
  55. C IER=6 NDIM less than L1MAX-L1MIN+1.
  56. C
  57. C *Description:
  58. C
  59. C The definition and properties of 6j symbols can be found, for
  60. C example, in Appendix C of Volume II of A. Messiah. Although the
  61. C parameters of the vector addition coefficients satisfy certain
  62. C conventional restrictions, the restriction that they be non-negative
  63. C integers or non-negative integers plus 1/2 is not imposed on input
  64. C to this subroutine. The restrictions imposed are
  65. C 1. L2+L3+L5+L6 and L2+L4+L6 must be integers;
  66. C 2. ABS(L2-L4).LE.L6.LE.L2+L4 must be satisfied;
  67. C 3. ABS(L4-L5).LE.L3.LE.L4+L5 must be satisfied;
  68. C 4. L1MAX-L1MIN must be a non-negative integer, where
  69. C L1MAX=MIN(L2+L3,L5+L6) and L1MIN=MAX(ABS(L2-L3),ABS(L5-L6)).
  70. C If all the conventional restrictions are satisfied, then these
  71. C restrictions are met. Conversely, if input to this subroutine meets
  72. C all of these restrictions and the conventional restriction stated
  73. C above, then all the conventional restrictions are satisfied.
  74. C
  75. C The user should be cautious in using input parameters that do
  76. C not satisfy the conventional restrictions. For example, the
  77. C the subroutine produces values of
  78. C h(L1) = { L1 2/3 1 }
  79. C {2/3 2/3 2/3}
  80. C for L1=1/3 and 4/3 but none of the symmetry properties of the 6j
  81. C symbol, set forth on pages 1063 and 1064 of Messiah, is satisfied.
  82. C
  83. C The subroutine generates h(L1MIN), h(L1MIN+1), ..., h(L1MAX)
  84. C where L1MIN and L1MAX are defined above. The sequence h(L1) is
  85. C generated by a three-term recurrence algorithm with scaling to
  86. C control overflow. Both backward and forward recurrence are used to
  87. C maintain numerical stability. The two recurrence sequences are
  88. C matched at an interior point and are normalized from the unitary
  89. C property of 6j coefficients and Wigner's phase convention.
  90. C
  91. C The algorithm is suited to applications in which large quantum
  92. C numbers arise, such as in molecular dynamics.
  93. C
  94. C***REFERENCES 1. Messiah, Albert., Quantum Mechanics, Volume II,
  95. C North-Holland Publishing Company, 1963.
  96. C 2. Schulten, Klaus and Gordon, Roy G., Exact recursive
  97. C evaluation of 3j and 6j coefficients for quantum-
  98. C mechanical coupling of angular momenta, J Math
  99. C Phys, v 16, no. 10, October 1975, pp. 1961-1970.
  100. C 3. Schulten, Klaus and Gordon, Roy G., Semiclassical
  101. C approximations to 3j and 6j coefficients for
  102. C quantum-mechanical coupling of angular momenta,
  103. C J Math Phys, v 16, no. 10, October 1975,
  104. C pp. 1971-1988.
  105. C 4. Schulten, Klaus and Gordon, Roy G., Recursive
  106. C evaluation of 3j and 6j coefficients, Computer
  107. C Phys Comm, v 11, 1976, pp. 269-278.
  108. C***ROUTINES CALLED R1MACH, XERMSG
  109. C***REVISION HISTORY (YYMMDD)
  110. C 750101 DATE WRITTEN
  111. C 880515 SLATEC prologue added by G. C. Nielson, NBS; parameters
  112. C HUGE and TINY revised to depend on R1MACH.
  113. C 891229 Prologue description rewritten; other prologue sections
  114. C revised; LMATCH (location of match point for recurrences)
  115. C removed from argument list; argument IER changed to serve
  116. C only as an error flag (previously, in cases without error,
  117. C it returned the number of scalings); number of error codes
  118. C increased to provide more precise error information;
  119. C program comments revised; SLATEC error handler calls
  120. C introduced to enable printing of error messages to meet
  121. C SLATEC standards. These changes were done by D. W. Lozier,
  122. C M. A. McClain and J. M. Smith of the National Institute
  123. C of Standards and Technology, formerly NBS.
  124. C 910415 Mixed type expressions eliminated; variable C1 initialized;
  125. C description of SIXCOF expanded. These changes were done by
  126. C D. W. Lozier.
  127. C***END PROLOGUE RC6J
  128. C
  129. INTEGER NDIM, IER
  130. REAL L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF(NDIM)
  131. C
  132. INTEGER I, INDEX, LSTEP, N, NFIN, NFINP1, NFINP2, NFINP3, NLIM,
  133. + NSTEP2
  134. REAL A1, A1S, A2, A2S, C1, C1OLD, C2, CNORM, R1MACH,
  135. + DENOM, DV, EPS, HUGE, L1, NEWFAC, OLDFAC, ONE,
  136. + RATIO, SIGN1, SIGN2, SRHUGE, SRTINY, SUM1, SUM2,
  137. + SUMBAC, SUMFOR, SUMUNI, THREE, THRESH, TINY, TWO,
  138. + X, X1, X2, X3, Y, Y1, Y2, Y3, ZERO
  139. C
  140. DATA ZERO,EPS,ONE,TWO,THREE /0.0,0.01,1.0,2.0,3.0/
  141. C
  142. C***FIRST EXECUTABLE STATEMENT RC6J
  143. IER=0
  144. C HUGE is the square root of one twentieth of the largest floating
  145. C point number, approximately.
  146. HUGE = SQRT(R1MACH(2)/20.0)
  147. SRHUGE = SQRT(HUGE)
  148. TINY = 1.0/HUGE
  149. SRTINY = 1.0/SRHUGE
  150. C
  151. C LMATCH = ZERO
  152. C
  153. C Check error conditions 1, 2, and 3.
  154. IF((MOD(L2+L3+L5+L6+EPS,ONE).GE.EPS+EPS).OR.
  155. + (MOD(L4+L2+L6+EPS,ONE).GE.EPS+EPS))THEN
  156. IER=1
  157. CALL XERMSG('SLATEC','RC6J','L2+L3+L5+L6 or L4+L2+L6 not '//
  158. + 'integer.',IER,1)
  159. RETURN
  160. ELSEIF((L4+L2-L6.LT.ZERO).OR.(L4-L2+L6.LT.ZERO).OR.
  161. + (-L4+L2+L6.LT.ZERO))THEN
  162. IER=2
  163. CALL XERMSG('SLATEC','RC6J','L4, L2, L6 triangular '//
  164. + 'condition not satisfied.',IER,1)
  165. RETURN
  166. ELSEIF((L4-L5+L3.LT.ZERO).OR.(L4+L5-L3.LT.ZERO).OR.
  167. + (-L4+L5+L3.LT.ZERO))THEN
  168. IER=3
  169. CALL XERMSG('SLATEC','RC6J','L4, L5, L3 triangular '//
  170. + 'condition not satisfied.',IER,1)
  171. RETURN
  172. ENDIF
  173. C
  174. C Limits for L1
  175. C
  176. L1MIN = MAX(ABS(L2-L3),ABS(L5-L6))
  177. L1MAX = MIN(L2+L3,L5+L6)
  178. C
  179. C Check error condition 4.
  180. IF(MOD(L1MAX-L1MIN+EPS,ONE).GE.EPS+EPS)THEN
  181. IER=4
  182. CALL XERMSG('SLATEC','RC6J','L1MAX-L1MIN not integer.',IER,1)
  183. RETURN
  184. ENDIF
  185. IF(L1MIN.LT.L1MAX-EPS) GO TO 20
  186. IF(L1MIN.LT.L1MAX+EPS) GO TO 10
  187. C
  188. C Check error condition 5.
  189. IER=5
  190. CALL XERMSG('SLATEC','RC6J','L1MIN greater than L1MAX.',IER,1)
  191. RETURN
  192. C
  193. C
  194. C This is reached in case that L1 can take only one value
  195. C
  196. 10 CONTINUE
  197. C LSCALE = 0
  198. SIXCOF(1) = (-ONE) ** INT(L2+L3+L5+L6+EPS) /
  199. 1 SQRT((L1MIN+L1MIN+ONE)*(L4+L4+ONE))
  200. RETURN
  201. C
  202. C
  203. C This is reached in case that L1 can take more than one value.
  204. C
  205. 20 CONTINUE
  206. C LSCALE = 0
  207. NFIN = INT(L1MAX-L1MIN+ONE+EPS)
  208. IF(NDIM-NFIN) 21, 23, 23
  209. C
  210. C Check error condition 6.
  211. 21 IER = 6
  212. CALL XERMSG('SLATEC','RC6J','Dimension of result array for 6j '//
  213. + 'coefficients too small.',IER,1)
  214. RETURN
  215. C
  216. C
  217. C Start of forward recursion
  218. C
  219. 23 L1 = L1MIN
  220. NEWFAC = 0.0
  221. C1 = 0.0
  222. SIXCOF(1) = SRTINY
  223. SUM1 = (L1+L1+ONE) * TINY
  224. C
  225. LSTEP = 1
  226. 30 LSTEP = LSTEP + 1
  227. L1 = L1 + ONE
  228. C
  229. OLDFAC = NEWFAC
  230. A1 = (L1+L2+L3+ONE) * (L1-L2+L3) * (L1+L2-L3) * (-L1+L2+L3+ONE)
  231. A2 = (L1+L5+L6+ONE) * (L1-L5+L6) * (L1+L5-L6) * (-L1+L5+L6+ONE)
  232. NEWFAC = SQRT(A1*A2)
  233. C
  234. IF(L1.LT.ONE+EPS) GO TO 40
  235. C
  236. DV = TWO * ( L2*(L2+ONE)*L5*(L5+ONE) + L3*(L3+ONE)*L6*(L6+ONE)
  237. 1 - L1*(L1-ONE)*L4*(L4+ONE) )
  238. 2 - (L2*(L2+ONE) + L3*(L3+ONE) - L1*(L1-ONE))
  239. 3 * (L5*(L5+ONE) + L6*(L6+ONE) - L1*(L1-ONE))
  240. C
  241. DENOM = (L1-ONE) * NEWFAC
  242. C
  243. IF(LSTEP-2) 32, 32, 31
  244. C
  245. 31 C1OLD = ABS(C1)
  246. 32 C1 = - (L1+L1-ONE) * DV / DENOM
  247. GO TO 50
  248. C
  249. C If L1 = 1, (L1 - 1) has to be factored out of DV, hence
  250. C
  251. 40 C1 = - TWO * ( L2*(L2+ONE) + L5*(L5+ONE) - L4*(L4+ONE) )
  252. 1 / NEWFAC
  253. C
  254. 50 IF(LSTEP.GT.2) GO TO 60
  255. C
  256. C If L1 = L1MIN + 1, the third term in recursion equation vanishes
  257. C
  258. X = SRTINY * C1
  259. SIXCOF(2) = X
  260. SUM1 = SUM1 + TINY * (L1+L1+ONE) * C1 * C1
  261. C
  262. IF(LSTEP.EQ.NFIN) GO TO 220
  263. GO TO 30
  264. C
  265. C
  266. 60 C2 = - L1 * OLDFAC / DENOM
  267. C
  268. C Recursion to the next 6j coefficient X
  269. C
  270. X = C1 * SIXCOF(LSTEP-1) + C2 * SIXCOF(LSTEP-2)
  271. SIXCOF(LSTEP) = X
  272. C
  273. SUMFOR = SUM1
  274. SUM1 = SUM1 + (L1+L1+ONE) * X * X
  275. IF(LSTEP.EQ.NFIN) GO TO 100
  276. C
  277. C See if last unnormalized 6j coefficient exceeds SRHUGE
  278. C
  279. IF(ABS(X).LT.SRHUGE) GO TO 80
  280. C
  281. C This is reached if last 6j coefficient larger than SRHUGE,
  282. C so that the recursion series SIXCOF(1), ... ,SIXCOF(LSTEP)
  283. C has to be rescaled to prevent overflow
  284. C
  285. C LSCALE = LSCALE + 1
  286. DO 70 I=1,LSTEP
  287. IF(ABS(SIXCOF(I)).LT.SRTINY) SIXCOF(I) = ZERO
  288. 70 SIXCOF(I) = SIXCOF(I) / SRHUGE
  289. SUM1 = SUM1 / HUGE
  290. SUMFOR = SUMFOR / HUGE
  291. X = X / SRHUGE
  292. C
  293. C
  294. C As long as the coefficient ABS(C1) is decreasing, the recursion
  295. C proceeds towards increasing 6j values and, hence, is numerically
  296. C stable. Once an increase of ABS(C1) is detected, the recursion
  297. C direction is reversed.
  298. C
  299. 80 IF(C1OLD-ABS(C1)) 100, 100, 30
  300. C
  301. C
  302. C Keep three 6j coefficients around LMATCH for comparison later
  303. C with backward recursion.
  304. C
  305. 100 CONTINUE
  306. C LMATCH = L1 - 1
  307. X1 = X
  308. X2 = SIXCOF(LSTEP-1)
  309. X3 = SIXCOF(LSTEP-2)
  310. C
  311. C
  312. C
  313. C Starting backward recursion from L1MAX taking NSTEP2 steps, so
  314. C that forward and backward recursion overlap at the three points
  315. C L1 = LMATCH+1, LMATCH, LMATCH-1.
  316. C
  317. NFINP1 = NFIN + 1
  318. NFINP2 = NFIN + 2
  319. NFINP3 = NFIN + 3
  320. NSTEP2 = NFIN - LSTEP + 3
  321. L1 = L1MAX
  322. C
  323. SIXCOF(NFIN) = SRTINY
  324. SUM2 = (L1+L1+ONE) * TINY
  325. C
  326. C
  327. L1 = L1 + TWO
  328. LSTEP = 1
  329. 110 LSTEP = LSTEP + 1
  330. L1 = L1 - ONE
  331. C
  332. OLDFAC = NEWFAC
  333. A1S = (L1+L2+L3)*(L1-L2+L3-ONE)*(L1+L2-L3-ONE)*(-L1+L2+L3+TWO)
  334. A2S = (L1+L5+L6)*(L1-L5+L6-ONE)*(L1+L5-L6-ONE)*(-L1+L5+L6+TWO)
  335. NEWFAC = SQRT(A1S*A2S)
  336. C
  337. DV = TWO * ( L2*(L2+ONE)*L5*(L5+ONE) + L3*(L3+ONE)*L6*(L6+ONE)
  338. 1 - L1*(L1-ONE)*L4*(L4+ONE) )
  339. 2 - (L2*(L2+ONE) + L3*(L3+ONE) - L1*(L1-ONE))
  340. 3 * (L5*(L5+ONE) + L6*(L6+ONE) - L1*(L1-ONE))
  341. C
  342. DENOM = L1 * NEWFAC
  343. C1 = - (L1+L1-ONE) * DV / DENOM
  344. IF(LSTEP.GT.2) GO TO 120
  345. C
  346. C If L1 = L1MAX + 1 the third term in the recursion equation vanishes
  347. C
  348. Y = SRTINY * C1
  349. SIXCOF(NFIN-1) = Y
  350. IF(LSTEP.EQ.NSTEP2) GO TO 200
  351. SUMBAC = SUM2
  352. SUM2 = SUM2 + (L1+L1-THREE) * C1 * C1 * TINY
  353. GO TO 110
  354. C
  355. C
  356. 120 C2 = - (L1-ONE) * OLDFAC / DENOM
  357. C
  358. C Recursion to the next 6j coefficient Y
  359. C
  360. Y = C1 * SIXCOF(NFINP2-LSTEP) + C2 * SIXCOF(NFINP3-LSTEP)
  361. IF(LSTEP.EQ.NSTEP2) GO TO 200
  362. SIXCOF(NFINP1-LSTEP) = Y
  363. SUMBAC = SUM2
  364. SUM2 = SUM2 + (L1+L1-THREE) * Y * Y
  365. C
  366. C See if last unnormalized 6j coefficient exceeds SRHUGE
  367. C
  368. IF(ABS(Y).LT.SRHUGE) GO TO 110
  369. C
  370. C This is reached if last 6j coefficient larger than SRHUGE,
  371. C so that the recursion series SIXCOF(NFIN), ... ,SIXCOF(NFIN-LSTEP+1)
  372. C has to be rescaled to prevent overflow
  373. C
  374. C LSCALE = LSCALE + 1
  375. DO 130 I=1,LSTEP
  376. INDEX = NFIN-I+1
  377. IF(ABS(SIXCOF(INDEX)).LT.SRTINY) SIXCOF(INDEX) = ZERO
  378. 130 SIXCOF(INDEX) = SIXCOF(INDEX) / SRHUGE
  379. SUMBAC = SUMBAC / HUGE
  380. SUM2 = SUM2 / HUGE
  381. C
  382. GO TO 110
  383. C
  384. C
  385. C The forward recursion 6j coefficients X1, X2, X3 are to be matched
  386. C with the corresponding backward recursion values Y1, Y2, Y3.
  387. C
  388. 200 Y3 = Y
  389. Y2 = SIXCOF(NFINP2-LSTEP)
  390. Y1 = SIXCOF(NFINP3-LSTEP)
  391. C
  392. C
  393. C Determine now RATIO such that YI = RATIO * XI (I=1,2,3) holds
  394. C with minimal error.
  395. C
  396. RATIO = ( X1*Y1 + X2*Y2 + X3*Y3 ) / ( X1*X1 + X2*X2 + X3*X3 )
  397. NLIM = NFIN - NSTEP2 + 1
  398. C
  399. IF(ABS(RATIO).LT.ONE) GO TO 211
  400. C
  401. DO 210 N=1,NLIM
  402. 210 SIXCOF(N) = RATIO * SIXCOF(N)
  403. SUMUNI = RATIO * RATIO * SUMFOR + SUMBAC
  404. GO TO 230
  405. C
  406. 211 NLIM = NLIM + 1
  407. RATIO = ONE / RATIO
  408. DO 212 N=NLIM,NFIN
  409. 212 SIXCOF(N) = RATIO * SIXCOF(N)
  410. SUMUNI = SUMFOR + RATIO*RATIO*SUMBAC
  411. GO TO 230
  412. C
  413. 220 SUMUNI = SUM1
  414. C
  415. C
  416. C Normalize 6j coefficients
  417. C
  418. 230 CNORM = ONE / SQRT((L4+L4+ONE)*SUMUNI)
  419. C
  420. C Sign convention for last 6j coefficient determines overall phase
  421. C
  422. SIGN1 = SIGN(ONE,SIXCOF(NFIN))
  423. SIGN2 = (-ONE) ** INT(L2+L3+L5+L6+EPS)
  424. IF(SIGN1*SIGN2) 235,235,236
  425. 235 CNORM = - CNORM
  426. C
  427. 236 IF(ABS(CNORM).LT.ONE) GO TO 250
  428. C
  429. DO 240 N=1,NFIN
  430. 240 SIXCOF(N) = CNORM * SIXCOF(N)
  431. RETURN
  432. C
  433. 250 THRESH = TINY / ABS(CNORM)
  434. DO 251 N=1,NFIN
  435. IF(ABS(SIXCOF(N)).LT.THRESH) SIXCOF(N) = ZERO
  436. 251 SIXCOF(N) = CNORM * SIXCOF(N)
  437. C
  438. RETURN
  439. END