Download research/quantum_protocol_check.py from PureOne/Avenyra-Geometric-Memory-Physics: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/datasets/PureOne/Avenyra-Geometric-Memory-Physics/resolve/main/research/quantum_protocol_check.py
- Command line
-
hf download hf://datasets/PureOne/Avenyra-Geometric-Memory-Physics/research/quantum_protocol_check.py
-
curl -L -o quantum_protocol_check.py https://huggingface.co/datasets/PureOne/Avenyra-Geometric-Memory-Physics/resolve/main/research/quantum_protocol_check.py
2.06 kB
| """Full propagator checks of multistage photon survival and finite dwell. | |
| No physical measurements are represented by this script. | |
| """ | |
| from pathlib import Path | |
| import json | |
| import numpy as np | |
| from scipy.linalg import expm | |
| rng=np.random.default_rng(8102028) | |
| max_telescope=0.;max_two=0.;max_bound_violation=0. | |
| for case in range(250): | |
| b=rng.normal(size=3);x=rng.normal(size=3) | |
| U0=np.dot(b,b);n0=b/np.sqrt(U0) | |
| actual=n0.copy();ideal=n0.copy();rbound=0.;Uprev=U0 | |
| for j in range(12): | |
| n=b/np.linalg.norm(b);pulse=rng.normal();a=pulse*n | |
| b=b+np.cross(x,a);x=x+a | |
| U=np.dot(b,b);nn=b/np.sqrt(U);P=np.outer(nn,nn) | |
| gamma=rng.uniform(.2,2);dwell=rng.uniform(.01,2) | |
| M=expm(-gamma*U*(np.eye(3)-P)*dwell/2) | |
| actual=M@actual;ideal=P@ideal | |
| eps=np.exp(-gamma*U*dwell/2) | |
| rbound+=eps*np.sqrt(U0*(U-Uprev)/(Uprev*U)) | |
| Uprev=U | |
| theo=U0/U | |
| max_telescope=max(max_telescope,abs(np.dot(ideal,ideal)-theo)) | |
| max_bound_violation=max(max_bound_violation,abs(np.dot(actual,actual)-theo)-2*rbound) | |
| assert abs(np.dot(actual,actual)-theo)<=2*rbound+1e-12 | |
| for case in range(100): | |
| gamma=rng.uniform(.1,2);t1,t2=rng.uniform(0,3,size=2) | |
| n1=np.array([0.,1.,1.])/np.sqrt(2);n2=np.array([0.,1.,0.]) | |
| M1=expm(-gamma*2*(np.eye(3)-np.outer(n1,n1))*t1/2) | |
| M2=expm(-gamma*4*(np.eye(3)-np.outer(n2,n2))*t2/2) | |
| psi=M2@M1@np.array([0.,0.,1.]) | |
| e=np.exp(-gamma*t1) | |
| pred=((1-e)**2+(1+e)**2*np.exp(-4*gamma*t2))/4 | |
| err=abs(np.dot(psi,psi)-pred);max_two=max(max_two,err) | |
| assert err<1e-12 | |
| result={'seed':8102028,'multistage_histories':250,'stages_per_history':12,'two_stage_checks':100,'max_ideal_telescope_residual':max_telescope,'max_two_stage_residual':max_two,'maximum_error_bound_violation':max_bound_violation,'status':'all checks passed; exact formulas concern the defined loss protocol'} | |
| out=Path(__file__).resolve().parent/'results';out.mkdir(exist_ok=True) | |
| (out/'quantum_protocol_check.json').write_text(json.dumps(result,indent=2)+'\n') | |
| print(json.dumps(result,indent=2)) | |