Does light charge the quons? › Files cited on the page › the trials

lepton_ladder_lattices.py

In the investigation at sim/models_AB/lepton_ladder_lattices.py · last changed in commit 03adabf, 18 November 2026 · 11,695 bytes · runnable copies in the scripts zip


"""Trial 15: the lepton ladder, with simple, body-centred and face-centred lattices (16 November 2026).

Lock: papers/Lock_lepton_ladder_lattices_2026-11-16.md, committed with this script before the run. Every choice is the lock's.
Aspden's zero-energy balance (Part 1 section 3; working paper 5.2-5.3), in units of e^2/d with d^3 the volume per quon:
    8 pi x^2 + F x^-4 / (4608 pi) = L,   L = -(phi_site + B),   x = r/d,   F = 1.
Only L depends on the lattice: phi_site (Ewald site potential, mean-zero convention) and B = (2 pi/3) <rho^2>_cell / d^2,
the whole-cell term (the mean potential of a block of whole neutral cells, referred to empty space outside it).
Cell energy over orbit quantum, with q = e and the universal alpha:  Q = (3/4 pi)(96 pi)^3 * 128 pi * alpha * x^9.
Doug's second layer: orbit quantum m_mu c^2; self-consistent if Q = 2 m_tau/m_mu (a tau pair) or m_tau/m_mu (one tau).
Run: python3 lepton_ladder_lattices.py   (numpy, scipy). About a minute.
"""
import numpy as np
import scipy
from scipy import constants as Kc
from scipy.special import erfc
from scipy.optimize import brentq

out = []
def say(s=""):
    print(s); out.append(s)
checks = []
def check(name, ok, detail=""):
    checks.append((name, bool(ok)))
    say(f"   CHECK {'pass' if ok else 'FAIL'}: {name} {detail}")

pc = Kc.physical_constants
me = pc["electron mass energy equivalent in MeV"][0]
mmu = pc["muon mass energy equivalent in MeV"][0]
mtau = pc["tau mass energy equivalent in MeV"][0]
alpha = Kc.fine_structure
CQ = (3 / (4 * np.pi)) * (96 * np.pi) ** 3 * 128 * np.pi          # Q = CQ alpha x^9
say("Trial 15: the lepton ladder with simple, body-centred and face-centred lattices. Lock: papers/Lock_lepton_ladder_lattices_2026-11-16.md")
say(f"scipy {scipy.__version__}; CODATA: m_e {me:.8f}, m_mu {mmu:.7f}, m_tau {mtau:.2f} MeV; 1/alpha = {1/alpha:.9f}")
T_pair, T_one, T_lvl1 = 2 * mtau / mmu, mtau / mmu, 2 * mmu / me
say(f"targets: tau pair 2 m_tau/m_mu = {T_pair:.4f}; one tau m_tau/m_mu = {T_one:.4f}; (level 1: 2 m_mu/m_e = {T_lvl1:.4f})")

# lattices, conventional cube side a = 1: primitive vectors (rows) and the basis in the conventional cube
LAT = {
    "simple cubic": (np.eye(3), np.array([[0, 0, 0]], float)),
    "body-centred": (0.5 * np.array([[-1, 1, 1], [1, -1, 1], [1, 1, -1]], float), np.array([[0, 0, 0], [.5, .5, .5]])),
    "face-centred": (0.5 * np.array([[0, 1, 1], [1, 0, 1], [1, 1, 0]], float),
                     np.array([[0, 0, 0], [0, .5, .5], [.5, 0, .5], [.5, .5, 0]])),
}

