Does light charge the quons? › Files cited on the page › check_trial15_fable/

check_trial15.py

In the investigation at sim/models_AB/check_trial15_fable/check_trial15.py · last changed in commit e082911, 18 November 2026 · 16,953 bytes · the folder as a zip


"""Sixteenth independent review: trial 15 (the lepton ladder with simple, body-centred and face-centred lattices).

Written from the lock's statement of Aspden's chain (Part 1 section 3) and from first principles, not from the trial's
script. Methods differ from the trial's on purpose:
  - Ewald sums with SPHERICAL cutoffs in both spaces, four splitting parameters, and a check against the Wigner-crystal
    Madelung constants (from memory: -0.880059 sc, -0.895929 bcc, -0.895874 fcc, in e^2/a_ws; the record's
    Lock_cubic_lattices_2026-11-13.md carries the same three numbers);
  - Wigner-Seitz second moments EXACTLY, by decomposing each cell into tetrahedra from its vertices (ConvexHull), plus a
    quasi-random Monte Carlo of nearest-site distances as a second route;
  - the balance solved with mpmath at 30 digits;
  - the chance measure re-implemented, and checked by Monte Carlo;
  - extras the lock did not run: I5 at level 2 (144 pi x), other cell terminations (a shifted conventional cube with
    whole quons; the sphere bound), and the sensitivity Q ~ L^4.5.
Run: ~/aspden-review-venv/bin/python3 check_trial15.py   (numpy, scipy, mpmath). About 20 s.
"""
import numpy as np, mpmath as mp, ast, os, itertools
from scipy import constants as Kc
from scipy.special import erfc
from scipy.spatial import ConvexHull

mp.mp.dps = 30
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
PI = np.pi

def hdr(s): print("\n" + "=" * 100 + "\n" + s + "\n" + "=" * 100)

hdr("0. Constants (scipy CODATA)")
print(f"m_e {me:.8f} MeV, m_mu {mmu:.7f} MeV, m_tau {mtau:.2f} MeV, 1/alpha {1/alpha:.9f}")
T_pair, T_one, T_l1 = 2 * mtau / mmu, mtau / mmu, 2 * mmu / me
print(f"targets: 2 m_tau/m_mu = {T_pair:.5f}, m_tau/m_mu = {T_one:.5f}; level 1's 2 m_mu/m_e = {T_l1:.4f}")

# ------------------------------------------------------------------------------------------------------------------
hdr("1. Ewald site potentials (mean-zero convention, unit volume per site, units of e/d), spherical cutoffs")
# primitive vectors with the conventional cube side a chosen so the volume per site is 1
A_BCC, A_FCC = 2 ** (1 / 3), 4 ** (1 / 3)
PRIM = {
    "sc":  np.eye(3),
    "bcc": 0.5 * A_BCC * np.array([[-1, 1, 1], [1, -1, 1], [1, 1, -1]], float),
    "fcc": 0.5 * A_FCC * np.array([[0, 1, 1], [1, 0, 1], [1, 1, 0]], float),
}
NB = {"sc": 1, "bcc": 2, "fcc": 4}
ASIDE = {"sc": 1.0, "bcc": A_BCC, "fcc": A_FCC}

def lattice_points(prim, rmax):
    """All lattice vectors with 0 < |R| <= rmax (spherical cutoff), by enumerating a safe index box."""
    inv = np.linalg.inv(prim)                      # rows of inv.T are the reciprocal basis / 2pi
    nmax = int(np.ceil(rmax * np.max(np.linalg.norm(inv, axis=0)))) + 1
    rng = np.arange(-nmax, nmax + 1)
    n = np.array(np.meshgrid(rng, rng, rng, indexing="ij")).reshape(3, -1).T
    R = n @ prim
    r = np.linalg.norm(R, axis=1)
    keep = (r > 1e-12) & (r <= rmax)
    return r[keep]

def ewald(prim, eta, tol=1e-16):
    V = abs(np.linalg.det(prim))
    rec = 2 * PI * np.linalg.inv(prim).T
    # cutoffs from the tolerance: erfc(eta r)/r < tol and exp(-G^2/4eta^2)/G^2 < tol
    rmax = np.sqrt(-np.log(tol)) / eta + 2.0
    gmax = 2 * eta * np.sqrt(-np.log(tol)) + 2.0
    r = lattice_points(prim, rmax)
    g = lattice_points(rec, gmax)
    real = np.sum(erfc(eta * r) / r)
    recip = (4 * PI / V) * np.sum(np.exp(-g ** 2 / (4 * eta ** 2)) / g ** 2)
    return real + recip - 2 * eta / np.sqrt(PI) - PI / (eta ** 2 * V), len(r), len(g)

