5.3. Physical Constants
Table of Contents
Speed of light
Geant4 provides many physical constants through the namespace CLHEP and also re-exports them into the G4PhysicalConstants.hh and G4SystemOfUnits.hh headers. The most frequently used one is the speed of light in vacuum.
To use the speed of light, you typically include:
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
The speed of light is defined as a constant with the symbol c_light. In Geant4 internal units it has the value:
c_light = 2.99792458e+8 * m/s;You can use it directly in your code when you need to convert between distance and time or when you want to compute a time of flight from a distance:
G4double distance = 10.0 * m;
G4double time = distance / c_light; // time in seconds, in Geant4 units
Because Geant4 uses its own unit system, you can always express c_light in different derived units. For example, you can print it in mm/ns:
G4cout << "c = " << c_light / (mm/ns) << " mm/ns" << G4endl;
This prints a dimensionless number that represents how many mm/ns correspond to the Geant4 value of c_light.
The speed of light constant in Geant4 is c_light.
Always combine it with Geant4 units, for example m/s or mm/ns, when doing calculations or printing values.
You should avoid hard-coding the numerical value of the speed of light. Using c_light keeps your code consistent with the rest of Geant4 and avoids mistakes when you change units or rescale quantities.
Particle masses
Geant4 defines the masses of all standard particles internally as part of the particle definitions. You rarely need to type a numeric mass value yourself. Instead, you either:
- Use the mass that is already associated with a
G4ParticleDefinition. - Use the predefined constant if it is available, for example
electron_mass_c2.
For any particle that is already defined in Geant4, you can access its mass using the GetPDGMass() method:
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
G4ParticleDefinition* electron =
G4ParticleTable::GetParticleTable()->FindParticle("e-");
G4double me = electron->GetPDGMass(); // in Geant4 energy units, usually MeV
The particle mass in Geant4 is stored as an energy, usually in units of MeV, since Geant4 uses natural units internally. For example, the electron mass is about 0.511 * MeV.
Some commonly used particle masses are also provided as named constants in G4PhysicalConstants.hh, for example:
electron_mass_c2 // electron mass (m_e c^2)
proton_mass_c2 // proton mass (m_p c^2)
neutron_mass_c2 // neutron mass (m_n c^2)You can use these constants directly in calculations:
G4double kineticEnergy = 10.0 * MeV;
G4double totalEnergy = kineticEnergy + electron_mass_c2;
If you need the mass in units of, say, GeV, you can convert it using the units from G4SystemOfUnits.hh:
G4cout << "Electron mass = "
<< electron_mass_c2 / GeV
<< " GeV" << G4endl;
Particle masses in Geant4 are stored as energies, typically in MeV, for example electron_mass_c2.
Always remember they represent $m c^2$, and convert to your preferred unit using Geant4 energy units such as MeV or GeV.
Using the built-in particle masses keeps your simulation consistent with Geant4 physics lists and avoids subtle inconsistencies that can appear if you use mismatched values.
Other Geant4 constants
In addition to the speed of light and particle masses, Geant4 provides a large set of physical constants. These constants are accessible through the same headers, mainly G4PhysicalConstants.hh and G4SystemOfUnits.hh. They cover fundamental constants, electromagnetic constants, and various derived quantities.
Some important examples include:
| Constant name | Meaning | Typical value (approximate) |
|---|---|---|
twopi | $2\pi$ | About 6.283185 |
halfpi | $\pi/2$ | About 1.570796 |
pi | $\pi$ | About 3.141593 |
Avogadro | Avogadro constant | $6.022 \times 10^{23}\ \text{mol}^{-1}$ |
k_Boltzmann | Boltzmann constant | $1.38 \times 10^{-23}\ \text{J/K}$ |
eplus | Elementary charge magnitude | $1.602 \times 10^{-19}\ \text{C}$ |
electron_mass_c2 | Electron mass energy | $0.511\ \text{MeV}$ |
proton_mass_c2 | Proton mass energy | $938.272\ \text{MeV}$ |
neutron_mass_c2 | Neutron mass energy | $939.565\ \text{MeV}$ |
h_Planck | Planck constant | $6.626 \times 10^{-34}\ \text{J s}$ |
hbar_Planck | Reduced Planck constant | $1.055 \times 10^{-34}\ \text{J s}$ |
fine_structure_const | Fine structure constant $\alpha$ | About 1/137 |
alpha_rcl2 | Thomson scattering length squared | Related to classical electron radius |
mu0 | Vacuum permeability | $4\pi \times 10^{-7}\ \text{N/A}^2$ |
epsilon0 | Vacuum permittivity | About $8.854 \times 10^{-12}\ \text{F/m}$ |
All these constants are defined using Geant4 units, so you can immediately combine them with lengths, energies, times, and charges defined in the Geant4 unit system.
A typical use of these constants might be in an analytical check, or in adding small corrections to a simple model:
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
G4double temperature = 300.0 * kelvin;
G4double kT = k_Boltzmann * temperature; // in energy units (J), then converted
G4cout << "kT at room temperature = "
<< kT / eV << " eV" << G4endl;
The units of each constant are chosen consistently, so expressions like k_Boltzmann * temperature automatically produce an energy. This consistency is one of the reasons to rely on these predefined constants instead of manually entering numeric values.
Always take constants from G4PhysicalConstants.hh and combine them with units from G4SystemOfUnits.hh.
Avoid hard-coded numerical constants, and always convert to the desired units (for example, divide by eV, MeV, GeV, m, or s) when printing or comparing values.
For most beginner applications you will only need a small subset of these constants, mainly c_light, particle masses such as electron_mass_c2, and perhaps Avogadro. As your simulations become more detailed, you can systematically use the rest of the provided constants to keep your calculations clear and consistent with the Geant4 physics framework.
Views: 9
KAHIBARO