Import Geant4 10.7.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2020-06-26 10:23:25 +02:00
parent c02c370437
commit 67ba86d073
1871 changed files with 174422 additions and 131884 deletions
@@ -1,20 +0,0 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4magneticfield
# Package: Geant4.src.G4geometry.G4magneticfield
#
# CMakeLists.txt for building a single granular library.
#
# Generated on : 24/9/2010
#
#
#------------------------------------------------------------------------------
if(GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
endif()
#if(GEANT4_ENABLE_TESTING)
# add_subdirectory(test)
#endif()
+33 -1
View File
@@ -16,11 +16,43 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
January 13, 2020 G.Cosmo - field-V10-05-18
June 15, 2020 G.Cosmo - field-V10-06-05
---------------------
- Implemented move constructor and operator for G4FieldTrack.
March 24, 2020 J.Apostolakis - field-V10-06-04
----------------------------
- New class G4DriverReporter to print progress of drivers.
Used for debugging differences between Old & fixed MagIntDriver
- Revisions in testing CMake config file and stepper/driver test
for magnetic field.
March 13, 2020 J.Apostolakis - field-V10-06-03
----------------------------
- G4VIntegrationDriver & dependent driver classes:
Added new virtual StreamInfo() method,
& used it to implement operator << for G4VIntegrationDriver
Made (virtual) DoesReIntegrate() const.
- G4MagInt_Driver: Fixed max iterations & clarified that its
ComputeNewStepSize does NOT (yet) respect maximum reduction factor (0.1).
( Done to enable comparisons with new G4IntegrationDriver<> implementation.)
- G4OldMagIntDriver maintains all old behaviour of G4MagInt_Driver.
January 22, 2020 G.Cosmo - field-V10-06-02
------------------------
- Fixed compilation errors and configuration for field07 unit test.
January 13, 2020 G.Cosmo - field-V10-06-01
------------------------
- Turn off verbosity flags by default in G4IntegratorDriver,
G4InterpolationDriver and G4MagIntegratorDriver.
December 10, 2019 B.Morgan - field-V10-06-00
--------------------------
- Cleanup CMake build, removing obsolete granular library options and
explicit include_directories.
November 14, 2019 J.Apostolakis - field-V10-05-17
-------------------------------
- Added method / attribute to G4VIntegrationDriver DoesReIntegrate()
@@ -57,13 +57,13 @@ class G4BFieldIntegrationDriver : public G4VIntegrationDriver
virtual G4bool AccurateAdvance(G4FieldTrack& track,
G4double hstep,
G4double eps,
G4double eps,
G4double hinitial = 0) override
{
return fCurrDriver->AccurateAdvance(track, hstep, eps, hinitial);
}
virtual G4bool DoesReIntegrate() override
virtual G4bool DoesReIntegrate() const override
{
return fCurrDriver->DoesReIntegrate();
}
@@ -130,6 +130,15 @@ class G4BFieldIntegrationDriver : public G4VIntegrationDriver
fLargeStepDriver->OnStartTracking();
}
virtual void StreamInfo( std::ostream& os ) const override
{
os << "Small Step Driver Info: " << std::endl;
fSmallStepDriver->StreamInfo(os);
os << "Large Step Driver Info: " << std::endl;
fLargeStepDriver->StreamInfo(os);
}
// Write out the parameters / state of the driver
void PrintStatistics() const;
private:
@@ -72,7 +72,7 @@ class G4IntegrationDriver<G4BulirschStoer>:
virtual void OnComputeStep() override {};
virtual G4bool DoesReIntegrate() override { return false; } /// ????
virtual G4bool DoesReIntegrate() const override { return false; } /// ????
virtual G4bool AccurateAdvance( G4FieldTrack& track,
G4double stepLen,
@@ -114,6 +114,9 @@ class G4IntegrationDriver<G4BulirschStoer>:
virtual const G4MagIntegratorStepper* GetStepper() const override;
virtual G4MagIntegratorStepper* GetStepper() override;
virtual void StreamInfo( std::ostream& os ) const override;
// Write out the parameters / state of the driver
private:
G4int GetNumberOfVarialbles() const;
@@ -425,3 +425,10 @@ G4IntegrationDriver<G4BulirschStoer>::GetStepper()
{
return nullptr;
}
void
G4IntegrationDriver<G4BulirschStoer>::StreamInfo( std::ostream& os ) const
{
os << "State of G4IntegrationDriver<G4BulirschStoer>: " << std::endl;
os << " Method is implemented, but gives no information. " << std::endl;
}
@@ -115,6 +115,9 @@ class G4ChordFinder
void OnComputeStep();
friend std::ostream&
operator<<( std::ostream& os, const G4ChordFinder& cf);
protected: // .........................................................
void PrintDchordTrial(G4int noTrials,
@@ -74,6 +74,9 @@ class G4ChordFinderDelegate
G4double GetLastStepEstimateUnc();
void SetLastStepEstimateUnc(G4double stepEst);
void StreamDelegateInfo( std::ostream& os ) const;
// Write out the parameters / state of the driver
private:
Driver& GetDriver();
@@ -392,3 +392,23 @@ void G4ChordFinderDelegate<T>::TestChordPrint(G4int noTrials,
G4cout << " nextStepTrial = " << std::setw(10) << nextStepTrial << G4endl;
G4cout.precision(oldprec);
}
template <class T>
void G4ChordFinderDelegate<T>::StreamDelegateInfo( std::ostream& os ) const
{
// Write out the parameters / state of the driver
os << "State of G4ChordFinderDelegate: " << std::endl;
os << "--Parameters: " << std::endl;
os << " First Fraction = " << fFirstFraction << std::endl;
os << " Last Fraction = " << fFractionLast << std::endl;
os << " Fract Next est = " << fFractionNextEstimate << std::endl;
os << "--State (fungible): " << std::endl;
os << " Maximum No Trials (seen) = " << fmaxTrials << std::endl;
os << " LastStepEstimate (Unconstrained) = " << fLastStepEstimate_Unconstrained
<< std::endl;
// os << " Statistics NOT printed. " << std::endl;
os << "--Statistics: trials= " << fTotalNoTrials
<< " calls= " << fNoCalls << std::endl;
}
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * 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
//
// Class description:
//
// Auxiliary class to print information from integration drivers
// Can be used by different types of drivers.
// Authors: J.Apostolakis - January/March 2020
// -------------------------------------------------------------------
#ifndef G4DRIVERREPORTER_HH
#define G4DRIVERREPORTER_HH
#include "G4FieldTrack.hh"
class G4DriverReporter
{
public:
static void PrintStatus(const G4double* StartArr,
G4double xstart,
const G4double* CurrentArr,
G4double xcurrent,
G4double requestStep,
unsigned int subStepNo,
unsigned int noIntegrationVariables);
static void PrintStatus(const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
unsigned int subStepNo);
static void PrintStat_Aux(const G4FieldTrack& aFieldTrack,
G4double requestStep,
G4double actualStep,
G4int subStepNo,
G4double subStepSize,
G4double dotVelocities);
private:
// G4int fVerboseLevel; // Verbose output for debugging
// unsigned int fNoIntegrationVariables);
};
#endif
@@ -66,7 +66,7 @@ class G4FSALIntegrationDriver
virtual void OnComputeStep() override {}
virtual G4bool DoesReIntegrate() override { return true; }
virtual G4bool DoesReIntegrate() const override { return true; }
virtual G4bool AccurateAdvance( G4FieldTrack& track,
G4double hstep,
@@ -86,6 +86,9 @@ class G4FSALIntegrationDriver
virtual void SetVerboseLevel(G4int newLevel) override;
virtual G4int GetVerboseLevel() const override;
virtual void StreamInfo( std::ostream& os ) const override;
// Write out the parameters / state of the driver
// Accessors
G4double GetMinimumStep() const;
@@ -334,3 +334,20 @@ G4FSALIntegrationDriver<T>::AdvanceChordLimited(G4FieldTrack& track,
return ChordFinderDelegate::AdvanceChordLimitedImpl(track, hstep,
eps, chordDistance);
}
template <class T>
void G4FSALIntegrationDriver<T>::StreamInfo( std::ostream& os ) const
{
// Write out the parameters / state of the driver
os << "State of G4IntegrationDriver: " << std::endl;
os << "--Base state (G4RKIntegrationDriver): " << std::endl;
Base::StreamInfo( os );
os << "--Own state (G4IntegrationDriver<>): " << std::endl;
os << " fMinimumStep = " << fMinimumStep << std::endl;
os << " Smallest Fraction = " << fSmallestFraction << std::endl;
os << " verbose level = " << fVerboseLevel << std::endl;
os << " Reintegrates = " << DoesReIntegrate() << std::endl;
os << "--Chord Finder Delegate state: " << std::endl;
ChordFinderDelegate::StreamDelegateInfo( os );
}
@@ -79,6 +79,10 @@ class G4FieldTrack
inline G4FieldTrack& operator= ( const G4FieldTrack& rStVec );
// Copy constructor & Assignment operator
inline G4FieldTrack(G4FieldTrack&& from);
inline G4FieldTrack& operator=(G4FieldTrack&& from);
// Move constructor & operator
inline void UpdateState( const G4ThreeVector& pPosition,
G4double LaboratoryTimeOfFlight,
const G4ThreeVector& pMomentumDirection,
@@ -78,6 +78,51 @@ G4FieldTrack& G4FieldTrack::operator= ( const G4FieldTrack& rStVec )
return *this;
}
inline
G4FieldTrack::G4FieldTrack(G4FieldTrack&& from)
: fDistanceAlongCurve( from.fDistanceAlongCurve),
fKineticEnergy( from.fKineticEnergy ),
fRestMass_c2( from.fRestMass_c2),
fLabTimeOfFlight( from.fLabTimeOfFlight ),
fProperTimeOfFlight( from.fProperTimeOfFlight ),
fChargeState( from.fChargeState )
{
SixVector[0]= from.SixVector[0];
SixVector[1]= from.SixVector[1];
SixVector[2]= from.SixVector[2];
SixVector[3]= from.SixVector[3];
SixVector[4]= from.SixVector[4];
SixVector[5]= from.SixVector[5];
fPolarization = std::move( from.fPolarization );
fMomentumDir = std::move( from.fMomentumDir );
}
inline
G4FieldTrack& G4FieldTrack::operator=(G4FieldTrack&& from)
{
if (&from == this) return *this;
SixVector[0]= from.SixVector[0];
SixVector[1]= from.SixVector[1];
SixVector[2]= from.SixVector[2];
SixVector[3]= from.SixVector[3];
SixVector[4]= from.SixVector[4];
SixVector[5]= from.SixVector[5];
fDistanceAlongCurve = from.fDistanceAlongCurve;
fKineticEnergy = from.fKineticEnergy;
fRestMass_c2 = from.fRestMass_c2;
fLabTimeOfFlight = from.fLabTimeOfFlight;
fProperTimeOfFlight = from.fProperTimeOfFlight;
fChargeState = from.fChargeState;
fPolarization = std::move( from.fPolarization );
fMomentumDir = std::move( from.fMomentumDir );
return *this;
}
inline
G4FieldTrack::~G4FieldTrack()
{
@@ -67,12 +67,12 @@ class G4IntegrationDriver : public G4RKIntegrationDriver<T>,
virtual void OnStartTracking() override;
virtual void OnComputeStep() override {}
virtual G4bool DoesReIntegrate() override { return true; }
virtual G4bool DoesReIntegrate() const override { return true; }
virtual G4bool AccurateAdvance(G4FieldTrack& track,
G4double hstep,
G4double eps, // Requested y_err/hstep
G4double hinitial = 0) override;
G4double hinitial = 0 ) override;
// Integrates ODE from current s (s=s0) to s=s0+h with accuracy eps.
// On output track is replaced by value at end of interval.
// The concept is similar to the odeint routine from NRC p.721-722.
@@ -87,6 +87,9 @@ class G4IntegrationDriver : public G4RKIntegrationDriver<T>,
virtual void SetVerboseLevel(G4int newLevel) override;
virtual G4int GetVerboseLevel() const override;
virtual void StreamInfo( std::ostream& os ) const override;
// Write out the parameters / state of the driver
// Accessors
//
G4double GetMinimumStep() const;
@@ -383,3 +383,20 @@ void G4IntegrationDriver<T>::IncrementQuickAdvanceCalls()
{
++fNoQuickAvanceCalls;
}
template <class T>
void G4IntegrationDriver<T>::StreamInfo( std::ostream& os ) const
{
// Write out the parameters / state of the driver
os << "State of G4IntegrationDriver: " << std::endl;
os << "--Base state (G4RKIntegrationDriver): " << std::endl;
Base::StreamInfo( os );
os << "--Own state (G4IntegrationDriver<>): " << std::endl;
os << " fMinimumStep = " << fMinimumStep << std::endl;
os << " Smallest Fraction = " << fSmallestFraction << std::endl;
os << " verbose level = " << fVerboseLevel << std::endl;
os << " Reintegrates = " << DoesReIntegrate() << std::endl;
os << "--Chord Finder Delegate state: " << std::endl;
ChordFinderDelegate::StreamDelegateInfo( os );
}
@@ -0,0 +1,443 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4IntegrationDriver inline implementation
//
// Author: Dmitry Sorokin, Google Summer of Code 2017
// Supervision: John Apostolakis, CERN
// --------------------------------------------------------------------
#include "G4FieldUtils.hh"
#include "G4DriverReporter.hh"
template <class T>
G4IntegrationDriver<T>::
G4IntegrationDriver ( G4double hminimum, T* pStepper,
G4int numComponents, G4int statisticsVerbose )
: G4RKIntegrationDriver<T>(pStepper),
fMinimumStep(hminimum),
fSmallestFraction(1e-12),
fVerboseLevel(statisticsVerbose),
fNoQuickAvanceCalls(0),
fNoAccurateAdvanceCalls(0),
fNoAccurateAdvanceBadSteps(0),
fNoAccurateAdvanceGoodSteps(0)
{
if (numComponents != Base::GetStepper()->GetNumberOfVariables())
{
std::ostringstream message;
message << "Driver's number of integrated components "
<< numComponents
<< " != Stepper's number of components "
<< pStepper->GetNumberOfVariables();
G4Exception("G4IntegrationDriver","GeomField0002",
FatalException, message);
}
}
template <class T>
G4IntegrationDriver<T>::~G4IntegrationDriver()
{
#ifdef G4VERBOSE
if (fVerboseLevel > 0)
{
G4cout << "G4Integration Driver Stats: "
<< "#QuickAdvance " << fNoQuickAvanceCalls
<< " - #AccurateAdvance " << fNoAccurateAdvanceCalls << " "
<< "#good steps " << fNoAccurateAdvanceGoodSteps << " "
<< "#bad steps " << fNoAccurateAdvanceBadSteps << G4endl;
}
#endif
}
template <class T>
G4double G4IntegrationDriver<T>::AdvanceChordLimited(G4FieldTrack& track,
G4double stepMax,
G4double epsStep,
G4double chordDistance)
{
return ChordFinderDelegate::AdvanceChordLimitedImpl(track, stepMax, epsStep,
chordDistance);
}
template <class T>
void G4IntegrationDriver<T>::OnStartTracking()
{
ChordFinderDelegate::ResetStepEstimate();
}
// Runge-Kutta driver with adaptive stepsize control. Integrate starting
// values at y_current over hstep x2 with accuracy eps.
// On output ystart is replaced by values at the end of the integration
// interval. RightHandSide is the right-hand side of ODE system.
// The source is similar to odeint routine from NRC p.721-722 .
//
template <class T>
G4bool G4IntegrationDriver<T>::
AccurateAdvance(G4FieldTrack& track, G4double hstep,
G4double eps, G4double hinitial)
{
++fNoAccurateAdvanceCalls;
if (hstep == 0.0)
{
std::ostringstream message;
message << "Proposed step is zero; hstep = " << hstep << " !";
G4Exception("G4IntegrationDriver::AccurateAdvance()",
"GeomField1001", JustWarning, message);
return true;
}
if (hstep < 0)
{
std::ostringstream message;
message << "Invalid run condition." << G4endl
<< "Proposed step is negative; hstep = " << hstep << "."
<< G4endl
<< "Requested step cannot be negative! Aborting event.";
G4Exception("G4IntegrationDriver::AccurateAdvance()",
"GeomField0003", EventMustBeAborted, message);
return false;
}
G4double hnext, hdid;
G4double dydx[G4FieldTrack::ncompSVEC];
G4bool succeeded = true, lastStepSucceeded;
G4int noFullIntegr = 0, noSmallIntegr = 0;
G4double y[G4FieldTrack::ncompSVEC];
track.DumpToArray(y);
const G4double startCurveLength = track.GetCurveLength();
const G4double endCurveLength = startCurveLength + hstep;
const G4double hThreshold =
std::min(eps * hstep, fSmallestFraction * startCurveLength);
G4double h = hstep;
if (hinitial > CLHEP::perMillion * hstep && hinitial < hstep)
{
h = hinitial;
}
#ifdef G4DEBUG_FIELD
if (fVerboseLevel > 3)
G4cout << "IDriver::AccurAdv called. "
<< " Input: hstep = " << hstep << " hinitial= " << hinitial
<< " , current: h = " << h << G4endl;
#endif
G4double curveLength = startCurveLength;
for (G4int nstp = 0; nstp < Base::GetMaxNoSteps(); ++nstp)
{
const G4ThreeVector StartPos =
field_utils::makeVector(y, field_utils::Value3D::Position);
#ifdef G4DEBUG_FIELD
const int nvar= Base::GetStepper()->GetNumberOfVariables();
G4double xStepStart= curveLength; // Initial: track.GetCurveLength();
G4double yStepStart[G4FieldTrack::ncompSVEC];
for (int i=0; i<nvar; ++i) { yStepStart[i] = y[i]; }
// G4FieldTrack yFldTrkStart( StartPos,
// field_utils::makeVector(y, field_utils::Value3D::Momentum),
// ... );
// G4FieldTrack yFldTrkStart('0');
// yFldTrkStart.LoadFromArray(y, Base::GetStepper()->GetNumberOfVariables());
// yFldTrkStart.SetCurveLength(curveLength);
G4cout << "----- Iteration = " << nstp << G4endl; // + 1
#endif
Base::GetStepper()->RightHandSide(y, dydx);
if (h > GetMinimumStep())
{
OneGoodStep(y, dydx, curveLength, h, eps, hdid, hnext);
lastStepSucceeded = (hdid == h);
#ifdef G4DEBUG_FIELD
G4cout << "IntegrationDriver -- after OneGoodStep / requesting step = " << h << G4endl;
G4DriverReporter::PrintStatus( yStepStart, xStepStart, y, curveLength, h, nstp+1, nvar); // Only
#endif
}
else
{
G4FieldTrack yFldTrk('0');
G4double dchord_step, dyerr, dyerr_len;
yFldTrk.LoadFromArray(y, Base::GetStepper()->GetNumberOfVariables());
yFldTrk.SetCurveLength(curveLength);
QuickAdvance(yFldTrk, dydx, h, dchord_step, dyerr_len);
yFldTrk.DumpToArray(y);
if (h == 0.0)
{
G4Exception("G4IntegrationDriver::AccurateAdvance()",
"GeomField0003", FatalException,
"Integration Step became Zero!");
}
dyerr = dyerr_len / h;
hdid = h;
curveLength += hdid;
hnext = Base::ComputeNewStepSize(dyerr / eps, h);
lastStepSucceeded = (dyerr <= eps);
}
if (lastStepSucceeded) { ++noFullIntegr; }
else { ++noSmallIntegr; }
const G4ThreeVector EndPos =
field_utils::makeVector(y, field_utils::Value3D::Position);
CheckStep(EndPos, StartPos, hdid);
// Avoid numerous small last steps
if (h < hThreshold || curveLength >= endCurveLength)
{
break;
}
h = std::max(hnext, GetMinimumStep());
if (curveLength + h > endCurveLength)
{
h = endCurveLength - curveLength;
}
}
// Have we reached the end ?
// --> a better test might be x-endCurveLength > an_epsilon
succeeded = (curveLength >= endCurveLength);
// If it was a "forced" last step
track.LoadFromArray(y, Base::GetStepper()->GetNumberOfVariables());
track.SetCurveLength(curveLength);
return succeeded;
}
// Driver for one Runge-Kutta Step with monitoring of local truncation error
// to ensure accuracy and adjust stepsize. Input are dependent variable
// array y[0,...,5] and its derivative dydx[0,...,5] at the
// starting value of the independent variable x . Also input are stepsize
// to be attempted htry, and the required accuracy eps. On output y and x
// are replaced by their new values, hdid is the stepsize that was actually
// accomplished, and hnext is the estimated next stepsize.
// This is similar to the function rkqs from the book:
// Numerical Recipes in C: The Art of Scientific Computing (NRC), Second
// Edition, by William H. Press, Saul A. Teukolsky, William T.
// Vetterling, and Brian P. Flannery (Cambridge University Press 1992),
// 16.2 Adaptive StepSize Control for Runge-Kutta, p. 719
//
template <class T>
void G4IntegrationDriver<T>::OneGoodStep(G4double y[], // InOut
const G4double dydx[],
G4double& curveLength, // InOut
G4double htry,
G4double eps_rel_max,
G4double& hdid, // Out
G4double& hnext) // Out
{
G4double error2 = DBL_MAX;
G4double yerr[G4FieldTrack::ncompSVEC], ytemp[G4FieldTrack::ncompSVEC];
G4double h = htry;
static G4ThreadLocal G4int tot_no_trials = 0;
const G4int max_trials = 100;
for (G4int iter = 0; iter < max_trials; ++iter)
{
tot_no_trials++;
Base::GetStepper()->Stepper(y, dydx, h, ytemp, yerr);
error2 = field_utils::relativeError2(y, yerr, std::max(h, fMinimumStep),
eps_rel_max);
if (error2 <= 1.0)
{
break;
}
h = Base::ShrinkStepSize2(h, error2);
G4double xnew = curveLength + h;
if(xnew == curveLength)
{
std::ostringstream message;
message << "Stepsize underflow in Stepper !" << G4endl
<< "- Step's start x=" << curveLength
<< " and end x= " << xnew
<< " are equal !! " << G4endl
<< " Due to step-size= " << h
<< ". Note that input step was " << htry;
G4Exception("G4IntegrationDriver::OneGoodStep()",
"GeomField1001", JustWarning, message);
break;
}
}
hnext = Base::GrowStepSize2(h, error2);
curveLength += (hdid = h);
field_utils::copy(y, ytemp, Base::GetStepper()->GetNumberOfVariables());
}
template <class T>
G4bool G4IntegrationDriver<T>::QuickAdvance(G4FieldTrack& track, // INOUT
const G4double dydx[],
G4double hstep,
G4double& dchord_step,
G4double& dyerr)
{
++fNoQuickAvanceCalls;
G4double yIn[G4FieldTrack::ncompSVEC],
yOut[G4FieldTrack::ncompSVEC],
yError[G4FieldTrack::ncompSVEC];
G4FieldTrack startTrack( track ); // For debugging
track.DumpToArray(yIn);
Base::GetStepper()->Stepper(yIn, dydx, hstep, yOut, yError);
dchord_step = Base::GetStepper()->DistChord();
dyerr = field_utils::absoluteError(yOut, yError, hstep);
track.LoadFromArray(yOut, Base::GetStepper()->GetNumberOfVariables());
track.SetCurveLength(track.GetCurveLength() + hstep);
#ifdef G4DEBUG_FIELD
// For debugging
static unsigned int numCall= 0;
G4cout // << "G4IntegratorDriver::"
<< "QuickAdvance call # " << ++numCall << G4endl
<< " Input: hstep= " << hstep << G4endl
<< " track= " << startTrack << G4endl
<< " Output: track= " << track << G4endl
<< " d_chord = " << dchord_step
<< " dyerr = " << dyerr << G4endl;
#endif
return true;
}
template <class T>
void G4IntegrationDriver<T>::SetSmallestFraction(G4double newFraction)
{
if (newFraction > 1.e-16 && newFraction < 1e-8)
{
fSmallestFraction = newFraction;
}
else
{
std::ostringstream message;
message << "Smallest Fraction not changed. " << G4endl
<< " Proposed value was " << newFraction << G4endl
<< " Value must be between 1.e-8 and 1.e-16";
G4Exception("G4IntegrationDriver::SetSmallestFraction()",
"GeomField1001", JustWarning, message);
}
}
template <class T>
void G4IntegrationDriver<T>::CheckStep(const G4ThreeVector& posIn,
const G4ThreeVector& posOut,
G4double hdid)
{
const G4double endPointDist = (posOut - posIn).mag();
if (endPointDist >= hdid * (1. + CLHEP::perMillion))
{
++fNoAccurateAdvanceBadSteps;
#ifdef G4DEBUG_FIELD
// Issue a warning only for gross differences -
// we understand how small difference occur.
if (endPointDist >= hdid * (1. + perThousand))
{
G4Exception("G4IntegrationDriver::CheckStep()",
"GeomField1002", JustWarning,
"endPointDist >= hdid!");
}
#endif
}
else
{
++fNoAccurateAdvanceGoodSteps;
}
}
template <class T>
inline G4double G4IntegrationDriver<T>::GetMinimumStep() const
{
return fMinimumStep;
}
template <class T>
void G4IntegrationDriver<T>::SetMinimumStep(G4double minimumStepLength)
{
fMinimumStep = minimumStepLength;
}
template <class T>
G4int G4IntegrationDriver<T>::GetVerboseLevel() const
{
return fVerboseLevel;
}
template <class T>
void G4IntegrationDriver<T>::SetVerboseLevel(G4int newLevel)
{
fVerboseLevel = newLevel;
}
template <class T>
G4double G4IntegrationDriver<T>::GetSmallestFraction() const
{
return fSmallestFraction;
}
template <class T>
void G4IntegrationDriver<T>::IncrementQuickAdvanceCalls()
{
++fNoQuickAvanceCalls;
}
template <class T>
void G4IntegrationDriver<T>::StreamInfo( std::ostream& os ) const
{
// Write out the parameters / state of the driver
os << "State of G4IntegrationDriver: " << std::endl;
os << "--Base state (G4RKIntegrationDriver): " << std::endl;
Base::StreamInfo( os );
os << "--Own state (G4IntegrationDriver<>): " << std::endl;
os << " fMinimumStep = " << fMinimumStep << std::endl;
os << " Smallest Fraction = " << fSmallestFraction << std::endl;
os << " verbose level = " << fVerboseLevel << std::endl;
os << " Reintegrates = " << DoesReIntegrate() << std::endl;
os << "--Chord Finder Delegate state: " << std::endl;
ChordFinderDelegate::StreamDelegateInfo( os );
}
@@ -65,7 +65,7 @@ class G4InterpolationDriver : public G4RKIntegrationDriver<T>
virtual void OnStartTracking() override;
virtual void OnComputeStep() override;
virtual G4bool DoesReIntegrate() override { return false; }
virtual G4bool DoesReIntegrate() const override { return false; }
// Interpolation driver does not recalculate when AccurateAdvance is called
// -- reintegration would require other calls
@@ -80,6 +80,8 @@ class G4InterpolationDriver : public G4RKIntegrationDriver<T>
virtual void SetVerboseLevel(G4int level) override;
virtual G4int GetVerboseLevel() const override;
virtual void StreamInfo( std::ostream& os ) const override;
private:
struct InterpStepper
@@ -388,7 +388,9 @@ G4double G4InterpolationDriver<T>::CalcChordStep(G4double stepTrialOld,
template <class T>
G4bool G4InterpolationDriver<T>::
AccurateAdvance(G4FieldTrack& track, G4double hstep,
G4double /*eps*/, G4double /*hinitial*/)
G4double /*eps*/,
G4double /*hinitial*/
)
{
if (hstep == 0.0)
{
@@ -574,3 +576,24 @@ void G4InterpolationDriver<T>::AccumulateStatistics(G4int noTrials)
}
}
template <class T>
void G4InterpolationDriver<T>::StreamInfo( std::ostream& os ) const
{
os << "State of G4InterpolationDriver: " << std::endl;
os << "--Base state (G4RKIntegrationDriver): " << std::endl;
Base::StreamInfo( os );
os << " fMinimumStep = " << fMinimumStep << std::endl;
// os << " Max number of Steps = " << fMaxNoSteps << std::endl;
// os << " Safety factor = " << safety << std::endl;
// os << " Power - shrink = " << pshrnk << std::endl;
// os << " Power - grow = " << pgrow << std::endl;
// os << " threshold - shrink = " << errorConstraintShrink << std::endl;
// os << " threshold - grow = " << errorConstraintGrow << std::endl;
os << " Max num of Trials = " << fMaxTrials << std::endl;
os << " Fract Next Estimate = " << fFractionNextEstimate << std::endl;
os << " Smallest Curve Fract= " << fSmallestCurveFraction << std::endl;
os << " VerboseLevel = " << fVerboseLevel << std::endl;
os << " KeepLastStepper = " << fKeepLastStepper << std::endl;
}
@@ -63,7 +63,7 @@ class G4MagInt_Driver : public G4VIntegrationDriver,
inline virtual void OnStartTracking() override;
inline virtual void OnComputeStep() override {};
virtual G4bool DoesReIntegrate() override { return true; }
virtual G4bool DoesReIntegrate() const override { return true; }
virtual G4bool AccurateAdvance(G4FieldTrack& y_current,
G4double hstep,
@@ -82,6 +82,9 @@ class G4MagInt_Driver : public G4VIntegrationDriver,
G4double& dyerr) override;
// QuickAdvance just tries one Step - it does not ensure accuracy.
void StreamInfo( std::ostream& os ) const override;
// Write out the parameters / state of the driver
G4bool QuickAdvance(G4FieldTrack& y_posvel, // INOUT
const G4double dydx[],
G4double hstep, // IN
@@ -146,9 +149,18 @@ class G4MagInt_Driver : public G4VIntegrationDriver,
G4double hstepCurrent) override;
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Do not limit the next step's size within a factor of the
// current one.
// Does it limit the next step's size within a factor of the current?
// -- DOES NOT limit for very bad steps
// -- DOES limit for very good (x5)
G4double
ComputeNewStepSize_WithoutReductionLimit(G4double errMaxNorm,
G4double hstepCurrent);
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Do not limit the next step's size within a factor of the
// current one when *reducing* the size, i.e. for badly failing steps.
G4double ComputeNewStepSize_WithinLimits(G4double errMaxNorm, // normalised
G4double hstepCurrent);
// Taking the last step's normalised error, calculate
@@ -55,7 +55,8 @@ class G4NystromRK4 : public G4MagIntegratorStepper
G4NystromRK4(G4Mag_EqRhs* EquationMotion,
G4double distanceConstField = 0.0);
// Can be used only for Magnetic Fields - and for 6 variables (x,p)
~G4NystromRK4() {}
virtual void Stepper(const G4double y[],
const G4double dydx[],
G4double hstep,
@@ -0,0 +1,268 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4OldMagIntDriver
//
// Class description:
//
// Provides a driver that talks to the Integrator Stepper, and insures that
// the error is within acceptable bounds.
// V.Grichine, 07.10.1996 - Created
// W.Wander, 28.01.1998 - Added ability for low order integrators
// J.Apostolakis, 08.11.2001 - Respect minimum step in AccurateAdvance
// --------------------------------------------------------------------
#ifndef G4OLD_MAGINT_DRIVER_HH
#define G4OLD_MAGINT_DRIVER_HH
#include "G4VIntegrationDriver.hh"
#include "G4MagIntegratorStepper.hh"
#include "G4ChordFinderDelegate.hh"
class G4OldMagIntDriver : public G4VIntegrationDriver,
public G4ChordFinderDelegate<G4OldMagIntDriver>
{
public: // with description
G4OldMagIntDriver(G4double hminimum,
G4MagIntegratorStepper* pItsStepper,
G4int numberOfComponents = 6,
G4int statisticsVerbosity = 0);
virtual ~G4OldMagIntDriver() override;
// Constructor, destructor.
G4OldMagIntDriver(const G4OldMagIntDriver&) = delete;
G4OldMagIntDriver& operator=(const G4OldMagIntDriver&) = delete;
inline virtual G4double AdvanceChordLimited(G4FieldTrack& track,
G4double stepMax,
G4double epsStep,
G4double chordDistance) override;
inline virtual void OnStartTracking() override;
inline virtual void OnComputeStep() override {};
virtual G4bool DoesReIntegrate() const override { return true; }
virtual G4bool AccurateAdvance(G4FieldTrack& y_current,
G4double hstep,
G4double eps, // Requested y_err/hstep
G4double hinitial = 0.0) override;
// Above drivers for integrator (Runge-Kutta) with stepsize control.
// Integrates ODE starting values y_current
// from current s (s=s0) to s=s0+h with accuracy eps.
// On output ystart is replaced by value at end of interval.
// The concept is similar to the odeint routine from NRC p.721-722.
virtual G4bool QuickAdvance(G4FieldTrack& y_val, // INOUT
const G4double dydx[],
G4double hstep,
G4double& dchord_step,
G4double& dyerr) override;
// QuickAdvance just tries one Step - it does not ensure accuracy.
G4bool QuickAdvance(G4FieldTrack& y_posvel, // INOUT
const G4double dydx[],
G4double hstep, // IN
G4double& dchord_step,
G4double& dyerr_pos_sq,
G4double& dyerr_mom_rel_sq );
// New QuickAdvance that also just tries one Step
// (so also does not ensure accuracy)
// but does return the errors in position and
// momentum (normalised: Delta_Integration(p^2)/(p^2) )
inline G4double GetHmin() const;
inline G4double Hmin() const; // Obsolete
inline G4double GetSafety() const;
inline G4double GetPshrnk() const;
inline G4double GetPgrow() const;
inline G4double GetErrcon() const;
virtual void GetDerivatives(const G4FieldTrack& y_curr, // INput
G4double dydx[]) const override; // OUTput
virtual void GetDerivatives(const G4FieldTrack& track,
G4double dydx[],
G4double field[]) const override;
// Accessors
virtual G4EquationOfMotion* GetEquationOfMotion() override;
virtual void SetEquationOfMotion(G4EquationOfMotion* equation) override;
virtual void RenewStepperAndAdjust(G4MagIntegratorStepper* pItsStepper) override;
// Sets a new stepper pItsStepper for this driver. Then it calls
// ReSetParameters to reset its parameters accordingly.
inline void ReSetParameters(G4double new_safety = 0.9);
// i) sets the exponents (pgrow & pshrnk),
// using the current Stepper's order,
// ii) sets the safety
// ii) calculates "errcon" according to the above values.
inline void SetSafety(G4double valS);
inline void SetPshrnk(G4double valPs);
inline void SetPgrow (G4double valPg);
inline void SetErrcon(G4double valEc);
// When setting safety or pgrow, errcon will be set to a compatible value.
inline G4double ComputeAndSetErrcon();
virtual const G4MagIntegratorStepper* GetStepper() const override;
virtual G4MagIntegratorStepper* GetStepper() override;
void OneGoodStep(G4double ystart[], // Like old RKF45step()
const G4double dydx[],
G4double& x,
G4double htry,
G4double eps, // memb variables ?
G4double& hdid,
G4double& hnext ) ;
// This takes one Step that is as large as possible while
// satisfying the accuracy criterion of:
// yerr < eps * |y_end-y_start|
virtual G4double ComputeNewStepSize(G4double errMaxNorm, // normalised
G4double hstepCurrent) override;
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Do not limit the next step's size within a factor of the
// current one.
void StreamInfo( std::ostream& os ) const override;
G4double ComputeNewStepSize_WithinLimits(G4double errMaxNorm, // normalised
G4double hstepCurrent);
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Limit the next step's size within a range around the current one.
inline G4int GetMaxNoSteps() const;
inline void SetMaxNoSteps(G4int val);
// Modify and Get the Maximum number of Steps that can be
// taken for the integration of a single segment -
// (i.e. a single call to AccurateAdvance).
public: // without description
inline void SetHmin(G4double newval);
virtual void SetVerboseLevel(G4int newLevel) override;
virtual G4int GetVerboseLevel() const override;
inline G4double GetSmallestFraction() const;
void SetSmallestFraction( G4double val );
protected: // without description
void WarnSmallStepSize(G4double hnext, G4double hstep,
G4double h, G4double xDone,
G4int noSteps);
void WarnTooManyStep(G4double x1start, G4double x2end, G4double xCurrent);
void WarnEndPointTooFar(G4double endPointDist,
G4double hStepSize ,
G4double epsilonRelative,
G4int debugFlag);
// Issue warnings for undesirable situations
void PrintStatus(const G4double* StartArr,
G4double xstart,
const G4double* CurrentArr,
G4double xcurrent,
G4double requestStep,
G4int subStepNo);
void PrintStatus(const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4int subStepNo);
void PrintStat_Aux(const G4FieldTrack& aFieldTrack,
G4double requestStep,
G4double actualStep,
G4int subStepNo,
G4double subStepSize,
G4double dotVelocities);
// Verbose output for debugging
void PrintStatisticsReport();
// Report on the number of steps, maximum errors etc.
#ifdef QUICK_ADV_TWO
G4bool QuickAdvance( G4double yarrin[], // In
const G4double dydx[],
G4double hstep,
G4double yarrout[], // Out
G4double& dchord_step, // Out
G4double& dyerr ); // in length
#endif
private:
// ---------------------------------------------------------------
// INVARIANTS
G4double fMinimumStep = 0.0;
// Minimum Step allowed in a Step (in absolute units)
G4double fSmallestFraction = 1.0e-12; // Expected range 1e-12 to 5e-15
// Smallest fraction of (existing) curve length - in relative units
// below this fraction the current step will be the last
const G4int fNoIntegrationVariables = 0; // Variables in integration
const G4int fMinNoVars = 12; // Minimum number for FieldTrack
const G4int fNoVars = 0; // Full number of variable
G4int fMaxNoSteps;
G4int fMaxStepBase = 250; // was 5000
// Default maximum number of steps is Base divided by the order of Stepper
G4double safety;
G4double pshrnk; // exponent for shrinking
G4double pgrow; // exponent for growth
G4double errcon;
// Parameters used to grow and shrink trial stepsize.
G4int fStatisticsVerboseLevel = 0;
// ---------------------------------------------------------------
// DEPENDENT Objects
G4MagIntegratorStepper* pIntStepper = nullptr;
// ---------------------------------------------------------------
// STATE
unsigned long fNoTotalSteps=0, fNoBadSteps=0;
unsigned long fNoSmallSteps=0, fNoInitialSmallSteps=0, fNoCalls=0;
G4double fDyerr_max=0.0, fDyerr_mx2=0.0;
G4double fDyerrPos_smTot=0.0, fDyerrPos_lgTot=0.0, fDyerrVel_lgTot=0.0;
G4double fSumH_sm=0.0, fSumH_lg=0.0;
// Step Statistics
G4int fVerboseLevel = 0; // Verbosity level for printing (debug, ..)
// Could be varied during tracking - to help identify issues
using ChordFinderDelegate = G4ChordFinderDelegate<G4OldMagIntDriver>;
};
#include "G4OldMagIntDriver.icc"
#endif
@@ -0,0 +1,152 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4OldMagIntDriver inline methods implementation
//
// V.Grichine, 07.10.1996 - Created
// --------------------------------------------------------------------
inline
G4double G4OldMagIntDriver::
AdvanceChordLimited(G4FieldTrack& track, G4double stepMax,
G4double epsStep, G4double chordDistance)
{
return ChordFinderDelegate::AdvanceChordLimitedImpl(track, stepMax,
epsStep, chordDistance);
}
inline
void G4OldMagIntDriver::OnStartTracking()
{
ChordFinderDelegate::ResetStepEstimate();
}
inline
G4double G4OldMagIntDriver::GetHmin() const
{
return fMinimumStep;
}
inline
G4double G4OldMagIntDriver::Hmin() const
{
return fMinimumStep;
}
inline
G4double G4OldMagIntDriver::GetSafety() const
{
return safety;
}
inline
G4double G4OldMagIntDriver::GetPshrnk() const
{
return pshrnk;
}
inline
G4double G4OldMagIntDriver::GetPgrow() const
{
return pgrow;
}
inline
G4double G4OldMagIntDriver::GetErrcon() const
{
return errcon;
}
inline
void G4OldMagIntDriver::SetHmin(G4double newval)
{
fMinimumStep = newval;
}
inline
G4double G4OldMagIntDriver::ComputeAndSetErrcon()
{
errcon = std::pow(max_stepping_increase/GetSafety(),1.0/GetPgrow());
return errcon;
}
inline
void G4OldMagIntDriver::ReSetParameters(G4double new_safety)
{
safety = new_safety;
pshrnk = -1.0 / pIntStepper->IntegratorOrder();
pgrow = -1.0 / (1.0 + pIntStepper->IntegratorOrder());
ComputeAndSetErrcon();
}
inline
void G4OldMagIntDriver::SetSafety(G4double val)
{
safety = val;
ComputeAndSetErrcon();
}
inline
void G4OldMagIntDriver::SetPgrow(G4double val)
{
pgrow = val;
ComputeAndSetErrcon();
}
inline
void G4OldMagIntDriver::SetErrcon(G4double val)
{
errcon = val;
}
inline
G4int G4OldMagIntDriver::GetMaxNoSteps() const
{
return fMaxNoSteps;
}
inline
void G4OldMagIntDriver::SetMaxNoSteps(G4int val)
{
fMaxNoSteps = val;
}
inline
G4int G4OldMagIntDriver::GetVerboseLevel() const
{
return fVerboseLevel;
}
inline
void G4OldMagIntDriver::SetVerboseLevel(G4int newLevel)
{
fVerboseLevel = newLevel;
}
inline
G4double G4OldMagIntDriver::GetSmallestFraction() const
{
return fSmallestFraction;
}
@@ -55,10 +55,10 @@ class G4RKIntegrationDriver : public G4VIntegrationDriver
G4double field[]) const override;
virtual G4double ComputeNewStepSize(G4double errMaxNorm, // normalised error
G4double hstepCurrent) override;
G4double hstepCurrent) override final;
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Do not limit the next step's size within a factor of the current one.
// - Limits the next step's size within a factor of the current one.
virtual G4EquationOfMotion* GetEquationOfMotion() override;
virtual void SetEquationOfMotion(G4EquationOfMotion* equation) override;
@@ -66,6 +66,8 @@ class G4RKIntegrationDriver : public G4VIntegrationDriver
virtual const T* GetStepper() const override;
virtual T* GetStepper() override;
virtual void StreamInfo( std::ostream& os ) const override;
// Accessors.
G4double GetSafety() const;
G4double GetPshrnk() const;
@@ -223,3 +223,15 @@ void G4RKIntegrationDriver<T>::SetEquationOfMotion(G4EquationOfMotion* equation)
{
pIntStepper->SetEquationOfMotion(equation);
}
template <class T>
void G4RKIntegrationDriver<T>::StreamInfo( std::ostream& os ) const
{
os << "State of G4RKIntegrationDriver: " << std::endl;
os << " Max number of Steps = " << fMaxNoSteps << std::endl;
os << " Safety factor = " << safety << std::endl;
os << " Power - shrink = " << pshrnk << std::endl;
os << " Power - grow = " << pgrow << std::endl;
os << " threshold - shrink = " << errorConstraintShrink << std::endl;
os << " threshold - grow = " << errorConstraintGrow << std::endl;
}
@@ -62,7 +62,7 @@ class G4VIntegrationDriver
virtual G4bool AccurateAdvance(G4FieldTrack& track,
G4double hstep,
G4double eps, // Requested y_err/hstep
G4double hinitial = 0) = 0;
G4double hinitial = 0 ) = 0;
virtual void SetEquationOfMotion(G4EquationOfMotion* equation) = 0;
virtual G4EquationOfMotion* GetEquationOfMotion() = 0;
@@ -104,13 +104,19 @@ class G4VIntegrationDriver
G4double hstepCurrent) = 0;
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Do not limit the next step's size within a factor of the current one.
// - Can limit the next step's size within a factor of the current one.
virtual G4bool DoesReIntegrate() = 0;
virtual G4bool DoesReIntegrate() const = 0;
// Whether the driver implementates re-integration
// - original Integration driver will re-start and re-calculate interval => yes
// - Interpolation Driver does not recalculate (it interpolates)
// Basically answer: does this driver *Recalculate* when AccurateAdvance is called ?
virtual void StreamInfo( std::ostream& os ) const = 0;
// Write out the parameters / state of the driver
friend std::ostream& operator<<( std::ostream& os, const G4VIntegrationDriver& id);
protected:
static constexpr G4double max_stepping_increase = 5;
+174 -191
View File
@@ -1,202 +1,185 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4magneticfield
# Package: Geant4.src.G4geometry.G4magneticfield
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
#
# Generated on : 29/9/2010
#
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4magneticfield
HEADERS
G4BFieldIntegrationDriver.hh
G4BogackiShampine23.hh
G4BogackiShampine45.hh
G4BulirschStoer.hh
G4BulirschStoer.icc
G4BulirschStoerDriver.hh
G4BulirschStoerDriver.icc
G4CachedMagneticField.hh
G4CashKarpRKF45.hh
G4ChargeState.hh
G4ChordFinder.hh
G4ChordFinder.icc
G4ChordFinderDelegate.hh
G4ChordFinderDelegate.icc
G4ClassicalRK4.hh
G4ConstRK4.hh
G4DELPHIMagField.hh
G4DoLoMcPriRK34.hh
G4DormandPrince745.hh
G4DormandPrinceRK56.hh
G4DormandPrinceRK78.hh
G4ElectricField.hh
G4ElectroMagneticField.hh
G4EqEMFieldWithEDM.hh
G4EqEMFieldWithSpin.hh
G4EqGravityField.hh
G4EqMagElectricField.hh
G4EquationOfMotion.hh
G4EquationOfMotion.icc
G4ErrorMag_UsualEqRhs.hh
G4ExactHelixStepper.hh
G4ExplicitEuler.hh
G4Field.hh
G4FieldManager.hh
G4FieldManager.icc
G4FieldManagerStore.hh
G4FieldTrack.hh
G4FieldTrack.icc
G4FieldUtils.hh
G4FieldUtils.icc
G4FSALBogackiShampine45.hh
G4FSALDormandPrince745.hh
G4FSALIntegrationDriver.hh
G4FSALIntegrationDriver.icc
G4VFSALIntegrationStepper.hh
G4VFSALIntegrationStepper.icc
G4HarmonicPolMagField.hh
G4HelixExplicitEuler.hh
G4HelixHeum.hh
G4HelixImplicitEuler.hh
G4HelixMixedStepper.hh
G4HelixSimpleRunge.hh
G4ImplicitEuler.hh
G4IntegrationDriver.hh
G4IntegrationDriver.icc
G4InterpolationDriver.hh
G4InterpolationDriver.icc
G4LineCurrentMagField.hh
G4LineSection.hh
G4MagErrorStepper.hh
G4MagErrorStepper.icc
G4MagHelicalStepper.hh
G4MagHelicalStepper.icc
G4MagIntegratorDriver.hh
G4MagIntegratorDriver.icc
G4MagIntegratorStepper.hh
G4MagIntegratorStepper.icc
G4Mag_EqRhs.hh
G4Mag_SpinEqRhs.hh
G4Mag_UsualEqRhs.hh
G4ModifiedMidpoint.hh
G4ModifiedMidpoint.icc
G4MonopoleEq.hh
G4MagneticField.hh
G4NystromRK4.hh
G4NystromRK4.icc
G4QuadrupoleMagField.hh
G4RepleteEofM.hh
G4SextupoleMagField.hh
G4RKG3_Stepper.hh
G4RK547FEq1.hh
G4RK547FEq2.hh
G4RK547FEq3.hh
G4RKIntegrationDriver.hh
G4RKIntegrationDriver.icc
G4SimpleHeum.hh
G4SimpleRunge.hh
G4TrialsCounter.hh
G4TrialsCounter.icc
G4TsitourasRK45.hh
G4UniformElectricField.hh
G4UniformGravityField.hh
G4UniformMagField.hh
G4VIntegrationDriver.hh
SOURCES
G4BFieldIntegrationDriver.cc
G4BogackiShampine23.cc
G4BogackiShampine45.cc
G4BulirschStoer.cc
G4CachedMagneticField.cc
G4CashKarpRKF45.cc
G4ChargeState.cc
G4ChordFinder.cc
G4ClassicalRK4.cc
G4ConstRK4.cc
G4DELPHIMagField.cc
G4DoLoMcPriRK34.cc
G4DormandPrince745.cc
G4DormandPrinceRK56.cc
G4DormandPrinceRK78.cc
G4ElectricField.cc
G4ElectroMagneticField.cc
G4EqEMFieldWithEDM.cc
G4EqEMFieldWithSpin.cc
G4EqGravityField.cc
G4EqMagElectricField.cc
G4EquationOfMotion.cc
G4ErrorMag_UsualEqRhs.cc
G4ExactHelixStepper.cc
G4ExplicitEuler.cc
G4Field.cc
G4FieldManager.cc
G4FieldManagerStore.cc
G4FieldTrack.cc
G4FieldUtils.cc
G4FSALBogackiShampine45.cc
G4FSALDormandPrince745.cc
G4VFSALIntegrationStepper.cc
G4HarmonicPolMagField.cc
G4HelixExplicitEuler.cc
G4HelixHeum.cc
G4HelixImplicitEuler.cc
G4HelixMixedStepper.cc
G4HelixSimpleRunge.cc
G4ImplicitEuler.cc
G4LineCurrentMagField.cc
G4LineSection.cc
G4MagErrorStepper.cc
G4MagHelicalStepper.cc
G4MagIntegratorDriver.cc
G4MagIntegratorStepper.cc
G4Mag_EqRhs.cc
G4Mag_SpinEqRhs.cc
G4Mag_UsualEqRhs.cc
G4MagneticField.cc
G4ModifiedMidpoint.cc
G4MonopoleEq.cc
G4NystromRK4.cc
G4QuadrupoleMagField.cc
G4RepleteEofM.cc
G4SextupoleMagField.cc
G4RKG3_Stepper.cc
G4RK547FEq1.cc
G4RK547FEq2.cc
G4RK547FEq3.cc
G4SimpleHeum.cc
G4SimpleRunge.cc
G4TrialsCounter.cc
G4TsitourasRK45.cc
G4UniformElectricField.cc
G4UniformGravityField.cc
G4UniformMagField.cc
G4VIntegrationDriver.cc
GRANULAR_DEPENDENCIES
G4globman
GLOBAL_DEPENDENCIES
G4global
LINK_LIBRARIES
geant4_define_module(NAME G4magneticfield
HEADERS
G4BFieldIntegrationDriver.hh
G4BogackiShampine23.hh
G4BogackiShampine45.hh
G4BulirschStoer.hh
G4BulirschStoer.icc
G4BulirschStoerDriver.hh
G4BulirschStoerDriver.icc
G4CachedMagneticField.hh
G4CashKarpRKF45.hh
G4ChargeState.hh
G4ChordFinder.hh
G4ChordFinder.icc
G4ChordFinderDelegate.hh
G4ChordFinderDelegate.icc
G4ClassicalRK4.hh
G4ConstRK4.hh
G4DELPHIMagField.hh
G4DoLoMcPriRK34.hh
G4DormandPrince745.hh
G4DormandPrinceRK56.hh
G4DormandPrinceRK78.hh
G4DriverReporter.hh
G4ElectricField.hh
G4ElectroMagneticField.hh
G4EqEMFieldWithEDM.hh
G4EqEMFieldWithSpin.hh
G4EqGravityField.hh
G4EqMagElectricField.hh
G4EquationOfMotion.hh
G4EquationOfMotion.icc
G4ErrorMag_UsualEqRhs.hh
G4ExactHelixStepper.hh
G4ExplicitEuler.hh
G4Field.hh
G4FieldManager.hh
G4FieldManager.icc
G4FieldManagerStore.hh
G4FieldTrack.hh
G4FieldTrack.icc
G4FieldUtils.hh
G4FieldUtils.icc
G4FSALBogackiShampine45.hh
G4FSALDormandPrince745.hh
G4FSALIntegrationDriver.hh
G4FSALIntegrationDriver.icc
G4VFSALIntegrationStepper.hh
G4VFSALIntegrationStepper.icc
G4HarmonicPolMagField.hh
G4HelixExplicitEuler.hh
G4HelixHeum.hh
G4HelixImplicitEuler.hh
G4HelixMixedStepper.hh
G4HelixSimpleRunge.hh
G4ImplicitEuler.hh
G4IntegrationDriver.hh
G4IntegrationDriver.icc
G4InterpolationDriver.hh
G4InterpolationDriver.icc
G4LineCurrentMagField.hh
G4LineSection.hh
G4MagErrorStepper.hh
G4MagErrorStepper.icc
G4MagHelicalStepper.hh
G4MagHelicalStepper.icc
G4MagIntegratorDriver.hh
G4MagIntegratorDriver.icc
G4MagIntegratorStepper.hh
G4MagIntegratorStepper.icc
G4Mag_EqRhs.hh
G4Mag_SpinEqRhs.hh
G4Mag_UsualEqRhs.hh
G4ModifiedMidpoint.hh
G4ModifiedMidpoint.icc
G4MonopoleEq.hh
G4MagneticField.hh
G4NystromRK4.hh
G4NystromRK4.icc
G4OldMagIntDriver.hh
G4OldMagIntDriver.icc
G4QuadrupoleMagField.hh
G4RepleteEofM.hh
G4SextupoleMagField.hh
G4RKG3_Stepper.hh
G4RK547FEq1.hh
G4RK547FEq2.hh
G4RK547FEq3.hh
G4RKIntegrationDriver.hh
G4RKIntegrationDriver.icc
G4SimpleHeum.hh
G4SimpleRunge.hh
G4TrialsCounter.hh
G4TrialsCounter.icc
G4TsitourasRK45.hh
G4UniformElectricField.hh
G4UniformGravityField.hh
G4UniformMagField.hh
G4VIntegrationDriver.hh
SOURCES
G4BFieldIntegrationDriver.cc
G4BogackiShampine23.cc
G4BogackiShampine45.cc
G4BulirschStoer.cc
G4CachedMagneticField.cc
G4CashKarpRKF45.cc
G4ChargeState.cc
G4ChordFinder.cc
G4ClassicalRK4.cc
G4ConstRK4.cc
G4DELPHIMagField.cc
G4DoLoMcPriRK34.cc
G4DormandPrince745.cc
G4DormandPrinceRK56.cc
G4DormandPrinceRK78.cc
G4DriverReporter.cc
G4ElectricField.cc
G4ElectroMagneticField.cc
G4EqEMFieldWithEDM.cc
G4EqEMFieldWithSpin.cc
G4EqGravityField.cc
G4EqMagElectricField.cc
G4EquationOfMotion.cc
G4ErrorMag_UsualEqRhs.cc
G4ExactHelixStepper.cc
G4ExplicitEuler.cc
G4Field.cc
G4FieldManager.cc
G4FieldManagerStore.cc
G4FieldTrack.cc
G4FieldUtils.cc
G4FSALBogackiShampine45.cc
G4FSALDormandPrince745.cc
G4VFSALIntegrationStepper.cc
G4HarmonicPolMagField.cc
G4HelixExplicitEuler.cc
G4HelixHeum.cc
G4HelixImplicitEuler.cc
G4HelixMixedStepper.cc
G4HelixSimpleRunge.cc
G4ImplicitEuler.cc
G4LineCurrentMagField.cc
G4LineSection.cc
G4MagErrorStepper.cc
G4MagHelicalStepper.cc
G4MagIntegratorDriver.cc
G4MagIntegratorStepper.cc
G4Mag_EqRhs.cc
G4Mag_SpinEqRhs.cc
G4Mag_UsualEqRhs.cc
G4MagneticField.cc
G4ModifiedMidpoint.cc
G4MonopoleEq.cc
G4NystromRK4.cc
G4OldMagIntDriver.cc
G4QuadrupoleMagField.cc
G4RepleteEofM.cc
G4SextupoleMagField.cc
G4RKG3_Stepper.cc
G4RK547FEq1.cc
G4RK547FEq2.cc
G4RK547FEq3.cc
G4SimpleHeum.cc
G4SimpleRunge.cc
G4TrialsCounter.cc
G4TsitourasRK45.cc
G4UniformElectricField.cc
G4UniformGravityField.cc
G4UniformMagField.cc
G4VIntegrationDriver.cc
GRANULAR_DEPENDENCIES
G4globman
GLOBAL_DEPENDENCIES
G4global
)
# List any source specific properties here
@@ -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;
}