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

check_time_supercell.py

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


"""check_time_supercell.py - the seventh reviewer's 2 x 2 x 2 supercell time run (8 quons, 64 finer quons), friction zeta = 1,
own Ewald forces (fable_tools.py, vectorised; checked against the pair-loop version to 1e-15 in the stopped third section of
check_time_fable_out.txt), own random start.
The one-cell run of trial 5 (R4d) allows k = 0 only, so every quon must keep its own eight finer quons; here the unstable
waves at X, M and R are allowed, and the finer quons at the sites halfway between two quons may go either way.
Run: ~/aspden-review-venv/bin/python3 -u check_time_supercell.py > check_time_supercell_out.txt
"""
import itertools, math, time
import numpy as np
from fable_tools import Ewald, stack

t0 = time.time()
pos0, q, s = stack(2, 0.32169013)
mass = np.concatenate([[1.0], np.full(8, 1 / 8)])
L = 2.0
cells = np.array(list(itertools.product(range(2), repeat=3)), float)
posS = np.vstack([pos0 + c for c in cells])
qS, sS, massS = np.tile(q, 8), np.tile(s, 8), np.tile(mass, 8)
ewS = Ewald(L, qS, sS, eta=2.2, rcells=2, gmax=8)      # exp(-G^2/4 eta^2) < 1e-12 beyond |m| = 7.4 (G = pi m)
E0, F0 = ewS.energy_forces_fast(posS)
print(f"supercell: {len(qS)} charges; largest force at the even arrangement {np.max(np.abs(F0)):.1e}; one force call {1000*(time.time()-t0):.0f} ms")
rng = np.random.default_rng(11)
u = rng.standard_normal(posS.shape)
u -= (massS[:, None] * u).sum(0) / massS.sum()
u *= 1e-7 / math.sqrt(np.mean(np.sum(u * u, 1)))
x = posS + u
v = np.zeros_like(x)
E, F = ewS.energy_forces_fast(x)
dt, zeta, tmax = 0.002, 1.0, 24.0
nstep = int(round(tmax / dt))
isq = massS == 1.0


def assign(x):
    quons, fins = x[isq], x[~isq]
    counts = np.zeros(len(quons), int)
    dmin = []
    for f in fins:
        d = f[None, :] - quons
        d -= L * np.round(d / L)
        r = np.linalg.norm(d, axis=1)
        j = int(np.argmin(r))
        counts[j] += 1
        dmin.append(r[j])
    return counts, np.array(dmin)


print("   t      rms displacement of finer quons   electric energy   kinetic energy   finer quons per quon (nearest)")
for it in range(nstep + 1):
    t = it * dt
    if it % 1000 == 0 or it == nstep:
        disp = x[~isq] - posS[~isq]
        rms = math.sqrt(np.mean(np.sum(disp * disp, 1)))
        ke = 0.5 * np.sum(massS[:, None] * v * v)
        counts, dmin = assign(x)
        print(f"   {t:5.1f}   {rms:.3e}                        {E:+.5f}         {ke:.2e}        {counts.tolist()}   (elapsed {time.time()-t0:.0f} s)", flush=True)
    if it == nstep:
        break
    a = F / massS[:, None] - zeta * v
    vh = v + 0.5 * dt * a
    x = x + dt * vh
    E, F = ewS.energy_forces_fast(x)
    v = (vh + 0.5 * dt * F / massS[:, None]) / (1 + 0.5 * zeta * dt)

counts, dmin = assign(x)
print(f"\nend (t = {tmax}): finer quons per quon {counts.tolist()}; their distances from their nearest quon: min {dmin.min():.4f}, "
      f"rms {math.sqrt(np.mean(dmin**2)):.4f}, max {dmin.max():.4f}")
dqn = x[isq] - posS[isq]
dqn -= L * np.round(dqn / L)
print(f"quons' displacement from their lattice sites: rms {math.sqrt(np.mean(np.sum(dqn**2, 1))):.4f}, max {np.max(np.linalg.norm(dqn, axis=1)):.4f}")
start_sites = posS[~isq] - np.floor(posS[~isq])
nhalf = np.sum(np.abs(start_sites - 0.5) < 1e-9, axis=1)
for name, k in {"on a quon (0,0,0)": 0, "edge (1/2,0,0)": 1, "face (1/2,1/2,0)": 2, "body (1/2,1/2,1/2)": 3}.items():
    m = nhalf == k
    print(f"   finer quons that started {name:22s}: {int(m.sum()):2d}; final distance from the nearest quon: min {dmin[m].min():.3f}, max {dmin[m].max():.3f}")
print(f"run time {time.time() - t0:.0f} s")