Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BFieldIntegrationDriver Class Reference

G4BFieldIntegrationDriver is specialised integration driver for pure magnetic field. More...

#include <G4BFieldIntegrationDriver.hh>

Inheritance diagram for G4BFieldIntegrationDriver:

Public Member Functions

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

Additional Inherited Members

Static Protected Attributes inherited from G4VIntegrationDriver
static constexpr G4double max_stepping_increase = 5
static constexpr G4double max_stepping_decrease = 0.1

Detailed Description

G4BFieldIntegrationDriver is specialised integration driver for pure magnetic field.

Definition at line 48 of file G4BFieldIntegrationDriver.hh.

Constructor & Destructor Documentation

◆ G4BFieldIntegrationDriver() [1/2]

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

Constructor for the integrator driver.

Parameters
[in]smallStepDriverPointer to driver for small steps.
[in]largeStepDriverPointer to driver for large steps.

Definition at line 61 of file G4BFieldIntegrationDriver.cc.

64 : fSmallStepDriver(std::move(smallStepDriver)),
65 fLargeStepDriver(std::move(largeStepDriver)),
66 fCurrDriver(fSmallStepDriver.get()),
67 fEquation(toMagneticEquation(fCurrDriver->GetEquationOfMotion()))
68{
69 if (fSmallStepDriver->GetEquationOfMotion()
70 != fLargeStepDriver->GetEquationOfMotion())
71 {
72 G4Exception("G4BFieldIntegrationDriver Constructor:",
73 "GeomField1001", FatalException, "different EoM");
74 }
75}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

Referenced by G4BFieldIntegrationDriver(), and operator=().

◆ ~G4BFieldIntegrationDriver()

G4BFieldIntegrationDriver::~G4BFieldIntegrationDriver ( )
overridedefault

Default Destructor.

◆ G4BFieldIntegrationDriver() [2/2]

G4BFieldIntegrationDriver::G4BFieldIntegrationDriver ( const G4BFieldIntegrationDriver & )
delete

Copy constructor and assignment operator not allowed.

Member Function Documentation

◆ AccurateAdvance()

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

Integrates ODE from current s (s=s0) to s=s0+h with accuracy eps.

Parameters
[in,out]trackThe current track in field.
[in]hstepProposed step length.
[in]epsRequested accuracy, y_err/hstep.
[in]hinitialInitial minimum integration step.
Returns
true if integration succeeds.

Implements G4VIntegrationDriver.

◆ AdvanceChordLimited()

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

Computes the step to take, based on chord limits.

Parameters
[in,out]trackThe current track in field.
[in]hstepProposed step length.
[in]epsRequested accuracy, y_err/hstep.
[in]chordDistanceMaximum sagitta distance.
Returns
The length of step taken.

Implements G4VIntegrationDriver.

Definition at line 77 of file G4BFieldIntegrationDriver.cc.

81{
82 const G4double radius = CurvatureRadius(yCurrent);
83
84 G4VIntegrationDriver* driver = nullptr;
85 if (chordDistance < 2 * radius)
86 {
87 stepMax = std::min(stepMax, twopi * radius);
88 driver = fSmallStepDriver.get();
89 ++fSmallDriverSteps;
90 }
91 else
92 {
93 driver = fLargeStepDriver.get();
94 ++fLargeDriverSteps;
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}
double G4double
Definition G4Types.hh:83
virtual G4double AdvanceChordLimited(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance)=0
virtual void OnComputeStep(const G4FieldTrack *=nullptr)=0

◆ ComputeNewStepSize()

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

Computes a step size for the next step, taking the last step's normalised error 'errMaxNorm'.

Parameters
[in]errMaxNormThe normalised error on last step.
[in]hstepCurrentThe current proposed step.
Returns
The step size for the next step.

Implements G4VIntegrationDriver.

◆ DoesReIntegrate()

G4bool G4BFieldIntegrationDriver::DoesReIntegrate ( ) const
inlineoverridevirtual

Checks whether the driver implements re-integration.

Returns
true if driver Recalculates when AccurateAdvance() is called.

Implements G4VIntegrationDriver.

◆ GetDerivatives() [1/2]

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

[[deprecated("will be removed")]]

Implements G4VIntegrationDriver.

◆ GetDerivatives() [2/2]

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

[[deprecated("will be removed")]]

Implements G4VIntegrationDriver.

◆ GetEquationOfMotion()

G4EquationOfMotion * G4BFieldIntegrationDriver::GetEquationOfMotion ( )
inlineoverridevirtual

◆ GetStepper() [1/2]

const G4MagIntegratorStepper * G4BFieldIntegrationDriver::GetStepper ( ) const
inlineoverridevirtual

[[deprecated("use GetEquationOfMotion() instead of GetStepper()->GetEquationOfMotion()")]]

Implements G4VIntegrationDriver.

◆ GetStepper() [2/2]

G4MagIntegratorStepper * G4BFieldIntegrationDriver::GetStepper ( )
inlineoverridevirtual

Returns a pointer to the integrator stepper.

Implements G4VIntegrationDriver.

◆ GetVerboseLevel()

G4int G4BFieldIntegrationDriver::GetVerboseLevel ( ) const
inlineoverridevirtual

Implements G4VIntegrationDriver.

◆ OnComputeStep()

void G4BFieldIntegrationDriver::OnComputeStep ( const G4FieldTrack * track)
inlineoverridevirtual

Dispatch interface method for computing step.

Implements G4VIntegrationDriver.

◆ OnStartTracking()

void G4BFieldIntegrationDriver::OnStartTracking ( )
inlineoverridevirtual

Dispatch interface method for initialisation/reset of driver.

Implements G4VIntegrationDriver.

◆ operator=()

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

◆ PrintStatistics()

void G4BFieldIntegrationDriver::PrintStatistics ( ) const

Prints out statistics of the integrator driver.

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

◆ SetEquationOfMotion()

void G4BFieldIntegrationDriver::SetEquationOfMotion ( G4EquationOfMotion * equation)
overridevirtual

Setter and getter for the equation of motion.

Implements G4VIntegrationDriver.

Definition at line 109 of file G4BFieldIntegrationDriver.cc.

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

◆ SetVerboseLevel()

void G4BFieldIntegrationDriver::SetVerboseLevel ( G4int level)
inlineoverridevirtual

Setter and getter for verbosity.

Implements G4VIntegrationDriver.

◆ StreamInfo()

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

Writes out to stream the parameters/state of the driver.

Implements G4VIntegrationDriver.


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