Does light charge the quons? › Files cited on the page › the trials
relay_in_time.py
"""relay_in_time.py - trial 3 of the charging-quons work (lock: papers/Lock_relay_in_time_2026-11-12.md).
The relay in time, from all four of Maxwell's equations: a plane wave (E along y, B along z) travelling along x through
sheets of quons, one per cell. Each quon's charge separates by x(t) with m x'' = -K x + q E; P = n q x; dP/dt is the charge
moving inside each cell across the beam (the quons' current); eps_b dE/dt is the displacement current of the space
between the quons (f = eps_b; f = 0 is the relay of section 7.2, item 5). Yee's scheme with the quons' equation by central
differences. Units: mu0 = eps0 = c = 1, dx = 1. Light at c at low frequency: w_q^2 = (1 - f) w_r^2.
Run: ~/aspden-review-venv/bin/python3 relay_in_time.py > relay_in_time_out.txt (writes relay_in_time_B.npz for the figure)
"""
import math
import numpy as np
W0 = 2 * np.pi / 100 # the light's angular frequency (wavelength about 100 cells)
SIG, T0, TEND = 500.0, 3000.0, 20000.0
JL, JR = -10000, 20000 # domain (cells), perfectly conducting ends
X1, X2 = 3000, 11000 # probes
def eps_cont(w, f, wr):
return 1.0 if wr is None else f + (1 - f) * wr**2 / (wr**2 - w**2)
def k_cont(w, f, wr):
return w * math.sqrt(eps_cont(w, f, wr))
def k_disc(w, f, wr, dt):
Om = 2 / dt * math.sin(w * dt / 2)
K = Om * math.sqrt(eps_cont(Om, f, wr))
return 2 * math.asin(K / 2)
def speeds(kfun, *a):
dw = 1e-6 * W0
vp = W0 / kfun(W0, *a)
vg = 2 * dw / (kfun(W0 + dw, *a) - kfun(W0 - dw, *a))
return vp, vg
def run(name, f, R):
wr = None if R is None else R * W0
wq2 = 0.0 if R is None else (1 - f) * wr**2
eb = f
dt = 0.5 * math.sqrt(f)
N = JR - JL + 1; j0 = -JL; i1, i2 = j0 + X1, j0 + X2
E = np.zeros(N); B = np.zeros(N - 1); P = np.zeros(N); Pm = np.zeros(N)
nsteps = int(math.ceil(TEND / dt))
rec = np.zeros((nsteps, 7)) # t, E1, E2, P1, S1, u1 (total), uq1 (quons)
Wt = {}
marks = {int(round(t / dt)): t for t in (8000.0, 14000.0, 19000.0)}
for n in range(nsteps):
t = n * dt
Bn = B - dt * (E[1:] - E[:-1]) # Faraday, B at n+1/2
Pn = 2 * P - Pm + dt * dt * (wq2 * E - (wr * wr if wr else 0.0) * P) if wq2 else P
En = E.copy()
En[1:-1] = E[1:-1] - (dt / eb) * (Bn[1:] - Bn[:-1]) - (Pn[1:-1] - P[1:-1]) / eb # Ampere-Maxwell
ts = (n + 0.5) * dt
En[j0] -= (dt / eb) * math.exp(-(ts - T0) ** 2 / (2 * SIG**2)) * math.sin(W0 * ts)
En[0] = En[-1] = 0.0
# quantities at time n (E, P at n; B averaged over n-1/2 and n+1/2; dP/dt centred)
Bc1 = 0.25 * (B[i1 - 1] + B[i1] + Bn[i1 - 1] + Bn[i1])
uq1 = 0.0
if wq2:
Pd1 = (Pn[i1] - Pm[i1]) / (2 * dt)
uq1 = (Pd1**2 + wr * wr * P[i1] ** 2) / (2 * wq2)
Bsq1 = 0.5 * ((0.5 * (B[i1 - 1] + Bn[i1 - 1])) ** 2 + (0.5 * (B[i1] + Bn[i1])) ** 2)
u1 = 0.5 * eb * E[i1] ** 2 + 0.5 * Bsq1 + uq1
rec[n] = (t, E[i1], E[i2], P[i1], E[i1] * Bc1, u1, uq1)
if n in marks:
Bbar = 0.5 * (B + Bn)
W = 0.5 * eb * np.sum(E**2) + 0.5 * np.sum(Bbar**2)
if wq2:
Pd = (Pn - Pm) / (2 * dt)
W += np.sum(Pd**2 + wr * wr * P**2) / (2 * wq2)
Wt[marks[n]] = W
if name == "B" and n == int(round(12000.0 / dt)):
snap = (E.copy(), 0.5 * (B + Bn), P.copy())
Pm, P, E, B = P, Pn, En, Bn
t, E1, E2, P1, S1, u1, uq1 = rec.T
# group speed: centroid of E^2 arrival
tc1 = np.sum(t * E1**2) / np.sum(E1**2); tc2 = np.sum(t * E2**2) / np.sum(E2**2)
sd1 = math.sqrt(np.sum((t - tc1) ** 2 * E1**2) / np.sum(E1**2))
vg = (X2 - X1) / (tc2 - tc1)
# phase speed: phase of the w0 component
ph = np.exp(1j * W0 * t) * dt
F1, F2 = np.sum(E1 * ph), np.sum(E2 * ph)
dphi = np.angle(F2 / F1)
kpred = k_disc(W0, f, wr, dt)
m = round((kpred * (X2 - X1) - dphi) / (2 * np.pi))
kmeas = (dphi + 2 * np.pi * m) / (X2 - X1)
vp = W0 / kmeas
vpd, vgd = speeds(k_disc, f, wr, dt)
vpc, vgc = speeds(k_cont, f, wr)
print(f"\nCase {name}: f = {f}, w_r = {'none (no quons)' if R is None else f'{R} w0'}, dt = {dt:.5f}, steps = {nsteps}")
print(f" {'':34s} {'measured':>12s} {'discrete':>12s} {'continuum':>12s} |measured - discrete|")
print(f" {'phase speed / c':34s} {vp:12.7f} {vpd:12.7f} {vpc:12.7f} {abs(vp - vpd):.2e}")
print(f" {'group speed / c':34s} {vg:12.7f} {vgd:12.7f} {vgc:12.7f} {abs(vg - vgd):.2e}")
vE = np.sum(S1) / np.sum(u1)
print(f" {'energy speed at x1, int S / int u':34s} {vE:12.7f} {vgd:12.7f} {'':12s} {abs(vE - vgd):.2e}")
res = {"vp": abs(vp - vpd), "vg": abs(vg - vgd), "vE": abs(vE - vgd)}
if wq2:
Om = 2 / dt * math.sin(W0 * dt / 2)
chid = wq2 / (wr**2 - Om**2)
G1 = np.sum(P1 * ph)
chim = abs(G1) / abs(F1)
print(f" {'stretch per unit field |P/E| at w0':34s} {chim:12.7f} {chid:12.7f} {(1-f)*wr**2/(wr**2-W0**2):12.7f} {abs(chim/chid - 1):.2e} (relative)")
after = t > tc1 + 8 * sd1
resid = np.max(np.abs(P1[after])) / np.max(np.abs(P1))
print(f" {'largest stretch after the pulse':34s} {resid:12.2e} (fraction of the peak; window t > {tc1 + 8*sd1:.0f})")
share_m = np.sum(uq1) / np.sum(u1)
eps = eps_cont(W0, f, wr); chi = (1 - f) * wr**2 / (wr**2 - W0**2)
uq = chi**2 * (W0**2 + wr**2) / (2 * wq2); share_c = uq / (0.5 * (f + eps) + uq)
print(f" {'quons share of the energy at x1':34s} {share_m:12.5f} {'':12s} {share_c:12.5f} {abs(share_m/share_c - 1):.2e} (relative; low frequency: {(1-f)/2:.3f})")
res.update(chi=abs(chim / chid - 1), resid=resid, share=abs(share_m / share_c - 1))
Ws = [Wt[k] for k in sorted(Wt)]
dW = (max(Ws) - min(Ws)) / max(Ws)
print(f" total energy at t = 8000, 14000, 19000: " + ", ".join(f"{w:.8e}" for w in Ws) + f" spread {dW:.2e}")
res["W"] = dW
if name == "B":
np.savez_compressed("relay_in_time_B.npz", t=t[::2], E1=E1[::2], P1=P1[::2], tc1=tc1, w0=W0,
snapE=snap[0], snapB=snap[1], snapP=snap[2], j0=j0)
return res
print("Trial 3: the relay in time, all four of Maxwell's equations, one dimension (lock: papers/Lock_relay_in_time_2026-11-12.md)")
print(f"light: w0 = 2 pi/100 (period {2*np.pi/W0:.0f}), pulse sigma = {SIG:.0f}, centre t0 = {T0:.0f}; probes at x = {X1} and {X2}")
print("static formula of draft 0.5 (8.2), 1/sqrt(mu0 eps(0)): 1 for every case below (eps(0) = 1 by construction)")
cases = [("A", 1.0, None), ("B", 0.25, 10), ("C", 0.25, 3), ("D", 0.25, 30), ("E", 0.05, 10)]
allres = {c[0]: run(*c) for c in cases}
ok = True
for nm, r in allres.items():
ok &= r["vp"] < 1e-5 and r["vg"] < 1e-3 and r["W"] < 1e-3 and r["vE"] < 2e-3
if "chi" in r:
ok &= r["chi"] < 1e-3 and r["resid"] < 1e-3 and r["share"] < 1e-2
print(f"\nPass criteria (phase 1e-5, group 1e-3, stretch 1e-3, residual 1e-3, energy 1e-3, share 1e-2, energy speed 2e-3): "
f"{'all met' if ok else 'NOT MET'}")