crab_coulomb.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. void coulset(){
  2. double qred,eta,rmass;
  3. int i0,kk,nkmax;
  4. double_complex c1phase,c2phase,cgamma;
  5. double_complex couly,cfact1,cfact2,chype[41],chype1[6],chype2[6];
  6. rmass=MASS1*MASS2/(MASS1+MASS2);
  7. for(kk=0;kk<INTERACTION_NKMAX;kk++){
  8. #ifdef REDUCED_MOM
  9. qred=(0.5+kk)*INTERACTION_DELK;
  10. #else
  11. qred=(0.5+kk)*INTERACTION_DELK*0.5;
  12. #endif
  13. eta=(double)Q1Q2*(rmass/137.036)/qred;
  14. coulpar(eta,&couly,&cfact1,&cfact2,chype,chype1,chype2);
  15. coulinfo[kk].couly=couly;
  16. coulinfo[kk].cfact1=cfact1;
  17. coulinfo[kk].cfact2=cfact2;
  18. for(i0=0;i0<40;i0++){
  19. coulinfo[kk].chype[i0]=chype[i0];
  20. }
  21. for(i0=0;i0<6;i0++){
  22. coulinfo[kk].chype1[i0]=chype1[i0];
  23. coulinfo[kk].chype2[i0]=chype2[i0];
  24. }
  25. }
  26. }
  27. /* ****************************************** */
  28. void coulpar(double eta, double_complex *couly,double_complex *cfact1,double_complex *cfact2,double_complex *chype, double_complex *chype1, double_complex *chype2){
  29. double_complex a,b,a0,b0;
  30. double_complex c1top1,c2top2,bot;
  31. double_complex c1top2,c2top1;
  32. int j;
  33. /*See appendix of Messiah. "cgamma" is the gamma function. "chyper" is
  34. appropriate hyperbolic function. This is explained in Messiah's
  35. section on coul wave func.s. Notation should be explanatory when
  36. reading the book. */
  37. *couly=cgamma(1.0+ci*eta);
  38. *couly=*couly*exp(-0.5*eta*pi);
  39. a=-ci*eta;
  40. b=1.0;
  41. a0=a;
  42. b0=b;
  43. for(j=1;j<=40;j++){
  44. chype[j]=a/(b*(double)j);
  45. a=a+1.0;
  46. b=b+1.0;
  47. }
  48. c1top1=1.0;
  49. c2top1=1.0;
  50. c1top2=1.0;
  51. c2top2=1.0;
  52. bot=1.0;
  53. for(j=1;j<=5;j++){
  54. c1top1=c1top1*((double)j+a0-1.0);
  55. c2top1=c2top1*((double)j-a0);
  56. c1top2=c1top2*((double)j-b0+a0);
  57. c2top2=c2top2*((double)j+b0-a0-1.0);
  58. bot=bot*(double)j;
  59. chype1[j]=(c1top1*c1top2)/(bot);
  60. chype2[j]=(c2top1*c2top2)/(bot);
  61. }
  62. *cfact1=1.0/(cgamma(b0-a0));
  63. *cfact2=1.0/(cgamma(a0));
  64. }
  65. double_complex coul(double qred,double r,double zk,double eta,int kk){
  66. double_complex bb,coulguy;
  67. double arg;
  68. /* See appendix of Messiah. "cgamma" is the gamma function. "chyper" is
  69. appropriate hyperbolic function. This is explained in Messiah's
  70. section on coul wave func.s. Notation should be explanatory
  71. when reading the book. */
  72. bb=1.0;
  73. coulguy=coulinfo[kk].couly*chyper(-ci*eta,bb,ci*qred*(r-zk)/197.323,kk);
  74. arg=zk*qred/197.323;
  75. arg=arg-2.0*pi*floor(arg/(2.0*pi));
  76. coulguy=coulguy*exp(ci*arg);
  77. return coulguy;
  78. }
  79. /* **************************************************** */
  80. double_complex chyper(double_complex a,double_complex b,double_complex cz,
  81. int kk){
  82. double_complex cw1,cw2,cf1,cf2,czarg,czstarj,answer;
  83. #define rcrit 10.0
  84. double dmag;
  85. int j;
  86. dmag=abs(cz);
  87. if(dmag<rcrit){
  88. cf1=1.0;
  89. czstarj=1.0;
  90. for(j=1;j<=40;j++){
  91. czstarj=czstarj*cz*coulinfo[kk].chype[j];
  92. cf1=cf1+czstarj;
  93. if(abs(czstarj)<0.0001) goto GOOD_ENOUGH;
  94. }
  95. printf("chyper not coverging!.\n");
  96. GOOD_ENOUGH:
  97. answer=cf1;
  98. }
  99. else{
  100. cf1=1.0;
  101. cf2=1.0;
  102. for(j=1;j<=5;j++){
  103. cf1=cf1+coulinfo[kk].chype1[j]/(pow(-cz,j));
  104. cf2=cf2+coulinfo[kk].chype2[j]/(pow(cz,j));
  105. }
  106. cw1=cf1*=coulinfo[kk].cfact1*(pow(-cz,-a));
  107. czarg=cz-ci*2.0*pi*floor(real(-ci*cz/(2.0*pi)));
  108. cw2=cf2*coulinfo[kk].cfact2*pow(cz,a-b)*exp(czarg);
  109. answer=cw1+cw2;
  110. }
  111. return answer;
  112. }
  113. /* ***************************************** */
  114. double_complex cgamma(double_complex c){
  115. /* This calc.s gamma functions which are in the form gamma(n+i*y)
  116. where n is an int and y is real. */
  117. double_complex cg,cphase;
  118. int mm,j;
  119. double x,y,phase,delp,cgmag;
  120. x=real(c);
  121. y=imag(c);
  122. phase=-EULER*y;
  123. for(j=1;j<=100000;j++){
  124. delp=(y/(double)j)-atan(y/(double)j);
  125. phase=phase+delp;
  126. if(fabs(delp)<1E-10) goto CGAMMA_ESCAPE;
  127. }
  128. printf("oops not accurate enough, increase jmax\n");
  129. CGAMMA_ESCAPE:
  130. phase=phase-2.0*pi*floor(phase/(2.0*pi));
  131. cphase=exp(ci*phase);
  132. cgmag=sqrt(pi*y/sinh(pi*y));
  133. mm=(int)floor(x+0.5);
  134. cg=cgmag*cphase;
  135. if(mm<1){
  136. for(j=1;j<=-mm+1;j++){
  137. cg=cg/(1.0+(double)(-j)+ci*y);
  138. }
  139. }
  140. if(mm>1) {
  141. for(j=1;j<=mm-1;j++){
  142. cg=cg*((double)(j)+ci*y);
  143. }
  144. }
  145. return cg;
  146. }