Does light charge the quons? › Files cited on the page › check_m8_fable/
a6b_gyrostat_alignment.py
#!/usr/bin/env python3
"""A6 (blind), part 2: second-order drift of a gimballed gyrostat under a to-and-fro twist theta = theta0 sin(omega t).
Prediction (slow motion, derived in the text): A beta_s'' = (theta0^2/4)(h^2/A - A omega^2) sin(2 beta_s).
For omega < h/A the perpendicular position beta = 0 is unstable with growth rate gamma = sqrt(theta0^2 (h^2/A^2 - omega^2)/2)."""
import subprocess
import numpy as np
from scipy.integrate import solve_ivp
print("git HEAD:", subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True).stdout.strip())
A_ = 1.0; h_ = 1.0
def rhs(t, y, theta0, omega):
beta, dbeta = y
th_dot = theta0 * omega * np.cos(omega * t)
return [dbeta, -h_ * th_dot * np.cos(beta) - A_ * th_dot**2 * np.sin(beta) * np.cos(beta)]
for theta0, omega, T in ((0.005, 0.1, 3000), (0.005, 0.3, 3000), (0.005, 2.0, 3000)):
sol = solve_ivp(rhs, (0, T), [0, 0], args=(theta0, omega), max_step=min(0.2, 0.1 / omega), rtol=1e-10, atol=1e-13, dense_output=True)
t = np.linspace(0, T, 300001); b = sol.sol(t)[0]
# slow part: running mean over one period
P = 2 * np.pi / omega; w = int(P / (t[1] - t[0]))
bs = np.convolve(b, np.ones(w) / w, mode="same")
gam2 = theta0**2 * ((h_ / A_)**2 - omega**2) / 2
gam = np.sqrt(gam2) if gam2 > 0 else float("nan")
samples = [(tt, bs[np.searchsorted(t, tt)]) for tt in (200, 500, 1000, 1500, 2000, 2500)]
txt = ", ".join(f"t={tt}: {bb:+.2e}" for tt, bb in samples)
# fit growth rate between t=500 and 1500 if growing
if gam2 > 0:
b1, b2 = abs(samples[1][1]), abs(samples[3][1])
fit = np.log(b2 / b1) / 1000 if b1 > 0 and b2 > b1 else float("nan")
print(f"theta0={theta0}, omega={omega}: slow tilt {txt}; predicted gamma = {gam:.4f}, fitted from 500-1500: {fit:.4f}")
else:
print(f"theta0={theta0}, omega={omega} (> h/A): slow tilt {txt}; predicted stable (gamma^2 = {gam2:.1e} < 0), max|beta| = {np.abs(b).max():.3e}")