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
+5 -6
View File
@@ -1,12 +1,11 @@
# utils.py
import numpy as np
from .constants import HBAR_C_MEV_FM, ME_MEV
from .constants import HBAR_C_MEV_FM, ME_MEV, R0_FM
def nuclear_radius(A: float, r0: float = 1.2) -> float:
r0_fm = 1.2 # fm
R_fm = r0_fm * A ** (1 / 3)
def nuclear_radius(A: float, r0: float = R0_FM) -> float:
R_fm = r0 * A ** (1 / 3)
return R_fm / (HBAR_C_MEV_FM / ME_MEV)
@@ -33,5 +32,5 @@ def W_to_T(W: float | np.ndarray) -> np.ndarray:
return (W - 1.0) * ME_MEV
def T_to_W(T_keV: float | np.ndarray) -> np.ndarray:
return T_keV / ME_MEV + 1.0
def T_to_W(T_MeV: float | np.ndarray) -> np.ndarray:
return T_MeV / ME_MEV + 1.0