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

G4Mag_SpinEqRhs defines the equation of motion for a particle with spin in a pure magnetic field. The three components of the particle's spin are treated utilising BMT equation. More...

#include <G4Mag_SpinEqRhs.hh>

Inheritance diagram for G4Mag_SpinEqRhs:

Public Member Functions

 G4Mag_SpinEqRhs (G4MagneticField *MagField)
 ~G4Mag_SpinEqRhs () override=default
void SetChargeMomentumMass (G4ChargeState particleCharge, G4double MomentumXc, G4double mass) override
void EvaluateRhsGivenB (const G4double y[], const G4double B[3], G4double dydx[]) const override
void SetAnomaly (G4double a)
G4double GetAnomaly () const
G4EquationType GetEquationType () const override
Public Member Functions inherited from G4Mag_EqRhs
 G4Mag_EqRhs (G4MagneticField *magField)
 ~G4Mag_EqRhs () override=default
G4double FCof () const
Public Member Functions inherited from G4EquationOfMotion
 G4EquationOfMotion (G4Field *Field)
virtual ~G4EquationOfMotion ()=default
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

G4Mag_SpinEqRhs defines the equation of motion for a particle with spin in a pure magnetic field. The three components of the particle's spin are treated utilising BMT equation.

Definition at line 51 of file G4Mag_SpinEqRhs.hh.

Constructor & Destructor Documentation

◆ G4Mag_SpinEqRhs()

G4Mag_SpinEqRhs::G4Mag_SpinEqRhs ( G4MagneticField * MagField)

Constructor for G4Mag_SpinEqRhs.

Parameters
[in]MagFieldPointer to the associated magnetic field.

Definition at line 37 of file G4Mag_SpinEqRhs.cc.

38 : G4Mag_EqRhs( MagField )
39{
40}
G4Mag_EqRhs(G4MagneticField *magField)

◆ ~G4Mag_SpinEqRhs()

G4Mag_SpinEqRhs::~G4Mag_SpinEqRhs ( )
overridedefault

Default Destructor.

Member Function Documentation

◆ EvaluateRhsGivenB()

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

Calculates the value of the derivative, given the value of the field.

Parameters
[in]yCoefficients array.
[in]BField value.
[out]dydxDerivatives array.

Implements G4Mag_EqRhs.

Definition at line 76 of file G4Mag_SpinEqRhs.cc.

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

◆ GetAnomaly()

G4double G4Mag_SpinEqRhs::GetAnomaly ( ) const
inline

Definition at line 87 of file G4Mag_SpinEqRhs.hh.

87{ return anomaly; }

◆ GetEquationType()

G4EquationType G4Mag_SpinEqRhs::GetEquationType ( ) const
inlineoverridevirtual

Returns the equation of motion type ID, i.e. "kEqMagneticWithSpin".

Reimplemented from G4EquationOfMotion.

Definition at line 92 of file G4Mag_SpinEqRhs.hh.

92{ return kEqMagneticWithSpin; }
@ kEqMagneticWithSpin

◆ SetAnomaly()

void G4Mag_SpinEqRhs::SetAnomaly ( G4double a)
inline

Setter and getter for the magnetic anomaly.

Definition at line 86 of file G4Mag_SpinEqRhs.hh.

86{ anomaly = a; }

◆ SetChargeMomentumMass()

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

Sets the charge momentum mass value.

Reimplemented from G4Mag_EqRhs.

Definition at line 43 of file G4Mag_SpinEqRhs.cc.

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

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