Geant4-11
Public Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes
G4BFieldIntegrationDriver Class Reference

#include <G4BFieldIntegrationDriver.hh>

Inheritance diagram for G4BFieldIntegrationDriver:
G4VIntegrationDriver

Public Member Functions

virtual G4bool AccurateAdvance (G4FieldTrack &track, G4double hstep, G4double eps, G4double hinitial=0) override
 
virtual G4double AdvanceChordLimited (G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance) override
 
virtual G4double ComputeNewStepSize (G4double errMaxNorm, G4double hstepCurrent) override
 
virtual G4bool DoesReIntegrate () const override
 
 G4BFieldIntegrationDriver (const G4BFieldIntegrationDriver &)=delete
 
 G4BFieldIntegrationDriver (std::unique_ptr< G4VIntegrationDriver > smallStepDriver, std::unique_ptr< G4VIntegrationDriver > largeStepDriver)
 
virtual void GetDerivatives (const G4FieldTrack &track, G4double dydx[]) const override
 
virtual void GetDerivatives (const G4FieldTrack &track, G4double dydx[], G4double field[]) const override
 
virtual G4EquationOfMotionGetEquationOfMotion () override
 
virtual const G4MagIntegratorStepperGetStepper () const override
 
virtual G4MagIntegratorStepperGetStepper () override
 
virtual G4int GetVerboseLevel () const override
 
virtual void OnComputeStep () override
 
virtual void OnStartTracking () override
 
const G4BFieldIntegrationDriveroperator= (const G4BFieldIntegrationDriver &)=delete
 
void PrintStatistics () const
 
virtual G4bool QuickAdvance (G4FieldTrack &, const G4double[], G4double, G4double &, G4double &)
 
virtual void RenewStepperAndAdjust (G4MagIntegratorStepper *pItsStepper)
 
virtual void SetEquationOfMotion (G4EquationOfMotion *equation) override
 
virtual void SetVerboseLevel (G4int level) override
 
virtual void StreamInfo (std::ostream &os) const override
 

Static Protected Attributes

static constexpr G4double max_stepping_decrease = 0.1
 
static constexpr G4double max_stepping_increase = 5
 

Private Member Functions

G4double CurvatureRadius (const G4FieldTrack &track) const
 
void GetFieldValue (const G4FieldTrack &track, G4double Field[]) const
 

Private Attributes

G4VIntegrationDriverfCurrDriver = nullptr
 
G4Mag_EqRhsfEquation = nullptr
 
G4int fLargeDriverSteps = 0
 
std::unique_ptr< G4VIntegrationDriverfLargeStepDriver
 
G4int fSmallDriverSteps = 0
 
std::unique_ptr< G4VIntegrationDriverfSmallStepDriver
 

Detailed Description

Definition at line 42 of file G4BFieldIntegrationDriver.hh.

Constructor & Destructor Documentation

◆ G4BFieldIntegrationDriver() [1/2]

G4BFieldIntegrationDriver::G4BFieldIntegrationDriver ( std::unique_ptr< G4VIntegrationDriver smallStepDriver,
std::unique_ptr< G4VIntegrationDriver largeStepDriver 
)

Definition at line 62 of file G4BFieldIntegrationDriver.cc.

65 : fSmallStepDriver(std::move(smallStepDriver)),
66 fLargeStepDriver(std::move(largeStepDriver)),
69{
70 if (fSmallStepDriver->GetEquationOfMotion()
71 != fLargeStepDriver->GetEquationOfMotion())
72 {
73 G4Exception("G4BFieldIntegrationDriver Constructor:",
74 "GeomField1001", FatalException, "different EoM");
75 }
76}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::unique_ptr< G4VIntegrationDriver > fSmallStepDriver
std::unique_ptr< G4VIntegrationDriver > fLargeStepDriver
virtual G4EquationOfMotion * GetEquationOfMotion()=0
G4Mag_EqRhs * toMagneticEquation(G4EquationOfMotion *equation)

References FatalException, fLargeStepDriver, fSmallStepDriver, and G4Exception().

◆ G4BFieldIntegrationDriver() [2/2]

G4BFieldIntegrationDriver::G4BFieldIntegrationDriver ( const G4BFieldIntegrationDriver )
delete

Member Function Documentation

◆ AccurateAdvance()

