refactor: centralize all physical constants in constants.py, fix unit naming

- Add EULER_GAMMA, ME_KEV, R0_FM to constants.py
- Replace hardcoded 0.511, 0.5772..., 1.2 with imports from constants
- Fix T_to_W parameter name: T_kev -> T_MeV (it takes MeV, not keV)
- Remove duplicate ME_ME from spectrum.py (import ME_MEV from constants)
- Remove hardcoded r_0 from detector_response.py and radiative.py
- Update CONVENTIONS.md to reference correct constant names
This commit is contained in:
2026-05-01 22:34:15 +03:00
parent 6a671bfb8b
commit 8b4545fe3e
6 changed files with 28 additions and 18 deletions
+10 -4
View File
@@ -3,7 +3,14 @@ import numpy as np
from scipy.special import spence
from beta_spectrum.base import SpectrumComponent
from beta_spectrum.constants import MP_MEV, ME_MEV, ALPHA, HBAR_C_MEV_FM
from beta_spectrum.constants import (
MP_MEV,
ME_MEV,
ALPHA,
HBAR_C_MEV_FM,
EULER_GAMMA,
R0_FM,
)
class RadiativeCorrection(SpectrumComponent):
@@ -49,7 +56,7 @@ class RadiativeCorrection(SpectrumComponent):
self.use_endpoint_resummation = use_endpoint_resummation
self.delta_cut = delta_cut
self.m_p = MP_MEV / ME_MEV # ~1836.15 (proton mass in m_e units)
self.gamma_E = 0.57721566490153286 # Euler-Mascheroni constant
self.gamma_E = EULER_GAMMA # Euler-Mascheroni constant
# Precompute constant terms
self._outer_normalization = ALPHA / (2.0 * np.pi) # ~0.00116
@@ -206,8 +213,7 @@ class RadiativeCorrection(SpectrumComponent):
return 0.0
# Nuclear radius from Wilkinson's r_0
r_0 = 1.2 # fm
a_fm = r_0 * A ** (1.0 / 3.0) # rms charge radius in fm
a_fm = R0_FM * A ** (1.0 / 3.0) # rms charge radius in fm
a_me = a_fm / (HBAR_C_MEV_FM / ME_MEV) # convert to m_e^{-1} units
# Lambda = sqrt(6)/a