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

#include <G4Mag_SpinEqRhs.hh>

+ Inheritance diagram for G4Mag_SpinEqRhs:

Public Member Functions

 G4Mag_SpinEqRhs (G4MagneticField *MagField)
 
 ~G4Mag_SpinEqRhs ()
 
void SetChargeMomentumMass (G4ChargeState particleCharge, G4double MomentumXc, G4double mass)
 
void EvaluateRhsGivenB (const G4double y[], const G4double B[3], G4double dydx[]) const
 
void SetAnomaly (G4double a)
 
G4double GetAnomaly () const
 
- Public Member Functions inherited from G4Mag_EqRhs
 G4Mag_EqRhs (G4MagneticField *magField)
 
virtual ~G4Mag_EqRhs ()
 
virtual void EvaluateRhsGivenB (const G4double y[], const G4double B[3], G4double dydx[]) const =0
 
G4double FCof () const
 
virtual void SetChargeMomentumMass (G4ChargeState particleCharge, G4double MomentumXc, G4double mass)
 
- Public Member Functions inherited from G4EquationOfMotion
 G4EquationOfMotion (G4Field *Field)
 
virtual ~G4EquationOfMotion ()
 
virtual void EvaluateRhsGivenB (const G4double y[], const G4double B[3], G4double dydx[]) const =0
 
virtual void SetChargeMomentumMass (G4ChargeState particleCharge, G4double MomentumXc, G4double MassXc2)=0
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void EvaluateRhsReturnB (const G4double y[], G4double dydx[], G4double Field[]) const
 
void GetFieldValue (const G4double Point[4], G4double Field[]) const
 
const G4FieldGetFieldObj () const
 
G4FieldGetFieldObj ()
 
void SetFieldObj (G4Field *pField)
 

Detailed Description

Definition at line 45 of file G4Mag_SpinEqRhs.hh.

Constructor & Destructor Documentation

◆ G4Mag_SpinEqRhs()

G4Mag_SpinEqRhs::G4Mag_SpinEqRhs ( G4MagneticField MagField)

Definition at line 37 of file G4Mag_SpinEqRhs.cc.

38 : G4Mag_EqRhs( MagField )
39{
40}

◆ ~G4Mag_SpinEqRhs()

G4Mag_SpinEqRhs::~G4Mag_SpinEqRhs ( )

Definition at line 42 of file G4Mag_SpinEqRhs.cc.

43{
44}

Member Function Documentation

◆ EvaluateRhsGivenB()

void G4Mag_SpinEqRhs::EvaluateRhsGivenB ( const G4double  y[],
const G4double  B[3],
G4double  dydx[] 
) const
virtual

Implements G4Mag_EqRhs.

Definition at line 74 of file G4Mag_SpinEqRhs.cc.

77{
78 G4double momentum_mag_square = sqr(y[3]) + sqr(y[4]) + sqr(y[5]);
79 G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
80 G4double cof = FCof()*inv_momentum_magnitude;
81
82 dydx[0] = y[3] * inv_momentum_magnitude; // (d/ds)x = Vx/V
83 dydx[1] = y[4] * inv_momentum_magnitude; // (d/ds)y = Vy/V
84 dydx[2] = y[5] * inv_momentum_magnitude; // (d/ds)z = Vz/V
85
86 if (charge == 0.)
87 {
88 dydx[3] = 0.;
89 dydx[4] = 0.;
90 dydx[5] = 0.;
91 }
92 else
93 {
94 dydx[3] = cof*(y[4]*B[2] - y[5]*B[1]) ; // Ax = a*(Vy*Bz - Vz*By)
95 dydx[4] = cof*(y[5]*B[0] - y[3]*B[2]) ; // Ay = a*(Vz*Bx - Vx*Bz)
96 dydx[5] = cof*(y[3]*B[1] - y[4]*B[0]) ; // Az = a*(Vx*By - Vy*Bx)
97 }
98
99 G4ThreeVector u(y[3], y[4], y[5]);
100 u *= inv_momentum_magnitude;
101
102 G4ThreeVector BField(B[0],B[1],B[2]);
103
104 G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
105 G4double ucb = (anomaly+1./gamma)/beta;
106
107 // Initialise the values of dydx that we do not update.
108 dydx[6] = dydx[7] = dydx[8] = 0.0;
109
110 G4ThreeVector Spin(y[9],y[10],y[11]);
111
112 G4double pcharge;
113 if (charge == 0.)
114 {
115 pcharge = 1.;
116 }
117 else
118 {
119 pcharge = charge;
120 }
121
122 G4ThreeVector dSpin(0.,0.,0.);
123 if (Spin.mag2() != 0.)
124 {
125 dSpin = pcharge*omegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
126 }
127
128 dydx[9] = dSpin.x();
129 dydx[10] = dSpin.y();
130 dydx[11] = dSpin.z();
131
132 return;
133}
double B(double temperature)
double G4double
Definition: G4Types.hh:83
G4double FCof() const
Definition: G4Mag_EqRhs.hh:62
T sqr(const T &x)
Definition: templates.hh:128

◆ GetAnomaly()

G4double G4Mag_SpinEqRhs::GetAnomaly ( ) const
inline

Definition at line 64 of file G4Mag_SpinEqRhs.hh.

64{ return anomaly; }

◆ SetAnomaly()

void G4Mag_SpinEqRhs::SetAnomaly ( G4double  a)
inline

Definition at line 63 of file G4Mag_SpinEqRhs.hh.

63{ anomaly = a; }

◆ SetChargeMomentumMass()

void G4Mag_SpinEqRhs::SetChargeMomentumMass ( G4ChargeState  particleCharge,
G4double  MomentumXc,
G4double  mass 
)
virtual

Reimplemented from G4Mag_EqRhs.

Definition at line 47 of file G4Mag_SpinEqRhs.cc.

50{
51 G4Mag_EqRhs::SetChargeMomentumMass( particleCharge, MomentumXc, mass);
52
53 charge = particleCharge.GetCharge();
54 mass = particleMass;
55 magMoment = particleCharge.GetMagneticDipoleMoment();
56 spin = particleCharge.GetSpin();
57
58 omegac = (eplus/mass)*c_light;
59
60 G4double muB = 0.5*eplus*hbar_Planck/(mass/c_squared);
61
62 G4double g_BMT;
63 if ( spin != 0. ) g_BMT = (std::abs(magMoment)/muB)/spin;
64 else g_BMT = 2.;
65
66 anomaly = (g_BMT - 2.)/2.;
67
68 G4double E = std::sqrt(sqr(MomentumXc)+sqr(mass));
69 beta = MomentumXc/E;
70 gamma = E/mass;
71}
G4double GetCharge() const
G4double GetMagneticDipoleMoment() const
G4double GetSpin() const
virtual void SetChargeMomentumMass(G4ChargeState particleCharge, G4double MomentumXc, G4double mass)
Definition: G4Mag_EqRhs.cc:49

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