virtual G4bool G4BFieldIntegrationDriver::AccurateAdvance ( G4FieldTrack track,
G4double  hstep,
G4double  eps,
G4double  hinitial = 0 
)
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 58 of file G4BFieldIntegrationDriver.hh.

62 {
63 return fCurrDriver->AccurateAdvance(track, hstep, eps, hinitial);
64 }
static const G4double eps
virtual G4bool AccurateAdvance(G4FieldTrack &track, G4double hstep, G4double eps, G4double hinitial=0)=0

References G4VIntegrationDriver::AccurateAdvance(), eps, and fCurrDriver.

◆ AdvanceChordLimited()

G4double G4BFieldIntegrationDriver::AdvanceChordLimited ( G4FieldTrack track,
G4double  hstep,
G4double  eps,
G4double  chordDistance 
)
overridevirtual

Implements G4VIntegrationDriver.

Definition at line 78 of file G4BFieldIntegrationDriver.cc.

82{
83 const G4double radius = CurvatureRadius(yCurrent);
84
85 G4VIntegrationDriver* driver = nullptr;
86 if (chordDistance < 2 * radius)
87 {
88 stepMax = std::min(stepMax, twopi * radius);
89 driver = fSmallStepDriver.get();
91 } else
92 {
93 driver = fLargeStepDriver.get();
95 }
96
97 if (driver != fCurrDriver)
98 {
99 driver->OnComputeStep();
100 }
101
102 fCurrDriver = driver;
103
104 return fCurrDriver->AdvanceChordLimited(yCurrent, stepMax,
105 epsStep, chordDistance);
106}
static constexpr double twopi
Definition: G4SIunits.hh:56
double G4double
Definition: G4Types.hh:83
G4double CurvatureRadius(const G4FieldTrack &track) const
virtual void OnComputeStep()=0
virtual G4double AdvanceChordLimited(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance)=0
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References G4VIntegrationDriver::AdvanceChordLimited(), CurvatureRadius(), fCurrDriver, fLargeDriverSteps, fLargeStepDriver, fSmallDriverSteps, fSmallStepDriver, G4INCL::Math::min(), G4VIntegrationDriver::OnComputeStep(), and twopi.

◆ ComputeNewStepSize()

virtual G4double G4BFieldIntegrationDriver::ComputeNewStepSize ( G4double  errMaxNorm,
G4double  hstepCurrent 
)
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 104 of file G4BFieldIntegrationDriver.hh.

106 {
107 return fCurrDriver->ComputeNewStepSize(errMaxNorm, hstepCurrent);
108 }
virtual G4double ComputeNewStepSize(G4double errMaxNorm, G4double hstepCurrent)=0

References G4VIntegrationDriver::ComputeNewStepSize(), and fCurrDriver.

◆ CurvatureRadius()

G4double G4BFieldIntegrationDriver::CurvatureRadius ( const G4FieldTrack track) const
private

Definition at line 117 of file G4BFieldIntegrationDriver.cc.

118{
120
121 GetFieldValue(track, field);
122
123 const G4double Bmag2 = field[0] * field[0]
124 + field[1] * field[1]
125 + field[2] * field[2] ;
126 if (Bmag2 == 0.0 )
127 {
128 return DBL_MAX;
129 }
130
131 const G4double momentum2 = track.GetMomentum().mag2();
132 const G4double fCof_inv = eplus / std::abs(fEquation->FCof());
133
134 return std::sqrt(momentum2 / Bmag2) * fCof_inv;
135}
static constexpr double eplus
Definition: G4SIunits.hh:184
double mag2() const
void GetFieldValue(const G4FieldTrack &track, G4double Field[]) const
G4ThreeVector GetMomentum() const
static constexpr G4int MAX_NUMBER_OF_COMPONENTS
Definition: G4Field.hh:92
G4double FCof() const
Definition: G4Mag_EqRhs.hh:62
#define DBL_MAX
Definition: templates.hh:62

References DBL_MAX, eplus, G4Mag_EqRhs::FCof(), fEquation, GetFieldValue(), G4FieldTrack::GetMomentum(), CLHEP::Hep3Vector::mag2(), and G4Field::MAX_NUMBER_OF_COMPONENTS.

Referenced by AdvanceChordLimited().

◆ DoesReIntegrate()

virtual G4bool G4BFieldIntegrationDriver::DoesReIntegrate ( ) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 66 of file G4BFieldIntegrationDriver.hh.

