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:
@@ -33,6 +33,8 @@ from scipy.interpolate import RegularGridInterpolator, interp1d
|
||||
from scipy.special import erfc
|
||||
from typing import Optional
|
||||
|
||||
from beta_spectrum.constants import ME_MEV
|
||||
|
||||
|
||||
class DetectorResponse:
|
||||
"""
|
||||
@@ -196,7 +198,7 @@ class DetectorResponse:
|
||||
sigma_sq = self.sigma_a**2 + (self.sigma_b * np.sqrt(E)) ** 2
|
||||
if self.fano_factor > 0:
|
||||
# Fano contribution: σ = sqrt(F * E * w) in natural units
|
||||
w_me = 3.6e-3 / 0.511 # 3.6 eV in m_e units
|
||||
w_me = 3.6e-3 / ME_MEV # 3.6 eV in m_e units
|
||||
sigma_sq += self.fano_factor * E * w_me
|
||||
return np.sqrt(sigma_sq)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user