Open dworogers opened 3 years ago
Agreed. Since this value is exact in the SI, I would go all the way and define e = 1.602 176 634 x 10^-19 C
.
Found this in src/EEMF_macros_beamnrc.mortran
: REPLACE{$EC_em}WITH{1.60217662E-19}; "electron charge"
. I suggest we simply make such a constant available throughout, along with conversion factors such as eVToMeV
, MeVPerGramToGray
, etc., as suggested by @MartinMartinov in #701.
Something like this, in a new header egs_constants.h
:
// Physical constants
const EGS_Float e_charge = 1.602176634e-19; // Coulomb, exact, CODATA 2018
// Conversion factors
const EGS_Float eV_to_MeV = 1e-6;
const EGS_Float eV_to_Joule = e_charge;
const EGS_Float MeV_to_Joule = 1e6 * eV_to_Joule;
const EGS_Float MeVPerGram_to_Gray = 1e3 * MeV_to_Joule;
// (and more...)
Just bumped into something where two codes were using slightly different values for the electron charge, which made it trickier than it should have been to tell if there was any difference between the two codes.
So, what I'm saying is: I hope this gets addressed soon!
Yes, the EGSnrc rewrite we are considering will use the exact value of $\large e$ as a constant, and perhaps a solid unit conversion library (or at the very least conversion factors as pointed out above). No more hard coded numbers!
Various RZ and other codes need to convert from scored MeV/g to Gy. Using latest codata values the conversion is 1.6021766E-10 rather than 1.602E-10 used in the codes, i.e. 0.011% higher. Not a big deal but might as well have it exact.