Import Geant4 5.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:15:15 +02:00
parent 37fff30d2e
commit fbd4999cf7
4396 changed files with 56662 additions and 52446 deletions
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4CashKarpRKF45.cc,v 1.10 2001/11/21 17:56:18 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4CashKarpRKF45.cc,v 1.11 2003/04/02 08:52:17 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
// The Cash-Karp Runge-Kutta-Fehlberg 4/5 method is an embedded fourth
// order method (giving fifth-order accuracy) for the solution
@@ -103,10 +103,10 @@ G4CashKarpRKF45::~G4CashKarpRKF45()
void
G4CashKarpRKF45::Stepper(const G4double yInput[],
const G4double dydx[],
G4double Step,
G4double yOut[],
G4double yErr[])
const G4double dydx[],
G4double Step,
G4double yOut[],
G4double yErr[])
{
// const G4int nvar = 6 ;
// const G4double a2 = 0.2 , a3 = 0.3 , a4 = 0.6 , a5 = 1.0 , a6 = 0.875;
@@ -128,7 +128,7 @@ G4CashKarpRKF45::Stepper(const G4double yInput[],
dc5 = -277.0/14336.0 ;
const G4double dc1 = c1 - 2825.0/27648.0 , dc3 = c3 - 18575.0/48384.0 ,
dc4 = c4 - 13525.0/55296.0 , dc6 = c6 - 0.25 ;
dc4 = c4 - 13525.0/55296.0 , dc6 = c6 - 0.25 ;
// Saving yInput because yInput and yOut can be aliases for same array
@@ -193,142 +193,22 @@ G4CashKarpRKF45::Stepper(const G4double yInput[],
fLastStepLength =Step;
return ;
}
///////////////////////////////////////////////////////////////////////////////
void
G4CashKarpRKF45::StepWithEst(const G4double yInput[],
const G4double dydx[],
G4double Step,
G4double yOut[],
G4double& alpha2,
G4double& beta2,
const G4double B1[],
G4double B2[] )
G4CashKarpRKF45::StepWithEst( const G4double*,
const G4double*,
G4double,
G4double*,
G4double&,
G4double&,
const G4double*,
G4double* )
{
G4Exception("G4CashKarpRKF45::StepWithEst ERROR: This Method is no longer used.");
#if 0
// const G4int nvar = 6 ;
G4int i;
// Saving yInput because yInput and yOut can be aliases for same array
for(i=0;i<fNumberOfVariables;i++)
{
yIn[i]=yInput[i];
}
const G4double a2 = 0.2 , a3 = 0.3 , a4 = 0.6 , a5 = 1.0 , a6 = 0.875 ,
b21 = 0.2 ,
b31 = 3.0/40.0 , b32 = 9.0/40.0 ,
b41 = 0.3 , b42 = -0.9 , b43 = 1.2 ,
b51 = -11.0/54.0 , b52 = 2.5 , b53 = -70.0/27.0 ,
b54 = 35.0/27.0 ,
b61 = 1631.0/55296.0 , b62 = 175.0/512.0 ,
b63 = 575.0/13824.0 , b64 = 44275.0/110592.0 ,
b65 = 253.0/4096.0 ,
c1 = 37.0/378.0 , c3 = 250.0/621.0 , c4 = 125.0/594.0 ,
c6 = 512.0/1771.0 ,
dc5 = -277.0/14336.0 ;
const G4double dc1 = c1 - 2825.0/27648.0 , dc3 = c3 - 18575.0/48384.0 ,
dc4 = c4 - 13525.0/55296.0 , dc6 = c6 - 0.25 ;
alpha2 = 0 ;
beta2 = 0 ;
// RightHandSide(yIn, dydx) ; // 1st Step
for(i=0;i<3;i++)
{
alpha2 += B1[i]*B1[i] ;
beta2 += dydx[i+3]*dydx[i+3] ;
}
for(i=0;i<fNumberOfVariables;i++)
{
yTemp[i] = yIn[i] + b21*Step*dydx[i] ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(yTemp,ak2,B2) ; // Calculates yderive &
// returns B too!
for(i=0;i<3;i++)
{
alpha2 += B2[i]*B2[i] ;
beta2 += ak2[i+3]*ak2[i+3] ;
}
for(i=0;i<fNumberOfVariables;i++)
{
yTemp[i] = yIn[i] + Step*(b31*dydx[i] + b32*ak2[i]) ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(yTemp,ak3,B2) ;
for(i=0;i<3;i++)
{
alpha2 += B2[i]*B2[i] ;
beta2 += ak3[i+3]*ak3[i+3] ;
}
for(i=0;i<fNumberOfVariables;i++)
{
yTemp[i] = yIn[i] + Step*(b41*dydx[i] + b42*ak2[i] + b43*ak3[i]) ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(yTemp,ak4,B2) ;
for(i=0;i<3;i++)
{
alpha2 += B2[i]*B2[i] ;
beta2 += ak4[i+3]*ak4[i+3] ;
}
for(i=0;i<fNumberOfVariables;i++)
{
yTemp[i] = yIn[i] + Step*(b51*dydx[i] + b52*ak2[i] + b53*ak3[i] +
b54*ak4[i]) ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(yTemp,ak5,B2) ;
for(i=0;i<3;i++)
{
alpha2 += B2[i]*B2[i] ;
beta2 += ak5[i+3]*ak5[i+3] ;
}
for(i=0;i<fNumberOfVariables;i++)
{
yTemp[i] = yIn[i] + Step*(b61*dydx[i] + b62*ak2[i] + b63*ak3[i] +
b64*ak4[i] + b65*ak5[i]) ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(yTemp,ak6,B2) ;
for(i=0;i<3;i++)
{
alpha2 += B2[i]*B2[i] ;
beta2 += ak6[i+3]*ak6[i+3] ;
}
for(i=0;i<fNumberOfVariables;i++)
{
// Accumulate increments with proper weights
yOut[i] = yIn[i] + Step*(c1*dydx[i] + c3*ak3[i] + c4*ak4[i] + c6*ak6[i]) ;
}
alpha2 *= sqr(GetEquationOfMotion()->FCof()*Step)/6.0 ;
beta2 *= (Step*Step)/6.0 ;
// NormaliseTangentVector( yOut );
#endif
return ;
G4Exception("ERROR - G4CashKarpRKF45::StepWithEst(): Method no longer used.");
return ;
}
/////////////////////////////////////////////////////////////////
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ChordFinder.cc,v 1.31 2002/11/09 02:50:48 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4ChordFinder.cc,v 1.32 2003/04/02 08:53:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
//
// 25.02.97 John Apostolakis, design and implimentation
@@ -44,9 +44,9 @@ const G4double G4ChordFinder::fDefaultDeltaChord = 3. * mm;
// ..........................................................................
G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
G4double stepMinimum,
G4MagIntegratorStepper* pItsStepper ) // A default one
: fDeltaChord( fDefaultDeltaChord )
G4double stepMinimum,
G4MagIntegratorStepper* pItsStepper )
: fDeltaChord( fDefaultDeltaChord )
{
// Construct the Chord Finder
// by creating in inverse order the Driver, the Stepper and EqRhs ...
@@ -66,9 +66,8 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
{
fAllocatedStepper= false;
}
fIntgrDriver = new G4MagInt_Driver(stepMinimum,
pItsStepper,
pItsStepper->GetNumberOfVariables() );
fIntgrDriver = new G4MagInt_Driver(stepMinimum, pItsStepper,
pItsStepper->GetNumberOfVariables() );
}
// ......................................................................
@@ -87,8 +86,8 @@ G4ChordFinder::~G4ChordFinder()
G4double
G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
G4double stepMax,
G4double epsStep )
G4double stepMax,
G4double epsStep )
{
G4double stepPossible;
G4double dyErr;
@@ -99,7 +98,7 @@ G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
static G4bool dbg= false;
if( dbg )
G4cerr << "Entered AdvanceChordLimited with:\n yCurrent: " << yCurrent
<< " and initial Step=stepMax=" << stepMax << " mm. " << G4endl;
<< " and initial Step=stepMax=" << stepMax << " mm. " << G4endl;
#endif
stepPossible= FindNextChord(yCurrent, stepMax, yEnd, dyErr, epsStep);
@@ -116,7 +115,7 @@ G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
good_advance = fIntgrDriver->AccurateAdvance(yCurrent, stepPossible, epsStep);
#ifdef G4DEBUG_FIELD
if (dbg) G4cerr << "Accurate advance to end of chord attemped"
<< "with result " << good_advance << G4endl ;
<< "with result " << good_advance << G4endl ;
#endif
if ( ! good_advance ){
// In this case the driver could not do the full distance
@@ -126,7 +125,7 @@ G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
#ifdef G4DEBUG_FIELD
if( dbg ) G4cerr << "Exiting FindNextChord Limited with:\n yCurrent: "
<< yCurrent<< G4endl;
<< yCurrent<< G4endl;
#endif
return stepPossible;
@@ -134,16 +133,15 @@ G4ChordFinder::AdvanceChordLimited( G4FieldTrack& yCurrent,
// #define TEST_CHORD_PRINT 1
// ..............................................................................
// ............................................................................
G4double
G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
G4double stepMax,
G4FieldTrack& yEnd, // Endpoint
G4double& dyErr, // Error of endpoint
G4double epsStep )
// Returns Length of Step taken
G4double stepMax,
G4FieldTrack& yEnd, // Endpoint
G4double& dyErr, // Error of endpoint
G4double )
// Returns Length of Step taken
{
// G4int stepRKnumber=0;
G4FieldTrack yCurrent= yStart;
@@ -162,7 +160,7 @@ G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
G4int noTrials=0;
stepTrial = G4std::min( stepMax,
(1-perThousand)*fLastStepEstimate_Unconstrained );
(1-perThousand)*fLastStepEstimate_Unconstrained );
do
{
@@ -181,22 +179,24 @@ G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
oldStepTrial = stepTrial;
// This method estimates to step size for a good chord.
stepForChord = NewStep(stepTrial, dChordStep, fLastStepEstimate_Unconstrained );
stepForChord = NewStep(stepTrial, dChordStep,
fLastStepEstimate_Unconstrained );
if( ! validEndPoint ) {
if( (stepForChord <= oldStepTrial) || (stepTrial<=0.0) )
stepTrial = stepForChord;
stepTrial = stepForChord;
else
stepTrial *= 0.1;
stepTrial *= 0.1;
#if 0
// Possible complementary approach:
// Get the driver to calculate the new step size, if it is needed
stepForAccuracy = fIntgrDriver->ComputeNewStepSize( dyErr/(epsStep*oldStepTrial),
stepTrial);
stepTrial = G4std::min(stepForChord, stepForAccuracy);
// Possible complementary approach:
// Get the driver to calculate the new step size, if it is needed
stepForAccuracy =
fIntgrDriver->ComputeNewStepSize( dyErr/(epsStep*oldStepTrial),
stepTrial );
stepTrial = G4std::min(stepForChord, stepForAccuracy);
#endif
// if(dbg) G4cerr<<"Dchord too big. Try new hstep="<<stepTrial<<G4endl;
// if(dbg) G4cerr<<"Dchord too big. Try new hstep="<<stepTrial<<G4endl;
}
#ifdef TEST_CHORD_PRINT
G4cout.precision(5);
@@ -210,12 +210,14 @@ G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
G4cout << " dChordStep= " << G4std::setw(12) << dChordStep;
}
if( dChordStep > fDeltaChord )
G4cout << " d+";
G4cout << " d+";
else
G4cout << " d-";
G4cout << " d-";
G4cout.precision(5);
G4cout << " new_step= " << G4std::setw(10) << fLastStepEstimate_Unconstrained
<< " new_step_constr= " << G4std::setw(10) << stepTrial << G4endl;
G4cout << " new_step= " << G4std::setw(10)
<< fLastStepEstimate_Unconstrained
<< " new_step_constr= " << G4std::setw(10)
<< stepTrial << G4endl;
#endif
noTrials++;
}
@@ -226,7 +228,7 @@ G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
static int dbg=0;
if( dbg )
G4cout << "ChordF/FindNextChord: NoTrials= " << noTrials
<< " StepForGoodChord=" << G4std::setw(10) << stepTrial << G4endl;
<< " StepForGoodChord=" << G4std::setw(10) << stepTrial << G4endl;
#endif
yEnd= yCurrent;
@@ -246,24 +248,25 @@ if( dbg ) {
// ...........................................................................
G4double G4ChordFinder::NewStep(G4double stepTrialOld,
G4double dChordStep, // Current dchord achieved.
G4double dChordStep, // Curr. dchord achieved
G4double& stepEstimate_Unconstrained )
//
// Is called to estimate the next step size, even for successful steps,
// in order to predict an accurate 'chord-sensitive' first step
// which is likely to assist in more performant 'stepping'.
// Is called to estimate the next step size, even for successful steps,
// in order to predict an accurate 'chord-sensitive' first step
// which is likely to assist in more performant 'stepping'.
//
{
G4double stepTrial;
static G4double lastStepTrial = 1., lastDchordStep= 1.;
#if 1
// const G4double threshold = 1.21, multiplier = 0.9; // 0.9 < 1 / sqrt(1.21)
// const G4double threshold = 1.21, multiplier = 0.9;
// 0.9 < 1 / sqrt(1.21)
if (dChordStep > 0.0)
{
stepEstimate_Unconstrained = stepTrialOld * sqrt( fDeltaChord / dChordStep );
stepEstimate_Unconstrained = stepTrialOld*sqrt( fDeltaChord / dChordStep );
stepTrial = 0.98 * stepEstimate_Unconstrained;
}
else
@@ -281,11 +284,11 @@ G4double G4ChordFinder::NewStep(G4double stepTrialOld,
stepTrial= stepTrialOld * 0.03;
}else{
if ( dChordStep > 100. * fDeltaChord ){
stepTrial= stepTrialOld * 0.1;
}else{
// Try halving the length until dChordStep OK
stepTrial= stepTrialOld * 0.5;
}
stepTrial= stepTrialOld * 0.1;
}else{
// Try halving the length until dChordStep OK
stepTrial= stepTrialOld * 0.5;
}
}
}else if (stepTrial > 1000.0 * stepTrialOld)
{
@@ -303,10 +306,10 @@ G4double G4ChordFinder::NewStep(G4double stepTrialOld,
stepTrial= stepTrialOld * 0.03;
}else{
if ( dChordStep > 100. * fDeltaChord ){
stepTrial= stepTrialOld * 0.1;
stepTrial= stepTrialOld * 0.1;
}else{
// Keep halving the length until dChordStep OK
stepTrial= stepTrialOld * 0.5;
stepTrial= stepTrialOld * 0.5;
}
}
#endif
@@ -324,17 +327,17 @@ G4double G4ChordFinder::NewStep(G4double stepTrialOld,
}
//
// Given a starting curve point A (CurveA_PointVelocity), a later
// Given a starting curve point A (CurveA_PointVelocity), a later
// curve point B (CurveB_PointVelocity) and a point E which is (generally)
// not on the curve, find and return a point F which is on the curve and
// which is close to E. While advancing towards F utilise eps_step
// as a measure of the relative accuracy of each Step.
G4FieldTrack G4ChordFinder::ApproxCurvePointV(
const G4FieldTrack& CurveA_PointVelocity,
const G4FieldTrack& CurveB_PointVelocity,
const G4ThreeVector& CurrentE_Point,
G4double eps_step)
G4FieldTrack
G4ChordFinder::ApproxCurvePointV( const G4FieldTrack& CurveA_PointVelocity,
const G4FieldTrack& CurveB_PointVelocity,
const G4ThreeVector& CurrentE_Point,
G4double eps_step)
{
// 1st implementation:
// if r=|AE|/|AB|, and s=true path lenght (AB)
@@ -352,23 +355,25 @@ G4FieldTrack G4ChordFinder::ApproxCurvePointV(
G4double curve_length; // A curve length of AB
G4double AE_fraction;
curve_length=
CurveB_PointVelocity.GetCurveLength() - CurveA_PointVelocity.GetCurveLength();
curve_length= CurveB_PointVelocity.GetCurveLength()
- CurveA_PointVelocity.GetCurveLength();
// const
G4double integrationInaccuracyLimit= G4std::max( perMillion, 0.5*eps_step );
if( curve_length < ABdist * (1. - integrationInaccuracyLimit) ){
#ifdef G4DEBUG_FIELD
G4cerr << " Warning in G4ChordFinder::ApproxCurvePoint: " << G4endl <<
" The two points are further apart than the curve length " << G4endl <<
" Dist = " << ABdist <<
" curve length = " << curve_length
<< " relativeDiff = " << (curve_length-ABdist)/ABdist
<< G4endl;
G4cerr << " Warning in G4ChordFinder::ApproxCurvePoint: "
<< G4endl
<< " The two points are further apart than the curve length "
<< G4endl
<< " Dist = " << ABdist
<< " curve length = " << curve_length
<< " relativeDiff = " << (curve_length-ABdist)/ABdist
<< G4endl;
if( curve_length < ABdist * (1. - 10*eps_step) ) {
G4cerr << " ERROR: the size of the above difference exceeds allowed limits. Aborting."
<< G4endl;
G4Exception("G4ChordFinder::ApproxCurvePoint> Unphysical curve length.");
G4cerr << " ERROR: the size of the above difference"
<< " exceeds allowed limits. Aborting." << G4endl;
G4Exception("G4ChordFinder::ApproxCurvePoint > Unphysical curve length.");
}
#endif
// Take default corrective action:
@@ -384,19 +389,22 @@ G4FieldTrack G4ChordFinder::ApproxCurvePointV(
}else{
AE_fraction = 0.5; // Guess .. ?;
#ifdef G4DEBUG_FIELD
G4cout << "Warning in G4ChordFinder::ApproxCurvePoint: A and B are the same point\n" <<
" Chord AB length = " << ChordAE_Vector.mag() << G4endl << G4endl;
G4cout << "Warning in G4ChordFinder::ApproxCurvePoint:"
<< " A and B are the same point!" << G4endl
<< " Chord AB length = " << ChordAE_Vector.mag() << G4endl
<< G4endl;
#endif
}
if( (AE_fraction> 1.0 + perMillion) || (AE_fraction< 0.) ){
#ifdef G4DEBUG_FIELD
G4cerr << " G4ChordFinder::ApproxCurvePointV: Warning: Anomalous condition:AE > AB or AE/AB <= 0 " << G4endl <<
" AE_fraction = " << AE_fraction << G4endl <<
" Chord AE length = " << ChordAE_Vector.mag() << G4endl <<
" Chord AB length = " << ABdist << G4endl << G4endl;
G4cerr << " OK if this condition occurs after a recalculation of 'B'" << G4endl
<< " Otherwise it is an error. " << G4endl ;
G4cerr << " G4ChordFinder::ApproxCurvePointV - Warning:"
<< " Anomalous condition:AE > AB or AE/AB <= 0 " << G4endl
<< " AE_fraction = " << AE_fraction << G4endl
<< " Chord AE length = " << ChordAE_Vector.mag() << G4endl
<< " Chord AB length = " << ABdist << G4endl << G4endl;
G4cerr << " OK if this condition occurs after a recalculation of 'B'"
<< G4endl << " Otherwise it is an error. " << G4endl ;
#endif
// This course can now result if B has been re-evaluated,
// without E being recomputed (1 July 99)
@@ -411,8 +419,8 @@ G4FieldTrack G4ChordFinder::ApproxCurvePointV(
if ( AE_fraction > 0.0 ) {
good_advance =
fIntgrDriver->AccurateAdvance(Current_PointVelocity,
new_st_length,
eps_step ); // Relative accuracy
new_st_length,
eps_step ); // Relative accuracy
// In this case it does not matter if it cannot advance the full distance
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ClassicalRK4.cc,v 1.6 2002/11/20 17:56:35 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4ClassicalRK4.cc,v 1.7 2003/04/02 08:52:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4ClassicalRK4.hh"
#include "G4ThreeVector.hh"
@@ -66,9 +66,9 @@ G4ClassicalRK4::~G4ClassicalRK4()
void
G4ClassicalRK4::DumbStepper( const G4double yIn[],
const G4double dydx[],
G4double h,
G4double yOut[])
const G4double dydx[],
G4double h,
G4double yOut[])
{
const G4int nvar = this->GetNumberOfVariables(); // fNumberOfVariables();
G4int i;
@@ -101,12 +101,11 @@ G4ClassicalRK4::DumbStepper( const G4double yIn[],
for(i=0;i<nvar;i++) // Final RK4 output
{
yOut[i] = yIn[i] + h6*(dydx[i]+dydxt[i]+2.0*dydxm[i]); //+K1/6+K4/6+(K2+K3)/3
yOut[i] = yIn[i]+h6*(dydx[i]+dydxt[i]+2.0*dydxm[i]); //+K1/6+K4/6+(K2+K3)/3
}
// NormaliseTangentVector( yOut );
return ;
} // end of DumbStepper ....................................................
////////////////////////////////////////////////////////////////////
@@ -114,74 +113,17 @@ G4ClassicalRK4::DumbStepper( const G4double yIn[],
//
void
G4ClassicalRK4::StepWithEst( const G4double yIn[],
const G4double dydx[],
G4double h,
G4double yOut[],
G4double& alpha2,
G4double& beta2,
const G4double B1[],
G4double B2[] )
G4ClassicalRK4::StepWithEst( const G4double*,
const G4double*,
G4double,
G4double*,
G4double&,
G4double&,
const G4double*,
G4double* )
{
G4Exception(" G4ClassicalRK4::StepWithEst ERROR: this Method is no longer used.");
#if 0 // const G4int nvar = 6 ;
G4int nvar = GetNumberOfVariables();
G4int i;
G4double hh = h*0.5 , h6 = h/6.0 ;
G4double B[3] ;
alpha2 = 0 ;
beta2 = 0 ;
for(i=0;i<nvar;i++)
{
yt[i] = yIn[i] + hh*dydx[i] ; // 1st Step K1=h*dydx
}
GetEquationOfMotion()->EvaluateRhsReturnB(yt,dydxt,B) ; // Calculates yderive &
// returns B too!
// RightHandSide(yt,dydxt) ; // 2nd Step K2=h*dydxt
for(i=0;i<nvar;i++)
{
yt[i] = yIn[i] + hh*dydxt[i] ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(yt,dydxm,B2) ;
// RightHandSide(yt,dydxm) ; // 3rd Step K3=h*dydxm
for(i=0;i<3;i++)
{
beta2 += dydx[i+3] *dydx[i+3]
+ dydxt[i+3]*dydxt[i+3]
+ dydxm[i+3]*dydxm[i+3] ;
alpha2 += B1[i]*B1[i] + B[i]*B[i] + B2[i]*B2[i] ;
}
for(i=0;i<nvar;i++)
{
yt[i] = yIn[i] + h*dydxm[i] ;
dydxm[i] += dydxt[i] ; // now dydxm=(K2+K3)/h
}
GetEquationOfMotion()->EvaluateRhsReturnB(yt,dydxt,B2) ;
// RightHandSide(yt,dydxt) ; // 4th Step K4=h*dydxt
for(i=0;i<nvar;i++) // Final RK4 output
{
yOut[i] = yIn[i] + h6*(dydx[i]+dydxt[i]+2.0*dydxm[i]); //+K1/6+K4/6+(K2+K3)/3
}
for(i=0;i<3;i++)
{
beta2 += dydxt[i+3]*dydxt[i+3] ;
alpha2 += B2[i]*B2[i] ;
}
beta2 *= 0.25*h*h;
alpha2 *= sqr(GetEquationOfMotion()->FCof()*h)*0.25 ;
// NormaliseTangentVector( yOut );
#endif
return ;
G4Exception("ERROR - G4ClassicalRK4::StepWithEst(): method no longer used.");
return ;
} // end of StepWithEst ......................................................
@@ -0,0 +1,49 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * 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: G4ElectroMagneticField.cc,v 1.1 2003/04/02 08:49:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
// --------------------------------------------------------------------
#include "G4ElectroMagneticField.hh"
G4ElectroMagneticField::G4ElectroMagneticField()
{
}
G4ElectroMagneticField::~G4ElectroMagneticField()
{
}
G4ElectroMagneticField::G4ElectroMagneticField(const G4ElectroMagneticField &r)
: G4MagneticField(r)
{
}
G4ElectroMagneticField&
G4ElectroMagneticField::operator = (const G4ElectroMagneticField &p)
{
if (&p == this) return *this;
*this = p; return *this;
}
@@ -33,7 +33,7 @@
void
G4EqMagElectricField::SetChargeMomentumMass(G4double particleCharge, // e+ units
G4double MomentumXc,
G4double,
G4double particleMass)
{
fElectroMagCof = eplus*particleCharge*c_light ;
@@ -22,7 +22,7 @@
//
//
// $Id: G4EquationOfMotion.cc,v 1.7 2002/06/11 08:34:27 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4EquationOfMotion.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4ExplicitEuler.cc,v 1.5 2002/11/29 13:50:18 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
//
// Explicit Euler: x_1 = x_0 + h * dx_0
@@ -22,7 +22,7 @@
//
//
// $Id: G4FieldManager.cc,v 1.7 2002/07/24 10:43:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4FieldManager.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4FieldTrack.cc,v 1.4 2001/07/11 09:59:11 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4FieldTrack.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4HelixExplicitEuler.cc,v 1.4 2001/07/11 09:59:11 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4HelixExplicitEuler.hh"
#include "G4ThreeVector.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4HelixHeum.cc,v 1.4 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4HelixHeum.hh"
#include "G4ThreeVector.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4HelixImplicitEuler.cc,v 1.4 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4HelixImplicitEuler.hh"
#include "G4ThreeVector.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4HelixSimpleRunge.cc,v 1.5 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4HelixSimpleRunge.hh"
#include "G4ThreeVector.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4ImplicitEuler.cc,v 1.5 2002/11/29 13:45:21 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
//
// Implicit Euler:
@@ -22,7 +22,7 @@
//
//
// $Id: G4LineSection.cc,v 1.6 2001/12/04 15:10:01 grichine Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
// typedef double G4double;
@@ -22,7 +22,7 @@
//
//
// $Id: G4MagErrorStepper.cc,v 1.11 2002/11/20 18:14:00 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4MagErrorStepper.hh"
#include "G4ThreeVector.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4MagHelicalStepper.cc,v 1.11 2002/01/17 08:12:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4MagHelicalStepper.cc,v 1.12 2003/04/02 08:53:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4MagHelicalStepper.hh"
#include "G4ThreeVector.hh"
@@ -156,7 +156,7 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
void
G4MagHelicalStepper::Stepper( const G4double yInput[],
const G4double dydx[],
const G4double*,
G4double hstep,
G4double yOut[],
G4double yErr[] )
@@ -22,7 +22,7 @@
//
//
// $Id: G4MagIntegratorDriver.cc,v 1.31 2002/12/12 08:19:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
//
//
@@ -22,7 +22,7 @@
//
//
// $Id: G4MagIntegratorStepper.cc,v 1.8 2002/11/20 18:12:56 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4MagIntegratorStepper.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Mag_EqRhs.cc,v 1.7 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4Mag_EqRhs.cc,v 1.8 2003/04/02 08:53:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
// This is the standard right-hand side for equation of motion
// in a pure Magnetic Field .
@@ -48,8 +48,8 @@ G4Mag_EqRhs::G4Mag_EqRhs( G4MagneticField *magField )
void
G4Mag_EqRhs::SetChargeMomentumMass( G4double particleCharge, // e+ units
G4double MomentumXc,
G4double particleMass)
G4double, // MomentumXc
G4double ) // particleMass
{
fCof_val = particleCharge*eplus*c_light ; // B must be in Tesla
// fCof_val = fUnitConstant*particleCharge/MomentumXc; // B must be in Tesla
@@ -22,7 +22,7 @@
//
//
// $Id: G4Mag_UsualEqRhs.cc,v 1.8 2002/11/09 02:58:14 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
//
// This is the 'standard' right-hand side for the equation of motion
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * 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: G4MagneticField.cc,v 1.1 2003/04/02 08:49:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
// --------------------------------------------------------------------
#include "G4MagneticField.hh"
G4MagneticField::G4MagneticField()
{
}
G4MagneticField::~G4MagneticField()
{
}
G4MagneticField::G4MagneticField(const G4MagneticField &)
: G4Field()
{
}
G4MagneticField& G4MagneticField::operator = (const G4MagneticField &p)
{
if (&p == this) return *this; *this = p; return *this;
}
@@ -21,18 +21,18 @@
// ********************************************************************
//
//
// $Id: G4RKG3_Stepper.cc,v 1.6 2001/07/11 09:59:13 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4RKG3_Stepper.cc,v 1.7 2003/04/02 08:52:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
#include "G4RKG3_Stepper.hh"
#include "G4ThreeVector.hh"
#include "G4LineSection.hh"
void G4RKG3_Stepper::Stepper( const G4double yInput[7],
const G4double dydx[7],
G4double Step,
G4double yOut[7],
G4double yErr[])
const G4double dydx[7],
G4double Step,
G4double yOut[7],
G4double yErr[])
{
G4double B[3];
// G4double yderiv[6];
@@ -52,8 +52,8 @@ void G4RKG3_Stepper::Stepper( const G4double yInput[7],
// To obtain B1 ...
// GetEquationOfMotion()->GetFieldValue(yIn,B);
// G4RKG3_Stepper::StepWithEst(yIn, dydx, Step, yOut,alpha2, beta2, B1, B2 );
// GetEquationOfMotion()->GetFieldValue(yIn,B);
// G4RKG3_Stepper::StepWithEst(yIn, dydx, Step, yOut,alpha2, beta2, B1, B2 );
StepNoErr(yIn, dydx,h, yTemp,B) ;
// RightHandSide(yTemp,dydxTemp) ;
@@ -88,7 +88,6 @@ void G4RKG3_Stepper::Stepper( const G4double yInput[7],
// beta2 *= 0.5 ;
// NormaliseTangentVector( yOut ); // Deleted
return ;
}
// ---------------------------------------------------------------------------
@@ -98,83 +97,18 @@ void G4RKG3_Stepper::Stepper( const G4double yInput[7],
// B1[3] is input and is the first magnetic field values
// B2[3] is output and is the final magnetic field values.
void G4RKG3_Stepper::StepWithEst( const G4double tIn[7],
const G4double dydx[7],
G4double Step,
G4double tOut[7],
G4double& alpha2,
G4double& beta2,
const G4double B1[3],
G4double B2[3]) // const
void G4RKG3_Stepper::StepWithEst( const G4double*,
const G4double*,
G4double,
G4double*,
G4double&,
G4double&,
const G4double*,
G4double* )
{
G4Exception(" G4RKG3_Stepper::StepWithEst ERROR: this Method is no longer used.");
#if 0
// G4int nvar = 6 ;
G4double K1[7],K2[7],K3[7],K4[7] ;
G4double tTemp[7], yderiv[6] ;
G4double B[3];
G4int i ;
alpha2 = 0 ;
beta2 = 0 ;
// GetEquationOfMotion()->EvaluateRhsReturnB(tIn,dydx,B1) ;
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] ;
alpha2 += B1[i]*B1[i] ;
beta2 += K1[i]*K1[i] ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ; // Calculates yderive & returns B too!
// GetFieldValue(tTemp,B) ;
for(i=0;i<3;i++)
{
K2[i] = Step * yderiv[i+3];
tTemp[i+3] = tIn[i+3] + 0.5*K2[i] ;
alpha2 += 2*B[i]*B[i] ;
beta2 += K2[i]*K2[i] ;
}
// 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] ;
beta2 += K3[i]*K3[i] ;
}
// Calculates y-deriv(atives) & returns B too!
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B2) ;
G4double drds2 = 0 ;
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 ;
alpha2 += B2[i]*B2[i] ;
beta2 += K4[i]*K4[i] ;
// drds2 += tOut[i+3]*tOut[i+3] ;
}
alpha2 *= sqr(GetEquationOfMotion()->FCof()*Step) * 0.25 ;
beta2 *= 0.25 ;
// drds2 = sqrt(drds2) ;
// for(i=0;i<3;i++) {tOut[i+3] /= drds2 ; } // Unit vector along momentum
// NormaliseTangentVector( tOut ); // Deleted
#endif
return ;
G4Exception(" ERROR - G4RKG3_Stepper::StepWithEst(): method no longer used.");
return ;
}
// -----------------------------------------------------------------
@@ -185,10 +119,10 @@ void G4RKG3_Stepper::StepWithEst( const G4double tIn[7],
// is passed from substep to substep.
void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
const G4double dydx[7],
G4double Step,
G4double tOut[7],
G4double B[3] ) // const
const G4double dydx[7],
G4double Step,
G4double tOut[7],
G4double B[3] ) // const
{
// Copy and edit the routine above, to delete alpha2, beta2, ...
@@ -197,7 +131,7 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
G4int i ;
#ifdef END_CODE_G3STEPPER
G4Exception(" G4RKG3_Stepper::StepNoErr ERROR: this Method should no longer be used.");
G4Exception(" G4RKG3_Stepper::StepNoErr(): method to be no longer used.");
#else
// GetEquationOfMotion()->EvaluateRhsReturnB(tIn,dydx,B1) ;
@@ -207,8 +141,9 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
tTemp[i] = tIn[i] + Step*(0.5*tIn[i+3] + 0.125*K1[i]) ;
tTemp[i+3] = tIn[i+3] + 0.5*K1[i] ;
}
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ; // Calculates yderive
// & returns B too!
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ;
// Calculates yderiv & returns B too!
for(i=0;i<3;i++)
{
K2[i] = Step * yderiv[i+3];
@@ -22,7 +22,7 @@
//
//
// $Id: G4SimpleHeum.cc,v 1.5 2001/07/11 09:59:13 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
// Simple Heum:
// x_1 = x_0 + h *
@@ -22,7 +22,7 @@
//
//
// $Id: G4SimpleRunge.cc,v 1.6 2002/11/29 23:17:16 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
// GEANT4 tag $Name: geant4-05-01 $
//
// Simple Runge:
//
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4UniformElectricField.cc,v 1.6 2001/12/04 17:35:54 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4UniformElectricField.cc,v 1.7 2003/04/02 08:50:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
//
//
@@ -45,8 +45,8 @@ G4UniformElectricField::G4UniformElectricField(const G4ThreeVector FieldVector )
}
G4UniformElectricField::G4UniformElectricField(G4double vField,
G4double vTheta,
G4double vPhi )
G4double vTheta,
G4double vPhi )
{
if(vField >= 0 &&
vTheta >= 0 && vTheta <= pi &&
@@ -67,16 +67,17 @@ G4UniformElectricField::G4UniformElectricField(G4double vField,
G4UniformElectricField::~G4UniformElectricField()
{
;
}
G4UniformElectricField::G4UniformElectricField (const G4UniformElectricField &p)
: G4ElectroMagneticField(p)
{
for (G4int i=0; i<6; i++)
fFieldComponents[i] = p.fFieldComponents[i];
}
G4UniformElectricField& G4UniformElectricField::operator = (const G4UniformElectricField &p)
G4UniformElectricField&
G4UniformElectricField::operator = (const G4UniformElectricField &p)
{
for (G4int i=0; i<6; i++)
fFieldComponents[i] = p.fFieldComponents[i];
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4UniformMagField.cc,v 1.5 2001/11/08 17:32:21 grichine Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4UniformMagField.cc,v 1.6 2003/04/02 08:50:39 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
//
//
@@ -50,8 +50,8 @@ G4UniformMagField::SetFieldValue(const G4ThreeVector& newFieldVector )
}
G4UniformMagField::G4UniformMagField(G4double vField,
G4double vTheta,
G4double vPhi )
G4double vTheta,
G4double vPhi )
{
if(vField >= 0 &&
vTheta >= 0 && vTheta <= pi &&
@@ -73,6 +73,7 @@ G4UniformMagField::~G4UniformMagField()
}
G4UniformMagField::G4UniformMagField (const G4UniformMagField &p)
: G4MagneticField(p)
{
for (G4int i=0; i<3; i++)
fFieldComponents[i] = p.fFieldComponents[i];