def ewald_site(prim, eta, nmax=9):
    """Site potential of unit charges on the lattice in a neutralizing background, mean-zero convention.
    prim is scaled so that the volume per site is 1, so the result is in units of e/d."""
    V = abs(np.linalg.det(prim))
    rec = 2 * np.pi * np.linalg.inv(prim).T
    rng = np.arange(-nmax, nmax + 1)
    n = np.array(np.meshgrid(rng, rng, rng, indexing="ij")).reshape(3, -1).T.astype(float)
    R = np.linalg.norm(n @ prim, axis=1); R = R[R > 1e-12]
    G = np.linalg.norm(n @ rec, axis=1); G = G[G > 1e-12]
    real = np.sum(erfc(eta * R) / R)
    recip = (4 * np.pi / V) * np.sum(np.exp(-G ** 2 / (4 * eta ** 2)) / G ** 2)
    return real + recip - 2 * eta / np.sqrt(np.pi) - np.pi / (eta ** 2 * V)

def ws_rho2(basis, n):
    """<rho^2> over the Wigner-Seitz cell, units of a^2: the mean over a midpoint grid in the conventional cube of the squared
    distance to the nearest lattice point (the cells tile space, so this is the cell average)."""
    shifts = np.array(np.meshgrid([-1, 0, 1], [-1, 0, 1], [-1, 0, 1], indexing="ij")).reshape(3, -1).T
    pts = (basis[None, :, :] + shifts[:, None, :]).reshape(-1, 3)
    g = (np.arange(n) + 0.5) / n
    X, Y = np.meshgrid(g, g, indexing="ij"); X = X.ravel(); Y = Y.ravel()
    dxy = (X[:, None] - pts[None, :, 0]) ** 2 + (Y[:, None] - pts[None, :, 1]) ** 2
    tot = 0.0
    for z in g:
        tot += (dxy + (z - pts[None, :, 2]) ** 2).min(axis=1).sum()
    return tot / n ** 3

def conv_second_moment(basis):
    """(1/e) x the integral of rho r^2 over the conventional cube [-1/2, 1/2]^3 centred on a site (units of a^2): lattice
    points in the closed cube with weights 1, 1/2, 1/4, 1/8 (interior, face, edge, corner), minus the background,
    n_basis spread uniformly over the cube (mean r^2 = 1/4)."""
    shifts = np.array(np.meshgrid([-1, 0, 1], [-1, 0, 1], [-1, 0, 1], indexing="ij")).reshape(3, -1).T
    pts = (basis[None, :, :] + shifts[:, None, :]).reshape(-1, 3)
    S = 0.0
    for p in pts:
        if np.all(np.abs(p) <= 0.5 + 1e-12):
            k = int(np.sum(np.isclose(np.abs(p), 0.5)))
            S += p @ p / 2 ** k
    return S - len(basis) * 0.25

def balance_x(L, F=1.0):
    return brentq(lambda x: 8 * np.pi * x ** 2 + F * x ** -4 / (4608 * np.pi) - L, 0.15, 1.2, xtol=1e-15, rtol=1e-15)

def L_of_x(x, F=1.0):
    return 8 * np.pi * x ** 2 + F * x ** -4 / (4608 * np.pi)

# ---------------- code checks on the machinery ----------------
say("\nCode checks")
closed = {"simple cubic": 0.25, "body-centred": 57 / 384, "face-centred": 3 / 32}
res = {}
for name, (prim, basis) in LAT.items():
    nb = len(basis)
    ps = prim * (1 / abs(np.linalg.det(prim))) ** (1 / 3)          # volume per site 1: lengths in units of d
    p1, p2 = ewald_site(ps, 1.5), ewald_site(ps, 2.5)
    check(f"K2 {name}: Ewald site potential independent of the splitting (eta 1.5 vs 2.5), to 1e-10", abs(p1 - p2) < 1e-10, f"({p1:.12f}, {p2:.12f})")
    n1, n2 = 160, 240
    v1, v2 = ws_rho2(basis, n1), ws_rho2(basis, n2)
    vinf = (n2 ** 2 * v2 - n1 ** 2 * v1) / (n2 ** 2 - n1 ** 2)
    tol = 1e-7 if name == "simple cubic" else 1e-5
    check(f"K3 {name}: <rho^2> over the Wigner-Seitz cell = {closed[name]:.10f} a^2, to {tol:g}", abs(vinf / closed[name] - 1) < tol,
          f"(grid {n1}: {v1:.10f}, {n2}: {v2:.10f}, extrapolated {vinf:.10f})")
    res[name] = dict(nb=nb, phi=p1, rho2=vinf, S=conv_second_moment(basis))
