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

The G4BorisScheme class implements of the Boris algorithm for advancing charged particles in an electromagnetic field. More...

#include <G4BorisScheme.hh>

Public Member Functions

 G4BorisScheme ()=default
 G4BorisScheme (G4EquationOfMotion *equation, G4int nvar=6)
 ~G4BorisScheme ()=default
void DoStep (G4double restMass, G4double charge, const G4double yIn[], G4double yOut[], G4double hstep) const
void StepWithErrorEstimate (const G4double yIn[], G4double restMass, G4double charge, G4double hstep, G4double yOut[], G4double yErr[]) const
void StepWithMidAndErrorEstimate (const G4double yIn[], G4double restMass, G4double charge, G4double hstep, G4double yMid[], G4double yOut[], G4double yErr[]) const
G4EquationOfMotionGetEquationOfMotion () const
G4int GetNumberOfVariables () const

Detailed Description

The G4BorisScheme class implements of the Boris algorithm for advancing charged particles in an electromagnetic field.

Definition at line 49 of file G4BorisScheme.hh.

Constructor & Destructor Documentation

◆ G4BorisScheme() [1/2]

G4BorisScheme::G4BorisScheme ( )
default

Default Constructor.

◆ G4BorisScheme() [2/2]

G4BorisScheme::G4BorisScheme ( G4EquationOfMotion * equation,
G4int nvar = 6 )

Constructor for the equation of motion.

Parameters
[in]equationPointer to the equation of motion algorithm.
[in]nvarThe number of integration variables.

Definition at line 41 of file G4BorisScheme.cc.

42 : fEquation(equation), fnvar(nvar)
43{
44 if (nvar <= 0)
45 {
46 G4Exception("G4BorisScheme::G4BorisScheme()",
47 "GeomField0002", FatalException,
48 "Invalid number of variables; must be greater than zero!");
49 }
50}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

◆ ~G4BorisScheme()

G4BorisScheme::~G4BorisScheme ( )
default

Default Destructor.

Member Function Documentation

◆ DoStep()

void G4BorisScheme::DoStep ( G4double restMass,
G4double charge,
const G4double yIn[],
G4double yOut[],
G4double hstep ) const

Does one step, updating velocity and position.

Parameters
[in]restMassParticle mass.
[in]chargeParticle charge.
[in]yInInitial position.
[out]yOutUpdated position.
[in]hstepProposed step.

Definition at line 52 of file G4BorisScheme.cc.

55{
58
59 // Used the scheme described in the following paper:
60 // https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/153167/eth-5175-01.pdf?sequence=1
61 UpdatePosition(restMass, charge, yIn, yOut1Temp, hstep/2);
62 UpdateVelocity(restMass, charge, yOut1Temp, yOut2Temp, hstep);
63 UpdatePosition(restMass, charge, yOut2Temp, yOut, hstep/2);
64}
double G4double
Definition G4Types.hh:83

Referenced by StepWithMidAndErrorEstimate().

◆ GetEquationOfMotion()

G4EquationOfMotion * G4BorisScheme::GetEquationOfMotion ( ) const
inline

Auxiliary methods returning a pointer to the equation of motion and the number of integration variables.

◆ GetNumberOfVariables()

G4int G4BorisScheme::GetNumberOfVariables ( ) const
inline

◆ StepWithErrorEstimate()

void G4BorisScheme::StepWithErrorEstimate ( const G4double yIn[],
G4double restMass,
G4double charge,
G4double hstep,
G4double yOut[],
G4double yErr[] ) const

Adopts the Boris Scheme Stepping to estimate the integration error. Uses two half-steps (comparing to a full step) to obtain output and error estimate.

Parameters
[in]yInInitial position.
[in]restMassParticle mass.
[in]chargeParticle charge.
[in]hstepProposed step.
[out]yOutUpdated position.
[out]yErrThe estimated error.

Definition at line 166 of file G4BorisScheme.cc.

170{
171 // Use two half-steps (comparing to a full step) to obtain output
172 // and error estimate
173
175 StepWithMidAndErrorEstimate(yIn, restMass, charge, hstep, yMid, yOut, yErr);
176}
void StepWithMidAndErrorEstimate(const G4double yIn[], G4double restMass, G4double charge, G4double hstep, G4double yMid[], G4double yOut[], G4double yErr[]) const

◆ StepWithMidAndErrorEstimate()

void G4BorisScheme::StepWithMidAndErrorEstimate ( const G4double yIn[],
G4double restMass,
G4double charge,
G4double hstep,
G4double yMid[],
G4double yOut[],
G4double yErr[] ) const

Adopts the Boris Scheme Stepping to estimate the integration error. Uses two half-steps (comparing to a full step) to obtain output and error estimate. Same as above, but also returns the mid-point evaluation.

Parameters
[in]yInInitial position.
[in]restMassParticle mass.
[in]chargeParticle charge.
[in]hstepProposed step.
[out]yMidtThe mid-point evaluation.
[out]yOutUpdated position.
[out]yErrThe estimated error.

Definition at line 180 of file G4BorisScheme.cc.

184{
185 G4double halfStep= 0.5*hstep;
187
188 // In a single step
189 DoStep(restMass, charge, yIn, yOutAlt, hstep );
190
191 // Same, and also return mid-point evaluation
192 DoStep(restMass, charge, yIn, yMid, halfStep );
193 DoStep(restMass, charge, yMid, yOut, halfStep );
194
195 for( G4int i = 0; i < fnvar; i++ )
196 {
197 yErr[i] = yOutAlt[i] - yOut[i];
198 }
199}
int G4int
Definition G4Types.hh:85
void DoStep(G4double restMass, G4double charge, const G4double yIn[], G4double yOut[], G4double hstep) const

Referenced by StepWithErrorEstimate().


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