EVE-QELTHA / research /code /original_verification.py
PureOne's picture
Add EVE-QELTHA v4.0 research release, proofs, verification data and manuscript
9427ec0 verified
Raw History Blame Contribute Delete
7.61 kB
#!/usr/bin/env python3
"""EVE-QELTHA: holonomy-gated hyperhorn mathematical verification.
Python 3.10+; requires numpy, scipy, mpmath (only for asymptotic check).
All quantities dimensionless; model is a reduced mathematical transport model,
not a numerical solution of the full Navier-Stokes equations.
Reproduces:
- genuinely noncommuting SU(2) two-loop holonomies;
- spectral formula for the leakage matrix;
- exact Bessel Dirichlet-to-Neumann impedances;
- independent variational finite-volume convergence;
- gauge-covariant inlet dissipation;
- supercritical algebraic divergence and marginal logarithmic divergence.
"""
import csv
from pathlib import Path
import numpy as np
import mpmath as mp
from scipy.linalg import eigh, expm, solve_banded
from scipy.special import kv
HERE = Path(__file__).resolve().parent
SX = np.array([[0, 1], [1, 0]], dtype=complex)
SY = np.array([[0, -1j], [1j, 0]], dtype=complex)
SZ = np.array([[1, 0], [0, -1]], dtype=complex)
E0 = np.array([1.0, 0.0], dtype=complex)
def transport(a, b, second_axis=SZ):
w1 = expm(1j * a * SX)
w2 = expm(1j * b * second_axis)
u, v = w1 @ w2 @ E0, w2 @ w1 @ E0
M = np.outer(u, u.conjugate()) + np.outer(v, v.conjugate())
delta = float(1 - abs(np.vdot(u, v)) ** 2)
return w1, w2, u, v, M, max(0.0, min(1.0, delta))
def geometry(n, p):
assert n >= 3 and (n - 1) * p > 1 and (n - 2) * p <= 1
alpha_h = 1 + 1.5 * p
nu = (1 - (n - 2) * p) / (2 + 3 * p)
return alpha_h, nu
def impedance(lam, n=4, p=0.4, A=1.0, B=1.0):
if lam <= 0:
return float('inf')
alpha_h, nu = geometry(n, p)
k = np.sqrt(A * B * lam) / alpha_h
return float(np.sqrt(A / (B * lam)) * kv(1 - nu, k) / kv(nu, k))
def flux(x, lam, n=4, p=0.4, A=1.0, B=1.0):
alpha_h, nu = geometry(n, p)
beta_h = (1 - (n - 2) * p) / 2
k = np.sqrt(A * B * lam) / alpha_h
x = np.asarray(x, dtype=float)
return x**beta_h * kv(nu, k * x**alpha_h) / kv(nu, k)
def finite_volume_impedance(lam, n=4, p=0.4, A=1, B=1, length=35, N=1000):
"""Independent variational discretization of the flux-energy functional.
Boundary values: Q(1)=1; Q(length)=0. Midpoint quadrature of
int R(x)*Q(x)^2 dx + int abs(Q'(x))^2/(G(x)*lam) dx.
Minimization yields a tridiagonal strictly-positive-definite system.
"""
assert lam > 0 and N >= 3
xs = np.linspace(1, length, N + 1)
h = xs[1] - xs[0]
mid = (xs[:-1] + xs[1:]) / 2
R = A * mid**((n + 1) * p)
G = B * mid**(-(n - 2) * p)
d = R * h / 2 + 2 / (G * lam * h)
off = R * h / 2 - 2 / (G * lam * h)
# Interior stationarity: (d[j-1]+d[j])*q[j]
# + off[j-1]*q[j-1] + off[j]*q[j+1] = 0.
main = d[:-1] + d[1:]
adjacent = off[1:-1]
ab = np.zeros((3, N - 1))
ab[0, 1:] = adjacent
ab[1, :] = main
ab[2, :-1] = adjacent
rhs = np.zeros(N - 1)
rhs[0] = -off[0]
sol = solve_banded((1, 1), ab, rhs, check_finite=True)
q = np.concatenate(([1.0], sol, [0.0]))
e = np.sum(R * h * ((q[:-1] + q[1:]) / 2)**2 +
((q[:-1] - q[1:])**2) / (G * lam * h))
return float(e)
def high_precision_log10_impedance(b_exp, p='0.4', n=4):
mp.mp.dps = 180
p = mp.mpf(p)
a_h = 1 + mp.mpf('1.5') * p
nu = (1 - (n - 2) * p) / (2 + 3*p)
b = mp.power(10, -b_exp)
lam = 1 - mp.cos(b) # exact for first SU2 angle a=pi/4, |b|<pi/2
k = mp.sqrt(lam) / a_h
z = mp.besselk(1-nu, k) / (mp.sqrt(lam)*mp.besselk(nu, k))
return float(mp.log10(z))
def run():
# 1. Noncommutativity, holonomy/observer invariant and spectral identity
a = np.pi / 4
b = 0.5
w1,w2,u,v,M,delta = transport(a,b)
assert np.linalg.norm(w1@w2-w2@w1) > 0.1
assert abs(delta - np.sin(2*a)**2*np.sin(b)**2) < 1e-12
eigs,U = eigh(M)
spectral_formula = np.array([1 - np.sqrt(1-delta), 1 + np.sqrt(1-delta)])
assert np.max(np.abs(eigs-spectral_formula)) < 1e-12
# 2. Individual Wilson-loop eigenvalues cannot resolve the obstruction:
# replace z-axis by x-axis while maintaining eigenvalues of W2.
_,_,_,_,M_parallel,delta_parallel = transport(a,b,second_axis=SX)
assert delta_parallel < 1e-12
assert abs(np.linalg.eigvalsh(M_parallel)[0]) < 1e-12
print('Spectral-insufficiency test: identical loop eigenvalues,')
print(' transverse-hole delta=%.10f, commuting-hole delta=%.2e' % (delta,delta_parallel))
# 3. Energy/impedance operator is covariant under change of local frame
q = np.array([1 + .2j, -.4 + .1j])
z = np.array([impedance(float(x)) for x in eigs])
Z = U @ np.diag(z) @ U.conjugate().T
s = expm(1j*.371*SY)
M2 = s @ M @ s.conjugate().T
eigs2,U2 = eigh(M2)
Z2 = U2 @ np.diag([impedance(float(x)) for x in eigs2]) @ U2.conjugate().T
e1 = np.vdot(q,Z@q).real
e2 = np.vdot(s@q,Z2@(s@q)).real
assert abs(e1-e2) < 1e-11
print('Gauge/frame invariance: %.12f vs %.12f (error %.2e)' % (e1,e2,abs(e1-e2)))
# 4. Independent numerical discretization and convergence
print('Four-dimensional horn: n=4, p=.4, A=B=1; b=0.5')
print(' leakage eigenvalues:', repr(eigs.tolist()))
numerical_errors=[]
for lam in eigs:
exact=impedance(float(lam))
print(' lambda %.9f exact impedance %.9f:' % (lam,exact))
for N in (400,800,1600,3200):
num=finite_volume_impedance(float(lam),N=N)
rel=abs(num-exact)/exact
numerical_errors.append(rel)
print(' grid=%4d, discrete energy=%.9f, rel error=%.4g' %(N,num,rel))
assert rel < 3e-4
# 5. Conductive vs dark channels; exact four-dimensional predictions
rows=[]
for theta in (np.pi/2,0.8,0.5,0.2,0.1,0.05,0.01,0.001):
_,_,_,_,_,d=transport(a,theta)
low=d/(1+np.sqrt(1-d))
high=1+np.sqrt(1-d)
zlow,zhi=impedance(low),impedance(high)
rows.append((theta,d,low,high,zlow,zhi))
with (HERE/'EVE_QELTHA_results.csv').open('w',newline='',encoding='utf-8') as f:
cw=csv.writer(f)
cw.writerow(['relative_SU2_angle_rad','projective_commutator_delta','lambda_dark',
'lambda_bright','inlet_impedance_dark','inlet_impedance_bright'])
cw.writerows(rows)
print('Holonomy-controlled impedance (dark eigenchannel):')
for theta,d,l,high,zlo,zhi in rows:
print(' beta=%8.5f delta=%10.7f lam=%12.8f Z=%.6g'% (theta,d,l,zlo))
# 6. Supercritical asymptotic exponent: p=0.4, n=4 => 1.875.
p4=.4
alpha_h,nu=geometry(4,p4)
pred=2*(1-nu)
z16=high_precision_log10_impedance(16)
z32=high_precision_log10_impedance(32)
z64=high_precision_log10_impedance(64)
s1=(z32-z16)/16
s2=(z64-z32)/32
print('Asymptotic critical exponent prediction: %.9f'%pred)
print(' high-precision effective slopes 1e-16 -> 1e-32: %.9f'%s1)
print(' high-precision effective slopes 1e-32 -> 1e-64: %.9f'%s2)
assert abs(s2-pred)<5e-4
# 7. Marginal case n=4 p=0.5: Z(b)*b^2*log(1/b)->2*alpha_h/B
p_m=.5
ah_m,_=geometry(4,p_m)
for exponent in (8,16,32,64):
mp.mp.dps=170
beta=mp.power(10,-exponent)
lam=1-mp.cos(beta)
kt=mp.sqrt(lam)/mp.mpf(ah_m)
zi=mp.besselk(1,kt)/(mp.sqrt(lam)*mp.besselk(0,kt))
scaled=zi*beta**2*mp.log(1/beta)
print(' marginal beta=1e-%d, Z*b^2*log(1/b)=%.8f; limit=%.8f' % (exponent,float(scaled),2*ah_m))
if exponent==64:
assert abs(float(scaled)-2*ah_m) / (2*ah_m) < .05
print('All tests passed. Wrote:', HERE/'EVE_QELTHA_results.csv')
if __name__=='__main__':
run()