BLHelicalUtils.hh File Reference

#include "G4VisAttributes.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4Color.hh"
#include "G4UserLimits.hh"
#include "G4Material.hh"
#include "BLElement.hh"
#include "BLElementField.hh"
#include "BLGlobalField.hh"
#include "BLParam.hh"
#include <math.h>
#include <gsl/gsl_sf_bessel.h>
#include <gsl/gsl_sf_pow_int.h>
#include <gsl/gsl_sf_gamma.h>

Go to the source code of this file.

Defines

#define M_PI   3.14159265358979323846264338327950288
#define cylPHI   0
#define cylRHO   1
#define cylZ   2
#define rectX   0
#define rectY   1
#define rectZ   2
#define LEFT_HANDED_THREAD   (-1)
#define RIGHT_HANDED_THREAD   (+1)
#define MuonsInc_PITCH_CONVENTION   RIGHT_HANDED_THREAD
#define MuonsInc_Target_Radius_mm   159.15494
#define ESSENTIALLY_ZERO   1.E-33

Functions

G4ThreeVector CYLTOCARTESIAN (G4ThreeVector Bcyl, G4double phi)
G4ThreeVector SIMPLEFIELD (G4double b, G4double kz, G4double Bsolenoid, G4double model)
G4double ICOOLDiv (G4int n, G4double lambda)
G4double ICOOLFact (G4int n, G4double krad)
G4ThreeVector ICOOLFIELD (G4int n, G4double rho, G4double psi, G4double k, G4double refrad)
G4ThreeVector DIPOLF (G4double bd, G4double k, G4double rho, G4double psiangle)
G4ThreeVector QUADF (G4double bprime, G4double k, G4double rho, G4double psiangle)


Define Documentation

#define M_PI   3.14159265358979323846264338327950288

#define cylPHI   0

#define cylRHO   1

#define cylZ   2

#define rectX   0

#define rectY   1

#define rectZ   2

#define LEFT_HANDED_THREAD   (-1)

#define RIGHT_HANDED_THREAD   (+1)

#define MuonsInc_PITCH_CONVENTION   RIGHT_HANDED_THREAD

#define MuonsInc_Target_Radius_mm   159.15494

Referenced by QUADRUPOLEFIELD().

#define ESSENTIALLY_ZERO   1.E-33

Referenced by modified_besselN_x().


Function Documentation

G4ThreeVector CYLTOCARTESIAN ( G4ThreeVector  Bcyl,
G4double  phi 
)

References cylPHI, cylRHO, cylZ, rectX, rectY, and rectZ.

Referenced by HelicalDipoleField::addFieldValue().

00066 {
00067             const int PHI=cylPHI,RHO=cylRHO,Z=cylZ;                      /* notation */
00068             G4ThreeVector Bcart;
00069 
00070             Bcart[rectX] = (Bcyl[RHO] * cos(phi)- Bcyl[PHI]*sin(phi));
00071             Bcart[rectY] = (Bcyl[RHO] * sin(phi)+ Bcyl[PHI]*cos(phi));
00072             Bcart[rectZ] = Bcyl[Z];
00073             return Bcart;
00074 }

G4ThreeVector SIMPLEFIELD ( G4double  b,
G4double  kz,
G4double  Bsolenoid,
G4double  model 
)

References MuonsInc_PITCH_CONVENTION, rectX, rectY, and rectZ.

Referenced by HelicalDipoleField::addFieldValue().

00079 {
00080             const int X=rectX,Y=rectY,Z=rectZ;
00081             G4ThreeVector SFIELD;
00082 
00083             SFIELD[X] = b * sin( MuonsInc_PITCH_CONVENTION * kz );
00084             SFIELD[Y] = b * cos( MuonsInc_PITCH_CONVENTION * kz );
00085             SFIELD[Z] = Bsolenoid + b; 
00086 
00087             return SFIELD;
00088 }

G4double ICOOLDiv ( G4int  n,
G4double  lambda 
)

References M_PI.

00091 {
00092   G4double k    =2*M_PI/lambda;
00093   G4double bip  =gsl_sf_bessel_In(n,n);
00094   G4double bipp =gsl_sf_bessel_In(n-1,n);
00095   return k*(n*bipp-(1+n)*bip);
00096 }

