Geant4 9.6.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 (G4double 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 (G4double 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 (G4double 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
 
void SetFieldObj (G4Field *pField)
 

Detailed Description

Definition at line 50 of file G4Mag_SpinEqRhs.hh.

Constructor & Destructor Documentation

◆ G4Mag_SpinEqRhs()

G4Mag_SpinEqRhs::G4Mag_SpinEqRhs ( G4MagneticField MagField)

Definition at line 45 of file G4Mag_SpinEqRhs.cc.

46 : G4Mag_EqRhs( MagField ), omegac(0.), anomaly(0.0011659208),
47 pcharge(0.), E(0.), gamma(0.), beta(0.)
48{
49}

◆ ~G4Mag_SpinEqRhs()

G4Mag_SpinEqRhs::~G4Mag_SpinEqRhs ( )

Definition at line 51 of file G4Mag_SpinEqRhs.cc.

52{
53}

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 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 (pcharge == 0.) {
89 dydx[3] = 0.;
90 dydx[4] = 0.;
91 dydx[5] = 0.;
92 } else {
93 dydx[3] = cof*(y[4]*B[2] - y[5]*B[1]) ; // Ax = a*(Vy*Bz - Vz*By)
94 dydx[4] = cof*(y[5]*B[0] - y[3]*B[2]) ; // Ay = a*(Vz*Bx - Vx*Bz)
95 dydx[5] = cof*(y[3]*B[1] - y[4]*B[0]) ; // Az = a*(Vx*By - Vy*Bx)
96 }
97
98 G4ThreeVector u(y[3], y[4], y[5]);
99 u *= inv_momentum_magnitude;
100
101 G4ThreeVector BField(B[0],B[1],B[2]);
102
103 G4double udb = anomaly*beta*gamma/(1.+gamma) * (BField * u);
104 G4double ucb = (anomaly+1./gamma)/beta;
105
106 // Initialise the values of dydx that we do not update.
107 dydx[6] = dydx[7] = dydx[8] = 0.0;
108
109 G4ThreeVector Spin(y[9],y[10],y[11]);
110
111 G4ThreeVector dSpin;
112
113 if (pcharge == 0.) {
114 // dSpin = (3.8260837/2.)*omegac*(Spin.cross(BField));
115 dSpin = omegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
116 } else {
117 dSpin = pcharge*omegac*(ucb*(Spin.cross(BField))-udb*(Spin.cross(u)));
118 }
119
120 dydx[ 9] = dSpin.x();
121 dydx[10] = dSpin.y();
122 dydx[11] = dSpin.z();
123
124 return ;
125}
double G4double
Definition: G4Types.hh:64
double z() const
double x() const
double y() const
G4double FCof() const
Definition: G4Mag_EqRhs.hh:83
T sqr(const T &x)
Definition: templates.hh:145

◆ GetAnomaly()

G4double G4Mag_SpinEqRhs::GetAnomaly ( ) const
inline

Definition at line 69 of file G4Mag_SpinEqRhs.hh.

69{ return anomaly; }

◆ SetAnomaly()

void G4Mag_SpinEqRhs::SetAnomaly ( G4double  a)
inline

Definition at line 68 of file G4Mag_SpinEqRhs.hh.

68{ anomaly = a; }

Referenced by SetChargeMomentumMass().

◆ SetChargeMomentumMass()

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

Reimplemented from G4Mag_EqRhs.

Definition at line 56 of file G4Mag_SpinEqRhs.cc.

59{
60 // To set fCof_val
61 G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, particleMass);
62
63 omegac = (eplus/particleMass)*c_light;
64
65 pcharge = particleCharge;
66
67 E = std::sqrt(sqr(MomentumXc)+sqr(particleMass));
68 beta = MomentumXc/E;
69 gamma = E/particleMass;
70
71 G4double neutronAnomaly = -2.913042725;
72 if (pcharge==0.) SetAnomaly(neutronAnomaly);
73}
virtual void SetChargeMomentumMass(G4double particleCharge, G4double MomentumXc, G4double mass)
Definition: G4Mag_EqRhs.cc:56
void SetAnomaly(G4double a)

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