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

check_rest_positions.py

In the investigation at sim/charge_wave/check_reflection_fable/check_rest_positions.py · last changed in commit 87fc6d0, 12 November 2026 · 9,632 bytes · the folder as a zip


"""check_rest_positions.py - where a uniform-ball quon rests in an even finer grid when it is larger than about 0.57 finer
spacings, and how it is held there. Seventh reviewer's own code and own [D]; not part of the lock (a post hoc check prompted
by check_closed_forms.py, section B).

Two routes to E(u) - E(0): (1) the Fourier series of the lock's D1; (2) a real-space Ewald potential of the point grid
(points -1/N^3 at (i,j,l)/N with a uniform neutralising background) averaged over the ball by the mean-value property:
for a point outside the ball its 1/r is unchanged, for a point inside the ball's own potential (3a^2 - r^2)/(2a^3) replaces it,
and the background's mean over a ball is u-independent apart from -(2 pi/3)|u|^2 ... which is NOT periodic; so the background
is handled inside the Ewald sum (the G = 0 term dropped), which is exact for a periodic neutral system.
Units: finer spacing delta = 1 in this script (so a = a*N); the quon's charge 1; the finer charge -1 per finer cell... no:
to match the lock's units (d = 1), energies are converted: E_lock = E_here / N (lengths scale by 1/N, charges q_f = -1/N^3,
Coulomb energy q q_f / r -> (1/N^3)/(r/N) = N^-2 ... see the code).
Run: ~/aspden-review-venv/bin/python3 check_rest_positions.py > check_rest_positions_out.txt
"""
import itertools, math
import numpy as np
from scipy.special import erfc

B_ASP = 0.036135562
CUT = 41.4

def F_ball(x):
    return 3 * (np.sin(x) - x * np.cos(x)) / x ** 3

def fourier_setup(s2N):
    M = int(math.ceil(math.sqrt(CUT / (2 * math.pi ** 2 * s2N ** 2)))) + 1
    h = np.arange(-M, M + 1)
    m = np.array(list(itertools.product(h, h, h)), float)
    m2 = np.einsum("ni,ni->n", m, m)
    keep = m2 > 0
    return m[keep], m2[keep]

def coef_ball(aN, s2N, m2):
    return F_ball(2 * np.pi * np.sqrt(m2) * aN) * np.exp(-2 * math.pi ** 2 * s2N ** 2 * m2)

def dE_fourier(coef, m, m2, u_fin, N):
    """E(u) - E(0) in the lock's units (d = 1, k = 1): (1/(pi N^2)) sum coef (1 - cos(2 pi m.u_fin))/|m|^2, u_fin in finer spacings."""
    return np.sum(coef / m2 * (1 - np.cos(2 * np.pi * (m @ u_fin)))) / (math.pi * N ** 2)

def K_tensor(coef, m, m2, u_fin):
    """Stiffness tensor at offset u (units 4 pi, k = 1): sum coef cos(2 pi m.u) m m^T/|m|^2."""
    w = coef * np.cos(2 * np.pi * (m @ u_fin)) / m2
    return np.einsum("n,ni,nj->ij", w, m, m)

# ------------------------------------------------------------------ real-space Ewald route (finer spacing = 1, point charges -1 at sites,
# background +1; a quon of charge 1 as a uniform ball of radius a; energy per quon; converted to the lock's units at the end)
ETA = 2.0
RNG = np.array(list(itertools.product(range(-5, 6), repeat=3)), float)
GV = 2 * np.pi * np.array([v for v in itertools.product(range(-7, 8), repeat=3) if any(v)], float)
G2 = np.einsum("ni,ni->n", GV, GV)
AG = np.exp(-G2 / (4 * ETA ** 2)) / G2

