Two Tally programs record 17 assertions in this follow-up. Five Python checkers accompany them. The 78 earlier assertions belong to the preceding walk, clock and recoil study. The geometry source archive includes the material needed for offline replay.
Independent Python checks
active_source.py
#!/usr/bin/env python3
"""Stationary linear-gravity exchange between two disjoint ideal octahedra."""
from collections import defaultdict
from fractions import Fraction
from math import cos, fsum, hypot, isclose, pi, sin
def dot(a, b):
return sum(x*y for x, y in zip(a, b))
def cross(a, b):
return (a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2],
a[0]*b[1] - a[1]*b[0])
def point(edge, t):
start, delta, _ = edge
return tuple(x + t*v for x, v in zip(start, delta))
def octahedron(a=1, center_z=0, angle=0):
"""Eight directed segments A -> equatorial vertex -> B, with signed weights."""
top = (0, 0, center_z + a)
bottom = (0, 0, center_z - a)
edges = []
for x, y, weight in [(a, 0, 1), (-a, 0, 1), (0, a, -1), (0, -a, -1)]:
if angle:
x, y = x*cos(angle) - y*sin(angle), x*sin(angle) + y*cos(angle)
mid = (x, y, center_z)
for start, end in [(top, mid), (mid, bottom)]:
delta = tuple(t - s for s, t in zip(start, end))
edges.append((start, delta, weight))
return edges
def check_source(edges):
balance = defaultdict(int)
momentum = [0, 0, 0]
angular_momentum = [0, 0, 0]
for edge in edges:
start, delta, weight = edge
balance[start] += weight
balance[point(edge, 1)] -= weight
orbital = cross(start, delta)
for i in range(3):
momentum[i] += weight * delta[i]
angular_momentum[i] += weight * orbital[i]
assert all(value == 0 for value in balance.values())
assert momentum == angular_momentum == [0, 0, 0]
def check_scattering():
"""One exact photon reflection, using c=1 and an initially stationary mirror."""
mirror_in, mirror_out = (8, 0), (Fraction(41, 5), Fraction(9, 5))
light_in, light_out = (1, 1), (Fraction(4, 5), Fraction(-4, 5))
assert mirror_out[0]**2 - mirror_out[1]**2 == mirror_in[0]**2
assert light_in[0]**2 == light_in[1]**2 and light_out[0]**2 == light_out[1]**2
for i in range(2):
assert mirror_out[i] - mirror_in[i] == light_in[i] - light_out[i]
# Boole's closed rule is exact through degree five. Each Green coefficient below
# is a polynomial of degree at most four in either segment parameter.
BOOLE = [(Fraction(j, 4), Fraction(w, 90))
for j, w in enumerate((7, 32, 12, 32, 7))]
def exact_multipoles(edges):
totals = [Fraction(0) for _ in range(5)]
for e in edges:
for f in edges:
factor = e[2] * f[2] * dot(e[1], f[1])
if not factor:
continue
for t, wt in BOOLE:
for u, wu in BOOLE:
v = tuple(a-b for a, b in zip(point(e, t), point(f, u)))
z, r2 = v[2], dot(v, v)
moments = (1, -z, (3*z*z-r2)/2, (3*z*r2-5*z**3)/2,
(35*z**4-30*z*z*r2+3*r2*r2)/8)
for j, value in enumerate(moments):
totals[j] += factor * wt * wu * value
return tuple(totals)
def polynomial_shift(edges):
"""Forward-minus-reverse path integral for h_0z = x**2 - y**2."""
return sum(2 * e[2] * e[1][2] * w * (point(e, t)[0]**2-point(e, t)[1]**2)
for e in edges for t, w in BOOLE)
def gaussian_rule(order):
"""Gauss-Legendre nodes and weights on [0, 1]."""
rule = []
for i in range(order):
x = cos(pi * (i + 0.75) / (order + 0.5))
for _ in range(24):
p0, p1 = 1.0, x
for k in range(2, order + 1):
p0, p1 = p1, ((2*k-1)*x*p1 - (k-1)*p0) / k
slope = order*(x*p1-p0)/(x*x-1)
step = p1/slope
if abs(step) < 1e-15:
break
x -= step
else:
raise RuntimeError("Legendre root did not converge")
rule.append(((1+x)/2, 1/((1-x*x)*slope*slope)))
return rule
def exchange(source, receiver, order):
rule = gaussian_rule(order)
def sample(edges):
return [(delta, w, [(point((start, delta, w), t), weight) for t, weight in rule])
for start, delta, w in edges]
source_points, receiver_points = sample(source), sample(receiver)
terms = []
for sd, sw, ss in source_points:
for rd, rw, rs in receiver_points:
gain = sw * rw * dot(sd, rd)
if not gain:
continue
value = fsum(a*b/hypot(x-u, y-v, z-w)
for (x, y, z), a in ss for (u, v, w), b in rs)
terms.append(gain * value)
return fsum(terms)
def main():
source = octahedron()
check_source(source)
check_scattering()
assert polynomial_shift(source) == Fraction(-16, 3)
multipoles = exact_multipoles(source)
assert multipoles == (0, 0, 0, 0, Fraction(-16, 3))
print("Green coefficients through D^-5:", ", ".join(map(str, multipoles)))
receiver = octahedron(center_z=4)
baseline = exchange(source, receiver, 24)
assert isclose(baseline, exchange(source, receiver, 14), abs_tol=2e-14, rel_tol=0)
assert isclose(baseline, exchange(receiver, source, 24), abs_tol=2e-14, rel_tol=0)
assert isclose(baseline, -0.00580038999892, abs_tol=2e-14, rel_tol=0)
null = exchange(source, octahedron(center_z=4, angle=pi/4), 24)
reversed_sign = exchange(source, octahedron(center_z=4, angle=pi/2), 24)
assert abs(null) < 2e-14 and abs(reversed_sign + baseline) < 2e-14
print(f"I/a at D=4a: 0 deg {baseline:.12g}, 45 deg {null:.3g}, "
f"90 deg {reversed_sign:.12g}")
c, grav = 299792458, 6.67430e-11
wavelength, power, a = 1064e-9, 1e6, 1.0
phase = -8 * grav * power / c**5 * (2*pi/wavelength) * a * baseline
print(f"Predicted differential phase for the stated SI example: {phase:.6g} rad")
if __name__ == "__main__":
main()
cartesian_links.py
"""Reproduce the 24-link Cartesian phase readout using only the Python standard library."""
from cmath import exp
from math import isclose, log2, sin
from random import Random
def shift(site, axis, sign):
x, y = site
return (x + sign, y) if axis == 0 else (x, y + sign)
def cartesian_output(link, tick):
"""Combine the 24 physical links about (0,0). link() uses reception time."""
def paired(axis, center, t):
left = shift(center, axis, -1)
right = shift(center, axis, 1)
return (link(center, axis, 1, t - 1) - link(left, axis, 1, t)
+ link(center, axis, -1, t - 1) - link(right, axis, -1, t))
def transverse_difference(axis, t):
cross = 1 - axis
origin = (0, 0)
return (paired(axis, origin, t - 2) + paired(axis, origin, t)
- paired(axis, shift(origin, cross, 1), t - 1)
- paired(axis, shift(origin, cross, -1), t - 1))
return transverse_difference(0, tick) - transverse_difference(1, tick)
def check_nodal_noise():
"""Inject independent clock and displacement samples at all nine actual nodes."""
ticks = 256
rng = Random(741277)
sites = {(x, y) for x in (-1, 0, 1) for y in (-1, 0, 1)}
samples = {(site, t): tuple(rng.randint(-1000, 1000) for _ in range(3))
for site in sorted(sites) for t in range(ticks + 4)}
edges = set()
def noisy_link(source, axis, sign, t):
destination = shift(source, axis, sign)
emitted = samples[source, t - 1]
received = samples[destination, t]
edges.add((source, destination))
return emitted[0] - received[0] - sign * (emitted[axis + 1] - received[axis + 1])
assert all(cartesian_output(noisy_link, t) == 0 for t in range(4, ticks + 4))
assert len(edges) == 24 and {node for pair in edges for node in pair} == sites
# A disturbance introduced on a single link, independently of its two nodes.
def local_impulse(site, axis, sign, t):
return int((site, axis, sign, t) == ((0, 0), 0, 1, -1))
assert cartesian_output(local_impulse, 0) == 1
print(f"{ticks} independent time samples of node clocks and displacements: zero residual")
print(f"{len(sites)} sites, {len(edges)} directed links; isolated link impulse: +1")
def check_wave_response():
"""Integrate the normal-incidence plus polarization on each optical link."""
# Unit strain amplitude, optical angular frequency times flight time = 1.
def amplitude(x):
flight_average = sin(x / 2) / (x / 2)
def wave_link(site, axis, sign, t):
axis_projection = 1 if axis == 0 else -1
return axis_projection * flight_average * exp(1j * x * (t - 0.5)) / 2
observed = cartesian_output(wave_link, 0)
delay = exp(-1j * x)
expected = 4 * (delay - 1) ** 3 * wave_link((0, 0), 0, 1, 0)
assert abs(observed - expected) < 3e-15
return abs(observed)
last = None
for x in (0.32, 0.16, 0.08, 0.04, 0.02, 0.01):
signal = amplitude(x)
slope = log2(last / signal) if last is not None else None
print(f"Omega*tau={x:.2f} |D|={signal:.9g}" +
(f" adjacent log slope={slope:.7f}" if slope is not None else ""))
last = signal
assert isclose(slope, 3.0, abs_tol=0.0001)
assert isclose(last / 0.01 ** 3, 2.0, rel_tol=0.0001)
if __name__ == "__main__":
check_nodal_noise()
check_wave_response()
material_support.py
#!/usr/bin/env python3
"""Material sidebands, motion of the shared support and the six-link clock."""
from cmath import exp as phase_exp
from fractions import Fraction
from math import asinh, ceil, exp, expm1, fsum, isclose, log, log1p, pi, sqrt
KICKS = (-1, 1, 0, 1, -1, 0)
Y_TURNS = ((1, -2), (2, 2), (4, 2), (5, -2))
def sideband_links(n, epsilon):
"""Both optical frequencies must be positive in an open sideband pair."""
high, low = 1 - n*epsilon, 1 - (n+1)*epsilon
if low <= 0 or high <= 0:
raise ValueError("closed optical sideband")
midpoint = (high+low)/2
geometric = sqrt(high*low)
return midpoint, geometric
def dark_probability(eta, theta, carrier_phase, geometric, levels=44):
epsilon = 6*theta/carrier_phase
index = int(geometric)
links = [eta * sqrt(n+1) * sideband_links(n, epsilon)[index]
for n in range(levels-1)]
parts = max(1, ceil(2 * max(links)))
drift = [phase_exp(-1j*n*theta) for n in range(levels)]
state = [1+0j] + [0j]*(levels-1)
for sign in KICKS:
state = [x*d for x, d in zip(state, drift)]
if not sign:
continue
for _ in range(parts):
term, total = state, state[:]
for order in range(1, 31):
next_term = [0j]*levels
for n, link in enumerate(links):
next_term[n] += link*term[n+1]
next_term[n+1] += link*term[n]
scale = 1j*sign/(parts*order)
term = [x*scale for x in next_term]
total = [a+b for a, b in zip(total, term)]
state = total
probabilities = [abs(x)**2 for x in state]
assert isclose(fsum(probabilities), 1, abs_tol=2e-13, rel_tol=0)
# Opposite kicks on the other route multiply the n-th final amplitude by (-1)^n.
return fsum(probabilities[1::2])/4
def check_sidebands():
carrier = 2*pi*1024 + pi/2
expected = [
(1/8, carrier, 0.0146693774791, 0.0146693700836),
(5/8, 5*carrier, 0.1195133328433, 0.1195133324754),
]
for eta, phase, published, boundary in expected:
epsilon = 3*pi/phase
for n in (0, 1, 10, 42):
mid, geom = sideband_links(n, epsilon)
# Rationalized arithmetic-minus-geometric mean, in units of omega_0.
assert isclose(mid-geom, (epsilon/2)**2/(mid+geom),
rel_tol=0, abs_tol=2e-16)
p_mid = dark_probability(eta, pi/2, phase, False)
p_geom = dark_probability(eta, pi/2, phase, True)
assert isclose(p_mid, published, abs_tol=2e-13, rel_tol=0)
assert isclose(p_geom, boundary, abs_tol=2e-13, rel_tol=0)
print(f"eta={eta:g}: midpoint {p_mid:.13f}, moving-boundary link {p_geom:.13f}")
def support_response(displacements):
"""Differential delay divided by a/c. Displacements are expressed in units of a."""
return sum(coefficient * displacements[tick] for tick, coefficient in Y_TURNS)
def check_rigid_motion():
offset, velocity, epsilon = Fraction(7, 11), Fraction(-2, 13), Fraction(1, 200)
offsets = [offset for _ in range(7)]
uniform = [offset + velocity*j for j in range(7)]
accelerated = [uniform[j] + epsilon*j*j/2 for j in range(7)]
assert support_response(offsets) == support_response(uniform) == 0
assert support_response(accelerated) == -6*epsilon
for w in (0.12, 0.43, 1.31):
z = phase_exp(-1j*w)
assert abs(support_response([z**j for j in range(7)])
+ 2*z*(z-1)*(z**3-1)) < 1e-14
def guide_time(epsilon, side):
if epsilon == 0:
return 6.0
u = side*epsilon
return 2 + 2*log1p(u)/u + 2/(1+u)
def segments(side):
# x, side*y, z, z, -side*y, x; each segment is one unit of proper length.
heights = (0, 0, side, side, side, 0, 0)
return zip(heights, heights[1:])
def time_by_quadrature(epsilon, side, steps=100):
"""Integrate dl/(1+epsilon*y) independently on each straight guide."""
if steps % 2:
raise ValueError("Simpson quadrature needs an even number of panels")
total = 0.0
for start, end in segments(side):
def integrand(j):
return 1/(1+epsilon*(start+(end-start)*j/steps))
total += (integrand(0)+integrand(steps)
+ 4*fsum(integrand(j) for j in range(1, steps, 2))
+ 2*fsum(integrand(j) for j in range(2, steps, 2)))/(3*steps)
return total
def vacuum_time(epsilon, side):
"""Free null flight between each pair of successive Rindler-fixed junctions."""
if epsilon == 0:
return 6.0
return fsum(2/epsilon * asinh(epsilon/(2*sqrt((1+epsilon*a)*(1+epsilon*b))))
for a, b in segments(side))
def check_rindler():
assert guide_time(0, 1) == vacuum_time(0, -1) == 6
for e in (0.001, 0.005, 0.02, 0.1):
for side in (-1, 1):
assert isclose(guide_time(e, side), time_by_quadrature(e, side),
abs_tol=2e-12, rel_tol=0)
guided = guide_time(e, 1) - guide_time(e, -1)
vacuum = vacuum_time(e, 1) - vacuum_time(e, -1)
if e <= 0.02:
assert abs(guided + 6*e + 5*e**3) < 5*e**5 + 2e-15
assert abs(vacuum + 6*e + 4.5*e**3) < 8*e**5 + 4e-15
print(f"epsilon={e:g}: guided delay {guided:.12g}, vacuum delay {vacuum:.12g}")
def check_structure_factor():
# A single positive mechanical frequency, in units of Omega=1. Factors shared
# by the three carriers (ground occupation and geometry) are divided out.
carriers = (20, 100, 180)
stokes = [w*(w-1) for w in carriers]
assert Fraction(stokes[1], stokes[0]) == Fraction(495, 19)
assert Fraction(stokes[2], 9) - 2*Fraction(stokes[1], 5) + stokes[0] == 0
# beta*hbar*Omega = log(3), so nbar=1/2. Test rates including optical flux.
b = log(3)
occupation = 1/expm1(b)
for w in carriers:
stokes_rate = w*(w-1)*(occupation+1)
antistokes_rate = w*(w+1)*occupation
assert isclose(antistokes_rate/stokes_rate, exp(-b)*(w+1)/(w-1), abs_tol=2e-15)
assert isclose((21/19)*occupation/(1+occupation), 7/19)
print("Three-carrier Stokes contrast = 0; five-to-one rate ratio = 495/19")
if __name__ == "__main__":
check_sidebands()
check_rigid_motion()
check_rindler()
check_structure_factor()
octahedron.py
"""Replay the equal-edge octahedron as a sum of directed optical travel times.
Units in the frequency-domain routines are one edge travel time for time and
one edge length for distance. Only the standard library is needed.
"""
from cmath import exp
from math import cos, isclose, pi, sin, sqrt
AXES = ((1, 0, 0), (0, 1, 0), (0, 0, 1))
X, Y, Z = AXES
V = 1 / sqrt(2)
NODES = tuple((axis, sign) for axis in range(3) for sign in (-1, 1))
def dot(a, b):
return sum(x * y for x, y in zip(a, b))
def scale(a, factor):
return tuple(factor * x for x in a)
def location(node):
axis, sign = node
return scale(AXES[axis], sign)
def delta(b, a):
return tuple(x - y for x, y in zip(b, a))
def arms():
for sender in (-1, 1):
for side in (-1, 1):
for axis, arm_sign in ((0, 1), (1, -1)):
yield sender * arm_sign, (2, sender), (axis, side), (2, -sender)
def links():
for weight, emitter, mirror, receiver in arms():
yield weight, emitter, mirror, 1
yield weight, mirror, receiver, 0
def noise_probe(node, component, tick):
# A displacement coefficient is expressed in units of 1/(sqrt(2)*c).
# Clock coefficients have units of one. Each probe is a separate column.
total = 0
uncombined = {}
for weight, emitter, mirror, receiver in arms():
subtotal = 0
for start, end, lag in ((emitter, mirror, 1), (mirror, receiver, 0)):
coefficient = 1 if component == 3 else delta(location(end), location(start))[component]
if (start, -lag - 1) == (node, tick):
subtotal -= coefficient
if (end, -lag) == (node, tick):
subtotal += coefficient
total += weight * subtotal
key = (emitter, mirror[1])
arm_sign = 1 if mirror[0] == 0 else -1
uncombined[key] = uncombined.get(key, 0) + arm_sign * subtotal
return total, tuple(uncombined.values())
def strain(p, transverse, polarization):
def contract(a, b):
if polarization == "+":
return dot(a, p) * dot(b, p) - dot(a, transverse) * dot(b, transverse)
return dot(a, p) * dot(b, transverse) + dot(a, transverse) * dot(b, p)
return contract
def sinc(x):
if abs(x) < 1e-4:
return 1 - x * x / 6 + x ** 4 / 120
return sin(x) / x
def response(x, sky, contract):
total = 0j
for weight, start, end, lag in links():
n = scale(delta(location(end), location(start)), V)
half_range = x * (1 - dot(sky, n)) / 2
phase = x * (lag + V * dot(sky, location(end))) + half_range
total += weight * contract(n, n) * exp(1j * phase) * sinc(half_range) / 2
return total
def integrate_rays(x, sky, contract, panels):
# Start at emission and integrate the plane-wave phase over the moving ray.
# This independent evaluation uses neither the receiver formula nor sinc.
total = 0j
for weight, emitter, mirror, receiver in arms():
for start, end, start_time in ((emitter, mirror, -2), (mirror, receiver, -1)):
a = scale(location(start), V)
b = scale(location(end), V)
n = delta(b, a)
delay = 0j
for i in range(panels):
u = (i + 0.5) / panels
r = tuple(a[j] + u * n[j] for j in range(3))
delay += exp(-1j * x * (start_time + u - dot(sky, r)))
total += weight * contract(n, n) * delay / (2 * panels)
return total
def low_frequency(sky, h):
return 2 * V / 3 * (
-sky[2] * (h(X, X) - h(Y, Y)) + sky[0] * h(X, Z) - sky[1] * h(Y, Z)
)
def main():
nonzero_raw = 0
for node in NODES:
for tick in (-2, -1, 0):
for component in range(4):
combined, raw = noise_probe(node, component, tick)
assert combined == 0, (node, tick, component)
if component == 3:
assert not any(raw)
else:
nonzero_raw += any(raw)
assert nonzero_raw > 0
print(f"72 independent node/time/component probes cancel; {nonzero_raw} displacement probes reach individual outputs.")
axial_plus, axial_cross = strain(X, Y, "+"), strain(X, Y, "cross")
for x in (0, 0.003, 0.3, 1, 2.4, pi, 7.5):
expected = 2 * exp(1j * x) * (sinc((1 + V) * x) - sinc((1 - V) * x))
assert abs(response(x, Z, axial_plus) - expected) < 3e-14
assert abs(response(x, Z, axial_cross)) < 3e-14
for direction, p, t in ((X, Y, Z), (Y, Z, X)):
for mode in ("+", "cross"):
assert abs(response(x, direction, strain(p, t, mode))) < 3e-14
print("Axial closed form and transverse-axis nulls agree at seven frequencies.")
sky = scale((2, 3, 6), 1 / 7)
p = scale((3, -2, 0), 1 / sqrt(13))
t = scale((12, 18, -13), 1 / (7 * sqrt(13)))
for a, b in ((sky, p), (sky, t), (p, t)):
assert abs(dot(a, b)) < 1e-14
expected = {"+": (-0.27084290000064, -0.78998710572063),
"cross": (-0.65883979432838, -1.94527558761293)}
for mode, targets in expected.items():
h = strain(p, t, mode)
for x, target in zip((1, 2.4), targets):
result = response(x, sky, h)
centered = result * exp(-1j * x)
assert abs(centered - target) < 3e-13
assert abs(result + response(x, scale(sky, -1), h)) < 3e-14
integrated = integrate_rays(x, sky, h, 4096)
assert abs(result - integrated) < 3e-8
print(f"x={x:g} {mode:5s} centered={centered.real:.12f} quadrature error={abs(result-integrated):.3g}")
x = 0.002
coefficient = (response(x, sky, h) * exp(-1j * x)).real / x ** 2
assert isclose(coefficient, low_frequency(sky, h), abs_tol=7e-7)
print(f"{mode:5s} low-frequency coefficient={low_frequency(sky, h):.12f}")
if __name__ == "__main__":
main()
walk_readout.py
"""Four phase-resolved, native six-stage dark-port readouts on translated cells.
Units: one fine link and one link transit time. The common first and last
links drop out of each phase difference. Time zero is the first y turn.
"""
import cmath
import hashlib
import math
import random
X, Y, Z = range(3)
ZERO = (0, 0, 0)
HALF = 1 / math.sqrt(2)
BASIS = (((HALF, HALF), (HALF, -HALF)),
((HALF, 1j * HALF), (HALF, -1j * HALF)),
((1, 0), (0, 1)))
def shifted(r, axis, distance):
v = list(r)
v[axis] += distance
return tuple(v)
def dot(a, b):
return sum(x * y for x, y in zip(a, b))
def spin_amplitudes(axis, direction):
outside = Z if axis == X else X
stages = (outside, Y, axis, axis, Y, outside)
amplitudes = []
for side in (0, 1):
port = (0, side, int(direction < 0), int(direction < 0), 1 - side, 0)
amplitude = 1
for j, current in enumerate(stages):
k = (j + 1) % 6
output = BASIS[stages[k]][port[k]]
amplitude *= dot([v.conjugate() for v in output], BASIS[current][port[j]])
amplitudes.append(amplitude)
return amplitudes
def material_record(axis, direction, r, t, field):
# field takes a site, a time and 0,1,2 for displacement or 3 for clock.
first, last = shifted(r, axis, -direction), shifted(r, axis, direction)
def arm(side):
a = shifted(first, Y, side)
b = shifted(last, Y, side)
legs = [(first, a, Y, side, t, t+1),
(a, b, axis, direction, t+1, t+3),
(b, last, Y, -side, t+3, t+4)]
result = 0
for start, end, component, sign, before, after in legs:
result += sign * (field(end, after, component) - field(start, before, component))
result += field(end, after, 3) - field(start, before, 3)
return result
return arm(1) - arm(-1)
def paired(read, axis, r, t):
return sum(read(axis, s, shifted(r, axis, s), t)
- read(axis, s, shifted(r, axis, -s), t+2) for s in (1, -1))
def twice_u(read, axis, r, t):
# Twice U avoids divisions for a bit-exact real-space integer test.
base = 2 * sum(read(r, t+j) for j in (0, 2, 4))
transverse = sum(read(shifted(r, Y, s), t+j) for s in (-1, 1) for j in (1, 3))
longitudinal = sum(read(shifted(r, axis, 2*s), t+2) for s in (-1, 1))
return base - transverse - longitudinal
def twice_observable(read, r, t):
return (twice_u(lambda u, v: paired(read, X, u, v), Z, r, t)
- twice_u(lambda u, v: paired(read, Z, u, v), X, r, t))
def cis(x):
return cmath.exp(1j*x)
def sinc(x):
return math.sin(x)/x if x else 1.
def light_record(axis, direction, center, t, k, w, diagonal):
start = shifted(center, axis, -direction)
def arm(side):
r, now = start, t
phase = 0j
for component, sign, length in ((Y, side, 1), (axis, direction, 2), (Y, -side, 1)):
half = (sign*k[component] - w)*length/2
integral = length*cis(dot(k, r)-w*now+half)*sinc(half)
phase += diagonal[component]*integral/2
r = shifted(r, component, sign*length)
now += length
return phase
return arm(1) - arm(-1)
def normal_response(w):
d = cis(-w)
return 4j * math.sin(w) * (1-d*d)**3 * d*d * sinc(w)
def check():
for axis in (X, Z):
for s in (-1, 1):
amps = spin_amplitudes(axis, s)
assert abs(sum(amps)) < 1e-14 and abs(abs(amps[0]) - .25) < 1e-14
def shake(r, t, component):
bits = hashlib.blake2s(bytes((48+n) % 256 for n in (*r,t,component)), digest_size=4).digest()
return int.from_bytes(bits, 'big', signed=True)
# Enumerate every coordinate/time degree of freedom in the finite stencil.
keys = set()
def register(pos, tick, component):
keys.add((pos, tick, component))
return 0
def from_field(field):
return lambda a,s,r,t: material_record(a,s,r,t,field)
twice_observable(from_field(register), ZERO, 0)
for key in keys:
impulse = lambda r,t,c: int((r,t,c) == key)
assert twice_observable(from_field(impulse), ZERO, 0) == 0, key
print(f"Every one of {len(keys)} separate endpoint/clock impulse responses is zero.")
# With one readout per full tick, the two distinct corner times alias.
z = cis(.373)
determinant = 1/z**2 - z**2
assert abs(determinant) > .5
rng = random.Random(1201)
raw = lambda a, s, r, t: material_record(a, s, r, t, shake)
assert raw(X, 1, ZERO, 0) != 0
for _ in range(32):
r = tuple(rng.randrange(-12,13) for _ in range(3))
assert twice_observable(raw,r,rng.randrange(-15,16)) == 0
for w in (.017, .05, .2, .8, math.pi/2, 2.4):
k = (0, w, 0)
def sim(diag):
return twice_observable(lambda a,s,r,t: light_record(a,s,r,t,k,w,diag),ZERO,0)/2
value = sim((1,0,-1))
assert abs(value - normal_response(w)) < 5e-14
assert abs(sim((1,1,1))) < 5e-14
print(f"omega*tau={w:.6f}: transfer={value:.10g}, |transfer|/w^4={abs(value)/w**4:.8f}")
w = .002
assert abs(abs(normal_response(w))/w**4 - 32) < .001
assert abs(normal_response(math.pi/2) + 64j/math.pi) < 1e-13
print("All 4 dark ports, 32 independent jitter tests and finite optical controls passed.")
if __name__ == "__main__":
check()