Main Page   Compound List   File List   Compound Members   File Members  

PositronRange.cpp

00001 #include <math.h>
00002 #include <iostream.h>
00003 #include "ReactorConstants.hh"
00004 #include "ReactorFortran.hh"
00005 //
00006 // Compute range of positron from dE/dx (Berger-Seltzer formula) 
00007 // and annihilation.
00008 // This function is part of dE/dx.
00009 //
00010 static double Fp(double t,double tup){
00011   if(t<=0||tup<=0||t<=tup)return 0;
00012   double y = 1/(2+t);
00013   return log(t*tup)
00014     -tup*tup*(t+2*tup-3*tup*tup*y/2
00015               -(tup-exp(3*log(tup))/3)*y*y
00016               -(tup*tup/2
00017                 -t*exp(3*log(tup))/2
00018                 +exp(4*log(tup))/4)*exp(3*log(y)));
00019 }
00020 //
00021 // This function is the positron annihilation cross section minus an overall
00022 // scale.
00023 //
00024 static double AnniFun(double g){
00025   return ((g*g+4*g+1)/(g*g-1)*log(g+sqrt(g*g-1))
00026           -(g+3)/sqrt(g*g-1))/(1+g);
00027 }
00028 
00029 void PositronRange(double KE,double& range,double& time){
00030 
00031   static ReactorConstants k;
00032 
00033   double step=0.01;
00034   double Emin=0.01;
00035 
00036   range = 0;
00037   time = 0;
00038   if(KE<=Emin)return;
00039 
00040   static double re = k.Relectron;
00041   static double pi = k.pi;
00042   static double me = k.Melectron;
00043   static double Na = k.Navogadro;
00044   static double c = k.c;
00045   static double density = k.density;
00046   //
00047   // For electron density.
00048   //
00049   static double nel[2];
00050   static double A[2] = {k.A0,k.A1};
00051   static double Z[2] = {k.Z0,k.Z1};
00052   static double f[2] = {k.f0,k.f1};
00053   static double I[2] = {k.I0,k.I1};
00054   static bool first = 1;
00055   for(int i=0;i<2;i++){
00056     nel[i]=Na*density*f[i]*Z[i]/A[i];
00057     first = 0;
00058   }
00059   //
00060   // Begin energy loss loop
00061   //
00062   double dE=0;
00063   while(KE-dE>=Emin){
00064     range+=step;
00065     double gamma = 1+(KE-dE)/me;
00066     double beta = sqrt(1-1/gamma/gamma);
00067     time+=step/beta/c;
00068     //
00069     // check for annihilation during step
00070     //
00071     double AnniMfp = 1/((nel[0]+nel[1])*pi*re*re*AnniFun(gamma));
00072     int len=1;
00073     float rv[len];
00074     ranlux_(rv,len);
00075     if(rv[0]<1-exp(-step/AnniMfp))return;
00076     //
00077     // increment energy loss
00078     //
00079     double t = gamma-1;
00080     double tc = Emin/me;
00081     double tmax = t;
00082     double tup = tc;
00083     if(tc>tmax)tup=tmax;
00084     for (int k=0;k<2;k++){
00085       dE+=2*pi*re*re*me*nel[k]*step/beta/beta*
00086         (log(2*(gamma+1)/(I[k]*I[k]/me/me))
00087          +Fp(t,tup));
00088     }
00089   }
00090   return;
00091 }
00092          
00093                                      
00094         

Generated on Fri Oct 22 13:56:25 2004 for ReactorFsim by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002