Does light charge the quons? › Files cited on the page › check_trial21_fable/
r27_chain.py
#!/usr/bin/env python3
"""Twenty-seventh reviewer (r27), trial 21 blind part: numerical checks that do not reuse the algebra.
C1. A periodic chain of N elements, each of mass m with one Kelvin gyrostat geared G:1 to a rigid ground.
Coordinates u_j (transverse displacement) and phi_j (gimbal angle); theta_j = -(u_{j+1}-u_{j-1})/(4a).
The full linear equations are integrated in time (no quasi-static elimination) from a Gaussian pulse;
the pulse's centroid speed is compared with c_w = G sqrt(K/(4m)), K = S^2/I.
The same chain's normal modes are found by a generalized eigenproblem and compared with the dispersion law.
C2. One gyrostat with the exact (nonlinear) equations of D1, mount turned to a held twist alpha0 and kept there:
the couple it supplies is recorded against time; Kelvin's wind-up.
C3. Two interpenetrating chains (medium + ground), K_g = 0, ground geared: pulse speed against
4 v^2 = K (G^2/m + (G-1)^2/m_g); and a held static twist in the two-chain system: does it hold?
Units are arbitrary (m = 1, a = 1); only ratios matter.
"""
import numpy as np
from scipy.integrate import solve_ivp
np.set_printoptions(precision=5, suppress=True)
def banner(s):
print("\n" + "=" * 78 + "\n" + s + "\n" + "=" * 78)
# ---------------------------------------------------------------- C1
banner("C1. Periodic chain of geared gyrostats on a rigid ground: pulse speed and normal modes")
N, a, m = 600, 1.0, 1.0
# rotor: thin ring, rim speed v, radius R -> I3 = m_r R^2, I = I3/2, S = I3 v/R ; take m_r = m
v_rim, R = 0.5, 0.02 # 'c' = 1 in these units; R small for a fine medium (ell << pulse width)
m_r = m
I3 = m_r * R**2
I = I3 / 2
S = I3 * v_rim / R
K = S**2 / I
print(f"ring: K = {K:.6g} = {K/(m_r*v_rim**2):.4g} m_r v^2 ; omega_max = S/I = {S/I:.6g} = {S/I/(v_rim/R):.3g} Omega_s")
# central-difference rotation matrix D (theta = D u), periodic
idx = np.arange(N)
D = np.zeros((N, N))
D[idx, (idx + 1) % N] = -1 / (4 * a)
D[idx, (idx - 1) % N] = +1 / (4 * a)
def run_chain(G, t_end, width=25.0, I_mount=0.0):
J = I + I_mount
Mu = m * np.eye(N) + J * G**2 * D.T @ D # mass matrix for u (rotor transverse inertia carried at G^2)
Mu_inv = np.linalg.inv(Mu)
cw = G * np.sqrt(S**2 / J / (4 * m))
# equations: Mu u_dd = -S G D^T phi_d ; J phi_dd = S G D u_d (from the Lagrangian; signs consistent)
def rhs(t, y):
u, ud, phi, phid = y[:N], y[N:2*N], y[2*N:3*N], y[3*N:]
udd = Mu_inv @ (-S * G * D.T @ phid)
phidd = (S * G / J) * (D @ ud)
return np.concatenate([ud, udd, phid, phidd])
x = (idx - N / 2) * a
# right-moving pulse: u = f(x - c t): u_d = -c f'(x) ; phi from the quasi-static relation phi_d = (S G/J) theta
f = np.exp(-x**2 / (2 * width**2))
fp = -x / width**2 * f
u0 = f.copy()
ud0 = -cw * fp
theta0 = D @ u0
phid0 = (S * G / J) * theta0
phi0 = np.zeros(N)
y0 = np.concatenate([u0, ud0, phi0, phid0])
sol = solve_ivp(rhs, (0, t_end), y0, method='DOP853', rtol=1e-9, atol=1e-12, dense_output=False,
t_eval=[0, t_end])
uT = sol.y[:N, -1]
def centroid(u):
wgt = u**2
return np.sum(x * wgt) / np.sum(wgt)
c_meas = (centroid(uT) - centroid(u0)) / t_end
return cw, c_meas, uT, u0
for G in (1, 2, 3, 4):
cw, c_meas, uT, u0 = run_chain(G, t_end=120.0)
print(f"G = {G}: predicted c_w = {cw:.5f} ; measured pulse speed = {c_meas:.5f} ; ratio = {c_meas/cw:.5f} ;"
f" peak kept = {uT.max()/u0.max():.4f}")
print("(ring at v_rim = 0.5 'c', ungeared: c_w should be 0.5/sqrt(2) = 0.35355; G = 2.828 would give 1.)")
# normal modes: (S^2 G^2/J) D^T D u = omega^2 (m I + J G^2 D^T D) u
G = 1
J = I
A = (S**2 * G**2 / J) * (D.T @ D)
B = m * np.eye(N) + J * G**2 * (D.T @ D)
from scipy.linalg import eigh
w2 = eigh(A, B, eigvals_only=True)
w2 = np.sort(w2)
# compare with the law omega^2 = c_w^2 keff^2/(1 + keff^2 ell^2), keff = sin(k a)/(2a)*2 ... central difference: |D| = sin(ka)/(2a)
ks = 2 * np.pi * np.arange(N) / (N * a)
keff = np.abs(np.sin(ks * a)) / (2 * a)
cw2 = G**2 * K / (4 * m)
ell2 = G**2 * J / (4 * m)
law = np.sort(cw2 * keff**2 / (1 + keff**2 * ell2))
print(f"normal modes: max |omega^2(numeric) - omega^2(law)| / omega_max^2 = {np.max(np.abs(w2 - law))/(S/J)**2:.2e}")
print(f"largest omega in the chain = {np.sqrt(w2.max()):.6g}; omega_max = S/J = {S/J:.6g}; discrete bound S/J/sqrt(1+4 m a^2/(J G^2)) = {S/J/np.sqrt(1+4*m*a**2/(J*G**2)):.6g}")
k_small = ks[1]
nonzero = w2[w2 > 1e-12 * w2.max()] # the central difference has two null modes (k = 0 and k = pi/a); skip them
print(f"lowest propagating mode (k = 2 pi/(N a)): omega/k = {np.sqrt(nonzero[0])/k_small:.6f} vs c_w = {np.sqrt(cw2):.6f}")
# ---------------------------------------------------------------- C2
banner("C2. One gyrostat, exact equations, held twist: the couple against time (Kelvin's wind-up)")
# exact: I phi_dd = -I al_d^2 cos phi sin phi - S al_d cos phi ; couple supplied by mount tau = d/dt(I al_d cos^2 phi - S sin phi)
alpha0 = 0.002 # held twist (rad)
wmax = S / I
t_ramp = 2.0 # ramp time: slow against the gimbal (1/omega_max = 0.02) but short against the wind-up time (10)
# (first draft had t_ramp = 50 > the whole run, so it sampled only the ramp: own slip, fixed)
def alpha(t):
return alpha0 * (0.5 - 0.5 * np.cos(np.pi * t / t_ramp)) if t < t_ramp else alpha0
def alpha_d(t):
return alpha0 * 0.5 * np.pi / t_ramp * np.sin(np.pi * t / t_ramp) if t < t_ramp else 0.0
def alpha_dd(t):
return alpha0 * 0.5 * (np.pi / t_ramp)**2 * np.cos(np.pi * t / t_ramp) if t < t_ramp else 0.0
def rhs2(t, y):
phi, phid = y
ad = alpha_d(t)
return [phid, -ad**2 * np.cos(phi) * np.sin(phi) - (S / I) * ad * np.cos(phi)]
T_wind = 1 / (wmax * alpha0) # time to a radian
t_end = 4 * np.pi * T_wind
ts = np.linspace(0, t_end, 2001)
sol = solve_ivp(rhs2, (0, t_end), [0.0, 0.0], t_eval=ts, rtol=1e-10, atol=1e-13, method='DOP853')
phi, phid = sol.y
ad = np.array([alpha_d(tt) for tt in ts]); add = np.array([alpha_dd(tt) for tt in ts])
# couple the mount supplies: tau = I al_dd cos^2 phi - 2 I al_d phid cos phi sin phi - S phid cos phi ; reaction on mount = -tau
reaction = -(I * add * np.cos(phi)**2 - 2 * I * ad * phid * np.cos(phi) * np.sin(phi) - S * phid * np.cos(phi))
print(f"omega_max = {wmax:.4g}; alpha0 = {alpha0}; wind-up time 1/(omega_max alpha0) = {T_wind:.4g}")
for frac in (0.0, 0.25, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0):
tt = t_ramp + frac * np.pi * T_wind
i = np.searchsorted(ts, tt)
i = min(i, len(ts) - 1)
print(f" t - t_ramp = {frac:.2f} pi T_wind: phi = {phi[i]:+.4f} rad, reaction/(−K alpha0) = {reaction[i]/(-K*alpha0):+.4f}")
print("-> the restoring couple falls as cos(phi) and reverses sign after phi = pi/2: a gyrostatic medium holds a static")
print(" twist only for t << 1/(omega_max theta). (Exact equations; the ramp is slow, so alpha_d^2 terms are small.)")
# ---------------------------------------------------------------- C3
banner("C3. Two interpenetrating chains: medium (m, gyrostat K geared G against the ground) and ground (m_g, K_g = 0)")
def two_chain_speed(G, mg_ratio, t_end=120.0, width=25.0):
mg = mg_ratio * m
# potential per element: 1/2 K (G th - (G-1) th_g)^2 ; th = D u, th_g = D u_g ; kinetic 1/2 m u_d^2 + 1/2 mg u_g_d^2
# (gyrostat as its equivalent spring; rotor inertia neglected: k ell << 1 here)
Kmat = np.block([[K * G**2 * D.T @ D, -K * G * (G - 1) * D.T @ D],
[-K * G * (G - 1) * D.T @ D, K * (G - 1)**2 * D.T @ D]])
Minv = np.concatenate([np.full(N, 1 / m), np.full(N, 1 / mg)])
v_pred = np.sqrt(K * (G**2 / m + (G - 1)**2 / mg) / 4)
x = (idx - N / 2) * a
f = np.exp(-x**2 / (2 * width**2)); fp = -x / width**2 * f
# light-branch eigenvector: U_g/U = -(G-1) m/(G m_g) (from the 2x2 problem)
r = -(G - 1) * m / (G * mg)
q0 = np.concatenate([f, r * f]); qd0 = -v_pred * np.concatenate([fp, r * fp])
def rhs(t, y):
q, qd = y[:2*N], y[2*N:]
return np.concatenate([qd, -Minv * (Kmat @ q)])
sol = solve_ivp(rhs, (0, t_end), np.concatenate([q0, qd0]), method='DOP853', rtol=1e-9, atol=1e-12, t_eval=[t_end])
uT = sol.y[:N, -1]
cen = lambda u: np.sum(x * u**2) / np.sum(u**2)
return v_pred, (cen(uT) - cen(f)) / t_end
for G, mgr in ((2, 1.0), (2, 7.0), (2, 1e4), (2.8284271, 1e4), (4, 1e4)):
vp, vm = two_chain_speed(G, mgr)
print(f"G = {G:.4f}, m_g/m = {mgr:8.4g}: predicted v = {vp:.5f}, measured = {vm:.5f}, ratio = {vm/vp:.4f}")
print("(ring at 0.5: G = 2.8284 on a heavy ground gives 1.000: c is reached by the gear ratio alone.)")
# A held field needs a source. Apply a constant transverse force pattern f0 sin(2 pi x/lam) to the medium (the analogue of a
# static charge holding a twist) and watch the medium's displacement:
# one chain (ungeared, or geared to a RIGID ground): a static displacement f0/(k^2 K_eff/4) is reached, with a standing
# wave about it (no damping here); its time average is the static field.
# two chains with K_g = 0 (ground geared, free to rotate): no static stiffness: the soft branch is driven secularly and
# the displacement grows without bound. The time average is not a static field.
# (first draft started a free standing wave and sampled it at half-periods, which showed nothing: own slip, replaced)
x = (idx - N / 2) * a
lam = N * a / 2
kw = 2 * np.pi / lam
f_pat = np.sin(kw * x)
f0 = 1e-3
def run_driven(G, mgr, Kg_over_K, t_end, n_out):
mg = mgr * m
Kmat = np.block([[K * G**2 * D.T @ D, -K * G * (G - 1) * D.T @ D],
[-K * G * (G - 1) * D.T @ D, K * (G - 1)**2 * D.T @ D + Kg_over_K * K * D.T @ D]])
Minv = np.concatenate([np.full(N, 1 / m), np.full(N, 1 / mg)])
force = np.concatenate([f0 * f_pat, np.zeros(N)])
def rhs(t, y):
q, qd = y[:2*N], y[2*N:]
return np.concatenate([qd, Minv * (force - Kmat @ q)])
sol = solve_ivp(rhs, (0, t_end), np.zeros(4 * N), method='DOP853', rtol=1e-8, atol=1e-12,
t_eval=np.linspace(0, t_end, n_out))
return sol
G = 2.0
v_light = np.sqrt(K * G**2 / m / 4)
t_per = lam / v_light # the light branch's period at this wavelength (rigid-ground value)
ic = np.argmax(f_pat) # the crest of the forcing pattern
# (a first draft sampled at whole periods, where an undamped driven standing wave passes through zero, and used a
# 1e4 ground whose own period is 67 t_per: aliasing and an unsettled ground. Own slip, replaced.)
for label, mgr, Kg in (("ground free (K_g = 0), m_g/m = 7", 7.0, 0.0),
("ground with its own gyrostats K_g = 9 K, m_g/m = 7", 7.0, 9.0),
("rigid ground (m_g/m = 1e8, K_g = 1e8 K)", 1e8, 1e8)):
n_out = 1201
sol = run_driven(G, mgr, Kg, 60 * t_per, n_out)
u_crest = sol.y[ic, :] # medium's displacement at the crest, against time
Kstat = G**2 / (1 + (G - 1)**2 / Kg) if Kg > 0 else 0.0
u_s = f0 / (kw**2 * Kstat * K / 4) if Kstat > 0 else np.inf
print(f" {label}: K_static/K = {Kstat:.3f}; a held field would be u = {u_s:.4g} at the crest")
for (t1, t2) in ((0, 20), (20, 40), (40, 60)):
sel = (sol.t >= t1 * t_per) & (sol.t < t2 * t_per)
print(f" periods {t1:2d}-{t2:2d}: time-average u = {np.mean(u_crest[sel]):8.4g}, "
f"range [{u_crest[sel].min():8.4g}, {u_crest[sel].max():8.4g}]")
print("-> free ground: the displacement grows without bound (no static stiffness; the twist is not held).")
print(" ground with K_g: a static field is held with K_static = G^2 K/(1 + (G-1)^2 K/K_g) < K + K_g, while the pulse")
print(" speed (above) used the full G^2 K: the static/wave split.")