Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -73,7 +73,7 @@ G4ChordFinder::G4ChordFinder(G4VIntegrationDriver* pIntegrationDriver)
|
||||
// ..........................................................................
|
||||
|
||||
G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
|
||||
G4double stepMinimum,
|
||||
G4double stepMinimum,
|
||||
G4MagIntegratorStepper* pItsStepper,
|
||||
G4bool useFSALstepper )
|
||||
: fDefaultDeltaChord(0.25 * mm)
|
||||
@@ -126,9 +126,20 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
|
||||
|
||||
if( pItsStepper != nullptr )
|
||||
{
|
||||
#if 0
|
||||
// G4cout << " G4ChordFinder: Creating G4IntegrationDriver<G4MagIntegratorStepper> with "
|
||||
// << " stepMinimum = " << stepMinimum
|
||||
// << " numVar= " << pItsStepper->GetNumberOfVariables() << G4endl;
|
||||
// Type is not known - so must use old class
|
||||
fIntgrDriver = new G4IntegrationDriver<G4MagIntegratorStepper>(
|
||||
stepMinimum, pItsStepper, pItsStepper->GetNumberOfVariables());
|
||||
#else
|
||||
G4cout << " G4ChordFinder: Creating G4MagInt_Driver with "
|
||||
<< " stepMinimum = " << stepMinimum
|
||||
<< " numVar= " << pItsStepper->GetNumberOfVariables() << G4endl;
|
||||
fIntgrDriver = new G4MagInt_Driver( stepMinimum, pItsStepper,
|
||||
pItsStepper->GetNumberOfVariables());
|
||||
#endif
|
||||
}
|
||||
else if ( !useFSALstepper )
|
||||
{
|
||||
@@ -150,7 +161,7 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
|
||||
errorInStepperCreation = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
using SmallStepDriver = G4InterpolationDriver<G4DormandPrince745>;
|
||||
using LargeStepDriver = G4IntegrationDriver<G4HelixHeum>;
|
||||
|
||||
@@ -483,3 +494,15 @@ ApproxCurvePointV( const G4FieldTrack& CurveA_PointVelocity,
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const G4ChordFinder& cf)
|
||||
{
|
||||
// Dumping the state of G4ChordFinder
|
||||
os << "State of G4ChordFinder : " << std::endl;
|
||||
os << " delta_chord = " << cf.fDeltaChord;
|
||||
os << " Default d_c = " << cf.fDefaultDeltaChord;
|
||||
|
||||
os << " stats-verbose = " << cf.fStatsVerbose;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4DriverReporter
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
//
|
||||
// Authors: J.Apostolakis - January/March 2020
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "G4DriverReporter.hh"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void G4DriverReporter::PrintStatus( const G4double* StartArr,
|
||||
G4double xstart,
|
||||
const G4double* CurrentArr,
|
||||
G4double xcurrent,
|
||||
G4double requestStep,
|
||||
unsigned int subStepNo,
|
||||
unsigned int noIntegrationVariables
|
||||
)
|
||||
// Potentially add as arguments:
|
||||
// <dydx> - as Initial Force
|
||||
// stepTaken(hdid) - last step taken
|
||||
// nextStep (hnext) - proposal for size
|
||||
{
|
||||
G4FieldTrack StartFT(G4ThreeVector(0,0,0),
|
||||
G4ThreeVector(0,0,0), 0., 0., 0., 0. );
|
||||
G4FieldTrack CurrentFT (StartFT);
|
||||
|
||||
StartFT.LoadFromArray( StartArr, noIntegrationVariables);
|
||||
StartFT.SetCurveLength( xstart);
|
||||
CurrentFT.LoadFromArray( CurrentArr, noIntegrationVariables);
|
||||
CurrentFT.SetCurveLength( xcurrent );
|
||||
|
||||
PrintStatus(StartFT, CurrentFT, requestStep, subStepNo );
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
const G4int noPrecision = 8;
|
||||
const int prec7= noPrecision+2;
|
||||
const int prec8= noPrecision+3;
|
||||
const int prec9= noPrecision+4;
|
||||
|
||||
void G4DriverReporter::PrintStatus(const G4FieldTrack& StartFT,
|
||||
const G4FieldTrack& CurrentFT,
|
||||
G4double requestStep,
|
||||
unsigned int subStepNo)
|
||||
{
|
||||
G4int verboseLevel= 2; // fVerboseLevel;
|
||||
G4int oldPrec= G4cout.precision(noPrecision);
|
||||
// G4cout.setf(ios_base::fixed,ios_base::floatfield);
|
||||
|
||||
const G4ThreeVector StartPosition= StartFT.GetPosition();
|
||||
const G4ThreeVector StartUnitVelocity= StartFT.GetMomentumDir();
|
||||
const G4ThreeVector CurrentPosition= CurrentFT.GetPosition();
|
||||
const G4ThreeVector CurrentUnitVelocity= CurrentFT.GetMomentumDir();
|
||||
|
||||
G4double DotStartCurrentVeloc= StartUnitVelocity.dot(CurrentUnitVelocity);
|
||||
|
||||
G4double step_len= CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
|
||||
G4double subStepSize = step_len;
|
||||
|
||||
if( (subStepNo <= 1) || (verboseLevel > 3) )
|
||||
{
|
||||
subStepNo = - subStepNo; // To allow printing banner
|
||||
|
||||
G4cout << "------------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
G4cout << std::setw( 6) << " " << std::setw( 25)
|
||||
<< " G4DriverReporter: Current Position and Direction" << " "
|
||||
<< G4endl;
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( prec7) << "s-curve" << " "
|
||||
<< std::setw( prec9) << "X(mm)" << " "
|
||||
<< std::setw( prec9) << "Y(mm)" << " "
|
||||
<< std::setw( prec9) << "Z(mm)" << " "
|
||||
<< std::setw( prec8) << " N_x " << " "
|
||||
<< std::setw( prec8) << " N_y " << " "
|
||||
<< std::setw( prec8) << " N_z " << " "
|
||||
<< std::setw( 6) << " N^2-1 " << " "
|
||||
<< std::setw(10) << " N(0).N " << " "
|
||||
<< std::setw( 7) << "KinEner " << " "
|
||||
<< std::setw(12) << "Track-l" << " " // Add the Sub-step ??
|
||||
<< std::setw(12) << "Step-len" << " "
|
||||
<< std::setw(12) << "Step-len" << " "
|
||||
<< std::setw( 9) << "ReqStep" << " "
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
G4cout.precision(noPrecision);
|
||||
|
||||
if( (subStepNo <= 0) )
|
||||
{
|
||||
PrintStat_Aux( StartFT, requestStep, 0.,
|
||||
0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
// if( verboseLevel <= 3 )
|
||||
{
|
||||
G4cout.precision(noPrecision);
|
||||
PrintStat_Aux( CurrentFT, requestStep, step_len,
|
||||
subStepNo, subStepSize, DotStartCurrentVeloc );
|
||||
}
|
||||
G4cout << "------------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
G4cout.precision(oldPrec);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void G4DriverReporter::PrintStat_Aux(const G4FieldTrack& aFieldTrack,
|
||||
G4double requestStep,
|
||||
G4double step_len,
|
||||
G4int subStepNo,
|
||||
G4double subStepSize,
|
||||
G4double dotVeloc_StartCurr)
|
||||
{
|
||||
const G4ThreeVector Position = aFieldTrack.GetPosition();
|
||||
const G4ThreeVector UnitVelocity = aFieldTrack.GetMomentumDir();
|
||||
|
||||
G4int oldprec= G4cout.precision(noPrecision);
|
||||
|
||||
if( subStepNo >= 0)
|
||||
{
|
||||
G4cout << std::setw( 5) << subStepNo << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << std::setw( 5) << "Start" << " ";
|
||||
}
|
||||
G4double curveLen= aFieldTrack.GetCurveLength();
|
||||
G4cout << std::setw( 7) << curveLen;
|
||||
// G4cout.precision(noPrecision);
|
||||
G4cout << std::setw( prec9) << Position.x() << " "
|
||||
<< std::setw( prec9) << Position.y() << " "
|
||||
<< std::setw( prec9) << Position.z() << " "
|
||||
<< std::setw( prec8) << UnitVelocity.x() << " "
|
||||
<< std::setw( prec8) << UnitVelocity.y() << " "
|
||||
<< std::setw( prec8) << UnitVelocity.z() << " ";
|
||||
G4cout.precision(3);
|
||||
G4double unitMagDif = UnitVelocity.mag2()-1.0;
|
||||
if( std::fabs( unitMagDif ) < 1.0e-15 ) { unitMagDif = 0.0; }
|
||||
G4cout << std::setw( 8) << unitMagDif << " ";
|
||||
G4cout.precision(6);
|
||||
G4cout << std::setw(10) << dotVeloc_StartCurr << " ";
|
||||
G4cout.precision(oldprec);
|
||||
G4cout << std::setw( prec7) << aFieldTrack.GetKineticEnergy();
|
||||
G4cout << std::setw(12) << step_len << " ";
|
||||
|
||||
static G4ThreadLocal G4double oldCurveLength = 0.0;
|
||||
static G4ThreadLocal G4double oldSubStepLength = 0.0;
|
||||
static G4ThreadLocal G4int oldSubStepNo = -1;
|
||||
|
||||
G4double subStep_len = 0.0;
|
||||
if( curveLen > oldCurveLength )
|
||||
{
|
||||
subStep_len= curveLen - oldCurveLength;
|
||||
}
|
||||
else if (subStepNo == oldSubStepNo)
|
||||
{
|
||||
subStep_len= oldSubStepLength;
|
||||
}
|
||||
oldCurveLength= curveLen;
|
||||
oldSubStepLength= subStep_len;
|
||||
|
||||
G4cout << std::setw(12) << subStep_len << " ";
|
||||
G4cout << std::setw(12) << subStepSize << " ";
|
||||
if( requestStep != -1.0 )
|
||||
{
|
||||
G4cout << std::setw( prec9) << requestStep << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << std::setw( prec9) << " InitialStep " << " ";
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
@@ -38,6 +38,10 @@
|
||||
#include "G4MagIntegratorDriver.hh"
|
||||
#include "G4FieldTrack.hh"
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
#include "G4DriverReporter.hh"
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// Constructor
|
||||
@@ -194,7 +198,8 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
#ifdef G4DEBUG_FIELD
|
||||
if (dbg>2)
|
||||
{
|
||||
PrintStatus( ySubStepStart, xSubStepStart, y, x, h, nstp); // Only
|
||||
// PrintStatus( ySubStepStart, xSubStepStart, y, x, h, nstp); // Only
|
||||
G4DriverReporter::PrintStatus( ySubStepStart, xSubStepStart, y, x, h, nstp, nvar);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -216,7 +221,7 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
if ( dyerr_len > fDyerr_max ) { fDyerr_max = dyerr_len; }
|
||||
fDyerrPos_smTot += dyerr_len;
|
||||
fSumH_sm += h; // Length total for 'small' steps
|
||||
if (nstp<=1) { ++fNoInitialSmallSteps; }
|
||||
if (nstp==1) { ++fNoInitialSmallSteps; }
|
||||
#endif
|
||||
#ifdef G4DEBUG_FIELD
|
||||
if (dbg>1)
|
||||
@@ -351,7 +356,7 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} while ( ((nstp++)<=fMaxNoSteps) && (x < x2) && (!lastStep) );
|
||||
} while ( ((++nstp)<=fMaxNoSteps) && (x < x2) && (!lastStep) );
|
||||
// Loop checking, 07.10.2016, J. Apostolakis
|
||||
|
||||
// Have we reached the end ?
|
||||
@@ -719,7 +724,7 @@ G4bool G4MagInt_Driver::QuickAdvance(G4double yarrin[], // In
|
||||
// within certain factors
|
||||
//
|
||||
G4double G4MagInt_Driver::
|
||||
ComputeNewStepSize(G4double errMaxNorm, // max error (normalised)
|
||||
ComputeNewStepSize_WithoutReductionLimit(G4double errMaxNorm, // max error (normalised)
|
||||
G4double hstepCurrent) // current step size
|
||||
{
|
||||
G4double hnew;
|
||||
@@ -746,6 +751,17 @@ ComputeNewStepSize(G4double errMaxNorm, // max error (normalised)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
G4double
|
||||
G4MagInt_Driver::ComputeNewStepSize(
|
||||
G4double errMaxNorm, // max error (normalised)
|
||||
G4double hstepCurrent) // current step size
|
||||
{
|
||||
// Legacy behaviour:
|
||||
return ComputeNewStepSize_WithoutReductionLimit( errMaxNorm, hstepCurrent );
|
||||
// 'Improved' behaviour - at least more consistent with other step estimates:
|
||||
// return ComputeNewStepSize_WithinLimits( errMaxNorm, hstepCurrent );
|
||||
}
|
||||
|
||||
// This method computes new step sizes limiting changes within certain factors
|
||||
//
|
||||
// It shares its logic with AccurateAdvance.
|
||||
@@ -1013,6 +1029,49 @@ G4MagIntegratorStepper* G4MagInt_Driver::GetStepper()
|
||||
void G4MagInt_Driver::
|
||||
RenewStepperAndAdjust(G4MagIntegratorStepper* pItsStepper)
|
||||
{
|
||||
pIntStepper = pItsStepper;
|
||||
pIntStepper = pItsStepper;
|
||||
ReSetParameters();
|
||||
}
|
||||
|
||||
void G4MagInt_Driver::StreamInfo( std::ostream& os ) const
|
||||
{
|
||||
os << "State of G4MagInt_Driver: " << std::endl;
|
||||
os << " Max number of Steps = " << fMaxNoSteps
|
||||
<< " (base # = " << fMaxStepBase << " )" << std::endl;
|
||||
os << " Safety factor = " << safety << std::endl;
|
||||
os << " Power - shrink = " << pshrnk << std::endl;
|
||||
os << " Power - grow = " << pgrow << std::endl;
|
||||
os << " threshold (errcon) = " << errcon << std::endl;
|
||||
|
||||
os << " fMinimumStep = " << fMinimumStep << std::endl;
|
||||
os << " Smallest Fraction = " << fSmallestFraction << std::endl;
|
||||
|
||||
os << " No Integrat Vars = " << fNoIntegrationVariables << std::endl;
|
||||
os << " Min No Vars = " << fMinNoVars << std::endl;
|
||||
os << " Num-Vars = " << fNoVars << std::endl;
|
||||
|
||||
os << " verbose level = " << fVerboseLevel << std::endl;
|
||||
os << " Reintegrates = " << DoesReIntegrate() << std::endl;
|
||||
}
|
||||
|
||||
void PrintInfo( const G4MagInt_Driver & magDrv, std::ostream& os )
|
||||
{
|
||||
os << "State of G4MagInt_Driver: " << std::endl;
|
||||
os << " Max number of Steps = " << magDrv.GetMaxNoSteps();
|
||||
// << " (base # = " << magDrv.fMaxStepBase << " )" << std::endl;
|
||||
os << " Safety factor = " << magDrv.GetSafety() << std::endl;
|
||||
os << " Power - shrink = " << magDrv.GetPshrnk() << std::endl;
|
||||
os << " Power - grow = " << magDrv.GetPgrow() << std::endl;
|
||||
os << " threshold (errcon) = " << magDrv.GetErrcon() << std::endl;
|
||||
|
||||
os << " fMinimumStep = " << magDrv.GetHmin() << std::endl;
|
||||
os << " Smallest Fraction = " << magDrv.GetSmallestFraction() << std::endl;
|
||||
|
||||
/*****
|
||||
os << " No Integrat Vars = " << magDrv.GetNoIntegrationVariables << std::endl;
|
||||
os << " Min No Vars = " << magDrv.GetMinNoVars << std::endl;
|
||||
os << " Num-Vars = " << magDrv.GetNoVars << std::endl;
|
||||
*****/
|
||||
os << " verbose level = " << magDrv.GetVerboseLevel() << std::endl;
|
||||
os << " Reintegrates = " << magDrv.DoesReIntegrate() << std::endl;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,3 +38,10 @@ void G4VIntegrationDriver::RenewStepperAndAdjust(G4MagIntegratorStepper *)
|
||||
"This method exists only for the original G4MagIntegratorDriver class. "
|
||||
"Not defined for other classes derived from G4VIntegrationDriver");
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const G4VIntegrationDriver& id)
|
||||
{
|
||||
id.StreamInfo( os );
|
||||
return os;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user