validate_ppn.py — src/21-gravity

The script src/21-gravity/validate_ppn.py of the validation package of the paper 21-grav, rendered with an anchor per line. ▶ run the predicates on Google Colab.

21-gravity ledgersrc/21-gravity/validate_ppn.py · 1.6 KBvalidate_ppn.pyColab
1"""Relativistic layer: PPN parameters, light deflection, perihelion, static-profile series.23Validates: Lemma (isotropic pair) + Prop (full light deflection)  alpha = 4Gm/(c^2 b);4           Prop (all three classical tests)  beta = gamma = 1 for the exponential metric;5           Prop (exact static profile)       u(r) = Gm/r (1 + (Gm/r^2)^2/30 + ...).6"""7import sympy as sp89ok = True10z, b, G, m, c, U, r, s, Gm = sp.symbols('z b G m c U r s Gm', positive=True)1112# Fermat deflection in index n = 1 + 2Gm/(c^2 r)13n1 = 2*G*m/(c**2*sp.sqrt(b**2 + z**2))14alpha = sp.integrate(-sp.diff(n1, b), (z, -sp.oo, sp.oo))15print("  deflection:", sp.simplify(alpha), " (target 4Gm/(b c^2))")16if sp.simplify(alpha - 4*G*m/(b*c**2)) != 0: ok = False1718# PPN of exponential isotropic metric19g00 = sp.series(-sp.exp(-2*U), U, 0, 3).removeO()20gij = sp.series(sp.exp(2*U), U, 0, 2).removeO()21beta = -sp.Rational(1, 2)*g00.coeff(U, 2)   # g00 = -1 + 2U - 2 beta U^222gamma = sp.Rational(1, 2)*gij.coeff(U, 1)   # gij = 1 + 2 gamma U23print(f"  PPN: beta = {beta}, gamma = {gamma}  (targets 1, 1)")24if beta != 1 or gamma != 1: ok = False25peri = sp.Rational(2 + 2*1 - 1, 3)26print(f"  perihelion factor (2+2*gamma-beta)/3 = {peri}  (target 1)")27if peri != 1: ok = False2829# exact static profile series: u = int_r^inf arcsin(Gm/s^2) ds30ser = sp.series(sp.asin(Gm/s**2), Gm, 0, 4).removeO()31user = sp.integrate(ser, (s, r, sp.oo))32target = Gm/r + Gm**3/(30*r**5)33print("  static profile:", sp.simplify(user), " (target Gm/r + Gm^3/(30 r^5))")34if sp.simplify(user - target) != 0: ok = False3536print("PASS" if ok else "FAIL", "- relativistic layer / PPN")37