42 : fEquation(equation), fnvar(nvar)
48 "Invalid number of variables; must be greater than zero!");
61 UpdatePosition(restMass, charge, yIn, yOut1Temp, hstep/2);
62 UpdateVelocity(restMass, charge, yOut1Temp, yOut2Temp, hstep);
63 UpdatePosition(restMass, charge, yOut2Temp, yOut, hstep/2);
66void G4BorisScheme::UpdatePosition(
const G4double restMass,
78 G4double velocity_mag = momentum_mag*(c_l)/(std::sqrt(
sqr(momentum_mag) +
sqr(restMass)));
83 hstep /= velocity_mag*CLHEP::m;
86 for(
G4int i = 0; i <3; i++ )
89 pos += hstep*velocity[i];
90 yOut[i] = pos*CLHEP::m;
94void G4BorisScheme::UpdateVelocity(
const G4double restMass,
104 G4double gamma = std::sqrt(
sqr(momentum_mag) +
sqr(restMass))/restMass;
106 G4double mass = (restMass/c_squared)/CLHEP::kg;
110 G4double velocity_mag = momentum_mag*(c_l)/(std::sqrt(
sqr(momentum_mag) +
sqr(restMass)));
115 hstep /= velocity_mag*CLHEP::m;
120 G4double fieldValue[6] ={0,0,0,0,0,0};
121 fEquation->EvaluateRhsReturnB(yIn, dydx, fieldValue);
128 for(
G4int i = 0; i < 3; i++)
130 E[i] = fieldValue[i+3]/CLHEP::volt*CLHEP::meter;
131 B[i] = fieldValue[i]/CLHEP::tesla;
136 G4double qd = hstep*(charge/(2*mass*gamma));
139 G4double h_l = h[0]*h[0] + h[1]*h[1] + h[2]*h[2];
145 G4double momen_mag = (restMass*v_mag)/(std::sqrt(c_l*c_l - v_mag*v_mag));
150 for(
G4int i = 3; i < 6; i++)
152 yOut[i] = momen[i-3];
160 std::memcpy(dst, src,
sizeof(
G4double) * fnvar);
189 DoStep(restMass, charge, yIn, yOutAlt, hstep );
192 DoStep(restMass, charge, yIn, yMid, halfStep );
193 DoStep(restMass, charge, yMid, yOut, halfStep );
195 for(
G4int i = 0; i < fnvar; i++ )
197 yErr[i] = yOutAlt[i] - yOut[i];
G4double B(G4double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector cross(const Hep3Vector &) const
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
G4EquationOfMotion is the abstract base class for the right hand size of the equation of motion of a ...
field_utils is a helper namespace, including simple methods to extract vectors from arrays in convent...
void copy(G4double dst[], const G4double src[], std::size_t size=G4FieldTrack::ncompSVEC)