//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//* // LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION // // ID :LEMuSRElectricField.cc , v 1.3 // AUTHOR: Taofiq PARAISO // DATE : 2004-09-17 10:20 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// // // & &&&&&&&&&& &&&&&&& &&&&&&&& // & & && && & && // & & & & & & && // & &&&&&&& & & &&&&&& &&&&&&&& // & & & && & & && // & & && & & && && & & // &&&&&&&&&& &&&&&&&&&& & &&&&& && &&&&&&& & && // & // & // & // & // Electric Field //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// #include"LEMuSRElectricField.hh" #include"G4UnitsTable.hh" LEMuSRElectricField::LEMuSRElectricField(G4double fieldval,G4String Xfile, G4String Yfile, G4String Zfile, G4String map_length_unit, G4double Offset, G4double nbx, G4double nby, G4double nbz) { FieldVal=fieldval; map_unit = map_length_unit; G4cout<> xval >> yval >> zval >> bx; fy >> xval >> yval >> zval >> by; fz >> xval >> yval >> zval >> bz; xField[ix][iy][iz] = bx*volt/meter; yField[ix][iy][iz] = by*volt/meter; zField[ix][iy][iz] = bz*volt/meter; if (firstline==0) { minx =xval; miny =yval; minz =zval; firstline=1; } } } } fx.close(); fy.close(); fz.close(); maxx = xval; maxy = yval; maxz = zval; G4cout<>output_name; std::ofstream fout (output_name); // open destination file fout.close (); fout.open(output_name); if (!fout.is_open()) exit(8); for (ix=0; ix>bx >>by >>bz; xField[ix][iy][iz] = bx*volt/meter; yField[ix][iy][iz] = by*volt/meter; zField[ix][iy][iz] = bz*volt/meter; } } } fmap>> maxx >> maxy >> maxz ; fmap>> minx >> miny >> minz ; G4cout<< maxx<<" " << maxy<<" " <> zöro"; } //! Scaling the distances acording to the unit. G4double x = (point[0]/mm)/length_ratio; G4double y = (point[1]/mm)/length_ratio; G4double z = ((point[2] - zOffset)/mm)/length_ratio; #ifdef DEBUG_INTERPOLATING_FIELD G4cout<<"POSITION:: " <=minx && x<=maxx && y>=miny && y<=maxy && (z)>=minz && (z)<=maxz ) { // Position of given point within region, normalized to the range // [0,1] G4double xfraction = (x - minx) / (maxx-minx); G4double yfraction = (y - miny) / (maxy-miny); G4double zfraction = (z - minz) / (maxz-minz);//!!!!! PROBLEM MAY BE HERE // Need addresses of these to pass to modf below. // modf uses its second argument as an OUTPUT argument. G4double xdindex, ydindex, zdindex; // Position of the point within the cuboid defined by the // nearest surrounding tabulated points G4double xlocal = ( modf(xfraction*(nx-1), &xdindex)); G4double ylocal = ( modf(yfraction*(ny-1), &ydindex)); G4double zlocal = ( modf(zfraction*(nz-1), &zdindex)); // The indices of the nearest tabulated point whose coordinates // are all less than those of the given point /* int xindex = static_cast(xdindex); int yindex = static_cast(ydindex); int zindex = static_cast(zdindex); */ G4int xindex = (G4int)(xdindex); G4int yindex = (G4int)(ydindex); G4int zindex = (G4int)(zdindex); #ifdef DEBUG_INTERPOLATING_FIELD G4cout << "Local x,y,z: " << xlocal << " " << ylocal << " " << zlocal << endl; G4cout << "Index x,y,z: " << xindex << " " << yindex << " " << zindex << endl; #endif //********************* FIELD INTERPOLATION***************************// //*********** FROM GEANT4 EXTENDED EXAMPLE PURGING MAGNET ************// // Full 3-dimensional version // example: if map_unit= 'dm' multiply by 10 since field map generated by femlab is in volt/decimeter! in order to get the field in V/m. Bfield[0] = (xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) + xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal + xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) + xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal + xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) + xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal + xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) + xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal); Bfield[1] = (yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) + yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal + yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) + yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal + yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) + yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal + yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) + yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal); Bfield[2] = (zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) + zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal + zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) + zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal + zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) + zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal + zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) + zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal); } else { // G4cout<<"RANGE ERROR=>field 0:: RANGE is " << minx <<" " << maxx <<" " << miny <<" " << maxy <<" " << minz <<" "<< maxz <<" "; Bfield[0] = 0.0; Bfield[1] = 0.0; Bfield[2] = 0.0; } Bfield[0] = Bfield[0]*FieldVal*field_factor; Bfield[1] = Bfield[1]*FieldVal*field_factor; Bfield[2] = Bfield[2]*FieldVal*field_factor; #ifdef DEBUG_INTERPOLATING_FIELD G4cout<<"Field Value " << G4BestUnit(Bfield[0]*meter,"Electric potential") <<"/m " <