Import Geant4 3.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:03:00 +02:00
parent cfcb558cfe
commit 137e303ecc
2843 changed files with 37082 additions and 38426 deletions
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4ChebyshevApproximation.hh,v 1.3 2000/11/20 17:26:41 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4DataInterpolation.hh,v 1.3 2000/11/20 17:26:41 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussChebyshevQ.hh,v 1.3 2000/11/20 17:26:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussHermiteQ.hh,v 1.3 2000/11/20 17:26:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussJacobiQ.hh,v 1.3 2000/11/20 17:26:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussLaguerreQ.hh,v 1.3 2000/11/20 17:26:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussLegendreQ.hh,v 1.3 2000/11/20 17:26:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4Integrator.hh,v 1.4 2000/06/15 17:31:23 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4Integrator.icc,v 1.6 2000/06/15 17:31:23 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Implementation of G4Integrator methods.
//
@@ -0,0 +1,118 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PolynomialSolver.hh,v 1.2 2001/01/29 09:49:54 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-01 $
//
// class G4PolynomialSolver
//
// Class description:
//
// G4PolynomialSolver allows the user to solve a polynomial equation
// with a great precision. This is used by Implicit Equation solver.
//
// The Bezier clipping method is used to solve the polynomial.
//
// How to use it:
// Create a class that is the function to be solved.
// This class could have internal parameters to allow to change
// the equation to be solved without recreating a new one.
//
// Define a Polynomial solver, example:
// G4PolynomialSolver<MyFunctionClass,G4double(MyFunctionClass::*)(G4double)>
// PolySolver (&MyFunction,
// &MyFunctionClass::Function,
// &MyFunctionClass::Derivative,
// precision);
//
// The precision is relative to the function to solve.
//
// In MyFunctionClass, provide the function to solve and its derivative:
// Example of function to provide :
//
// x,y,z,dx,dy,dz,Rmin,Rmax are internal variables of MyFunctionClass
//
// G4double MyFunctionClass::Function(G4double value)
// {
// G4double Lx,Ly,Lz;
// G4double result;
//
// Lx = x + value*dx;
// Ly = y + value*dy;
// Lz = z + value*dz;
//
// result = TorusEquation(Lx,Ly,Lz,Rmax,Rmin);
//
// return result ;
// }
//
// G4double MyFunctionClass::Derivative(G4double value)
// {
// G4double Lx,Ly,Lz;
// G4double result;
//
// Lx = x + value*dx;
// Ly = y + value*dy;
// Lz = z + value*dz;
//
// result = dx*TorusDerivativeX(Lx,Ly,Lz,Rmax,Rmin);
// result += dy*TorusDerivativeY(Lx,Ly,Lz,Rmax,Rmin);
// result += dz*TorusDerivativeZ(Lx,Ly,Lz,Rmax,Rmin);
//
// return result;
// }
//
// Then to have a root inside an interval [IntervalMin,IntervalMax] do the
// following:
//
// MyRoot = PolySolver.solve(IntervalMin,IntervalMax);
//
// History:
//
// - 19.12.00 E.Medernach, First implementation
//
#ifndef G4POL_SOLVER_HH
#define G4POL_SOLVER_HH
#include "globals.hh"
template <class T, class F>
class G4PolynomialSolver
{
public: // with description
G4PolynomialSolver(T* typeF, F func, F deriv, G4double precision);
~G4PolynomialSolver();
G4double solve (G4double IntervalMin, G4double IntervalMax);
private:
G4double Newton (G4double IntervalMin, G4double IntervalMax);
//General Newton method with Bezier Clipping
// Works for polynomial of order less or equal than 4.
// But could be changed to work for polynomial of any order providing
// that we find the bezier control points.
G4int BezierClipping(G4double *IntervalMin, G4double *IntervalMax);
// This is just one iteration of Bezier Clipping
T* FunctionClass ;
F Function ;
F Derivative ;
G4double Precision;
};
#include "G4PolynomialSolver.icc"
#endif
@@ -0,0 +1,201 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PolynomialSolver.icc,v 1.5 2001/01/29 13:13:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-01 $
//
// class G4PolynomialSolver
//
// 19.12.00 E.Medernach, First implementation
//
#define POLEPSILON 1e-12
#define POLINFINITY 9.0E99
#define ITERATION 12 // 20 But 8 is really enough for Newton with a good guess
template <class T, class F>
G4PolynomialSolver<T,F>::G4PolynomialSolver (T* typeF, F func, F deriv,
G4double precision)
{
Precision = precision ;
FunctionClass = typeF ;
Function = func ;
Derivative = deriv ;
}
template <class T, class F>
G4PolynomialSolver<T,F>::~G4PolynomialSolver ()
{
}
template <class T, class F>
G4double G4PolynomialSolver<T,F>::solve(G4double IntervalMin,
G4double IntervalMax)
{
return Newton(IntervalMin,IntervalMax);
}
/* If we want to be general this could work for any
polynomial of order more that 4 if we find the (ORDER + 1)
control points
*/
#define NBBEZIER 5
template <class T, class F>
G4int
G4PolynomialSolver<T,F>::BezierClipping(/*T* typeF,F func,F deriv,*/
G4double *IntervalMin,
G4double *IntervalMax)
{
/** BezierClipping is a clipping interval Newton method **/
/** It works by clipping the area where the polynomial is **/
G4double P[NBBEZIER][2],D[2];
G4double NewMin,NewMax;
G4int IntervalIsVoid = 1;
/*** Calculating Control Points ***/
/* We see the polynomial as a Bezier curve for some control points to find */
/*
For 5 control points (polynomial of degree 4) this is:
0 p0 = F((*IntervalMin))
1/4 p1 = F((*IntervalMin)) + ((*IntervalMax) - (*IntervalMin))/4
* F'((*IntervalMin))
2/4 p2 = 1/6 * (16*F(((*IntervalMax) + (*IntervalMin))/2)
- (p0 + 4*p1 + 4*p3 + p4))
3/4 p3 = F((*IntervalMax)) - ((*IntervalMax) - (*IntervalMin))/4
* F'((*IntervalMax))
1 p4 = F((*IntervalMax))
*/
/* x,y,z,dx,dy,dz are constant during searching */
D[0] = (FunctionClass->*Derivative)(*IntervalMin);
P[0][0] = (*IntervalMin);
P[0][1] = (FunctionClass->*Function)(*IntervalMin);
if (fabs(P[0][1]) < Precision) {
return 1;
}
if (((*IntervalMax) - (*IntervalMin)) < POLEPSILON) {
return 1;
}
P[1][0] = (*IntervalMin) + ((*IntervalMax) - (*IntervalMin))/4;
P[1][1] = P[0][1] + (((*IntervalMax) - (*IntervalMin))/4.0) * D[0];
D[1] = (FunctionClass->*Derivative)(*IntervalMax);
P[4][0] = (*IntervalMax);
P[4][1] = (FunctionClass->*Function)(*IntervalMax);
P[3][0] = (*IntervalMax) - ((*IntervalMax) - (*IntervalMin))/4;
P[3][1] = P[4][1] - ((*IntervalMax) - (*IntervalMin))/4 * D[1];
P[2][0] = ((*IntervalMax) + (*IntervalMin))/2;
P[2][1] = (16*(FunctionClass->*Function)(((*IntervalMax)+(*IntervalMin))/2)
- (P[0][1] + 4*P[1][1] + 4*P[3][1] + P[4][1]))/6 ;
{
G4double Intersection ;
G4int i,j;
NewMin = (*IntervalMax) ;
NewMax = (*IntervalMin) ;
for (i=0;i<5;i++)
for (j=i+1;j<5;j++)
{
/* there is an intersection only if each have different signs */
if (((P[j][1] > -Precision) && (P[i][1] < Precision)) ||
((P[j][1] < Precision) && (P[i][1] > -Precision))) {
IntervalIsVoid = 0;
Intersection = P[j][0] - P[j][1]*((P[i][0] - P[j][0])/
(P[i][1] - P[j][1]));
if (Intersection < NewMin) {
NewMin = Intersection;
}
if (Intersection > NewMax) {
NewMax = Intersection;
}
}
}
if (IntervalIsVoid != 1) {
(*IntervalMax) = NewMax;
(*IntervalMin) = NewMin;
}
}
if (IntervalIsVoid == 1) {
return -1;
}
return 0;
}
template <class T, class F>
G4double G4PolynomialSolver<T,F>::Newton (G4double IntervalMin,
G4double IntervalMax)
{
/* So now we have a good guess and an interval where
if there are an intersection the root must be */
G4double Value = 0;
G4double Gradient = 0;
G4double Lambda ;
G4int i=0;
G4int j=0;
/* Reduce interval before applying Newton Method */
{
G4int NewtonIsSafe ;
while ((NewtonIsSafe = BezierClipping(&IntervalMin,&IntervalMax)) == 0) ;
if (NewtonIsSafe == -1) {
return POLINFINITY;
}
}
Lambda = IntervalMin;
Value = (FunctionClass->*Function)(Lambda);
// while ((fabs(Value) > Precision)) {
while (j != -1) {
Value = (FunctionClass->*Function)(Lambda);
Gradient = (FunctionClass->*Derivative)(Lambda);
Lambda = Lambda - Value/Gradient ;
if (fabs(Value) <= Precision) {
j ++;
if (j == 2) {
j = -1;
}
} else {
i ++;
if (i > ITERATION)
return POLINFINITY;
}
}
return Lambda ;
}
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4SimpleIntegration.hh,v 1.2 1999/11/16 17:30:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4VGaussianQuadrature.hh,v 1.3 2000/11/20 17:26:43 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Class description:
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4ChebyshevApproximation.cc,v 1.2 1999/11/16 17:31:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4ChebyshevApproximation.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4DataInterpolation.cc,v 1.3 1999/11/16 17:31:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4DataInterpolation.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussChebyshevQ.cc,v 1.2 1999/11/16 17:31:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4GaussChebyshevQ.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussHermiteQ.cc,v 1.3 2000/11/20 17:26:43 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4GaussHermiteQ.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussJacobiQ.cc,v 1.3 2000/11/20 17:26:43 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4GaussJacobiQ.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussLaguerreQ.cc,v 1.3 2000/11/20 17:26:43 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4GaussLaguerreQ.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4GaussLegendreQ.cc,v 1.2 1999/11/16 17:31:10 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
#include "G4GaussLegendreQ.hh"
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4SimpleIntegration.cc,v 1.2 1999/11/16 17:31:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Implementation file for simple integration methods
//
@@ -6,7 +6,7 @@
// and all its terms.
//
// $Id: G4VGaussianQuadrature.cc,v 1.2 1999/11/16 17:31:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
// GEANT4 tag $Name: geant4-03-01 $
//
// Implementation file for G4VGaussianQuadrature virtual base class
//