Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
field_utils Namespace Reference

Typedefs

using State = G4double[G4FieldTrack::ncompSVEC]
 
template<unsigned int N>
using ShortState = G4double[N]
 

Enumerations

enum class  Value3D { Position = 0 , Momentum = 3 , Spin = 9 }
 
enum class  Value1D { KineticEnergy = 6 , LabTime = 7 , ProperTime = 8 }
 

Functions

template<typename ArrayType >
G4double getValue (const ArrayType &array, Value1D value)
 
template<typename ArrayType >
G4double getValue2 (const ArrayType &array, Value1D value)
 
template<typename ArrayType >
G4double getValue (const ArrayType &array, Value3D value)
 
template<typename ArrayType >
G4double getValue2 (const ArrayType &array, Value3D value)
 
template<typename ArrayType >
G4ThreeVector makeVector (const ArrayType &array, Value3D value)
 
G4double absoluteError (const G4double y[], const G4double yerr[], G4double hstep)
 
G4double relativeError2 (const G4double y[], const G4double yerr[], G4double hstep, G4double errorTolerance)
 
G4double relativeError (const G4double y[], const G4double yerr[], G4double hstep, G4double errorTolerance)
 
template<typename SourceArray , typename TargetArray >
void setValue (const SourceArray &src, Value1D value, TargetArray &trg)
 
template<typename SourceArray , typename TargetArray , typename ... TargetArrays>
void setValue (const SourceArray &src, Value1D value, TargetArray &trg, TargetArrays &... trgs)
 
void copy (G4double dst[], const G4double src[], std::size_t size=G4FieldTrack::ncompSVEC)
 
G4double inverseCurvatureRadius (G4double particleCharge, G4double momentum, G4double BField)
 
template<typename T >
clamp (T value, T lo, T hi)
 

Typedef Documentation

◆ ShortState

template<unsigned int N>
using field_utils::ShortState = G4double[N]

Definition at line 48 of file G4FieldUtils.hh.

◆ State

Enumeration Type Documentation

◆ Value1D

enum class field_utils::Value1D
strong
Enumerator
KineticEnergy 
LabTime 
ProperTime 

Definition at line 57 of file G4FieldUtils.hh.

◆ Value3D

enum class field_utils::Value3D
strong
Enumerator
Position 
Momentum 
Spin 

Definition at line 50 of file G4FieldUtils.hh.

Function Documentation

◆ absoluteError()

G4double field_utils::absoluteError ( const G4double y[],
const G4double yerr[],
G4double hstep )

Definition at line 38 of file G4FieldUtils.cc.

41{
42 const G4double momentum2 = getValue2(y, Value3D::Momentum);
43 const G4double invMomentum2 = 1.0 / momentum2;
44 const G4double positionError2 = getValue2(yError, Value3D::Position);
45 const G4double momentumError2 = getValue2(yError, Value3D::Momentum);
46 const G4double relativeMomentumError2 = momentumError2 * invMomentum2;
47
48 return std::max(std::sqrt(positionError2),
49 std::sqrt(relativeMomentumError2) * hstep);
50}
double G4double
Definition G4Types.hh:83
G4double getValue2(const ArrayType &array, Value1D value)

Referenced by G4BorisDriver::QuickAdvance().

◆ clamp()

template<typename T >
T field_utils::clamp ( T value,
T lo,
T hi )

◆ copy()

◆ getValue() [1/2]

template<typename ArrayType >
G4double field_utils::getValue ( const ArrayType & array,
Value1D value )

Referenced by G4NystromRK4::Stepper().

◆ getValue() [2/2]

template<typename ArrayType >
G4double field_utils::getValue ( const ArrayType & array,
Value3D value )

◆ getValue2() [1/2]

template<typename ArrayType >
G4double field_utils::getValue2 ( const ArrayType & array,
Value1D value )

◆ getValue2() [2/2]

template<typename ArrayType >
G4double field_utils::getValue2 ( const ArrayType & array,
Value3D value )

◆ inverseCurvatureRadius()

G4double field_utils::inverseCurvatureRadius ( G4double particleCharge,
G4double momentum,
G4double BField )

Definition at line 104 of file G4FieldUtils.cc.

107{
108 return -c_light * particleCharge * BField / momentum;
109}

◆ makeVector()

◆ relativeError()

G4double field_utils::relativeError ( const G4double y[],
const G4double yerr[],
G4double hstep,
G4double errorTolerance )

Definition at line 90 of file G4FieldUtils.cc.

94{
95 return std::sqrt(relativeError2(y, yError, h, errorTolerance));
96}
G4double relativeError2(const G4double y[], const G4double yerr[], G4double hstep, G4double errorTolerance)

Referenced by G4BulirschStoer::try_step().

◆ relativeError2()

G4double field_utils::relativeError2 ( const G4double y[],
const G4double yerr[],
G4double hstep,
G4double errorTolerance )

Definition at line 52 of file G4FieldUtils.cc.

56{
57 G4double errmax_sq;
58
59 G4double inv_eps_vel_sq = 1.0 / (eps_rel_max * eps_rel_max);
60 G4double errvel_sq = 0.0; // square of momentum vector difference
61
62 G4double eps_pos = eps_rel_max * h;
63 G4double inv_eps_pos_sq = 1.0 / (eps_pos * eps_pos);
64
65 // Evaluate accuracy
66 //
67 G4double errpos_sq = getValue2(yerr, Value3D::Position);
68 errpos_sq *= inv_eps_pos_sq; // Scale relative to required tolerance
69
70 // Accuracy for momentum
71 //
72 G4double magvel_sq = getValue2(y, Value3D::Momentum);
73 G4double sumerr_sq = getValue2(yerr, Value3D::Momentum);
74 if (magvel_sq > 0.0)
75 {
76 errvel_sq = sumerr_sq / magvel_sq;
77 }
78 else
79 {
80 G4Exception("field_utils::relativeError","Field001",
81 JustWarning, "found case of zero momentum");
82 errvel_sq = sumerr_sq;
83 }
84 errvel_sq *= inv_eps_vel_sq;
85 errmax_sq = std::max(errpos_sq, errvel_sq);
86
87 return errmax_sq;
88}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

Referenced by G4BorisDriver::OneGoodStep(), and relativeError().

◆ setValue() [1/2]

template<typename SourceArray , typename TargetArray >
void field_utils::setValue ( const SourceArray & src,
Value1D value,
TargetArray & trg )

◆ setValue() [2/2]

template<typename SourceArray , typename TargetArray , typename ... TargetArrays>
void field_utils::setValue ( const SourceArray & src,
Value1D value,
TargetArray & trg,
TargetArrays &... trgs )