PHI = {}
MADELUNG_MEMORY = {"sc": -0.880059, "bcc": -0.895929, "fcc": -0.895874}   # e^2/a_ws, from memory
a_ws = (3 / (4 * PI)) ** (1 / 3)                                       # in units of d
for name, prim in PRIM.items():
    vals = []
    for eta in (0.9, 1.5, 2.5, 3.5):
        p, nr, ng = ewald(prim, eta)
        vals.append(p)
        print(f"  {name:3s} eta {eta:3.1f}: phi_site = {p:.12f}   ({nr} real-space, {ng} reciprocal vectors)")
    PHI[name] = vals[2]
    spread = max(vals) - min(vals)
    mad = PHI[name] / 2 * a_ws
    print(f"  {name:3s} spread over eta {spread:.1e}; Madelung energy phi/2 x a_ws = {mad:.6f} e^2/a_ws"
          f" (memory {MADELUNG_MEMORY[name]}: diff {mad - MADELUNG_MEMORY[name]:+.1e})")
print(f"  sc against the record's -2.8372974795: {PHI['sc'] + 2.8372974795:+.2e}")
print(f"  bcc/sc Madelung ratio {MADELUNG_MEMORY['bcc']/MADELUNG_MEMORY['sc']:.4f} (the lock's 'about 2% deeper')")

# ------------------------------------------------------------------------------------------------------------------
hdr("2. Wigner-Seitz second moments <rho^2>, exactly, by tetrahedra from the cell's vertices (units of a^2)")
def perms_signs(base):
    pts = set()
    for p in itertools.permutations(base):
        for s in itertools.product([1, -1], repeat=3):
            pts.add(tuple(np.array(p) * np.array(s)))
    return np.array(sorted(pts), float)

WS_VERTS = {
    "sc":  perms_signs((0.5, 0.5, 0.5)),                       # the cube: 8 vertices
    "bcc": perms_signs((0.5, 0.25, 0.0)),                      # truncated octahedron: 24 vertices
    "fcc": np.vstack([perms_signs((0.5, 0.0, 0.0)), perms_signs((0.25, 0.25, 0.25))]),   # rhombic dodecahedron: 14
}
def second_moment_polytope(verts):
    """Volume and integral of r^2 over a convex polytope containing the origin, via tetrahedra (0, v1, v2, v3)."""
    hull = ConvexHull(verts)
    V = 0.0; I2 = 0.0
    for s in hull.simplices:
        v1, v2, v3 = verts[s]
        vol = abs(np.linalg.det(np.array([v1, v2, v3]))) / 6
        I2 += vol / 10 * (v1 @ v1 + v2 @ v2 + v3 @ v3 + v1 @ v2 + v1 @ v3 + v2 @ v3)
        V += vol
    return V, I2

CLOSED = {"sc": 1 / 4, "bcc": 57 / 384, "fcc": 3 / 32}
RHO2 = {}
rng = np.random.default_rng(7)
for name, verts in WS_VERTS.items():
    V, I2 = second_moment_polytope(verts)
    RHO2[name] = I2 / V
    # also verify the vertex set IS the Wigner-Seitz cell: every vertex equidistant from the origin and >= 4 neighbours
    print(f"  {name:3s}: {len(verts)} vertices, volume {V:.10f} (expected {1/NB[name]:.10f}), "
          f"<rho^2> = {RHO2[name]:.12f} a^2; closed form {CLOSED[name]:.12f}; diff {RHO2[name]-CLOSED[name]:+.1e}")
    # Monte Carlo cross-check: nearest-site distance^2 averaged over the conventional cube
    prim = PRIM[name] / ASIDE[name]                          # conventional cube side 1
    sh = np.array(list(itertools.product([-2, -1, 0, 1, 2], repeat=3)), float) @ prim
    pts = rng.random((400000, 3)) - 0.5
    d2 = np.min(((pts[:, None, :] - sh[None, :, :]) ** 2).sum(-1), axis=1)
    print(f"       Monte Carlo (4e5 points): {d2.mean():.5f} +- {d2.std()/np.sqrt(len(d2)):.5f}")
# Conway-Sloane normalized second moments G = (1/3) <rho^2> / V^(2/3)
for name in RHO2:
    G = RHO2[name] / 3 / (1 / NB[name]) ** (2 / 3)
    print(f"  {name:3s}: normalized second moment G = {G:.7f}  (memory: cube 0.0833333, bcc 0.0785433, fcc 0.0787451)")