check("K1 simple cubic site potential = the record's -2.8372974795, to 1e-9", abs(res["simple cubic"]["phi"] + 2.8372974795) < 1e-9,
      f"({res['simple cubic']['phi']:.10f})")
L_sc = -(res["simple cubic"]["phi"] + np.pi / 6)
x_sc = balance_x(L_sc)
check("K4 simple cubic: x = r/d = the record's 0.3028737692, to 1e-9", abs(x_sc - 0.3028737692) < 1e-9, f"({x_sc:.10f}; L = {L_sc:.7f})")
N_sc_A = (9 / 8) ** 3 * x_sc ** -6
check("K4 simple cubic: N0 = (9/8)^3 x^-6 = 1844.538 (Aspden's photon-unit form), to 1e-3", abs(N_sc_A - 1844.538) < 1e-3, f"({N_sc_A:.4f})")

# ---------------- Q1 and Q2: each lattice and cell ----------------
say("\nQ1. Each lattice and cell convention: phi_site, B, L, x = r/d, Q = E0/(hbar Omega), N0; level 2 with its orbit at the muon")
x_pair = (T_pair / (CQ * alpha)) ** (1 / 9)
x_one = (T_one / (CQ * alpha)) ** (1 / 9)
rows = []
for name in LAT:
    r = res[name]; nb = r["nb"]
    B_ws = (2 * np.pi / 3) * r["rho2"] * nb ** (2 / 3)
    B_cv = -(2 * np.pi / 3) * r["S"] * nb ** (-1 / 3)
    for cell, B in (("Wigner-Seitz cell", B_ws), ("conventional cube", B_cv)):
        if name == "simple cubic" and cell == "conventional cube":
            continue                                               # the same cell for the simple cubic lattice
        L = -(r["phi"] + B)
        x = balance_x(L)
        Q = CQ * alpha * x ** 9
        N0 = (x ** -3 / (128 * np.pi * alpha)) ** 3
        Nodd = int(np.floor(N0)); Nodd -= (Nodd % 2 == 0)
        r2 = Kc.hbar / (2 * Kc.m_e * Kc.c) * me / mmu               # level 2's orbit radius, m
        rows.append((name, cell, r["phi"], B, L, x, Q, N0, Nodd, r2 / x))
        say(f"   {name:13s} {cell:18s}: phi_site = {r['phi']:.7f}, B = {B:+.7f}, L = {L:.7f}, x = {x:.7f}, Q = {Q:.4f}, N0 = {N0:.2f}"
            f" (odd below: {Nodd}, which would change Q by {(N0/Nodd - 1)*100:+.3f}%)")
        say(f"   {'':32s}  level 2 (orbit at the muon): spacing {r2/x:.4e} m; cell energy Q m_mu c^2 = {Q*mmu/1e3:.3f} GeV;"
            f" Q / tau pair = {Q/T_pair:.3f}; Q / one tau = {Q/T_one:.3f}")
say(f"   level 1 check (simple cubic, universal alpha, no rounding): Q = {CQ*alpha*x_sc**9:.4f} against 2 m_mu/m_e = {T_lvl1:.4f}")

say("\nQ2. What the targets would need, and which way the lattices move")
for tname, T, xT in (("a tau pair", T_pair, x_pair), ("one tau", T_one, x_one)):
    say(f"   {tname}: Q = {T:.4f} needs x = {xT:.7f} and L = {L_of_x(xT):.7f} (simple cubic has L = {L_sc:.7f};"
        f" L would have to fall by {(1 - L_of_x(xT)/L_sc)*100:.1f}%)")
