EGSnrc
EGSnrc copied to clipboard
Unit conversion 1.602E-10 in DOSRZnrc, DOSXYZnrc etc is off by 0.011% vs current data
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.
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...)