print(f"  exact: G_bcc = 19/(192 2^(1/3)) = {19/(192*2**(1/3)):.7f}; G_fcc = 2^(-11/3) = {2**(-11/3):.7f}")

# ------------------------------------------------------------------------------------------------------------------
hdr("3. Whole-cell term B = (2 pi/3) <rho^2>_cell / d^2, and other terminations (units of e/d)")
B_WS = {n: (2 * PI / 3) * RHO2[n] * NB[n] ** (2 / 3) for n in RHO2}     # a = nb^(1/3) d
for n in B_WS:
    print(f"  {n:3s} Wigner-Seitz: B = {B_WS[n]:.7f}" + ("  (= pi/6 = %.7f)" % (PI / 6) if n == "sc" else ""))
B_sphere = (2 * PI / 3) * 0.6 * a_ws ** 2
print(f"  sphere of the same volume (the least second moment any cell can have): B = {B_sphere:.7f}")

def conv_cube_S(basis_pts, centre, nb):
    """(1/e a^2) x integral of rho r^2 over the unit cube centred at `centre`, lattice points counted with the
    fraction of them inside the closed cube (1, 1/2, 1/4, 1/8), background -nb spread uniformly. The moment is
    taken about the cube's centre; for a dipole-free cell it is origin-independent."""
    S = 0.0; count = 0.0
    for p in basis_pts:
        q = p - centre
        if np.all(np.abs(q) <= 0.5 + 1e-12):
            k = int(np.sum(np.isclose(np.abs(q), 0.5)))
            w = 1 / 2 ** k
            S += w * (q @ q); count += w
    dip = sum((1 / 2 ** int(np.sum(np.isclose(np.abs(p - centre), 0.5)))) * (p - centre)
              for p in basis_pts if np.all(np.abs(p - centre) <= 0.5 + 1e-12))
    return S - nb * 0.25, count, dip

BASIS = {"sc": np.array([[0, 0, 0]]), "bcc": np.array([[0, 0, 0], [.5, .5, .5]]),
         "fcc": np.array([[0, 0, 0], [0, .5, .5], [.5, 0, .5], [.5, .5, 0]])}
TERMS = {
    "sc":  (("centred on the quon (Aspden's cube = its Wigner-Seitz cell)", np.zeros(3)),
            ("quon at the 8 corners, counted 1/8 each (the lock's fractional recipe applied to Aspden's own lattice)", np.array([.5, .5, .5]))),
    "bcc": (("centred on a quon, 8 corner quons counted 1/8 (the lock's variant)", np.zeros(3)),
            ("shifted to (1/4,1/4,1/4): both quons whole and interior", np.array([.25, .25, .25]))),
    "fcc": (("centred on a quon, 12 edge quons counted 1/4 (the lock's variant)", np.zeros(3)),
            ("shifted to (1/4,1/4,1/4): all four quons whole and interior", np.array([.25, .25, .25])),
            ("shifted to (1/4,1/4,0): two whole, four halved on the z faces", np.array([.25, .25, 0]))),
}
CQ = 96 * (96 * mp.pi) ** 3                        # Q = CQ alpha x^9
def solve_x(L):
    f = lambda x: 8 * mp.pi * x ** 2 + 1 / (4608 * mp.pi * x ** 4) - L
    return mp.findroot(f, mp.mpf("0.3"))
def L_of(x): return 8 * mp.pi * x ** 2 + 1 / (4608 * mp.pi * x ** 4)
print("  The same infinite lattice tiled by different neutral, dipole-free cells gives different B (a surface-termination term):")
for n in ("sc", "bcc", "fcc"):
    sh = np.array(list(itertools.product([-1, 0, 1], repeat=3)), float)
    pts = (BASIS[n][None] + sh[:, None]).reshape(-1, 3)
    for label, centre in TERMS[n]:
        S, cnt, dip = conv_cube_S(pts, centre, NB[n])
        Bcv = -(2 * PI / 3) * S * NB[n] ** (-1 / 3)
        L = -(PHI[n] + Bcv); xx = solve_x(mp.mpf(L)); QQ = float(CQ * alpha * xx ** 9)
        print(f"  {n:3s} cube {label}: quons {cnt:.2f}, dipole {np.round(dip, 6)}, S = {S:+.5f} a^2 -> B = {Bcv:+.7f},"
              f" L = {L:.4f}, x = {float(xx):.4f}, Q = {QQ:.1f}")

