Import Geant4 8.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:07:44 +02:00
parent fe73f43734
commit 75c7fd177d
764 changed files with 45230 additions and 95238 deletions
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4MagHelicalStepper.cc,v 1.16 2006/06/29 18:24:20 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MagHelicalStepper.cc,v 1.17 2007/04/26 06:26:54 tnikitin Exp $
// GEANT4 tag $Name: geant4-08-03 $
//
// --------------------------------------------------------------------
@@ -58,8 +58,12 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
G4double yHelix[]) const
{
// const G4int nvar = 6;
const G4double approc_limit = 0.05;
//OLD const G4double approc_limit = 0.05;
// OLD approc_limit = 0.05 gives max.error=x^5/5!=(0.05)^5/5!=2.6*e-9
// NEW approc_limit = 0.005 gives max.error=x^5/5!=2.6*e-14
const G4double approc_limit = 0.005;
G4ThreeVector Bnorm, B_x_P, vperp, vpar;
// G4double norm;
G4double B_d_P; // B_perp;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4MagIntegratorDriver.cc,v 1.44 2006/06/29 18:24:23 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MagIntegratorDriver.cc,v 1.46 2007/05/10 10:10:31 japost Exp $
// GEANT4 tag $Name: geant4-08-03 $
//
//
//
@@ -66,7 +66,8 @@ G4MagInt_Driver::G4MagInt_Driver( G4double hminimum,
G4MagIntegratorStepper *pItsStepper,
G4int numComponents,
G4int statisticsVerbose)
: fNoIntegrationVariables(numComponents),
: fSmallestFraction( 1.0e-12 ),
fNoIntegrationVariables(numComponents),
fMinNoVars(12),
fNoVars( std::max( fNoIntegrationVariables, fMinNoVars )),
fVerboseLevel(0),
@@ -143,16 +144,26 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
G4double x1, x2;
G4bool succeeded = true, lastStepSucceeded;
G4double startCurveLength;
G4int noFullIntegr=0, noSmallIntegr = 0 ;
static G4int noGoodSteps =0 ; // Bad = chord > curve-len
const int nvar= fNoVars;
G4FieldTrack yStartFT(y_current);
// Assume that hstep > 0
// Ensure that hstep > 0
if( hstep <= 0.0 ) {
G4cerr << " Hstep is " << hstep << G4endl;
G4Exception("G4MagInt_Driver::AccurateAdvance()",
"Requested Integration Step is zero or negative: it must be positive",
FatalException, "Requested-Step-not-Positive.");
}
y_current.DumpToArray( ystart );
x1= y_current.GetCurveLength();
startCurveLength= y_current.GetCurveLength();
x1= startCurveLength;
x2= x1 + hstep;
if( (hinitial > 0.0)
@@ -182,13 +193,6 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
pIntStepper->RightHandSide( y, dydx );
if( x+h > x2 ) {
h = x2 - x ; // When stepsize overshoots, decrease it!
if( h < eps * hstep) {
lastStep = true; // Avoid numerous small last steps
}
}
fNoTotalSteps++;
// Perform the Integration
//
@@ -233,6 +237,10 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
<< G4endl;
}
#endif
if( h == 0.0 ) {
G4Exception("G4MagInt_Driver::AccurateAdvance()", "Integration Step became Zero",
FatalException, "IntegrationStepUnderflow.");
}
dyerr = dyerr_len / h;
hdid= h;
x += hdid;
@@ -277,15 +285,23 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
}
// #endif
// Check the proposed next stepsize
if(std::fabs(hnext) <= Hmin())
{
// Avoid numerous small last steps
if( (h < eps * hstep) || (h < fSmallestFraction * startCurveLength) ) {
// No more integration -- the next step will not happen
lastStep = true;
// fNoLastStep++;
} else {
// Check the proposed next stepsize
if(std::fabs(hnext) <= Hmin())
{
#ifdef G4DEBUG_FIELD
// If simply a very small interval is being integrated, do not warn
if( (x < x2 * (1-eps) ) && // The last step can be small: it's OK
(std::fabs(hstep) > Hmin()) // and if we are asked, it's OK
// && (hnext < hstep * PerThousand )
){
// If simply a very small interval is being integrated, do not warn
if( (x < x2 * (1-eps) ) && // The last step can be small: it's OK
(std::fabs(hstep) > Hmin()) // and if we are asked, it's OK
// && (hnext < hstep * PerThousand )
)
{
if(dbg>0){ // G4cerr << "Mid:SmallStep> ";
WarnSmallStepSize( hnext, hstep, h, x-x1, nstp );
PrintStatus( ystart, x1, y, x, hstep, no_warnings?nstp:-nstp);
@@ -293,10 +309,29 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
no_warnings++;
}
#endif
// Make sure that the next step is at least Hmin.
h = Hmin();
}else{
h = hnext ;
// Make sure that the next step is at least Hmin.
h = Hmin();
}else{
h = hnext ;
}
// Ensure that the next step does not overshoot
if( x+h > x2 ) {
h = x2 - x ; // When stepsize overshoots, decrease it!
// Must cope with difficult rounding-error issues if hstep << x2
}
// if( h < smallestFraction * startCurveLength )
if( h == 0.0 ){
// Cannot progress - accept this as last step - by default
lastStep = true;
#ifdef G4DEBUG_FIELD
if(dbg){
G4cout << "Warning: G4MagIntegratorDriver::AccurateAdvance" << G4endl
<< " Integration step 'h' became " << h << " due to roundoff " << G4endl
<< " Forcing termination of advance." << G4endl;
}
#endif
}
}
}while ( ((nstp++)<=fMaxNoSteps)
@@ -908,3 +943,14 @@ void G4MagInt_Driver::PrintStatisticsReport()
G4cout.precision(oldPrec);
}
void G4MagInt_Driver::SetSmallestFraction(G4double newFraction)
{
if( (newFraction > 1.e-16) && (newFraction < 1e-8) ) {
fSmallestFraction= newFraction;
}else{
G4cerr << "Warning: SmallestFraction not changed. " << G4endl
<< " Proposed value was " << newFraction << G4endl
<< " Value must be between 1.e-8 and 1.e-16" << G4endl;
}
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4RKG3_Stepper.cc,v 1.10 2006/06/29 18:24:48 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4RKG3_Stepper.cc,v 1.12 2007/04/26 12:23:55 tnikitin Exp $
// GEANT4 tag $Name: geant4-08-03 $
//
// -------------------------------------------------------------------
@@ -36,8 +36,8 @@
G4RKG3_Stepper::G4RKG3_Stepper(G4Mag_EqRhs *EqRhs)
: G4MagIntegratorStepper(EqRhs,6)
{
G4Exception("G4RKG3_Stepper::G4RKG3_Stepper()", "NotImplemented",
FatalException, "Stepper not yet available.");
// G4Exception("G4RKG3_Stepper::G4RKG3_Stepper()", "NotImplemented",
// FatalException, "Stepper not yet available.");
}
G4RKG3_Stepper::~G4RKG3_Stepper()
@@ -128,6 +128,7 @@ void G4RKG3_Stepper::StepWithEst( const G4double*,
// -----------------------------------------------------------------
// Integrator RK Stepper from G3 with only two field evaluation per Step.
// It is used in propagation initial Step by small substeps after solution
// error and delta geometry considerations. B[3] is magnetic field which
@@ -140,62 +141,83 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
G4double B[3] ) // const
{
// Copy and edit the routine above, to delete alpha2, beta2, ...
G4double K1[7],K2[7],K3[7],K4[7] ;
G4double tTemp[7], yderiv[6] ;
// Need Momentum value to give correct values to the coefficients in equation
// Integration on unit velocity, but tIn[3,4,5] is momentum
G4double mom;
G4int i ;
#ifdef END_CODE_G3STEPPER
G4Exception(" G4RKG3_Stepper::StepNoErr(): method to be no longer used.");
#else
// GetEquationOfMotion()->EvaluateRhsReturnB(tIn,dydx,B1) ;
// Correction for momentum not a velocity
mom=std::sqrt(tIn[3]*tIn[3]+tIn[4]*tIn[4]+tIn[5]*tIn[5]);
for(i=0;i<3;i++)
{
K1[i] = Step * dydx[i+3];
tTemp[i] = tIn[i] + Step*(0.5*tIn[i+3] + 0.125*K1[i]) ;
tTemp[i+3] = tIn[i+3] + 0.5*K1[i] ;
K1[i] = Step * dydx[i+3]/mom;
tTemp[i] = tIn[i] + Step*(0.5*tIn[i+3]/mom + 0.125*K1[i]) ;
tTemp[i+3] = tIn[i+3] + 0.5*K1[i]*mom ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ;
// Calculates yderiv & returns B too!
for(i=0;i<3;i++)
{
K2[i] = Step * yderiv[i+3];
tTemp[i+3] = tIn[i+3] + 0.5*K2[i] ;
K2[i] = Step * yderiv[i+3]/mom;
tTemp[i+3] = tIn[i+3] + 0.5*K2[i]*mom ;
}
// Given B, calculate yderiv !
GetEquationOfMotion()->EvaluateRhsGivenB(tTemp,B,yderiv) ;
for(i=0;i<3;i++)
{
K3[i] = Step * yderiv[i+3];
tTemp[i] = tIn[i] + Step*(tIn[i+3] + 0.5*K3[i]) ;
tTemp[i+3] = tIn[i+3] + K3[i] ;
K3[i] = Step * yderiv[i+3]/mom;
tTemp[i] = tIn[i] + Step*(tIn[i+3]/mom + 0.5*K3[i]) ;
tTemp[i+3] = tIn[i+3] + K3[i]*mom ;
}
// Calculates y-deriv(atives) & returns B too!
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ;
for(i=0;i<3;i++) // Output trajectory vector
{
K4[i] = Step * yderiv[i+3];
tOut[i] = tIn[i] + Step*(tIn[i+3] + (K1[i] + K2[i] + K3[i])/6.0) ;
tOut[i+3] = tIn[i+3] + (K1[i] + 2*K2[i] + 2*K3[i] +K4[i])/6.0 ;
K4[i] = Step * yderiv[i+3]/mom;
tOut[i] = tIn[i] + Step*(tIn[i+3]/mom + (K1[i] + K2[i] + K3[i])/6.0) ;
tOut[i+3] = tIn[i+3] + mom*(K1[i] + 2*K2[i] + 2*K3[i] +K4[i])/6.0 ;
}
// NormaliseTangentVector( tOut );
#endif
}
// ---------------------------------------------------------------------------
G4double G4RKG3_Stepper::DistChord() const
{
// Soon: must check whether h/R > 2 pi !!
// Method below is good only for < 2 pi
G4double distChord,distLine;
if (fyInitial != fyFinal) {
distLine= G4LineSection::Distline(fyMidPoint,fyInitial,fyFinal );
distChord = distLine;
}else{
distChord = (fyMidPoint-fyInitial).mag();
}
return G4LineSection::Distline( fyMidPoint, fyInitial, fyFinal );
// This is a class method that gives distance of Mid
// from the Chord between the Initial and Final points.
return distChord;
}