Relativistic Energy Calculations: SI vs Natural Units¶
Try it live on Compiler Explorer
Overview¶
This example demonstrates the relativistic energy-momentum relation \(E^2 = (pc)^2 + (mc^2)^2\) using both SI units (with explicit c factors) and natural units (where c = 1). It showcases how mp-units supports multiple systems of quantities and how natural units simplify complex relativistic formulas while maintaining dimensional correctness.
Key Concepts¶
The Energy-Momentum Relation¶
In special relativity, the total energy of a particle is related to its momentum and rest mass through:
SI units (explicit constants):
Natural units (c = ℏ = 1):
Dual Implementation Strategy¶
The example provides two implementations of the same physics:
SI units version - requires explicit speed of light:
QuantityOf<isq::mechanical_energy> auto total_energy(QuantityOf<isq::momentum> auto p, QuantityOf<isq::mass> auto m,
QuantityOf<isq::speed> auto c)
{
return isq::mechanical_energy(hypot(p * c, m * pow<2>(c)));
}
Natural units version - c = 1 by definition, no parameter needed:
// In natural units (ℏ = c = 1), the energy-momentum relation simplifies to E² = p² + m²
QuantityOf<natural::energy> auto total_energy(QuantityOf<natural::momentum> auto p, QuantityOf<natural::mass> auto m)
{
return natural::energy(hypot(p, m));
}
Notice how the natural units version is simpler: no c parameter, and the formula
directly matches the mathematical notation used by physicists.
SI Units: Multiple Representations¶
The SI example demonstrates the same calculation in three different unit representations:
Using GeV and c:
const quantity p1 = isq::momentum(4. * GeV / c);
const QuantityOf<isq::mass> auto m1 = 3. * GeV / c2;
const quantity E = total_energy(p1, m1, c);
std::cout << "\n*** SI units (c = " << c << " = " << c.in(si::metre / s) << ") ***\n";
std::cout << "\n[in `GeV` and `c`]\n"
<< "p = " << p1 << "\n"
<< "m = " << m1 << "\n"
<< "E = " << E << "\n";
Converting to pure GeV:
const quantity p2 = p1.in(GeV / (m / s));
const quantity m2 = m1.in(GeV / pow<2>(m / s));
const quantity E2 = total_energy(p2, m2, c).in(GeV);
std::cout << "\n[in `GeV`]\n"
<< "p = " << p2 << "\n"
<< "m = " << m2 << "\n"
<< "E = " << E2 << "\n";
Using SI base units (kg, m, s):
const quantity p3 = p1.in(kg * m / s);
const quantity m3 = m1.in(kg);
const quantity E3 = total_energy(p3, m3, c).in(J);
std::cout << "\n[in SI base units]\n"
<< "p = " << p3 << "\n"
<< "m = " << m3 << "\n"
<< "E = " << E3 << "\n";
std::cout << "\n[converted from SI units back to GeV]\n"
<< "E = " << E3.force_in(GeV) << "\n";
Each representation is physically equivalent, but the choice affects numerical values and readability.
Sample Output:
*** SI units (c = 1 c = 2.99792e+08 m/s) ***
[in `GeV` and `c`]
p = 4 GeV/c
m = 3 GeV/c²
E = 5 GeV
[in `GeV`]
p = 1.33426e-08 GeV s/m
m = 3.33795e-17 GeV s²/m²
E = 5 GeV
[in SI base units]
p = 2.13771e-18 kg m/s
m = 5.34799e-27 kg
E = 8.01088e-10 J
[converted from SI units back to GeV]
E = 5 GeV
Natural Units: Simplified Physics¶
The natural units example shows the elegance of setting c = 1:
const auto p = momentum(4. * GeV); // momentum
const auto m = mass(3. * GeV); // mass (rest energy: E = m when c = 1)
const auto E = total_energy(p, m);
std::cout << "\n*** Natural units (c = 1) ***\n"
<< "p = " << p << "\n"
<< "m = " << m << "\n"
<< "E = " << E << "\n";
Sample Output:
Notice:
- Momentum, mass, and energy all have the same dimension (energy) in natural units
- No conversion factors needed between quantities
- The Pythagorean relation \(E^2 = p^2 + m^2\) is immediately visible
- The formula matches exactly what appears in physics textbooks
Why This Matters¶
SI Units Advantages¶
- Explicit Constants: All physical constants are visible in formulas
- Intuitive Scaling: Familiar units (meters, seconds, kilograms)
- Experimental Context: Direct connection to laboratory measurements
- Engineering Applications: Practical for real-world calculations
Natural Units Advantages¶
- Simplified Formulas: Match theoretical physics notation exactly
- Dimensional Insights: Relationships like "mass IS energy" become explicit
- Particle Physics: Standard in high-energy physics research
- Reduced Clutter: Eliminates repetitive factors of c and ℏ
Library Support for Both¶
mp-units uniquely supports both paradigms:
- SI uses ISQ quantity types with explicit dimensional relationships
- Natural units use a separate quantity system based on energy dimensions
- The two systems are incompatible - conversions require extracting numerical values and manually applying conversion factors (no automatic type-safe conversion)
- Both provide compile-time dimensional checking within their respective systems
Practical Applications¶
This pattern is essential for:
- Particle Physics: Calculating particle energies, decay rates, cross-sections
- Relativistic Mechanics: Any application where \(v \approx c\)
- Quantum Field Theory: Natural units are the standard
- Educational Code: Teaching relativity with simplified formulas
- Cross-Domain Work: Working with both experimental (SI) and theoretical (natural) contexts