Q_sc = rows[0][6]
for name, cell, phi, B, L, x, Q, *_ in rows[1:]:
    say(f"   {name} ({cell}): L {L/L_sc:.4f} x simple cubic's; Q {Q/Q_sc:.4f} x simple cubic's -> "
        f"{'away from' if Q > Q_sc else 'toward'} the targets")

# ---------------- Q3: the nearest particle, if not a tau (Doug's addition) ----------------
import ast, os
say("\nQ3. The nearest particle to the second layer's cell energy, if not a tau (U44's list, read unchanged)")
src = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "lepton_photon", "ladder_scan.py"), encoding="utf-8").read()
PL = None
for node in ast.walk(ast.parse(src)):
    if isinstance(node, ast.Assign) and any(getattr(tg, "id", None) == "P" for tg in node.targets):
        PL = ast.literal_eval(node.value)
pn = list(PL); pm = np.array([PL[k] for k in pn], float)
say(f"   {len(pn)} particles, {pm.min():.3f} to {pm.max():.1f} MeV")

def nearest_and_p(E, masses):
    lm = np.log(masses); lE = np.log(E)
    i = int(np.argmin(np.abs(lm - lE))); dl = abs(lm[i] - lE)
    lo, hi = lm.min(), lm.max()
    iv = sorted((max(lo, x - dl), min(hi, x + dl)) for x in lm)       # union of windows of half-width dl
    cov, cs, ce = 0.0, iv[0][0], iv[0][1]
    for a_, b_ in iv[1:]:
        if a_ > ce:
            cov += ce - cs; cs, ce = a_, b_
        else:
            ce = max(ce, b_)
    cov += ce - cs
    return i, (np.exp(lE - lm[i]) - 1) * 100, cov / (hi - lo)

ncand = 0
for name, cell, phi, B, L, x, Q, *_ in rows:
    E2 = Q * mmu
    for reading, masses, label in (("pair", 2 * pm, "2 m"), ("single", pm, "m")):
        i, pct, p = nearest_and_p(E2, masses)
        cand = abs(pct) < 1 and p < 0.005
        ncand += cand
        say(f"   {name:13s} {cell:18s} E0,2 = {E2/1e3:8.3f} GeV, as a {reading:6s}: nearest {pn[i]:8s} ({label} = {masses[i]/1e3:.4f} GeV),"
            f" E0,2 is {pct:+.2f}% from it; p = {p:.3f}{'  CANDIDATE' if cand else ''}")

# ---------------- verdict ----------------
say("\nVerdict, by the lock's rules")
hits = [(n, c, Q) for n, c, _, _, _, _, Q, *_ in rows if abs(Q / T_pair - 1) < 0.01 or abs(Q / T_one - 1) < 0.01]
if not hits:
    say("   V1: Under Aspden's rules, a second layer with its orbit at the muon cannot hold the next lepton in its cells, for simple,"
        " body-centred or face-centred lattices.")
    say(f"       A tau pair would need x = {x_pair:.4f} and L = {L_of_x(x_pair):.4f}; one tau x = {x_one:.4f} and L = {L_of_x(x_one):.4f}"
        f" (against {L_sc:.4f} for the simple cubic lattice).")
else:
    say(f"   V3: candidates within 1% (not results): {hits}")
away = [f"{n} ({c}) x{Q/Q_sc:.3f}" for n, c, _, _, _, _, Q, *_ in rows[1:] if Q > Q_sc]
toward = [f"{n} ({c}) x{Q/Q_sc:.3f}" for n, c, _, _, _, _, Q, *_ in rows[1:] if Q <= Q_sc]
say(f"   V2: away from the targets: {', '.join(away) if away else 'none'}; toward them: {', '.join(toward) if toward else 'none'}.")
say(f"   V4: candidates for the nearest particle (within 1% and p < 0.005): {ncand}"
    + (" -- the nearest particles above do not match." if ncand == 0 else " (candidates, not results)."))
nfail = sum(1 for _, ok in checks if not ok)
say(f"\nCode checks: {len(checks)-nfail} of {len(checks)} pass.")