# ------------------------------------------------------------------------------------------------------------------
hdr("4. The balance 8 pi x^2 + 1/(4608 pi x^4) = L, then Q = 96 (96 pi)^3 alpha x^9 (= (3/4pi)(96pi)^3 128pi alpha x^9)")
CQ_lock = (3 / (4 * mp.pi)) * (96 * mp.pi) ** 3 * 128 * mp.pi
print(f"  coefficient check: 96 (96 pi)^3 = {float(CQ):.6e}; the lock's (3/4pi)(96pi)^3 128pi = {float(CQ_lock):.6e}")

cases = [("sc", "WS", PHI["sc"], B_WS["sc"]),
         ("bcc", "WS", PHI["bcc"], B_WS["bcc"]),
         ("bcc", "conv cube (fractional)", PHI["bcc"], -(2 * PI / 3) * 0.25 * 2 ** (-1 / 3)),
         ("fcc", "WS", PHI["fcc"], B_WS["fcc"]),
         ("fcc", "conv cube (fractional)", PHI["fcc"], -(2 * PI / 3) * 0.5 * 4 ** (-1 / 3))]
ROWS = []
for name, cell, phi, B in cases:
    L = -(phi + B)
    x = solve_x(mp.mpf(L))
    Q = CQ * alpha * x ** 9
    N0 = (1 / (128 * mp.pi * alpha * x ** 3)) ** 3
    NA = (mp.mpf(9) / 8) ** 3 * x ** -6
    E2 = Q * mmu / 1e3                                     # GeV
    d2 = Kc.hbar / (2 * Kc.m_e * Kc.c) * (me / mmu) / float(x)
    inv_alpha_I5 = 144 * mp.pi * x
    ROWS.append((name, cell, phi, B, L, float(x), float(Q), float(N0), float(E2)))
    print(f"  {name:3s} {cell:24s}: phi {phi:.7f}, B {B:+.7f}, L {L:.7f}, x {float(x):.10f}, Q {float(Q):.4f}, "
          f"N0 {float(N0):.3f} (Aspden's form {float(NA):.3f}), E0,2 = {float(E2):.3f} GeV, d2 = {d2:.4e} m, "
          f"Q/pair {float(Q)/T_pair:.3f}, Q/one {float(Q)/T_one:.3f}; I5 at level 2 would give 1/alpha = {float(inv_alpha_I5):.3f}")
x_sc = ROWS[0][5]; L_sc = ROWS[0][4]; Q_sc = ROWS[0][6]
print(f"  sc x against the record's 0.3028737692: {x_sc - 0.3028737692:+.1e}; Aspden's N form {float((mp.mpf(9)/8)**3 * mp.mpf(x_sc)**-6):.4f} vs 1844.538")
# level 1 forms
x_A = 0.30291588                                           # Aspden's x with N = 1843 (Part 1 step 2)
Q_univ_A = float(CQ) * alpha * x_A ** 9
Q_his_A = (3 / (4 * PI)) * (96 * PI) ** 3 * (8 / 9) * x_A ** 8
Q_his_sc = (3 / (4 * PI)) * (96 * PI) ** 3 * (8 / 9) * x_sc ** 8
print(f"  level 1 at Aspden's x = {x_A}: universal-alpha form {Q_univ_A:.4f}, his form {Q_his_A:.4f} "
      f"(ratio - 1 = {Q_univ_A/Q_his_A - 1:+.2e}; his 412.6658); 2 m_mu/m_e = {T_l1:.4f}")
print(f"  level 1 at the F = 1 root x = {x_sc:.7f}: universal-alpha form {Q_sc:.4f}, his form {Q_his_sc:.4f} "
      f"(ratio - 1 = {Q_sc/Q_his_sc - 1:+.2e} = the 140 ppm of 144 pi x = {144*PI*x_sc:.4f} against 137.036)")
print(f"  the model's level-1 Q ({Q_sc:.4f}) against Aspden's 412.6658: {(Q_sc/412.6658 - 1)*100:+.3f}%; against 2 m_mu/m_e: {(Q_sc/T_l1-1)*100:+.3f}%")

# ------------------------------------------------------------------------------------------------------------------
hdr("5. The targets, and the way the lattices move")
for tn, T in (("tau pair", T_pair), ("one tau", T_one)):
    xT = (mp.mpf(T) / (CQ * alpha)) ** (mp.mpf(1) / 9)
    LT = L_of(xT)
    # in the photon-unit (I5) form, Q = (3/4pi)(96pi)^3 (8/9) x^8
    xT5 = (mp.mpf(T) / ((3 / (4 * mp.pi)) * (96 * mp.pi) ** 3 * mp.mpf(8) / 9)) ** (mp.mpf(1) / 8)
    print(f"  {tn:8s}: Q = {T:.4f} needs x = {float(xT):.7f}, L = {float(LT):.7f} ({(1-float(LT)/L_sc)*100:.1f}% below sc's {L_sc:.7f});"
          f" with I5's alpha instead: x = {float(xT5):.4f}, L = {float(L_of(xT5)):.4f} ({(1-float(L_of(xT5))/L_sc)*100:.1f}% below)")
