Public Member Functions | |
HelicalHarmonicField (BLCoordinateTransform &_global2local, BLCMDhelicalharmonic *hh) | |
constructor. | |
void | addFieldValue (const G4double point[4], G4double field[6]) const |
addFieldValue() adds the field for this hh into field[]. point[] is in global coordinates. | |
Private Attributes | |
G4double | radius |
G4double | halflength |
int | n |
G4double | b |
G4double | lambda |
G4double | phi0 |
BLCoordinateTransform | global2local |
G4RotationMatrix | rotation |
HelicalHarmonicField::HelicalHarmonicField | ( | BLCoordinateTransform & | _global2local, | |
BLCMDhelicalharmonic * | hh | |||
) |
constructor.
References BLCMDhelicalharmonic::b, b, BLCoordinateTransform::getGlobal(), BLCoordinateTransform::getRotation(), global2local, halflength, BLCMDhelicalharmonic::lambda, lambda, BLCMDhelicalharmonic::length, BLCMDhelicalharmonic::n, n, BLCMDhelicalharmonic::phi0, phi0, BLCMDhelicalharmonic::radius, radius, rotation, and BLElementField::setGlobalPoint().
00307 : 00308 BLElementField(), rotation() 00309 { 00310 radius = hd->radius; 00311 halflength = hd->length/2.0; 00312 n = hd->n; 00313 b = hd->b; 00314 lambda = hd->lambda; 00315 phi0 = hd->phi0; 00316 global2local = _global2local; 00317 rotation = global2local.getRotation().inverse(); 00318 00319 // set global bounding box 00320 G4double local[4], global[4]; 00321 local[3] = 0.0; 00322 for(int i=0; i<2; ++i) { 00323 local[0] = (i==0 ? -1.0 : 1.0) * radius; 00324 for(int j=0; j<2; ++j) { 00325 local[1] = (j==0 ? -1.0 : 1.0) * radius; 00326 for(int k=0; k<2; ++k) { 00327 local[2] = (k==0 ? -1.0 : 1.0) * halflength; 00328 global2local.getGlobal(local,global); 00329 setGlobalPoint(global); 00330 } 00331 } 00332 } 00333 }
void HelicalHarmonicField::addFieldValue | ( | const G4double | point[4], | |
G4double | field[6] | |||
) | const [virtual] |
addFieldValue() adds the field for this hh into field[]. point[] is in global coordinates.
Implements BLElementField.
References B, b, BLCoordinateTransform::getLocal(), global2local, halflength, BLCoordinateTransform::isRotated(), lambda, n, phi0, radius, and rotation.
00336 { 00337 const char *CoDE="HelicalHarmonicField::addFieldValue"; 00338 const int X=0,Y=1,Z=2; 00339 const int PHI=0,RHO=1; /* notation */ 00340 00341 G4ThreeVector global(point[X],point[Y],point[Z]); 00342 G4ThreeVector local; 00343 00344 global2local.getLocal(local,global); /*fetch local location in mm*/ 00345 G4double phi = atan2( local[Y], local[X]); 00346 G4double rho = sqrt( local[X]*local[X] + local[Y]*local[Y] ); /*mm*/ 00347 00348 if( rho>radius || fabs(local[Z]) > halflength) return; 00349 00350 G4double cosphi = cos(phi); 00351 G4double sinphi = sin(phi); 00352 G4double k = 2*pi/lambda; 00353 G4double kz = k*(local[Z]+halflength); 00354 G4double psi = n*(phi-kz+phi0); 00355 G4double cospsi = cos(psi); 00356 G4double sinpsi = sin(psi); 00357 G4double nkrho = n*k*rho; 00358 G4double Inm1=gsl_sf_bessel_In(n-1,nkrho); 00359 G4double In=gsl_sf_bessel_In(n,nkrho); 00360 G4double Inp1=gsl_sf_bessel_In(n+1,nkrho); 00361 G4double bb=b*pow(2/(n*k),(n-1)); 00362 double Bcyl_phi=bb*(Inm1-Inp1)*cospsi; 00363 double Bcyl_rho=bb*(Inm1+Inp1)*sinpsi; 00364 G4ThreeVector B; 00365 B[Z]=-2*bb*In*cospsi; 00366 B[X]=Bcyl_rho*cosphi-Bcyl_phi*sinphi; 00367 B[Y]=Bcyl_rho*sinphi+Bcyl_phi*cosphi; 00368 00369 /* Rotation if applicable */ 00370 if(global2local.isRotated()) B = rotation * B; 00371 00372 field[0] += B[X]; /* update the field */ 00373 field[1] += B[Y]; 00374 field[2] += B[Z]; 00375 }
G4double HelicalHarmonicField::radius [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().
G4double HelicalHarmonicField::halflength [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().
int HelicalHarmonicField::n [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().
G4double HelicalHarmonicField::b [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().
G4double HelicalHarmonicField::lambda [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().
G4double HelicalHarmonicField::phi0 [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().
Referenced by addFieldValue(), and HelicalHarmonicField().
G4RotationMatrix HelicalHarmonicField::rotation [private] |
Referenced by addFieldValue(), and HelicalHarmonicField().