Does light charge the quons? › Files cited on the page › the trials

gyro_band.py

In the investigation at sim/m8_engine/gyro_band.py · last changed in commit 3e5c39b, 25 November 2026 · 2,919 bytes · runnable copies in the scripts zip


"""Variant G on the engine: a gyrostat (Kelvin's) stands in for every band. Author seat (Claude Opus 5.5), 25 November 2026.

Per band b: its twist theta_b = (S phi)_b + slip_b (the wheels' signed turns round the edge, as for a band); a flywheel of spin momentum h and diameter
inertia A in one gimbal, gimbal angle beta_b [M, the outline's 11.4; S, Lagrange, the Routhian checked in review_full.py section 1]:
   A beta''  = h theta' cos(beta) - A theta'^2 sin(beta) cos(beta)
   couple C  = A theta'' cos^2(beta) - 2 A theta' beta' sin(beta) cos(beta) + h beta' cos(beta)     (no frame inertia: If = 0)
The wheels: I phi'' = -S^T C, with I = 1. Small angles: C = (h^2/A) theta + A theta'': a band of stiffness K = h^2/A with an inertia A.
theta'' enters C, so phi'' is found from (I + A S^T cos^2(beta) S) phi'' = -S^T R by fixed-point iteration (A lambda_max/I < 1)."""
import numpy as np

from engine import curl_e2f, curl_f2e

S = curl_f2e            # wheels (faces) -> bands (edges): the outline's S
ST = curl_e2f           # its transpose


class GyroLattice:
    def __init__(self, shape, h, A, slip=None):
        self.shape, self.h, self.A = shape, h, A
        self.phi = np.zeros((3, *shape)); self.w = np.zeros((3, *shape))
        self.beta = np.zeros((3, *shape)); self.bd = np.zeros((3, *shape))
        self.slip = np.zeros((3, *shape)) if slip is None else slip
        self.t = 0.0

    def accel(self, phi, w, beta, bd):
        h, A = self.h, self.A
        th_d = S(w)
        c, s = np.cos(beta), np.sin(beta)
        R = -2 * A * th_d * bd * s * c + h * bd * c
        acc = -ST(R)
        for _ in range(40):
            new = -ST(R + A * c * c * S(acc))
            if np.abs(new - acc).max() < 1e-13 * (1 + np.abs(new).max()):
                acc = new
                break
            acc = new
        bdd = (h * th_d * c - A * th_d**2 * s * c) / A
        return acc, bdd

    def couple(self):
        acc, _ = self.accel(self.phi, self.w, self.beta, self.bd)
        th_d = S(self.w)
        c, s = np.cos(self.beta), np.sin(self.beta)
        return self.A * c * c * S(acc) - 2 * self.A * th_d * self.bd * s * c + self.h * self.bd * c

    def step(self, dt):
        y = (self.phi, self.w, self.beta, self.bd)

        def f(y):
            acc, bdd = self.accel(*y)
            return (y[1], acc, y[3], bdd)
        k1 = f(y)
        k2 = f(tuple(a + dt / 2 * b for a, b in zip(y, k1)))
        k3 = f(tuple(a + dt / 2 * b for a, b in zip(y, k2)))
        k4 = f(tuple(a + dt * b for a, b in zip(y, k3)))
        self.phi, self.w, self.beta, self.bd = (a + dt / 6 * (b1 + 2 * b2 + 2 * b3 + b4) for a, b1, b2, b3, b4 in zip(y, k1, k2, k3, k4))
        self.t += dt

    def start_in_step(self):
        """Gimbal rates in step with the twists (A beta' - h theta = 0 at small angles), so nothing drifts at first order."""
        self.bd = self.h / self.A * (S(self.phi) + self.slip)