Aetheria/docs/research/gravity-tail-taming/check_laws.py
Meta Vens ca37b45687 Research: taming summed gravity tails (screened K0, caps, force switch, disc subtraction, exponent, hyperbolic kernel), for ruling tame-tails-parent-only-rails
Eyes pass eyes-ag3-tail-taming, session self-2026-10-15-ag3. Facts file plus
numpy probe over the orbit-probe bodies: enclosed/parent speed ratio by child
class, mid-zone inward pull, planets round a median sun, HLSL cost per well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 21:19:49 +02:00

14 lines
979 B
Python

# Checks: A&S K0/K1 against a direct integral; each law's force equals -dphi/dr (grid equals field).
import numpy as np, sys, os
sys.path.insert(0, os.path.dirname(__file__))
from laws import *
x = np.array([0.05, 0.3, 1.0, 1.99, 2.01, 4.0, 10.0])
t = np.linspace(0, 12, 200001)
ref0 = np.array([np.trapezoid(np.exp(-xi * np.cosh(t)), t) for xi in x])
ref1 = np.array([np.trapezoid(np.exp(-xi * np.cosh(t)) * np.cosh(t), t) for xi in x])
print('K0 rel err', np.max(np.abs(k0(x) / ref0 - 1)), ' K1 rel err', np.max(np.abs(k1(x) / ref1 - 1)))
r = np.linspace(20, 5000, 20000); c = 300.0
for name, tf, pf, s in [('log', tail_log, phi_log, 0), ('k0', tail_k0, phi_k0, 800.0), ('cap', tail_cap, phi_cap, 1000.0),
('switch', tail_switch, phi_switch, 1000.0), ('hyp', tail_hyp, phi_hyp, 1500.0)]:
ph = pf(c, r, s); dphi = np.gradient(ph, r); F = tf(c, r, s)
print(f'{name:7s} max |F - dphi/dr| / max F = {np.max(np.abs(F - dphi)[5:-5]) / F.max():.2e}')