#!/usr/bin/env python3
"""
a0_triplelock_and_bec.py  --  DFD dark-sector key verifications (App AV + reframe).
Run: python3 a0_triplelock_and_bec.py
Reproduces: (1) the TRIPLE LOCK from alpha (H0, a0, Donato surface density);
            (2) the BEC/superfluid condition for chi in galaxies.
"""
import math
alpha = 7.2973525643e-3
c = 2.998e8; G = 6.674e-11; Msun = 1.989e30; pc = 3.086e16; Mpc = 3.086e22
k = 2*math.sqrt(alpha)
def a0(H0_kms): return k*c*(H0_kms*1e3/Mpc)   # m/s^2
print("=== TRIPLE LOCK (all from alpha) ===")
print(f"2 sqrt(alpha)          = {k:.5f}   (vs Milgrom coincidence 1/2pi={1/(2*math.pi):.5f})")
for name,H in [("Planck 67.4",67.4),("DFD-derived 72.1",72.1),("SH0ES 73.04",73.04)]:
    Sig = a0(H)/(2*math.pi*G)*pc**2/Msun
    print(f"  H0={name:16s}: a0={a0(H):.3e} m/s^2 ; Sigma_chi=a0/2piG={Sig:.0f} Msun/pc^2")
print("  observed: RAR knee a0=1.20e-10 ; Donato halo Sigma=141 (log 2.15+/-0.2)")
print(f"  => DFD's OWN H0=72.1 gives a0={a0(72.1):.3e} (=obs to 0.3%) AND Sigma={a0(72.1)/(2*math.pi*G)*pc**2/Msun:.0f} (=Donato).")
print("     H0, the RAR knee, and the universal halo density are ONE number from alpha.\n")
print("=== BEC / superfluid condition for chi in galaxies (5 eV branch) ===")
hbarc=1.973e-5; m=5.09  # eV
rho=0.4e9; n=rho/m; spacing=n**(-1/3)  # cm
print(f"  n=rho/m={n:.2e}/cm^3 ; interparticle spacing={spacing*1e4:.0f} microns")
for v in [50,150,300]:
    lam=2*math.pi*hbarc/(m*(v*1e5/c))
    print(f"  v={v} km/s: lambda_dB={lam*1e4:.0f} microns ; lambda/spacing={lam/spacing:.0f} (>>1 => degenerate)")
print("  => 5 eV chi Bose-condenses in galaxies. (Phonon is ordinary rho^2, NOT MOND rho^3 --")
print("     so the tight RAR is the mu-law on baryons, not a chi superfluid phonon.)")
