-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_robustness_scan.py
More file actions
143 lines (113 loc) · 4.33 KB
/
simple_robustness_scan.py
File metadata and controls
143 lines (113 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env python3
"""
Simple Robustness Scan for Ghost EFT
A streamlined robustness validation around the optimal Ghost EFT configuration.
"""
import sys
import json
import time
import numpy as np
from pathlib import Path
# Add src to path
sys.path.append('src')
try:
from ghost_condensate_eft import GhostCondensateEFT
print("✓ Ghost EFT module imported successfully")
except ImportError as e:
print(f"✗ Import error: {e}")
sys.exit(1)
def simple_robustness_check():
"""Simple robustness check around optimal parameters."""
print("=== Ghost EFT Robustness Validation ===")
# Optimal parameters
optimal = {
'M': 1000.0,
'alpha': 0.01,
'beta': 0.1,
'target': -1.418e-12
}
print(f"Optimal: M={optimal['M']}, α={optimal['alpha']}, β={optimal['beta']}")
print(f"Target ANEC: {optimal['target']:.2e} W")
# Grid setup
grid = np.linspace(-1e6, 1e6, 2000)
tau0 = 7 * 24 * 3600 # Week-scale
def gaussian_kernel(tau):
return (1 / np.sqrt(2 * np.pi * tau0**2)) * np.exp(-tau**2 / (2 * tau0**2))
# Test parameter variations (±10% around optimal)
variations = [
{'M': 900, 'alpha': 0.009, 'beta': 0.09}, # -10%
{'M': 1000, 'alpha': 0.01, 'beta': 0.1}, # Optimal
{'M': 1100, 'alpha': 0.011, 'beta': 0.11}, # +10%
{'M': 950, 'alpha': 0.01, 'beta': 0.1}, # M variation
{'M': 1000, 'alpha': 0.008, 'beta': 0.1}, # α variation
{'M': 1000, 'alpha': 0.01, 'beta': 0.12}, # β variation
]
results = []
violations = 0
print(f"\nTesting {len(variations)} parameter configurations...")
for i, params in enumerate(variations, 1):
try:
print(f"\n{i}. M={params['M']}, α={params['alpha']:.3f}, β={params['beta']:.2f}")
eft = GhostCondensateEFT(
M=params['M'],
alpha=params['alpha'],
beta=params['beta'],
grid=grid
)
anec = eft.compute_anec(gaussian_kernel)
result = {
'config': i,
'parameters': params,
'anec_value': float(anec),
'qi_violation': anec < 0,
'target_ratio': float(anec / optimal['target']) if anec < 0 else 0
}
results.append(result)
if anec < 0:
violations += 1
print(f" ✓ ANEC: {anec:.2e} W (violation confirmed)")
print(f" ✓ Ratio: {anec/optimal['target']:.2f}× target strength")
else:
print(f" ✗ ANEC: {anec:.2e} W (no violation)")
except Exception as e:
print(f" ✗ Error: {e}")
continue
# Summary
success_rate = violations / len(results) * 100 if results else 0
print(f"\n=== Robustness Summary ===")
print(f"Configurations tested: {len(results)}")
print(f"Successful violations: {violations}")
print(f"Success rate: {success_rate:.1f}%")
if violations >= len(results) * 0.8: # 80% threshold
print(f"✓ ROBUSTNESS CONFIRMED: Parameter variations maintain ANEC violations")
status = "VALIDATED"
else:
print(f"⚠ ROBUSTNESS UNCERTAIN: Lower success rate detected")
status = "NEEDS_REVIEW"
# Save results
output = {
'validation_type': 'parameter_robustness',
'optimal_config': optimal,
'test_results': results,
'summary': {
'total_tests': len(results),
'violations': violations,
'success_rate_percent': success_rate,
'robustness_status': status
},
'timestamp': time.strftime('%Y-%m-%d %H:%M:%S')
}
# Save to JSON
output_file = Path("results") / "ghost_eft_robustness_validation.json"
output_file.parent.mkdir(exist_ok=True)
with open(output_file, 'w') as f:
json.dump(output, f, indent=2)
print(f"\nResults saved to: {output_file}")
return output
if __name__ == "__main__":
try:
results = simple_robustness_check()
print(f"\n🎯 Robustness validation completed successfully!")
except Exception as e:
print(f"\n✗ Validation failed: {e}")
sys.exit(1)