def E_ball_real(u, a):
    """Energy of a unit uniform ball of radius a centred at u (finer units) in the field of point charges -1 at the integer
    sites plus a uniform background +1 (Ewald, G = 0 dropped; constants that do not depend on u are left out)."""
    d = RNG - u                       # vectors from the ball's centre to the sites
    r = np.linalg.norm(d, axis=1)
    inside = r < a
    # outside points: the ball acts as a point charge, Ewald real-space term erfc(eta r)/r with charge -1
    E = -np.sum(erfc(ETA * r[~inside]) / r[~inside])
    # inside points: replace 1/r by the ball's interior potential; keep the Ewald split consistent: the reciprocal sum below
    # contains erf(eta r)/r for every point, so for an inside point add [phi_ball(r) - 1/r] + [1/r - erf(eta r)/r] = phi_ball - erf(eta r)/r
    for rr in r[inside]:
        phib = (3 * a ** 2 - rr ** 2) / (2 * a ** 3)
        erfterm = (2 * ETA / math.sqrt(math.pi)) if rr < 1e-12 else math.erf(ETA * rr) / rr
        E += -(phib - erfterm)
    # reciprocal part: the periodic Gaussian-smeared point lattice (charge -1 per cell) with its background, at the ball's CENTRE.
    # Why the centre and not the ball average: psi = phi_grid + (2 pi/3)|r - u|^2 is harmonic in the ball except for the -1/|r - r_j|
    # of the points inside; adding those back gives a harmonic h whose ball mean is h(u). So <phi_grid> = phi_excl(u)
    # - sum_inside phi_ball(rho_j) - (2 pi/3)(3 a^2/5), where phi_excl is the full Ewald potential at u less the inside points' 1/rho.
    # (A first version of this check averaged the Ewald terms over the ball; that is wrong for the short-range part and was removed.)
    E += -4 * np.pi * np.sum(AG * np.cos(GV @ u))
    return E

def dE_real(u, a, N):
    """E(u) - E(0) converted to the lock's units: lengths x 1/N, finer charge -1/N^3: energy scales as (1/N^3)/(1/N) = 1/N^2."""
    return (E_ball_real(np.asarray(u, float), a) - E_ball_real(np.zeros(3), a)) / N ** 2

print("Seventh reviewer: rest positions of a uniform-ball quon in an even finer grid (own code; post hoc to the trial)\n")
print("1. Two routes to E(u) - E(0), N = 4, finer quons as points (Fourier with a Gaussian of s2 N = 0.01 for convergence):")
m, m2 = fourier_setup(0.01)
print(f"   Fourier vectors: {len(m)}")
pts = {"edge midpoint (0,0,1/2)": np.array([0, 0, 0.5]), "face centre (0,1/2,1/2)": np.array([0, 0.5, 0.5]),
       "cube centre (1/2,1/2,1/2)": np.array([0.5, 0.5, 0.5]), "(0,0,1/4)": np.array([0, 0, 0.25])}
for aN in (0.5, 0.55, 0.6, 0.7, 0.8, 0.9, 1.0):
    coef = coef_ball(aN, 0.01, m2)
    print(f"   a*N = {aN:.2f}:")
    for name, u in pts.items():
        f = dE_fourier(coef, m, m2, u, 4)
        r = dE_real(u, aN, 4)
        print(f"      {name:28s} Fourier {f:+.6e}   real-space Ewald {r:+.6e}   diff {abs(f-r):.1e}")

# ------------------------------------------------------------------ 2. the global minimum and the hold tensor there, as a*N grows
print("\n2. Global minimum of E(u) over the wedge (i,j,l)/32 of a finer cell, the stiffness tensor there (eigenvalues, units 4 pi),")
print("   and how many finer quons the ball holds there. Finer quons Gaussian with s2 N = 0.02 (as R2b). K_T = trace/3.")
m, m2 = fourier_setup(0.02)
wedge = np.array([(i, j, l) for i in range(17) for j in range(i, 17) for l in range(j, 17)], float) / 32
phase = 1 - np.cos(2 * np.pi * (wedge @ m.T))
print("     a*N    y_f     K_T(0)    rest position     E(rest)-E(0)   n inside   K_T(rest)   eigenvalues of K(rest)            stable there?")
rows = []
for aN in [0.45, 0.50, 0.55, 0.56, 0.57, 0.58, 0.60, 0.62, 0.65, 0.70, 0.75, 0.80, 0.85, 0.87, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20, 1.30, 1.40, 1.50]:
    coef = coef_ball(aN, 0.02, m2)
    dE = (coef / m2) @ phase.T / (math.pi * 16)
    t = int(np.argmin(dE))
    u = wedge[t]
    K0 = K_tensor(coef, m, m2, np.zeros(3))
    Kr = K_tensor(coef, m, m2, u)
    ev = np.linalg.eigvalsh(0.5 * (Kr + Kr.T))
    sites = np.array(list(itertools.product(range(-2, 3), repeat=3)), float)
    nin = int(np.sum(np.linalg.norm(sites - u, axis=1) < aN))
    yf = 4 * math.pi / 3 * aN ** 3
    rows.append((aN, u, ev))
    print(f"     {aN:.2f}  {yf:6.3f}  {np.trace(K0)/3:+.4f}   ({u[0]*32:2.0f},{u[1]*32:2.0f},{u[2]*32:2.0f})/32     {dE[t]:+.4e}      {nin}      "
          f"{np.trace(Kr)/3:+.4f}    {ev[0]:+.4f} {ev[1]:+.4f} {ev[2]:+.4f}    {'yes' if ev[0] > 0 else 'NO'}"
          f"   (n/y_f - 1)/3 = {(nin/yf - 1)/3:+.4f}")
print("   Reading: the quon rests on a finer quon up to a*N = 0.56; from 0.57 to about 0.86 at the midpoint of an edge, holding two finer")
print("   quons; from about 0.87 at the cube's centre, holding eight (isotropic by symmetry); the face centre (four) is the minimum")
print("   only in a narrow band if at all (check the rows). Where the ball holds n finer quons entirely, K_T(rest) = (n/y_f - 1)/3 exactly")
print("   (the trace rule), and the tensor is isotropic only at positions of cubic symmetry (u = 0 and the cube centre).")

# ------------------------------------------------------------------ 3. the same at Aspden's radius for N up to 60
print("\n3. At Aspden's radius b/d = 0.036135562: the rest position and the hold there for N = 12..60 (the paper's table stops at 17")
print("   with 'pushed off' for 18 to 27). Finer quons Gaussian s2 N = 0.02; wedge (i,j,l)/32.")
print("      N    a*N     rest position   n inside   K_T(0)     K_T(rest)   lowest eigenvalue   share 1/(1+K_T(rest))   sc stable (min eig >= 0.0927)?")
for N in list(range(12, 31)) + [32, 35, 40, 45, 50, 60]:
    aN = N * B_ASP
    coef = coef_ball(aN, 0.02, m2)
    dE = (coef / m2) @ phase.T / (math.pi * N ** 2)
    t = int(np.argmin(dE))
    u = wedge[t]
    K0 = K_tensor(coef, m, m2, np.zeros(3))
    Kr = K_tensor(coef, m, m2, u)
    ev = np.linalg.eigvalsh(0.5 * (Kr + Kr.T))
    sites = np.array(list(itertools.product(range(-2, 3), repeat=3)), float)
    nin = int(np.sum(np.linalg.norm(sites - u, axis=1) < aN))
    kt = np.trace(Kr) / 3
    print(f"     {N:3d}  {aN:.4f}   ({u[0]*32:2.0f},{u[1]*32:2.0f},{u[2]*32:2.0f})/32      {nin}      {np.trace(K0)/3:+.4f}    {kt:+.4f}      {ev[0]:+.4f}            "
          f"{(1/(1+kt) if kt > 0 else float('nan')):.3f}                 {ev[0] >= 0.0927}")
print("   Note: 'sc stable' here uses the lowest eigenvalue of the hold tensor against trial 2's -0.0927 at M, which is only an")
print("   estimate when the tensor is not isotropic (trial 2 assumed the same stiffness in every direction). A tetragonal rest")
print("   position (edge midpoint) would also make the medium birefringent for light at long wavelengths: a different dielectric")
print("   constant for E along the edge and across it. The cube centre is cubic and gives none.")