"""
Physical constants for DiffTB.

All values in eV, Angstrom, femtosecond units.
"""

# Fundamental constants
HBAR = 0.6582119569  # eV·fs (ℏ)
HBAR_SQ = 7.6199682  # eV·Å²·m_e (ℏ²/m_e)
ELECTRON_MASS = 1.0  # in units where m_e = 1
BOHR_RADIUS = 0.529177  # Å
HARTREE = 27.211386  # eV
RYDBERG = 13.605693  # eV
BOLTZMANN = 8.617333e-5  # eV/K

# Conversion factors
EV_TO_HARTREE = 1.0 / HARTREE
HARTREE_TO_EV = HARTREE
ANGSTROM_TO_BOHR = 1.0 / BOHR_RADIUS
BOHR_TO_ANGSTROM = BOHR_RADIUS

# Speed of light
C_LIGHT = 299792458.0  # m/s
C_LIGHT_AFS = 2997.92458  # Å/fs

# Fine structure constant
ALPHA = 1.0 / 137.036


# Temperature conversion
def kelvin_to_ev(T_K: float) -> float:
    """Convert temperature from Kelvin to eV (k_B T)."""
    return BOLTZMANN * T_K


def ev_to_kelvin(E_eV: float) -> float:
    """Convert energy from eV to equivalent temperature."""
    return E_eV / BOLTZMANN


# Thermal broadening
def thermal_broadening(T_K: float) -> float:
    """
    Thermal broadening ~4 k_B T (full width at half maximum).

    At room temperature (300 K): ~103 meV
    At liquid He (4 K): ~1.4 meV
    """
    return 4 * BOLTZMANN * T_K


# Fermi velocity conversion
def fermi_velocity_to_ms(v_evA: float) -> float:
    """
    Convert Fermi velocity from eV·Å/ℏ to m/s.

    v [m/s] = v [eV·Å] / ℏ [eV·s] × 10⁻¹⁰ [m/Å]
    """
    return v_evA / HBAR * 1e-10 * 1e15  # fs to s


# Typical values for reference
TYPICAL_VALUES = {
    "graphene_vF": 1e6,  # m/s
    "bi2te3_gap": 0.165,  # eV (bulk)
    "bi2te3_soc": 1.5,  # eV (Bi p-orbital ξ)
    "bi2se3_gap": 0.3,  # eV (bulk)
    "mnbi2te4_gap": 0.2,  # eV (bulk, DFT)
    "mnbi2te4_exchange": 0.06,  # eV (exchange splitting)
    "room_temp_broadening": 0.103,  # eV (4 k_B × 300 K)
    "helium_temp_broadening": 0.0014,  # eV (4 k_B × 4 K)
}
