Import Geant4 5.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:57:27 +02:00
parent 330b82b769
commit 37fff30d2e
5733 changed files with 263867 additions and 74574 deletions
@@ -22,7 +22,7 @@
//
//
// $Id: G4CashKarpRKF45.cc,v 1.10 2001/11/21 17:56:18 japost Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
// The Cash-Karp Runge-Kutta-Fehlberg 4/5 method is an embedded fourth
// order method (giving fifth-order accuracy) for the solution
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ChordFinder.cc,v 1.27 2002/06/01 02:37:14 japost Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4ChordFinder.cc,v 1.31 2002/11/09 02:50:48 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// 25.02.97 John Apostolakis, design and implimentation
@@ -184,7 +184,7 @@ G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
stepForChord = NewStep(stepTrial, dChordStep, fLastStepEstimate_Unconstrained );
if( ! validEndPoint ) {
if( stepForChord <= oldStepTrial )
if( (stepForChord <= oldStepTrial) || (stepTrial<=0.0) )
stepTrial = stepForChord;
else
stepTrial *= 0.1;
@@ -223,6 +223,7 @@ G4ChordFinder::FindNextChord( const G4FieldTrack yStart,
stepOfLastGoodChord = stepTrial;
#ifdef TEST_CHORD_PRINT
static int dbg=0;
if( dbg )
G4cout << "ChordF/FindNextChord: NoTrials= " << noTrials
<< " StepForGoodChord=" << G4std::setw(10) << stepTrial << G4endl;
@@ -247,6 +248,11 @@ if( dbg ) {
G4double G4ChordFinder::NewStep(G4double stepTrialOld,
G4double dChordStep, // Current 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'.
//
{
G4double stepTrial;
@@ -255,15 +261,22 @@ G4double G4ChordFinder::NewStep(G4double stepTrialOld,
#if 1
// const G4double threshold = 1.21, multiplier = 0.9; // 0.9 < 1 / sqrt(1.21)
stepEstimate_Unconstrained = stepTrialOld * sqrt( fDeltaChord / dChordStep );
stepTrial = 0.98 * stepEstimate_Unconstrained;
if (dChordStep > 0.0)
{
stepEstimate_Unconstrained = stepTrialOld * sqrt( fDeltaChord / dChordStep );
stepTrial = 0.98 * stepEstimate_Unconstrained;
}
else
{
// Should not update the Unconstrained Step estimate: incorrect!
stepTrial = stepTrialOld * 2.;
}
// if ( dChordStep < threshold * fDeltaChord ){
// stepTrial= stepTrialOld * multiplier;
// }
if( (stepTrial < 0.001 * stepTrialOld)
|| (stepTrial > 1000.0 * stepTrialOld)
){
if( stepTrial <= 0.001 * stepTrialOld)
{
if ( dChordStep > 1000.0 * fDeltaChord ){
stepTrial= stepTrialOld * 0.03;
}else{
@@ -274,6 +287,13 @@ G4double G4ChordFinder::NewStep(G4double stepTrialOld,
stepTrial= stepTrialOld * 0.5;
}
}
}else if (stepTrial > 1000.0 * stepTrialOld)
{
stepTrial= 1000.0 * stepTrialOld;
}
if( stepTrial == 0.0 ){
stepTrial= 0.000001;
}
lastStepTrial = stepTrialOld;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ClassicalRK4.cc,v 1.4 2001/07/11 09:59:10 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4ClassicalRK4.cc,v 1.6 2002/11/20 17:56:35 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4ClassicalRK4.hh"
#include "G4ThreeVector.hh"
@@ -33,12 +33,14 @@
// Constructor sets the number of variables (default = 6)
G4ClassicalRK4::G4ClassicalRK4(G4Mag_EqRhs *EqRhs, G4int numberOfVariables)
: G4MagErrorStepper(EqRhs, numberOfVariables),
fNumberOfVariables(numberOfVariables)
: G4MagErrorStepper(EqRhs, numberOfVariables)
// fNumberOfVariables(numberOfVariables)
{
dydxm = new G4double[fNumberOfVariables];
dydxt = new G4double[fNumberOfVariables];
yt = new G4double[fNumberOfVariables];
unsigned int noVariables= G4std::max(numberOfVariables,8); // For Time .. 7+1
dydxm = new G4double[noVariables];
dydxt = new G4double[noVariables];
yt = new G4double[noVariables];
}
////////////////////////////////////////////////////////////////
@@ -68,10 +70,15 @@ G4ClassicalRK4::DumbStepper( const G4double yIn[],
G4double h,
G4double yOut[])
{
const G4int nvar = fNumberOfVariables; // GetNumberOfVariables();
const G4int nvar = this->GetNumberOfVariables(); // fNumberOfVariables();
G4int i;
G4double hh = h*0.5 , h6 = h/6.0 ;
// Initialise time to t0, needed when it is not updated by the integration.
// [ Note: Only for time dependent fields (usually electric)
// is it neccessary to integrate the time.]
yt[7] = yIn[7];
yOut[7] = yIn[7];
for(i=0;i<nvar;i++)
{
@@ -21,34 +21,14 @@
// ********************************************************************
//
//
// $Id: G4EquationOfMotion.cc,v 1.5 2001/11/09 20:39:07 japost Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4EquationOfMotion.cc,v 1.7 2002/06/11 08:34:27 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4EquationOfMotion.hh"
static const int G4maximum_number_of_field_components = 16;
G4EquationOfMotion::~G4EquationOfMotion()
{}
void
G4EquationOfMotion::RightHandSide( const G4double y[],
G4double dydx[] ) const
{
G4double Field[G4maximum_number_of_field_components];
G4double PositionAndTime[4];
// Position
PositionAndTime[0] = y[0];
PositionAndTime[1] = y[1];
PositionAndTime[2] = y[2];
// Global Time
PositionAndTime[3] = y[7]; // See G4FieldTrack::LoadFromArray
GetFieldValue(PositionAndTime, Field) ;
EvaluateRhsGivenB( y, Field, dydx );
}
void
G4EquationOfMotion::EvaluateRhsReturnB( const G4double y[],
G4double dydx[],
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ExplicitEuler.cc,v 1.4 2001/07/11 09:59:11 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4ExplicitEuler.cc,v 1.5 2002/11/29 13:50:18 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// Explicit Euler: x_1 = x_0 + h * dx_0
@@ -41,8 +41,7 @@
G4ExplicitEuler::G4ExplicitEuler(G4Mag_EqRhs *EqRhs,
G4int numberOfVariables)
: G4MagErrorStepper(EqRhs, numberOfVariables),
fNumberOfVariables(numberOfVariables)
: G4MagErrorStepper(EqRhs, numberOfVariables)
{
}
@@ -66,17 +65,17 @@ G4ExplicitEuler::DumbStepper( const G4double yIn[],
G4double h,
G4double yOut[] )
{
// const G4int nvar = 6 ;
const G4int numberOfVariables= GetNumberOfVariables();
// Initialise time to t0, needed when it is not updated by the integration.
// yOut[7] = yIn[7]; // Better to set it to NaN; // TODO
G4int i;
for(i=0;i<fNumberOfVariables;i++)
for(i=0;i< numberOfVariables;i++)
{
yOut[i] = yIn[i] + h*dydx[i] ; // 1st and only Step
}
// NormaliseTangentVector( yOut ); // this could harm more than
// it helps - FIXME ???
return ;
}
@@ -21,32 +21,28 @@
// ********************************************************************
//
//
// $Id: G4FieldManager.cc,v 1.6 2001/11/28 18:44:43 japost Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4FieldManager.cc,v 1.7 2002/07/24 10:43:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4FieldManager.hh"
G4FieldManager::G4FieldManager()
: fDetectorField(0), fChordFinder(0), fAllocatedChordFinder(false),
fFieldChangesEnergy(false), fDefault_Delta_One_Step_Value(0.25*mm),
fDefault_Delta_Intersection_Val(0.1*mm)
{
fDetectorField= 0;
fAllocatedChordFinder= false;
fDelta_One_Step_Value= fDefault_Delta_One_Step_Value;
fDelta_Intersection_Val= fDefault_Delta_Intersection_Val;
fFieldChangesEnergy= false;
}
G4FieldManager::G4FieldManager(G4MagneticField *detectorField)
: fDetectorField(detectorField), fAllocatedChordFinder(true),
fFieldChangesEnergy(false), fDefault_Delta_One_Step_Value(0.25*mm),
fDefault_Delta_Intersection_Val(0.1*mm)
{
fDetectorField= detectorField;
this->CreateChordFinder(detectorField);
fChordFinder= new G4ChordFinder( detectorField );
fDelta_One_Step_Value= fDefault_Delta_One_Step_Value;
fDelta_Intersection_Val= fDefault_Delta_Intersection_Val;
fFieldChangesEnergy= false;
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4FieldTrack.cc,v 1.4 2001/07/11 09:59:11 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#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-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#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-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#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-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#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-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4HelixSimpleRunge.hh"
#include "G4ThreeVector.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ImplicitEuler.cc,v 1.4 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4ImplicitEuler.cc,v 1.5 2002/11/29 13:45:21 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// Implicit Euler:
@@ -47,9 +47,11 @@
G4ImplicitEuler::G4ImplicitEuler(G4Mag_EqRhs *EqRhs,
G4int numberOfVariables):
G4MagErrorStepper(EqRhs, numberOfVariables),
fNumberOfVariables(numberOfVariables)
G4MagErrorStepper(EqRhs, numberOfVariables)
{
unsigned int noVariables= G4std::max(numberOfVariables,8); // For Time .. 7+1
dydxTemp = new G4double[noVariables] ;
yTemp = new G4double[noVariables] ;
}
@@ -59,6 +61,8 @@ G4MagErrorStepper(EqRhs, numberOfVariables),
G4ImplicitEuler::~G4ImplicitEuler()
{
delete[] dydxTemp;
delete[] yTemp;
}
//////////////////////////////////////////////////////////////////////
@@ -71,25 +75,23 @@ G4ImplicitEuler::DumbStepper( const G4double yIn[],
G4double h,
G4double yOut[])
{
// const G4int nvar = 6 ;
G4double* dydxTemp = new G4double[fNumberOfVariables] ;
G4double* yTemp = new G4double[fNumberOfVariables] ;
G4int i;
const G4int numberOfVariables= GetNumberOfVariables();
for( i = 0; i < fNumberOfVariables; i++ )
// Initialise time to t0, needed when it is not updated by the integration.
yTemp[7] = yOut[7] = yIn[7]; // Better to set it to NaN; // TODO
for( i = 0; i < numberOfVariables; i++ )
{
yTemp[i] = yIn[i] + h*dydx[i] ;
}
RightHandSide(yTemp,dydxTemp);
for( i = 0; i < fNumberOfVariables; i++ )
for( i = 0; i < numberOfVariables; i++ )
{
yOut[i] = yIn[i] + 0.5 * h * ( dydx[i] + dydxTemp[i] );
}
// NormaliseTangentVector( yOut );
return ;
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4LineSection.cc,v 1.6 2001/12/04 15:10:01 grichine Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
// typedef double G4double;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4MagErrorStepper.cc,v 1.9 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4MagErrorStepper.cc,v 1.11 2002/11/20 18:14:00 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4MagErrorStepper.hh"
#include "G4ThreeVector.hh"
@@ -44,6 +44,7 @@ G4MagErrorStepper::Stepper( const G4double yInput[],
G4double yError [] )
{
const G4int nvar = this->GetNumberOfVariables() ;
const G4int maxvar= GetNumberOfStateVariables();
G4int i;
// correction for Richardson Extrapolation.
@@ -52,6 +53,12 @@ G4MagErrorStepper::Stepper( const G4double yInput[],
// Saving yInput because yInput and yOutput can be aliases for same array
for(i=0;i<nvar;i++) yInitial[i]=yInput[i];
yInitial[7]= yInput[7]; // Copy the time in case ... even if not really needed
yMiddle[7] = yInput[7]; // Copy the time from initial value
yOneStep[7] = yInput[7]; // As it contributes to final value of yOutput ?
// yOutput[7] = yInput[7]; // -> dumb stepper does it too for RK4
for(i=nvar;i<maxvar;i++) yOutput[i]=yInput[i];
// yError[7] = 0.0;
G4double halfStep = hstep * 0.5;
@@ -22,7 +22,7 @@
//
//
// $Id: G4MagHelicalStepper.cc,v 1.11 2002/01/17 08:12:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4MagHelicalStepper.hh"
#include "G4ThreeVector.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4MagIntegratorDriver.cc,v 1.25 2002/05/07 17:18:49 japost Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4MagIntegratorDriver.cc,v 1.31 2002/12/12 08:19:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
//
@@ -57,9 +57,15 @@ const G4int G4MagInt_Driver::fMaxStepBase = 250; // Was 5000
G4MagInt_Driver::G4MagInt_Driver( G4double hminimum,
G4MagIntegratorStepper *pItsStepper,
G4int numComponents)
: nvar(numComponents),
: fNoIntegrationVariables(numComponents),
fMinNoVars(12),
fNoVars( G4std::max( fNoIntegrationVariables, fMinNoVars )),
fVerboseLevel(0)
{
// In order to accomodate "Laboratory Time", which is [7], fMinNoVars=8 is required.
// For proper time of flight and spin, fMinNoVars must be 12
// fNoVars= G4std::max( fNoVars, fMinNoVars );
RenewStepperAndAdjust( pItsStepper );
hminimum_val= hminimum;
fMaxNoSteps = fMaxStepBase / pIntStepper->IntegratorOrder();
@@ -101,7 +107,6 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
G4FieldTrack yFldTrkStart(y_current);
#endif
// G4double yscal[ncompSVEC];
G4double y[G4FieldTrack::ncompSVEC], dydx[G4FieldTrack::ncompSVEC];
G4double ystart[G4FieldTrack::ncompSVEC], yEnd[G4FieldTrack::ncompSVEC];
G4double x1, x2;
@@ -111,19 +116,17 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
// Assume that hstep > 0
// ystart = y_current.PosVelVec();
y_current.DumpToArray( ystart );
x1= y_current.GetCurveLength();
x2= x1 + hstep;
// // Initial Step size "h" is half the interval
// h = 0.5 * hstep;
// Initial Step size "h" is the full interval
h = hstep;
x = x1;
G4int noFullIntegr=0, noSmallIntegr = 0 ;
static G4int noGoodSteps =0, noBadSteps = 0 ; // Bad = chord > curve-len
const int nvar= fNoVars;
for(i=0;i<nvar;i++) y[i] = ystart[i] ;
@@ -150,7 +153,9 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
}
}
static G4int nStpPr=50; // For debug printing of integrations with many steps
#ifdef G4DEBUG_FIELD
static G4int nStpPr=50; // For debug printing of long integrations
#endif
// Perform the Integration
//
@@ -159,9 +164,9 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
OneGoodStep(y,dydx,x,h,eps,hdid,hnext) ;
//--------------------------------------
lastStepSucceeded= (hdid == h);
# ifdef G4DEBUG_FIELD
#ifdef G4DEBUG_FIELD
if(dbg>2) PrintStatus( ySubStepStart, x1, y, x, h, nstp); // Only
# endif
#endif
}else{
G4FieldTrack yFldTrk( G4ThreeVector(0,0,0),
G4ThreeVector(0,0,0), 0., 0., 0., 0. );
@@ -172,15 +177,15 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
QuickAdvance( yFldTrk, dydx, h, dchord_step, dyerr_len );
//-----------------------------------------------------
# ifdef G4DEBUG_FIELD
// #ifdef G4DEBUG_FIELD
// if(dbg>1) OneGoodStep(y,dydx,x,h,2*eps,hdid,hnext) ;
// if(dbg>1) PrintStatus( ystart, x1, y, x, h, -nstp);
# endif
yFldTrk.DumpToArray(y);
# ifdef G4DEBUG_FIELD
#ifdef G4DEBUG_FIELD
if(dbg>1) PrintStatus( ySubStepStart, x1, y, x, h, nstp); // Only this
# endif
dyerr = dyerr_len / h; // was dyerr_len / hstep;
#endif
dyerr = dyerr_len / h;
hdid= h;
x += hdid;
// Compute suggested new step
@@ -193,9 +198,9 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
G4ThreeVector EndPos( y[0], y[1], y[2] );
#ifdef G4DEBUG_FIELD
if(nstp>nStpPr) {
if(dbg && (nstp>nStpPr)) {
G4cout << "hdid=" << G4std::setw(12) << hdid << " "
<< "hnext=" << G4std::setw(12) << hnext << " " << endl;
<< "hnext=" << G4std::setw(12) << hnext << " " << G4endl;
PrintStatus( ystart, x1, y, x, h, (nstp==nStpPr) ? -nstp: nstp);
}
#endif
@@ -208,11 +213,13 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
// we understand how small difference occur.
if( endPointDist >= hdid*(1.+perThousand) ){
#ifdef G4DEBUG_FIELD
WarnEndPointTooFar ( endPointDist, hdid, eps, dbg );
G4cerr << " Total steps: bad" << noBadSteps << " good " << noGoodSteps << endl;
// G4cerr << "Mid:EndPtFar> ";
if(dbg>1) PrintStatus( ystart, x1, y, x, hstep, no_warnings?nstp:-nstp);
if(dbg){
WarnEndPointTooFar ( endPointDist, hdid, eps, dbg );
G4cerr << " Total steps: bad" << noBadSteps << " good " << noGoodSteps << G4endl;
// G4cerr << "Mid:EndPtFar> ";
PrintStatus( ystart, x1, y, x, hstep, no_warnings?nstp:-nstp);
// Potentially add as arguments: <dydx> - as Initial Force
}
#endif
no_warnings++;
}
@@ -230,10 +237,12 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
(fabs(hstep) > Hmin()) // and if we are asked, it's OK
// && (hnext < hstep * PerThousand )
){
// Issue WARNING
WarnSmallStepSize( hnext, hstep, h, x-x1, nstp );
// G4cerr << "Mid:SmallStep> ";
if(dbg>1) PrintStatus( ystart, x1, y, x, hstep, no_warnings?nstp:-nstp);
if(dbg>0){
// Issue WARNING
WarnSmallStepSize( hnext, hstep, h, x-x1, nstp );
// G4cerr << "Mid:SmallStep> ";
PrintStatus( ystart, x1, y, x, hstep, no_warnings?nstp:-nstp);
}
no_warnings++;
}
#endif
@@ -266,16 +275,16 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
no_warnings++;
succeeded = false;
#ifdef G4DEBUG_FIELD
WarnTooManyStep( x1, x2, x ); // Issue WARNING
if( dbg>1) PrintStatus( yEnd, x1, y, x, hstep, -nstp);
if(dbg){
WarnTooManyStep( x1, x2, x ); // Issue WARNING
PrintStatus( yEnd, x1, y, x, hstep, -nstp);
}
#endif
}
#ifdef G4DEBUG_FIELD
if( no_warnings ){
G4cerr << " Exiting status: "
<< " no-steps " << nstp
<<endl;
if( dbg && no_warnings ){
G4cerr << "G4MagIntegratorDriver exit status: no-steps " << nstp <<G4endl;
PrintStatus( yEnd, x1, y, x, hstep, nstp);
}
#endif
@@ -394,7 +403,6 @@ G4MagInt_Driver::OneGoodStep( G4double y[], // InOut
{
G4double errpos_sq, errvel_sq, errmax_sq;
G4double errmax, h, htemp, xnew ;
G4int i;
G4double yerr[G4FieldTrack::ncompSVEC], ytemp[G4FieldTrack::ncompSVEC];
@@ -411,7 +419,7 @@ G4MagInt_Driver::OneGoodStep( G4double y[], // InOut
errpos_sq = sqr(yerr[0]) + sqr(yerr[1]) + sqr(yerr[2]) ;
errpos_sq /= eps_pos*eps_pos; // Scale relative to required tolerance
// Accuracy for velocity
// Accuracy for momentum
errvel_sq = (sqr(yerr[3]) + sqr(yerr[4]) + sqr(yerr[5]) )
/ (sqr(y[3]) + sqr(y[4]) + sqr(y[5]) );
errvel_sq /= eps_rel_max*eps_rel_max;
@@ -444,10 +452,10 @@ G4MagInt_Driver::OneGoodStep( G4double y[], // InOut
x += (hdid = h) ;
int i;
const int nvar= fNoIntegrationVariables;
for(i=0;i<nvar;i++) y[i] = ytemp[i] ;
// delete[] ytemp ;
// delete[] yerr ;
return ;
} // end of OneGoodStep .............................
@@ -543,9 +551,12 @@ G4MagInt_Driver::ComputeNewStepSize(
// Step failed; compute the size of retrial Step.
hnew = GetSafety()*hstepCurrent*pow(errMaxNorm,GetPshrnk()) ;
}else{
}else if(errMaxNorm > 0.0 ){
// Compute size of next Step for a successful step
hnew = GetSafety()*hstepCurrent*pow(errMaxNorm,GetPgrow()) ;
}else {
// if error estimate is zero (possible) or negative (dubious)
hnew = max_stepping_increase * hstepCurrent;
}
return hnew;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4MagIntegratorStepper.cc,v 1.7 2002/05/07 16:11:59 japost Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4MagIntegratorStepper.cc,v 1.8 2002/11/20 18:12:56 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4MagIntegratorStepper.hh"
@@ -30,9 +30,12 @@
//
G4MagIntegratorStepper::G4MagIntegratorStepper(G4EquationOfMotion* Equation,
G4int num_var)
G4int num_integration_vars,
G4int num_state_vars)
: fEquation_Rhs(Equation),
fNumberOfVariables(num_var)
fNoIntegrationVariables(num_integration_vars),
fNoStateVariables(num_state_vars)
// fNumberOfVariables( G4std::max(num_var,fNoStateVariables) )
{
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4Mag_EqRhs.cc,v 1.7 2001/07/11 09:59:12 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
// This is the standard right-hand side for equation of motion
// in a pure Magnetic Field .
@@ -76,8 +76,10 @@ G4Mag_SpinEqRhs::EvaluateRhsGivenB( const G4double y[],
G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
G4double ucb = (anomaly+1./gamma)/beta;
G4ThreeVector Spin(y[9],y[10],y[11]);
// Initialise the values of dydx that we do not update.
dydx[6] = dydx[7] = dydx[8] = 0.0;
G4ThreeVector Spin(y[9],y[10],y[11]);
G4ThreeVector dSpin;
dSpin = ParticleCharge*omegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
@@ -21,17 +21,15 @@
// ********************************************************************
//
//
// $Id: G4Mag_UsualEqRhs.cc,v 1.4 2001/07/11 09:59:13 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4Mag_UsualEqRhs.cc,v 1.8 2002/11/09 02:58:14 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
// This is the standard right-hand side for equation of motion.
// This is the 'standard' right-hand side for the equation of motion
// of a charged particle in a magnetic field.
//
// The only case another is required is when using a moving reference
// frame ... or extending the class to include additional Forces,
// eg an electric field
//
// J. Apostolakis, January 13th, 1997
// Initial version: J. Apostolakis, January 13th, 1997
// Modified: J. Apostolakis, November 9th, 2002
//
#include "G4Mag_UsualEqRhs.hh"
@@ -56,5 +54,13 @@ G4Mag_UsualEqRhs::EvaluateRhsGivenB( const G4double y[],
return ;
}
void
G4Mag_UsualEqRhs::
SetChargeMomentumMass( G4double particleCharge, // in e+ units
G4double MomentumXc,
G4double mass)
{
fInvCurrentMomentumXc= 1.0 / MomentumXc;
G4Mag_EqRhs::SetChargeMomentumMass( particleCharge, MomentumXc, mass);
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4RKG3_Stepper.cc,v 1.6 2001/07/11 09:59:13 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
#include "G4RKG3_Stepper.hh"
#include "G4ThreeVector.hh"
@@ -22,7 +22,7 @@
//
//
// $Id: G4SimpleHeum.cc,v 1.5 2001/07/11 09:59:13 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
// Simple Heum:
// x_1 = x_0 + h *
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4SimpleRunge.cc,v 1.4 2001/07/11 09:59:13 gunter Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4SimpleRunge.cc,v 1.6 2002/11/29 23:17:16 japost Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// Simple Runge:
//
@@ -49,8 +49,12 @@ G4SimpleRunge::G4SimpleRunge(G4Mag_EqRhs *EqRhs, G4int numberOfVariables)
: G4MagErrorStepper(EqRhs, numberOfVariables),
fNumberOfVariables(numberOfVariables)
{
dydxTemp = new G4double[fNumberOfVariables] ;
yTemp = new G4double[fNumberOfVariables] ;
unsigned int noVariables= G4std::max(numberOfVariables,
GetNumberOfStateVariables());
// To deal with Time >= 7+1
dydxTemp = new G4double[noVariables] ;
yTemp = new G4double[noVariables] ;
}
@@ -60,10 +64,10 @@ G4SimpleRunge::G4SimpleRunge(G4Mag_EqRhs *EqRhs, G4int numberOfVariables)
G4SimpleRunge::~G4SimpleRunge()
{
;
delete[] dydxTemp;
delete[] yTemp;
}
//////////////////////////////////////////////////////////////////
//
//
@@ -74,7 +78,9 @@ G4SimpleRunge::DumbStepper( const G4double yIn[],
G4double h,
G4double yOut[])
{
// const G4int nvar = 6 ;
// Initialise time to t0, needed when it is not updated by the integration.
yTemp[7] = yOut[7] = yIn[7]; // Better to set it to NaN; // TODO
G4int i;
for( i = 0; i < fNumberOfVariables; i++ )
@@ -89,7 +95,5 @@ G4SimpleRunge::DumbStepper( const G4double yIn[],
yOut[i] = yIn[i] + h * ( dydxTemp[i] );
}
// NormaliseTangentVector( yOut );
return ;
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4UniformElectricField.cc,v 1.6 2001/12/04 17:35:54 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
//
//
@@ -22,7 +22,7 @@
//
//
// $Id: G4UniformMagField.cc,v 1.5 2001/11/08 17:32:21 grichine Exp $
// GEANT4 tag $Name: geant4-04-01 $
// GEANT4 tag $Name: geant4-05-00 $
//
//
//