67 {
69 }
virtual G4bool DoesReIntegrate() const =0

References G4VIntegrationDriver::DoesReIntegrate(), and fCurrDriver.

◆ GetDerivatives() [1/2]

virtual void G4BFieldIntegrationDriver::GetDerivatives ( const G4FieldTrack track,
G4double  dydx[] 
) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 72 of file G4BFieldIntegrationDriver.hh.

74 {
75 fCurrDriver->GetDerivatives(track, dydx);
76 }
virtual void GetDerivatives(const G4FieldTrack &track, G4double dydx[]) const =0

References fCurrDriver, and G4VIntegrationDriver::GetDerivatives().

◆ GetDerivatives() [2/2]

virtual void G4BFieldIntegrationDriver::GetDerivatives ( const G4FieldTrack track,
G4double  dydx[],
G4double  field[] 
) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 79 of file G4BFieldIntegrationDriver.hh.

82 {
83 fCurrDriver->GetDerivatives(track, dydx, field);
84 }

References fCurrDriver, and G4VIntegrationDriver::GetDerivatives().

◆ GetEquationOfMotion()

virtual G4EquationOfMotion * G4BFieldIntegrationDriver::GetEquationOfMotion ( )
inlineoverridevirtual

◆ GetFieldValue()

void G4BFieldIntegrationDriver::GetFieldValue ( const G4FieldTrack track,
G4double  Field[] 
) const
private

Definition at line 138 of file G4BFieldIntegrationDriver.cc.

140{
142 G4double positionTime[4]= { pos.x(), pos.y(), pos.z(),
143 track.GetLabTimeOfFlight() } ;
144
145 fEquation->GetFieldValue(positionTime, Field);
146}
static const G4double pos
void GetFieldValue(const G4double Point[4], G4double Field[]) const
G4ThreeVector GetPosition() const
G4double GetLabTimeOfFlight() const

References fEquation, G4EquationOfMotion::GetFieldValue(), G4FieldTrack::GetLabTimeOfFlight(), G4FieldTrack::GetPosition(), and pos.

Referenced by CurvatureRadius().

◆ GetStepper() [1/2]

virtual const G4MagIntegratorStepper * G4BFieldIntegrationDriver::GetStepper ( ) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 94 of file G4BFieldIntegrationDriver.hh.

95 {
96 return fCurrDriver->GetStepper();
97 }
virtual const G4MagIntegratorStepper * GetStepper() const =0

References fCurrDriver, and G4VIntegrationDriver::GetStepper().

◆ GetStepper() [2/2]

virtual G4MagIntegratorStepper * G4BFieldIntegrationDriver::GetStepper ( )
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 99 of file G4BFieldIntegrationDriver.hh.

100 {
101 return fCurrDriver->GetStepper();
102 }

References fCurrDriver, and G4VIntegrationDriver::GetStepper().

◆ GetVerboseLevel()

virtual G4int G4BFieldIntegrationDriver::GetVerboseLevel ( ) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 116 of file G4BFieldIntegrationDriver.hh.

117 {
119 }
virtual G4int GetVerboseLevel() const =0

References fCurrDriver, and G4VIntegrationDriver::GetVerboseLevel().

◆ OnComputeStep()

virtual void G4BFieldIntegrationDriver::OnComputeStep ( )
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 121 of file G4BFieldIntegrationDriver.hh.

122 {
123 fSmallStepDriver->OnComputeStep();
124 fLargeStepDriver->OnComputeStep();
125 }

References fLargeStepDriver, and fSmallStepDriver.

◆ OnStartTracking()

virtual void G4BFieldIntegrationDriver::OnStartTracking ( )
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 127 of file G4BFieldIntegrationDriver.hh.

128 {
129 fSmallStepDriver->OnStartTracking();
130 fLargeStepDriver->OnStartTracking();
131 }

References fLargeStepDriver, and fSmallStepDriver.

◆ operator=()

const G4BFieldIntegrationDriver & G4BFieldIntegrationDriver::operator= ( const G4BFieldIntegrationDriver )
delete

◆ PrintStatistics()

void G4BFieldIntegrationDriver::PrintStatistics ( ) const

Definition at line 148 of file G4BFieldIntegrationDriver.cc.