G4double ICOOLFact ( G4int  n,
G4double  krad 
)

Referenced by ICOOLFIELD().

00099 {
00100   return gsl_sf_gamma(n+1)*gsl_sf_pow_int(2.0/(n*krad),n);
00101 }

G4ThreeVector ICOOLFIELD ( G4int  n,
G4double  rho,
G4double  psi,
G4double  k,
G4double  refrad 
)

References cylPHI, cylRHO, cylZ, and ICOOLFact().

Referenced by HelicalDipoleField::addFieldValue().

00106 {
00107   const int PHI=cylPHI, RHO=cylRHO, Z=cylZ;
00108   G4ThreeVector BICOOL;
00109   G4double bn,bnp;
00110   G4double kr,sz,cz,fac;
00111   G4double bref0=-1.0;
00112 
00113   kr  = k*rho;
00114   sz  = sin(n*psi);
00115   cz  = cos(n*psi);
00116   fac = ICOOLFact(n,k*refrad);
00117 
00118   bnp = 0.5*(gsl_sf_bessel_In(n+1,n*kr)+gsl_sf_bessel_In(n-1,n*kr));
00119   bn  = gsl_sf_bessel_In(n,n*kr);
00120 
00121   BICOOL[RHO]   =  bref0*refrad*fac*k*bnp*(-0.0*cz+1.0*sz);
00122   BICOOL[Z]     = -bref0*refrad*fac*k*bn*(0.0*sz+1.0*cz);
00123 
00124   if(rho > 0.0){
00125     BICOOL[PHI] = -BICOOL[Z]/kr;
00126   }else{
00127     BICOOL[PHI] = 0.0;
00128   }
00129 
00130   //  printf("n=%d Bfield Br=%e Bz=%e Bp=%e \n",
00131   //     n,BICOOL[RHO],BICOOL[Z],BICOOL[PHI]);
00132   return BICOOL;
00133 }

G4ThreeVector DIPOLF ( G4double  bd,
G4double  k,
G4double  rho,
G4double  psiangle 
)

References cylPHI, cylRHO, and cylZ.

00136 {
00137           const int PHI=cylPHI,RHO=cylRHO,Z=cylZ;        /* notation */
00138           G4double t,I0,I1_t,psi;
00139           G4ThreeVector Bcyl;
00140 
00141           t= k * rho;
00142           I0   = gsl_sf_bessel_In(0,t);
00143           I1_t = gsl_sf_bessel_In(1,t);
00144 
00145           Bcyl[PHI]= 2 * bd * I1_t    * cos(psiangle);
00146           Bcyl[RHO]= 2 * bd * (I0-I1_t) * sin(psiangle);
00147 
00148           Bcyl[Z]=   - k * rho * Bcyl[PHI];
00149           return Bcyl;
00150 }

G4ThreeVector QUADF ( G4double  bprime,
G4double  k,
G4double  rho,
G4double  psiangle 
)

References cylPHI, cylRHO, and cylZ.

00154 {
00155   const char *CoDE="QUADRUPOLEFIELD";
00156   const int PHI=cylPHI,RHO=cylRHO,Z=cylZ;                /* notation */
00157   static int messageCount=0;
00158   G4double t,I1,I2_t,Bprime;
00159   G4ThreeVector Bcyl;
00160   if( 0==messageCount++ )  printf("%s: version of 4/27/04\n", CoDE);
00161   Bprime= bprime/(tesla/meter) * (millimeter/meter) * (tesla/millimeter); 
00162   
00163   t= 2 * k * rho;
00164   I2_t = gsl_sf_bessel_In(2,t);
00165   I1   = gsl_sf_bessel_In(1,t);
00166 
00167   Bcyl[PHI] = 2/k * Bprime * I2_t * cos(2*psiangle); 
00168   Bcyl[RHO] = 1/k * Bprime * (I1 - 2*I2_t) * sin(2*psiangle);  // <== fixed! 
00169   Bcyl[Z] = - k * rho * Bcyl[PHI];
00170 
00171   return Bcyl;
00172 }

g4beamline