BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSMagUsualEqRhs.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSGlobalConstants.hh"
19#include "BDSMagUsualEqRhs.hh"
20#include "BDSStep.hh"
21#include "G4Mag_EqRhs.hh"
22
23#include "globals.hh" // geant4 types / globals
24#include "G4ClassicalRK4.hh"
25#include "G4ChargeState.hh"
26#include "G4MagneticField.hh"
27#include "G4SystemOfUnits.hh"
28#include "G4PhysicalConstants.hh"
29#include "BDSGlobalConstants.hh"
30
31BDSMagUsualEqRhs::BDSMagUsualEqRhs(G4MagneticField* MagField):
32 G4Mag_UsualEqRhs(MagField),
33 fMassCof(0.),
34 fCof_val(0.)
35{;}
36
37void BDSMagUsualEqRhs::SetChargeMomentumMass( G4ChargeState particleCharge,
38 G4double MomentumXc,
39 G4double particleMass)
40{
41 G4Mag_EqRhs::SetChargeMomentumMass(particleCharge, MomentumXc, particleMass);
42 G4double pcharge = particleCharge.GetCharge();
43
44 fCof_val = pcharge*eplus*c_light ; // B must be in Tesla
45 fMassCof = particleMass*particleMass;
46}
47
48G4double BDSMagUsualEqRhs::Beta(const G4double y[6])
49{
50 G4ThreeVector mom = G4ThreeVector(y[3], y[4], y[5]);
51 G4double beta = Beta(mom);
52 return beta;
53}
54
55G4double BDSMagUsualEqRhs::Beta(const G4ThreeVector& mom)
56{
57 G4double momentum_mag_square = mom.mag2();
58 G4double Energy = std::sqrt(momentum_mag_square + fMassCof);
59 G4double beta = std::sqrt(momentum_mag_square) / Energy;
60 return beta;
61}
62
63G4double BDSMagUsualEqRhs::TotalEnergy(const G4double y[])
64{
65 G4ThreeVector mom = G4ThreeVector(y[3], y[4], y[5]);
66 G4double Energy = TotalEnergy(mom);
67 return Energy;
68}
69
70G4double BDSMagUsualEqRhs::TotalEnergy(const G4ThreeVector& mom)
71{
72 G4double momentum_mag_square = mom.mag2();
73 G4double Energy = std::sqrt(momentum_mag_square + fMassCof);
74 return Energy;
75}
G4double fMassCof
Particle mass squared.
G4double TotalEnergy(const G4double y[])
Calculate total particle energy.
G4double Beta(const G4double y[6])
Calculate particle velocity W.R.T speed of light.
virtual void SetChargeMomentumMass(G4ChargeState particleCharge, G4double MomentumXc, G4double particleMass)
Copy of class method from G4Mag_UsualEqRhs.