for r in ROWS[1:]:
    print(f"  {r[0]:3s} {r[1]:24s}: L x{r[4]/L_sc:.4f}, Q x{r[6]/Q_sc:.4f} -> {'away' if r[6] > Q_sc else 'toward'};"
          f" (L/L_sc)^4.5 = {(r[4]/L_sc)**4.5:.4f}")
# sensitivity
xs = mp.mpf(x_sc)
dLdx = 16 * mp.pi * xs - 4 / (4608 * mp.pi * xs ** 5)
print(f"  sensitivity at sc: d ln Q / d ln L = 9 (L/x)/(dL/dx) = {float(9 * L_sc / xs / dLdx):.3f}")
print(f"  what phi_site would give the tau pair with B = pi/6: {-(float(L_of((mp.mpf(T_pair)/(CQ*alpha))**(mp.mpf(1)/9))) + PI/6):.4f} e/d"
      f" = a Madelung energy of {-(float(L_of((mp.mpf(T_pair)/(CQ*alpha))**(mp.mpf(1)/9))) + PI/6)/2*a_ws:.4f} e^2/a_ws (sc -0.880, bcc -0.896)")

# ------------------------------------------------------------------------------------------------------------------
hdr("6. Q3: the nearest particle and the chance measure (U44's list, read from ladder_scan.py)")
src = open("/home/doug/aetherscience.org/aspden-investigation/sim/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(t, "id", None) == "P" for t in node.targets):
        PL = ast.literal_eval(node.value)
names = list(PL); masses = np.array([PL[k] for k in names])
print(f"  {len(names)} particles, {masses.min()} to {masses.max()} MeV; log range {np.log(masses.max()/masses.min()):.4f}")

def union_measure(centres, half):
    iv = sorted((c - half, c + half) for c in centres)
    tot = 0.0; cs, ce = iv[0]
    for a, b in iv[1:]:
        if a > ce: tot += ce - cs; cs, ce = a, b
        else: ce = max(ce, b)
    return tot + (ce - cs)

def nearest_p(E, ms, nmc=400000):
    lm = np.log(ms); lE = np.log(E)
    i = int(np.argmin(np.abs(lm - lE))); dl = abs(lm[i] - lE)
    lo, hi = lm.min(), lm.max()
    clipped = sorted((max(lo, c - dl), min(hi, c + dl)) for c in lm)
    # union of clipped windows
    tot = 0.0; cs, ce = clipped[0]
    for a, b in clipped[1:]:
        if a > ce: tot += ce - cs; cs, ce = a, b
        else: ce = max(ce, b)
    p = (tot + ce - cs) / (hi - lo)
    # Monte Carlo of the same measure
    u = rng.uniform(lo, hi, nmc)
    pmc = np.mean(np.min(np.abs(u[:, None] - lm[None, :]), axis=1) <= dl)
    return i, (E / ms[i] - 1) * 100, p, pmc

for r in ROWS:
    E2 = r[8] * 1e3
    for reading, ms, lab in (("pair", 2 * masses, "2m"), ("single", masses, "m")):
        i, pct, p, pmc = nearest_p(E2, ms)
        print(f"  {r[0]:3s} {r[1]:24s} E0,2 {E2/1e3:8.3f} GeV as {reading:6s}: nearest {names[i]:8s} ({lab} = {ms[i]/1e3:9.4f} GeV), "
              f"{pct:+7.2f}%, p = {p:.3f} (MC {pmc:.3f})")
# what V4's p < 0.005 actually demands
lm = np.log(masses); lo, hi = lm.min(), lm.max()
for target_p in (0.005, 0.05):
    f = lambda h: union_measure(lm, h) / (hi - lo) - target_p
    import scipy.optimize as so
    h = so.brentq(f, 1e-6, 0.5)
    print(f"  p = {target_p}: a hit must be within {h:.5f} in log mass = {(np.exp(h)-1)*100:.3f}% of a listed mass "
          f"(so V4's 'within 1%' is implied by its p < 0.005 and does no work)")
print(f"  for reference: a 1% match has p = {union_measure(lm, np.log(1.01))/(hi-lo):.3f} on this list")