The present changes increase (fix) the electron rest energy in [eV] units.
The electron rest energy constant in trackcpp has 2 definitions: one in [kgm^2/s^2] and other in [MeV]. The MeV definition is used in the creation of Accelerator objects. When the Accelerator's constructor is called and the energy argument isnt passed or is below the electron rest energy, for example: acc = trackcpp.Accelerator() -> the constructor uses energy=-1, then it checks if
```-1 < electron_rest_energy_MeV1e6 , finally, if `true`, it sets the accelerator's energy equal toelectron_rest_energy_MeV*1e6``` that implies in a lost of precision (the mantissa lose its last right digit).
To fix it, was created a new constant electron_rest_energy_eV to replace the electron_rest_energy_MeV, recovering the full precision of it.
This little imprecision was spotted using the Accelerator object constructor in PyAccel, doing:
import pyaccel
accelerator = pyaccel.accelerator.Accelerator() # the energy must be the electron rest energy
print(accelerator.energy) # it prints: 510998.9499961641
print(accelerator.gamma_factor) # it prints: 0.9999999999999998
The expected values for the electron rest energy in eV is 510998.94999616424 and the gamma_factor should be 1.0.
The present changes increase (fix) the electron rest energy in [eV] units.
The electron rest energy constant in trackcpp has 2 definitions: one in [kgm^2/s^2] and other in [MeV]. The MeV definition is used in the creation of Accelerator objects. When the Accelerator's constructor is called and the energy argument isnt passed or is below the electron rest energy, for example:
acc = trackcpp.Accelerator()
-> the constructor usesenergy=-1
, then it checks if ```-1 < electron_rest_energy_MeV1e6, finally, if `true`, it sets the accelerator's energy equal to
electron_rest_energy_MeV*1e6``` that implies in a lost of precision (the mantissa lose its last right digit).To fix it, was created a new constant
electron_rest_energy_eV
to replace theelectron_rest_energy_MeV
, recovering the full precision of it.This little imprecision was spotted using the Accelerator object constructor in PyAccel, doing:
The expected values for the electron rest energy in eV is
510998.94999616424
and the gamma_factor should be1.0
.