149{
150 const auto totSteps = fSmallDriverSteps + fLargeDriverSteps;
151 const auto toFraction = [&](double value) { return value / totSteps * 100; };
152
153 G4cout << "============= G4BFieldIntegrationDriver statistics ===========\n"
154 << "total steps " << totSteps << " "
155 << "smallDriverSteps " << toFraction(fSmallDriverSteps) << " "
156 << "largeDriverSteps " << toFraction(fLargeDriverSteps) << "\n"
157 << "======================================\n";
158}
G4GLOB_DLL std::ostream G4cout

References fLargeDriverSteps, fSmallDriverSteps, and G4cout.

◆ QuickAdvance()

virtual G4bool G4VIntegrationDriver::QuickAdvance ( G4FieldTrack ,
const  G4double[],
G4double  ,
G4double ,
G4double  
)
inlinevirtualinherited

◆ RenewStepperAndAdjust()

void G4VIntegrationDriver::RenewStepperAndAdjust ( G4MagIntegratorStepper pItsStepper)
virtualinherited

Reimplemented in G4MagInt_Driver, G4OldMagIntDriver, and G4RKIntegrationDriver< T >.

Definition at line 34 of file G4VIntegrationDriver.cc.

35{
36 G4Exception("G4VIntegrationDriver::RenewStepperAndAdjust",
37 "Geometry001", FatalException,
38 "This method exists only for the original G4MagIntegratorDriver class. "
39 "Not defined for other classes derived from G4VIntegrationDriver");
40}

References FatalException, and G4Exception().

◆ SetEquationOfMotion()

void G4BFieldIntegrationDriver::SetEquationOfMotion ( G4EquationOfMotion equation)
overridevirtual

Implements G4VIntegrationDriver.

Definition at line 109 of file G4BFieldIntegrationDriver.cc.

110{
111 fEquation = toMagneticEquation(equation);
112 fSmallStepDriver->SetEquationOfMotion(equation);
113 fLargeStepDriver->SetEquationOfMotion(equation);
114}

References fEquation, fLargeStepDriver, fSmallStepDriver, and anonymous_namespace{G4BFieldIntegrationDriver.cc}::toMagneticEquation().

◆ SetVerboseLevel()

virtual void G4BFieldIntegrationDriver::SetVerboseLevel ( G4int  level)
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 110 of file G4BFieldIntegrationDriver.hh.

111 {
112 fSmallStepDriver->SetVerboseLevel(level);
113 fLargeStepDriver->SetVerboseLevel(level);
114 }

References fLargeStepDriver, and fSmallStepDriver.

◆ StreamInfo()

virtual void G4BFieldIntegrationDriver::StreamInfo ( std::ostream &  os) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

Definition at line 133 of file G4BFieldIntegrationDriver.hh.

134 {
135 os << "Small Step Driver Info: " << std::endl;
136 fSmallStepDriver->StreamInfo(os);
137 os << "Large Step Driver Info: " << std::endl;
138 fLargeStepDriver->StreamInfo(os);
139 }

References fLargeStepDriver, and fSmallStepDriver.

Field Documentation

◆ fCurrDriver

G4VIntegrationDriver* G4BFieldIntegrationDriver::fCurrDriver = nullptr
private

◆ fEquation

G4Mag_EqRhs* G4BFieldIntegrationDriver::fEquation = nullptr
private

◆ fLargeDriverSteps

G4int G4BFieldIntegrationDriver::fLargeDriverSteps = 0
private

Definition at line 157 of file G4BFieldIntegrationDriver.hh.

Referenced by AdvanceChordLimited(), and PrintStatistics().

◆ fLargeStepDriver

std::unique_ptr<G4VIntegrationDriver> G4BFieldIntegrationDriver::fLargeStepDriver
private

◆ fSmallDriverSteps

G4int G4BFieldIntegrationDriver::fSmallDriverSteps = 0
private

Definition at line 156 of file G4BFieldIntegrationDriver.hh.

Referenced by AdvanceChordLimited(), and PrintStatistics().

◆ fSmallStepDriver

std::unique_ptr<G4VIntegrationDriver> G4BFieldIntegrationDriver::fSmallStepDriver
private

◆ max_stepping_decrease

constexpr G4double G4VIntegrationDriver::max_stepping_decrease = 0.1
staticconstexprprotectedinherited

◆ max_stepping_increase

constexpr G4double G4VIntegrationDriver::max_stepping_increase = 5
staticconstexprprotectedinherited

The documentation for this class was generated from the following files: