Does light charge the quons? › Files cited on the page › check_trials25-27_fable/

a3_random.py

In the investigation at sim/m8_engine/check_trials25-27_fable/a3_random.py · last changed in commit 46c285d, 25 November 2026 · 5,443 bytes · the folder as a zip


"""A3 (blind): bands of all three families filled at random with fraction p, lone-charge polarizability alpha = 3y.
The static permittivity to lowest order beyond Clausius-Mossotti. Thirty-fifth reviewer, 25 November 2026.

By hand [D], units d = eps0 = 1. Let G_ij be the static field along band i from a unit dipole on band j (G_ii = -1/3; G symmetric;
sum_j over all x-bands of G_ij = 0, because a uniform polarization makes no field). A charge on band i, bare answer alpha_b
(1/alpha = 1/alpha_b + 1/3), obeys P_i = n_i alpha_b (E0 + sum_j G_ij P_j), n_i = 1 with probability p. Expand in alpha_b and average,
with <n_i n_j n_k> = p^3 + p^2(1-p)(d_ij + d_ik + d_jk) + p(1-p)(1-2p) d_ij d_jk. Per cell (one x-band per cell):
  <P>/E0 = p alpha_b - p(1-p) alpha_b^2/3 + [p(1-p)^2/9 + p^2(1-p) T'] alpha_b^3 + ...,   T' = sum_{j != i} G_ij^2 (all three families).
Clausius-Mossotti, eps_CM = (1 + 2py)/(1 - py) = 1 + p alpha_b/(1 + (1-p) alpha_b/3), gives p alpha_b - p(1-p) alpha_b^2/3 + p(1-p)^2 alpha_b^3/9 - ...
So CM is exact through alpha_b^2, and the first correction is
  eps - eps_CM = p^2 (1-p) T' alpha_b^3 + O(alpha_b^4) = 27 p^2 (1-p) T' y^3 + O(y^4).
Its physics: a filled band polarizes its neighbours (of all three families) and their dipoles act back on it; the mean field counts that
return with the neighbours' average dipole, but a neighbour's induced dipole is there only when the neighbour is (p^2, not p^3), and
is correlated with the first. It vanishes at p = 1 (CM exact, the outline's crystal) and at order p (dilute), and is positive.
"""
import subprocess, sys, time
import numpy as np

sys.path.insert(0, "/home/doug/aetherscience.org/aspden-investigation/sim/m8_engine")
import engine as eng

print("git HEAD:", subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True,
                                  cwd="/home/doug/aetherscience.org/aspden-investigation").stdout.strip())
print("clock:", time.strftime("%Y-%m-%d %H:%M:%S %Z"))


def lattice_green(shape):
    """Potential of a unit point charge at the origin, lattice Laplacian, k = 0 removed."""
    kv = [2 * np.pi * np.fft.fftfreq(n) for n in shape]
    K2 = sum(np.abs(np.exp(1j * k) - 1) ** 2 for k in np.meshgrid(*kv, indexing="ij"))
    K2[(0,) * 3] = 1.0
    Vh = np.ones(shape) / K2
    Vh[(0,) * 3] = 0.0
    return np.real(np.fft.ifftn(Vh))


print("\n-- lattice constants --")
for N in (32, 64):
    shape = (N, N, N)
    G = lattice_green(shape)
    print(f"N = {N}: G(0,0,0) = {G[0, 0, 0]:.7f}, G(1,0,0) = {G[1, 0, 0]:.7f} (G(0) - 1/6 = {G[0, 0, 0] - 1 / 6:.7f}), G(1,1,0) = {G[1, 1, 0]:.7f}, G(1,1,1) = {G[1, 1, 1]:.7f}")
    P = np.zeros((3, *shape)); c = N // 2; P[0, c, c, c] = 1.0
    E = eng.static_field_of(P)
    self_f = E[0, c, c, c]
    Tp = float(np.sum(E**2) - self_f**2)
    print(f"        unit dipole on an x-band: self-field {self_f:.7f} (by hand -(1/3)(1 - 1/N^3) = {-(1 - 1 / N**3) / 3:.7f});"
          f" T' = sum over the other bands of G^2 = {Tp:.7f}")
    print(f"        field along the y-band of the same corner: C_xy = {E[1, c, c, c]:.7f}; by hand -(G(0) - 2 G(1,0,0) + G(1,1,0)) = {-(G[0, 0, 0] - 2 * G[1, 0, 0] + G[1, 1, 0]):.7f}")
    print(f"        along the y-band at the far end (corner + e_x): {E[1, c + 1, c, c]:.7f}; along the next x-band in line: {E[0, c + 1, c, c]:.7f}; x-band one cell sideways: {E[0, c, c + 1, c]:.7f}")
    if N == 64:
        TP = Tp

print("\n-- series coefficients from random fillings (N = 32, per cell, coefficient of alpha_b^k E0) --")
N = 32; shape = (N, N, N); E0 = np.zeros((3, *shape)); E0[0] = 1.0
print(f"{'p':>5} {'seed':>4} {'c1':>9} {'c2':>10} {'c3':>10} | {'CM c2':>10} {'CM c3':>10} {'c3 by hand':>10}")
for p in (0.25, 0.5, 0.75):
    c3s = []
    for seed in range(4):
        rng = np.random.default_rng(seed)
        n = (rng.random((3, *shape)) < p).astype(float)
        P1 = n * E0
        P2 = n * eng.static_field_of(P1)
        P3 = n * eng.static_field_of(P2)
        c1, c2, c3 = P1[0].mean(), P2[0].mean(), P3[0].mean()
        c3s.append(c3)
        print(f"{p:>5} {seed:>4} {c1:>9.5f} {c2:>10.6f} {c3:>10.6f} | {-p * (1 - p) / 3:>10.6f} {p * (1 - p)**2 / 9:>10.6f} {p * (1 - p)**2 / 9 + p * p * (1 - p) * TP:>10.6f}")
    print(f"      mean c3 over seeds = {np.mean(c3s):.6f} +- {np.std(c3s) / 2:.6f};  by hand {p * (1 - p)**2 / 9 + p * p * (1 - p) * TP:.6f};  CM {p * (1 - p)**2 / 9:.6f}")

print("\n-- full static solution at p = 0.5 (N = 32; eps_CM at the sample's own x-band fraction) --")
p = 0.5
print(f"{'y':>5} {'alpha_b':>8} {'eps run':>10} {'eps_CM':>10} {'run - CM':>10} {'by hand p^2(1-p)T' + 'alpha_b^3':>22}")
for y in (0.05, 0.10, 0.15):
    ab = 3 * y / (1 - y)
    res = []
    for seed in range(4):
        rng = np.random.default_rng(seed)
        n = (rng.random((3, *shape)) < p).astype(float)
        P = ab * n * E0
        for it in range(400):
            Pn = ab * n * (E0 + eng.static_field_of(P))
            if np.abs(Pn - P).max() < 1e-13:
                P = Pn; break
            P = Pn
        px = n[0].mean()
        eps = 1 + P[0].mean()
        eps_cm = 1 + px * ab / (1 + (1 - px) * ab / 3)
        res.append((eps, eps_cm))
    res = np.array(res)
    d = res[:, 0] - res[:, 1]
    print(f"{y:>5} {ab:>8.4f} {res[:, 0].mean():>10.6f} {res[:, 1].mean():>10.6f} {d.mean():>10.6f} +- {d.std() / 2:.6f} {p * p * (1 - p) * TP * ab**3:>12.6f}")
print("clock:", time.strftime("%Y-%m-%d %H:%M:%S %Z"))