38 :feXoffset(exOffset),feYoffset(eyOffset),feZoffset(ezOffset),einvertX(
false),einvertY(
false),einvertZ(
false)
44 G4cout <<
"\n-----------------------------------------------------------"
45 <<
"\n Electric field"
46 <<
"\n-----------------------------------------------------------";
48 G4cout <<
"\n ---> " "Reading the field grid from " << filename <<
" ... " <<
G4endl;
51 ifstream
file( filename );
55 file.getline(ebuffer,256);
60 G4cout <<
" [ Number of values x,y,z: "
61 <<
Enx <<
" " <<
Eny <<
" " << Enz <<
" ] "
69 for (ix=0; ix<
Enx; ix++) {
73 for (iy=0; iy<
Eny; iy++) {
87 for (iz=0; iz<
Enz; iz++) {
88 for (iy=0; iy<
Eny; iy++) {
89 for (ix=0; ix<
Enx; ix++) {
90 file >> Exval >> Eyval >> Ezval >> Ex >> Ey >> Ez;
92 if ( ix==0 && iy==0 && iz==0 ) {
93 Eminx = Exval * ElenUnit;
94 Eminy = Eyval * ElenUnit;
95 Eminz = Ezval * ElenUnit;
97 xEField[ix][iy][iz] = Ex * EfieldUnit;
98 yEField[ix][iy][iz] = Ey * EfieldUnit;
99 zEField[ix][iy][iz] = Ez * EfieldUnit;
106 Emaxx = Exval * ElenUnit;
107 Emaxy = Eyval * ElenUnit;
108 Emaxz = Ezval * ElenUnit;
113 G4cout <<
" ---> assumed the order: x, y, z, Ex, Ey, Ez "
114 <<
"\n ---> Min values x,y,z: "
116 <<
"\n ---> Max values x,y,z: "
118 <<
"\n ---> The field will be offset in x by " << exOffset/
cm <<
" cm "
119 <<
"\n ---> The field will be offset in y by " << eyOffset/
cm <<
" cm "
120 <<
"\n ---> The field will be offset in z by " << ezOffset/
cm <<
" cm " <<
G4endl;
126 G4cout <<
"\nAfter reordering if neccesary"
127 <<
"\n ---> Min values x,y,z: "
129 <<
" \n ---> Max values x,y,z: "
135 G4cout <<
"\n ---> Dif values x,y,z (range): "
137 <<
"\n-----------------------------------------------------------" <<
G4endl;
153 if (
einvertX) { Exfraction = 1 - Exfraction;}
154 if (
einvertY) { Eyfraction = 1 - Eyfraction;}
155 if (
einvertZ) { Ezfraction = 1 - Ezfraction;}
159 G4double exdindex, eydindex, ezdindex;
163 G4double exlocal = ( std::modf(Exfraction*(
Enx-1), &exdindex));
164 G4double eylocal = ( std::modf(Eyfraction*(
Eny-1), &eydindex));
165 G4double ezlocal = ( std::modf(Ezfraction*(
Enz-1), &ezdindex));
169 G4int exindex =
static_cast<G4int>(std::floor(exdindex));
170 G4int eyindex =
static_cast<G4int>(std::floor(eydindex));
171 G4int ezindex =
static_cast<G4int>(std::floor(ezdindex));
173 if ((exindex < 0) || (exindex >=
Enx - 1) ||
174 (eyindex < 0) || (eyindex >=
Eny - 1) ||
175 (ezindex < 0) || (ezindex >=
Enz - 1))
206 xEField[exindex ][eyindex ][ezindex ] * (1-exlocal) * (1-eylocal) * (1-ezlocal) +
207 xEField[exindex ][eyindex ][ezindex+1] * (1-exlocal) * (1-eylocal) * ezlocal +
208 xEField[exindex ][eyindex+1][ezindex ] * (1-exlocal) * eylocal * (1-ezlocal) +
209 xEField[exindex ][eyindex+1][ezindex+1] * (1-exlocal) * eylocal * ezlocal +
210 xEField[exindex+1][eyindex ][ezindex ] * exlocal * (1-eylocal) * (1-ezlocal) +
211 xEField[exindex+1][eyindex ][ezindex+1] * exlocal * (1-eylocal) * ezlocal +
212 xEField[exindex+1][eyindex+1][ezindex ] * exlocal * eylocal * (1-ezlocal) +
213 xEField[exindex+1][eyindex+1][ezindex+1] * exlocal * eylocal * ezlocal ;
215 yEField[exindex ][eyindex ][ezindex ] * (1-exlocal) * (1-eylocal) * (1-ezlocal) +
216 yEField[exindex ][eyindex ][ezindex+1] * (1-exlocal) * (1-eylocal) * ezlocal +
217 yEField[exindex ][eyindex+1][ezindex ] * (1-exlocal) * eylocal * (1-ezlocal) +
218 yEField[exindex ][eyindex+1][ezindex+1] * (1-exlocal) * eylocal * ezlocal +
219 yEField[exindex+1][eyindex ][ezindex ] * exlocal * (1-eylocal) * (1-ezlocal) +
220 yEField[exindex+1][eyindex ][ezindex+1] * exlocal * (1-eylocal) * ezlocal +
221 yEField[exindex+1][eyindex+1][ezindex ] * exlocal * eylocal * (1-ezlocal) +
222 yEField[exindex+1][eyindex+1][ezindex+1] * exlocal * eylocal * ezlocal ;
224 zEField[exindex ][eyindex ][ezindex ] * (1-exlocal) * (1-eylocal) * (1-ezlocal) +
225 zEField[exindex ][eyindex ][ezindex+1] * (1-exlocal) * (1-eylocal) * ezlocal +
226 zEField[exindex ][eyindex+1][ezindex ] * (1-exlocal) * eylocal * (1-ezlocal) +
227 zEField[exindex ][eyindex+1][ezindex+1] * (1-exlocal) * eylocal * ezlocal +
228 zEField[exindex+1][eyindex ][ezindex ] * exlocal * (1-eylocal) * (1-ezlocal) +
229 zEField[exindex+1][eyindex ][ezindex+1] * exlocal * (1-eylocal) * ezlocal +
230 zEField[exindex+1][eyindex+1][ezindex ] * exlocal * eylocal * (1-ezlocal) +
231 zEField[exindex+1][eyindex+1][ezindex+1] * exlocal * eylocal * ezlocal ;