Does light charge the quons? › Files cited on the page › check_trial23_fable/
dipole_lattice_bravais.py
#!/usr/bin/env python3
"""The (k d)^2 law of a lattice of point dipoles: simple cubic, body-centred and face-centred.
29th reviewer, task T1 (trial 23), comparison stage: post hoc, the reviewer's own derivation and code.
Written after reading section 8 of the charging-quons page (lines 595 to 601), which gives the record's
own law for a relay of dipoles: "the relay's group speed changes by (1 - f)^2 x 3 beta (kd)^2 / (2f)",
beta = -0.013 to +0.057 on the simple cubic lattice and +0.003 to +0.023 on the body-centred one, "the
electric part only. The magnetic coupling has its own lattice correction, of order 1/8 ... which was not
computed here and adds to it."
This script computes the whole law (electric part and retardation together) for the three cubic lattices
and separates the two parts, so that the record's beta can be checked and its uncomputed part supplied.
Physics, term by term (Gaussian units inside the bare space the dipoles sit in; d = cube root of the
volume per dipole = 1, the record's convention):
* each site holds a charge on a spring, far below its resonance: a fixed polarizability alpha;
* a wave p_j = p exp(i q.r_j) runs over the sites; each dipole is driven by the retarded fields of all
the others; k = omega / (the speed of light in the bare space);
* the wave exists when 1/alpha = e.Lam(q, k).e. For k d -> 0 this is Clausius-Mossotti;
* to order (k d)^2: 1/alpha = CM(m^2) + B (k d)^2, B = b1 + m^2 (b2 + b3 S), m = q/k,
S = sum_j (a_j e_j)^2 (a = direction of travel, e = direction of the dipoles, cube axes).
b2 and b3 multiply q^2: they are how the STATIC dipole sum changes with the wavelength of the
pattern (the record's "electric part"). b1 multiplies k^2 alone: it is the part of each neighbour's
field that exists only because the field takes time to cross (retardation; the record's "magnetic
coupling", not computed there).
* For a relay with share f in the bare space (m0^2 = 1/f, k_bare = sqrt(f) omega/c):
n - 1 = (1 - f)^2 (kd)^2 B / (8 pi), n_g - 1 = 3 (n - 1),
group speed change dv_g/c = (1 - f)^2 (kd)^2 * 3 [ beta/(2f) - b1/(8 pi) ], beta = -(b2 + b3 S)/(4 pi).
The first term is the record's law; the second is the part it left uncomputed.
The lattice sum is done in Fourier space with Gaussian-smeared dipoles (width sigma = 0.07 d), as in
dipole_lattice_dispersion.py: sum over the reciprocal lattice of
(4 pi) (k^2 - ((q+g).e)^2)/(|q+g|^2 - k^2) exp(-|q+g|^2 sigma^2), minus the smeared dipole's own field
at its centre, divided by the form factor exp(-k^2 sigma^2).
Run: OMP_NUM_THREADS=1 ~/aspden-review-venv/bin/python3 dipole_lattice_bravais.py > dipole_lattice_bravais_out.txt 2> dipole_lattice_bravais_err.txt
"""
import math
import subprocess
import sys
import numpy as np
import scipy
from scipy.optimize import brentq
from scipy.special import erfi
NCHK = [0, 0]
def check(name, ok, detail=""):
NCHK[0] += 1
NCHK[1] += 1 if ok else 0
print(" CHECK %s: %s %s" % ("pass" if ok else "FAIL", name, detail))
def head(s):
print()
print("=" * 100)
print(s)
print("=" * 100)
# conventional cube edge a_c for unit volume per site, and the rule that picks the reciprocal lattice's points
LATTICES = {
"simple cubic": (1.0, lambda h, k, l: np.ones_like(h, dtype=bool)),
"body-centred cubic": (2.0 ** (1 / 3), lambda h, k, l: (h + k + l) % 2 == 0),
"face-centred cubic": (4.0 ** (1 / 3), lambda h, k, l: ((h % 2 == k % 2) & (k % 2 == l % 2))),
}
_GRID = {}
def grid(lat, sigma):
key = (lat, sigma)
if key not in _GRID:
ac, rule = LATTICES[lat]
nmax = int(math.ceil(math.sqrt(40.0) / sigma * ac / (2 * math.pi))) + 1
r = np.arange(-nmax, nmax + 1)
h, k, l = np.meshgrid(r, r, r, indexing="ij")
h, k, l = h.ravel(), k.ravel(), l.ravel()
keep = rule(h, k, l)
_GRID[key] = (2 * math.pi / ac) * np.stack([h[keep], k[keep], l[keep]], axis=1).astype(float)
return _GRID[key]
def lam_ee(lat, m, k, a_hat, e_hat, sigma=0.07):
"""Re of e.Lam.e for a wave q = m k a_hat, dipoles along e_hat (volume per site 1). Needs m > 1, k small."""
Q = grid(lat, sigma) + m * k * np.asarray(a_hat)[None, :]
Q2 = np.einsum("ij,ij->i", Q, Q)
Qe = Q @ np.asarray(e_hat)
tot = 4 * math.pi * np.sum((k * k - Qe**2) / (Q2 - k * k) * np.exp(-Q2 * sigma**2))
self_re = -1.0 / (6 * math.sqrt(math.pi) * sigma**3) + (4 * k * k / (3 * math.pi)) * (
math.sqrt(math.pi) / (2 * sigma) - 0.5 * math.pi * k * math.exp(-(k * sigma) ** 2) * erfi(k * sigma))
return math.exp((k * sigma) ** 2) * (tot - self_re)
def cm(m2):
return (4 * math.pi / 3) * (m2 + 2) / (m2 - 1)
def B_of(lat, m2, k, a_hat, e_hat, sigma=0.07):
return (lam_ee(lat, math.sqrt(m2), k, a_hat, e_hat, sigma) - cm(m2)) / k**2
def extrap(fun, ks=(0.2, 0.1, 0.05)):
"""Richardson: the value at k -> 0 of a function with error terms k^2, k^4."""
v = [fun(k) for k in ks]
r1 = (4 * v[1] - v[0]) / 3
r2 = (4 * v[2] - v[1]) / 3
return (16 * r2 - r1) / 15
s2, s3, s6, s14, s42 = math.sqrt(2), math.sqrt(3), math.sqrt(6), math.sqrt(14), math.sqrt(42)
CASES = (
("[100], dipoles along [010]", (1, 0, 0), (0, 1, 0)),
("[110], dipoles along [001]", (1 / s2, 1 / s2, 0), (0, 0, 1)),
("[110], dipoles along [1-10]", (1 / s2, 1 / s2, 0), (1 / s2, -1 / s2, 0)),
("[111], dipoles along [1-10]", (1 / s3, 1 / s3, 1 / s3), (1 / s2, -1 / s2, 0)),
("[111], dipoles along [11-2]", (1 / s3, 1 / s3, 1 / s3), (1 / s6, 1 / s6, -2 / s6)),
("[123], dipoles along [11-1]", (1 / s14, 2 / s14, 3 / s14), (1 / s3, 1 / s3, -1 / s3)),
("[123], dipoles along [-54-1]", (1 / s14, 2 / s14, 3 / s14), (-5 / s42, 4 / s42, -1 / s42)),
)
def S_of(a, e):
return sum((a[i] * e[i]) ** 2 for i in range(3))
if __name__ == "__main__":
try:
headc = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True).stdout.strip()
except Exception as ex: # pragma: no cover
headc = "unknown (%s)" % ex
print("The (k d)^2 law of a lattice of point dipoles: sc, bcc, fcc. 29th reviewer, post hoc, own derivation.")
print("git HEAD: %s ; python %s ; numpy %s ; scipy %s" % (headc, sys.version.split()[0], np.__version__, scipy.__version__))
print("d = the cube root of the volume per dipole (the record's convention, section 8 line 596).")
head("1. Code checks for each lattice")
for lat in LATTICES:
worst = 0.0
for m2 in (2.0, 4.0, 1 / 0.085):
for lab, a, e in CASES:
v = lam_ee(lat, math.sqrt(m2), 1e-4, a, e)
worst = max(worst, abs(v / cm(m2) - 1))
check("%s, k d = 1e-4: e.Lam.e equals Clausius-Mossotti for every case" % lat, worst < 1e-6, "(worst relative difference %.1e)" % worst)
worst = 0.0
for m2 in (4.0, 1 / 0.085):
for lab, a, e in CASES:
v1 = lam_ee(lat, math.sqrt(m2), 0.1, a, e, sigma=0.07)
v2 = lam_ee(lat, math.sqrt(m2), 0.1, a, e, sigma=0.06)
v3 = lam_ee(lat, math.sqrt(m2), 0.1, a, e, sigma=0.08)
worst = max(worst, abs(v1 - v2), abs(v1 - v3))
check("%s, k d = 0.1: the same sum with smearing widths 0.06, 0.07, 0.08 d" % lat, worst < 1e-9, "(largest difference %.1e)" % worst)
head("2. The coefficients: B = b1 + m^2 (b2 + b3 S), fitted to 28 computed cases per lattice")
print(" (7 pairs of direction and polarization, two of them off the symmetry axes, at m^2 = 1.5, 2, 4, 11.76)")
COEF = {}
for lat in LATTICES:
rows, rhs = [], []
for m2 in (1.5, 2.0, 4.0, 1 / 0.085):
for lab, a, e in CASES:
Bc = extrap(lambda k: B_of(lat, m2, k, a, e))
rows.append([1.0, m2, m2 * S_of(a, e)])
rhs.append(Bc)
A, y = np.array(rows), np.array(rhs)
sol = np.linalg.lstsq(A, y, rcond=None)[0]
resid = float(np.max(np.abs(A @ sol - y)))
COEF[lat] = sol
print(" %-20s b1 = %+.6f b2 = %+.6f b3 = %+.6f (largest residual of the fit %.1e)" % (lat, sol[0], sol[1], sol[2], resid))
check("%s: the 28 cases fit the three-coefficient form" % lat, resid < 2e-6, "")
dg = np.array([-1.8915316, 0.1648469, -1.7700004])
check("simple cubic: equals Draine and Goodman's coefficients (FROM MEMORY: -1.8915316, 0.1648469, -1.7700004)",
float(np.max(np.abs(COEF["simple cubic"] - dg))) < 2e-6, "(largest difference %.1e)" % float(np.max(np.abs(COEF["simple cubic"] - dg))))
head("3. The two parts of the law, in the record's own form (section 8, lines 596 to 597)")
print(" group speed change dv_g/c = (1 - f)^2 (kd)^2 * 3 [ beta/(2f) + R ], beta = -(b2 + b3 S)/(4 pi) (electric part),")
print(" R = -b1/(8 pi) (retardation; the record's uncomputed 'magnetic' part, guessed there as 'of order 1/8').")
print(" S runs from 0 (along a cube axis, or along a face diagonal with the dipoles on the third axis) to 1/2")
print(" (along a face diagonal with the dipoles on the other face diagonal); 1/3 along a cube diagonal.")
print(" %-20s %-12s %-12s %-12s %-22s %-14s" % ("lattice", "beta(S=0)", "beta(S=1/3)", "beta(S=1/2)", "the record's range", "3R (retard.)"))
REC = {"simple cubic": "-0.013 to +0.057", "body-centred cubic": "+0.003 to +0.023", "face-centred cubic": "(not given)"}
BETA = {}
for lat in LATTICES:
b1, b2, b3 = COEF[lat]
be = [-(b2 + b3 * S) / (4 * math.pi) for S in (0.0, 1 / 3, 0.5)]
BETA[lat] = be
print(" %-20s %-+12.5f %-+12.5f %-+12.5f %-22s %-+14.5f" % (lat, be[0], be[1], be[2], REC[lat], -3 * b1 / (8 * math.pi)))
be = BETA["simple cubic"]
check("simple cubic: my electric part reproduces the record's range -0.013 to +0.057", abs(min(be) + 0.013) < 6e-4 and abs(max(be) - 0.057) < 6e-4,
"(%.4f to %.4f)" % (min(be), max(be)))
be = BETA["body-centred cubic"]
check("body-centred cubic: my electric part reproduces the record's range +0.003 to +0.023", abs(min(be) - 0.003) < 6e-4 and abs(max(be) - 0.023) < 6e-4,
"(%.4f to %.4f)" % (min(be), max(be)))
head("4. The whole law for a relay with share f in the bare space")
print(" n_g - 1 = -dv_g/c = 3 (1 - f)^2 (kd)^2 B/(8 pi), B = b1 + (b2 + b3 S)/f. Negative: high-energy light arrives EARLY.")
hbarc = 1.9732698045930252e-07 # eV m
T2 = 6.6835e17 # s, Int (1+z)^2 dz/H to z = 0.903 (compare_trial23_out.txt, section 6)
k28 = 28e9 / hbarc
print(" Spacing bound from GRB 090510: limit (e), 10 ms, either sign, 28 GeV, (1+z)^2 weighting (the record's footing in 7.3 and 8).")
print(" Limit (a) (0.859 s) is for a delay only: given where the sign is a delay.")
print(" %-20s %-7s %-6s %-22s %-22s %-14s %-14s" % ("lattice", "f", "S", "electric part only", "whole law", "d below, (e)", "d below, (a)"))
for lat in LATTICES:
b1, b2, b3 = COEF[lat]
for f in (0.01, 0.085, 0.25, 0.5):
for S in (0.0, 1 / 3, 0.5):
el = 3 * (1 - f) ** 2 * (b2 + b3 * S) / f / (8 * math.pi)
full = 3 * (1 - f) ** 2 * (b1 + (b2 + b3 * S) / f) / (8 * math.pi)
d_e = math.sqrt(0.010 / (abs(full) * T2)) / k28
d_a = ("%.2e m" % (math.sqrt(0.859 / (abs(full) * T2)) / k28)) if full > 0 else "no (advance)"
print(" %-20s %-7.3f %-6.3f n_g - 1 = %-+12.4f n_g - 1 = %-+12.4f %-14s %-14s"
% (lat, f, S, el, full, "%.2e m" % d_e, d_a))
# the share at which the whole law changes sign, for S = 0 and S = 1/2
z0 = -b2 / b1
zh = -(b2 + 0.5 * b3) / b1
print(" %-20s the whole law is zero at f = %s (S = 0), %s (S = 1/2)"
% (lat, ("%.4f" % z0) if 0 < z0 < 1 else "none in (0,1)", ("%.4f" % zh) if 0 < zh < 1 else "none in (0,1)"))
print()
head("5. The record's bounds of section 8 (line 599), recomputed, and what the retardation part does to them")
for lat in ("body-centred cubic", "simple cubic"):
b1, b2, b3 = COEF[lat]
be = sorted(BETA[lat], key=abs)
for beta, lab in ((be[-1], "largest |beta|"), (be[0], "smallest |beta|")):
pref = math.sqrt(2 * 0.010 / (3 * abs(beta) * T2)) / k28
print(" %-20s %s = %+.5f: electric part only: d below %.2e x sqrt(f)/(1 - f) m" % (lat, lab, beta, pref))
print(" (the record: 4.6e-27 sqrt(f)/(1-f) m for beta = 0.023 and 1.3e-26 sqrt(f)/(1-f) m for beta = 0.003, body-centred)")
print(" With the retardation part the bound is d below sqrt(0.010 s/(|n_g - 1 coefficient| T2))/k: section 4's column.")
head("6. One direct solution as a check of the closed form (body-centred, f = 0.25, along a cube axis)")
lat, f = "body-centred cubic", 0.25
b1, b2, b3 = COEF[lat]
a, e = CASES[0][1], CASES[0][2]
target = cm(1 / f)
def cn(kd):
kb = math.sqrt(f) * kd
m0 = math.sqrt(1 / f)
msol = brentq(lambda m: lam_ee(lat, m, kb, a, e) - target, m0 * 0.9, m0 * 1.1, xtol=1e-15, rtol=1e-15)
return (msol * math.sqrt(f) - 1) / kd**2
direct = extrap(cn, ks=(0.4, 0.2, 0.1))
closed = (1 - f) ** 2 * (b1 + b2 / f) / (8 * math.pi)
print(" n - 1 over (kd)^2: direct solution %+.5f ; closed form %+.5f" % (direct, closed))
check("the closed form agrees with the direct solution", abs(direct - closed) < 2e-4, "(difference %.1e)" % abs(direct - closed))
head("7. Double refraction: the two polarizations along a face diagonal")
print(" n(dipoles on the third axis) - n(dipoles on the other face diagonal) = (1 - f)^2 (kd)^2 (-b3) / (16 pi f)")
for lat in LATTICES:
b1, b2, b3 = COEF[lat]
print(" %-20s f = 0.25: %+.4f (kd)^2 ; f = 0.085: %+.4f (kd)^2 ; f = 0.01: %+.4f (kd)^2"
% (lat, 0.75**2 * (-b3) / (16 * math.pi * 0.25), 0.915**2 * (-b3) / (16 * math.pi * 0.085), 0.99**2 * (-b3) / (16 * math.pi * 0.01)))
print()
print("Checks: %d of %d pass." % (NCHK[1], NCHK[0]))