46 ed <<
"G4Physics2DVector is too short: nx= " << nx <<
" numy= " << ny;
47 G4Exception(
"G4Physics2DVector::G4Physics2DVector()",
"glob03",
65 numberOfXNodes = right.numberOfXNodes;
66 numberOfYNodes = right.numberOfYNodes;
68 verboseLevel = right.verboseLevel;
69 useBicubic = right.useBicubic;
71 xVector = right.xVector;
72 yVector = right.yVector;
90 numberOfXNodes = right.numberOfXNodes;
91 numberOfYNodes = right.numberOfYNodes;
93 verboseLevel = right.verboseLevel;
94 useBicubic = right.useBicubic;
106 xVector.resize(numberOfXNodes, 0.);
107 yVector.resize(numberOfYNodes, 0.);
108 value.resize(numberOfYNodes);
109 for(std::size_t j = 0; j < numberOfYNodes; ++j)
119 for(std::size_t j = 0; j < numberOfYNodes; ++j)
129 for(std::size_t i = 0; i < numberOfXNodes; ++i)
131 xVector[i] = right.xVector[i];
133 for(std::size_t j = 0; j < numberOfYNodes; ++j)
135 yVector[j] = right.yVector[j];
137 for(std::size_t i = 0; i < numberOfXNodes; ++i)
147 std::size_t& idy)
const
151 std::min(std::max(xx, xVector[0]), xVector[numberOfXNodes - 1]);
153 std::min(std::max(yy, yVector[0]), yVector[numberOfYNodes - 1]);
166 const G4double x2 = xVector[idx + 1];
168 const G4double y2 = yVector[idy + 1];
173 return ((y2 - y) * (v11 * (x2 - x) + v12 * (x - x1)) +
174 ((y - y1) * (v21 * (x2 - x) + v22 * (x - x1)))) /
175 ((x2 - x1) * (y2 - y1));
183 const std::size_t idx,
184 const std::size_t idy)
const
192 const G4double x2 = xVector[idx + 1];
194 const G4double y2 = yVector[idy + 1];
215 const G4double f1x = DerivativeX(idx, idy, dx);
216 const G4double f2x = DerivativeX(idx + 1, idy, dx);
217 const G4double f3x = DerivativeX(idx + 1, idy + 1, dx);
218 const G4double f4x = DerivativeX(idx, idy + 1, dx);
220 const G4double f1y = DerivativeY(idx, idy, dy);
221 const G4double f2y = DerivativeY(idx + 1, idy, dy);
222 const G4double f3y = DerivativeY(idx + 1, idy + 1, dy);
223 const G4double f4y = DerivativeY(idx, idy + 1, dy);
226 const G4double f1xy = DerivativeXY(idx, idy, dxy);
227 const G4double f2xy = DerivativeXY(idx + 1, idy, dxy);
228 const G4double f3xy = DerivativeXY(idx + 1, idy + 1, dxy);
229 const G4double f4xy = DerivativeXY(idx, idy + 1, dxy);
231 return f1 + f1y * h2 + (3 * (f4 - f1) - 2 * f1y - f4y) * h22 +
232 (2 * (f1 - f4) + f1y + f4y) * h23 + f1x * h1 + f1xy * h1 * h2 +
233 (3 * (f4x - f1x) - 2 * f1xy - f4xy) * h1 * h22 +
234 (2 * (f1x - f4x) + f1xy + f4xy) * h1 * h23 +
235 (3 * (f2 - f1) - 2 * f1x - f2x) * h12 +
236 (3 * f2y - 3 * f1y - 2 * f1xy - f2xy) * h12 * h2 +
237 (9 * (f1 - f2 + f3 - f4) + 6 * f1x + 3 * f2x - 3 * f3x - 6 * f4x +
238 6 * f1y - 6 * f2y - 3 * f3y + 3 * f4y + 4 * f1xy + 2 * f2xy + f3xy +
241 (6 * (-f1 + f2 - f3 + f4) - 4 * f1x - 2 * f2x + 2 * f3x + 4 * f4x -
242 3 * f1y + 3 * f2y + 3 * f3y - 3 * f4y - 2 * f1xy - f2xy - f3xy -
245 (2 * (f1 - f2) + f1x + f2x) * h13 +
246 (2 * (f1y - f2y) + f1xy + f2xy) * h13 * h2 +
247 (6 * (-f1 + f2 - f3 + f4) + 3 * (-f1x - f2x + f3x + f4x) - 4 * f1y +
248 4 * f2y + 2 * f3y - 2 * f4y - 2 * f1xy - 2 * f2xy - f3xy - f4xy) *
250 (4 * (f1 - f2 + f3 - f4) + 2 * (f1x + f2x - f3x - f4x) +
251 2 * (f1y - f2y - f3y + f4y) + f1xy + f2xy + f3xy + f4xy) *
258 const std::vector<G4double>& vecY)
261 std::size_t nx = vecX.size();
262 std::size_t ny = vecY.size();
266 ed <<
"G4Physics2DVector is too short: nx= " << nx <<
" ny= " << ny;
268 "Both lengths should be above 1");
274 for(std::size_t i = 0; i < nx; ++i)
276 xVector[i] = vecX[i];
278 for(std::size_t j = 0; j < ny; ++j)
280 yVector[j] = vecY[j];
289 G4long prec = out.precision();
290 out <<
G4int(type) <<
" " << numberOfXNodes <<
" " << numberOfYNodes
292 out << std::setprecision(8);
295 for(std::size_t i = 0; i < numberOfXNodes - 1; ++i)
297 out << xVector[i] <<
" ";
299 out << xVector[numberOfXNodes - 1] <<
G4endl;
300 for(std::size_t j = 0; j < numberOfYNodes - 1; ++j)
302 out << yVector[j] <<
" ";
304 out << yVector[numberOfYNodes - 1] <<
G4endl;
305 for(std::size_t j = 0; j < numberOfYNodes; ++j)
307 for(std::size_t i = 0; i < numberOfXNodes - 1; ++i)
327 if(in.fail() || 2 > nx || 2 > ny || nx >=
INT_MAX || ny >=
INT_MAX)
338 for(
G4int i = 0; i < nx; ++i)
346 for(
G4int j = 0; j < ny; ++j)
354 for(
G4int j = 0; j < ny; ++j)
356 for(
G4int i = 0; i < nx; ++i)
375 for(std::size_t j = 0; j < numberOfYNodes; ++j)
377 for(std::size_t i = 0; i < numberOfXNodes; ++i)
388 std::size_t& idy)
const
390 G4double y = std::min(std::max(yy, yVector[0]), yVector[numberOfYNodes - 1]);
395 G4double x1 = InterpolateLinearX(*(value[idy]), rand);
396 G4double x2 = InterpolateLinearX(*(value[idy + 1]), rand);
398 G4double del = yVector[idy + 1] - yVector[idy];
401 res += (x2 - x1) * (y - yVector[idy]) / del;
411 std::size_t nn = v.size();
417 std::size_t n2 =
nn / 2;
418 std::size_t n3 =
nn - 1;
430 n2 = (n3 + n1 + 1) / 2;
436 res += (y - v[n1]) * (xVector[n3] - res) / del;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::vector< G4double > G4PV2DDataVector
G4bool Retrieve(std::ifstream &fIn)
G4Physics2DVector & operator=(const G4Physics2DVector &)
std::size_t FindBinLocationX(const G4double x, const std::size_t lastidx) const
void Store(std::ofstream &fOut) const
std::size_t FindBinLocationY(const G4double y, const std::size_t lastidy) const
void CopyData(const G4Physics2DVector &vec)
void PutVectors(const std::vector< G4double > &vecX, const std::vector< G4double > &vecY)
G4double BicubicInterpolation(const G4double x, const G4double y, const std::size_t idx, const std::size_t idy) const
G4double Value(G4double x, G4double y, std::size_t &lastidx, std::size_t &lastidy) const
void ScaleVector(G4double factor)
void PutValue(std::size_t idx, std::size_t idy, G4double value)
G4double GetValue(std::size_t idx, std::size_t idy) const
G4double FindLinearX(G4double rand, G4double y, std::size_t &lastidy) const