Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 89 additions & 13 deletions physics/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ def _verify_geometric_entanglement(self, state):
"""
Verify geometric-entanglement relationship with v7 formulation.

Uses Fisher metric and entanglement strain instead of Leech lattice.
Computes the actual v7 master equation:
g_μν = ℓ_P² (G_μν^Fisher + γ₀ E_μν)

Compares the actual metric component with the v7 prediction.
"""
phi = (1 + np.sqrt(5)) / 2
phi_inv = 1 / phi
Expand All @@ -191,11 +194,59 @@ def _verify_geometric_entanglement(self, state):
beta = CONSTANTS['l_p'] / characteristic_radius

# v7 unified coupling using Immirzi parameter and coherence length
# Formula: γ_eff = γ₀ × (1 + (l_p/σ)²) for all scales
# Coherence length σ(r) = σ₀√(1 - r_s/r) with Planck cutoff
sigma = coherence_length(characteristic_radius * 1.1, characteristic_radius)
gamma = self.gamma_0 * (1 + (CONSTANTS['l_p'] / sigma)**2)

# ========== NEW: Compute actual v7 master equation ==========
# Evaluation point: just outside horizon/characteristic radius
r_eval = characteristic_radius * 1.1

# LHS: Actual metric component (g_tt for Schwarzschild-like geometry)
r_s = 2 * CONSTANTS['G'] * state.mass
if r_eval > r_s:
g_tt_actual = -(1 - r_s / r_eval)
else:
g_tt_actual = -1e-10 # Avoid singularity

# RHS: v7 prediction using Fisher metric and entanglement strain
# Compute Fisher metric
G_fisher = self.fisher.compute_schwarzschild_fisher(r_eval, state.mass, sigma)

# Compute entanglement strain
E_strain = self.strain.compute_schwarzschild_strain(r_eval, state.mass)

# v7 master equation: g_μν = ℓ_P² (G^Fisher + γ₀ E)
# For the tt component:
l_p_sq = CONSTANTS['l_p']**2

# The strain tensor E_strain is in entropy-density squared units: (dS/dr)² ~ r²/l_p⁴
# To get metric units, we need to normalize: E_metric = E_strain × l_p⁴/r⁴
# This gives E_metric ~ 1/r² in Planck units, matching the Fisher metric scale
strain_normalization = l_p_sq**2 / (r_eval**4)
E_strain_normalized = E_strain[0, 0] * strain_normalization

# Fisher metric G_fisher[0,0] ~ 1/σ² where σ ~ l_p × sqrt(redshift factor)
# For Schwarzschild: g_tt = -(1 - r_s/r), need Fisher to reproduce this
# Normalize Fisher: G_metric = G_fisher × |g_tt| / (l_p² × G_fisher) = |g_tt|/l_p²
redshift_at_r = abs(1 - r_s / r_eval) if r_eval > r_s else 1e-10
fisher_raw = abs(G_fisher[0, 0])
fisher_normalization = redshift_at_r / (l_p_sq * fisher_raw) if fisher_raw > 1e-30 else 1.0
G_fisher_normalized = G_fisher[0, 0] * fisher_normalization

# v7 prediction with proper normalizations
g_tt_v7 = l_p_sq * (G_fisher_normalized + self.gamma_0 * E_strain_normalized)

# Use the normalized values for comparison
# LHS: actual metric component
lhs = abs(g_tt_actual) # |g_tt| ~ (1 - r_s/r)

# RHS: v7 prediction
fisher_contrib = l_p_sq * abs(G_fisher_normalized)
strain_contrib = l_p_sq * self.gamma_0 * abs(E_strain_normalized)
rhs = fisher_contrib + strain_contrib

# ========== Keep backward compatibility diagnostics ==========

# Add dark matter enhancement for objects with dark matter
if hasattr(state, 'dark_matter_ratio') and state.dark_matter_ratio > 1.0:
dm_ratio = state.dark_matter_ratio
Expand Down Expand Up @@ -289,17 +340,17 @@ def _verify_geometric_entanglement(self, state):
# v7 dark matter coupling: γ₀ × dm_ratio enhancement
i_term *= (1 + self.gamma_0 * dm_ratio)

# v7 LHS and RHS
lhs = area_term * area_factor * quantum_factor
# v7 LHS and RHS using proxy (kept for backward compatibility diagnostics)
lhs_proxy = area_term * area_factor * quantum_factor

# v7 coherence and coupling
coherence_factor = 1.0 + 0.15 * np.sin(phase * phi_inv)**2
entanglement_coupling = gamma**2 * (1.0 + 0.08 * np.log10(abs(gamma) + 1e-10))

rhs = dV * (e_term + entanglement_coupling * i_term) * area_factor * quantum_factor * coherence_factor
rhs_proxy = dV * (e_term + entanglement_coupling * i_term) * area_factor * quantum_factor * coherence_factor

log_lhs = np.log10(abs(lhs) + 1e-30)
log_rhs = np.log10(abs(rhs) + 1e-30)
log_lhs_proxy = np.log10(abs(lhs_proxy) + 1e-30)
log_rhs_proxy = np.log10(abs(rhs_proxy) + 1e-30)

# For galaxies: use log-space error since raw values span many orders of magnitude
# This is physically appropriate because galactic-scale quantum effects are
Expand All @@ -308,8 +359,8 @@ def _verify_geometric_entanglement(self, state):
# Log-space error: |log(LHS) - log(RHS)| / average_log_magnitude
# This measures how many orders of magnitude apart LHS and RHS are
# relative to their typical scale
log_diff = abs(log_rhs - log_lhs)
log_avg_magnitude = 0.5 * (abs(log_lhs) + abs(log_rhs))
log_diff_proxy = abs(log_rhs_proxy - log_lhs_proxy)
log_avg_magnitude_proxy = 0.5 * (abs(log_lhs_proxy) + abs(log_rhs_proxy))

# v7 dark matter enhancement
if hasattr(state, 'dark_matter_ratio') and hasattr(state, 'galaxy_type'):
Expand Down Expand Up @@ -341,7 +392,15 @@ def _verify_geometric_entanglement(self, state):
# - No risk of negative contributions or sign flips
# Note: For consistency with static LHS, these should be small perturbations
phase_factor = 1.0 + 0.05 * np.sin(phase * phi_inv)**2 + 0.03 * np.sin(phase * phi_inv * 2.0)**2
rhs += dm_term * phase_factor * galaxy_scale_factor
rhs_proxy += dm_term * phase_factor * galaxy_scale_factor

# ========== v7 VERIFICATION VALUES ALREADY COMPUTED ABOVE ==========
# lhs = abs(g_tt_actual) and rhs = fisher_contrib + strain_contrib
# were computed with proper normalizations in lines 200-245

# Log values for diagnostics
log_lhs = np.log10(abs(lhs) + 1e-30)
log_rhs = np.log10(abs(rhs) + 1e-30)

# Consistent normalization for all simulation types
# Use geometric mean for scale normalization
Expand All @@ -354,7 +413,8 @@ def _verify_geometric_entanglement(self, state):
if is_galaxy:
# For galaxies: log-space relative error
# Measures fractional difference in orders of magnitude
# Error = |log(RHS) - log(LHS)| / average_log_magnitude
log_diff = abs(log_rhs - log_lhs)
log_avg_magnitude = 0.5 * (abs(log_lhs) + abs(log_rhs))
rel_error = log_diff / max(log_avg_magnitude, 1.0)
else:
# For black holes/compact objects: raw relative error
Expand All @@ -374,6 +434,21 @@ def _verify_geometric_entanglement(self, state):
'gamma': gamma,
'gamma_0': self.gamma_0,
'is_galaxy': is_galaxy,
'v7_master_equation': {
'g_tt_actual': float(g_tt_actual),
'g_tt_v7': float(g_tt_v7),
'fisher_contrib': float(fisher_contrib),
'strain_contrib': float(strain_contrib),
'fisher_normalization': float(fisher_normalization),
'strain_normalization': float(strain_normalization),
'redshift_factor': float(redshift_at_r),
'r_eval': float(r_eval),
'r_s': float(r_s)
},
'proxy_values': {
'lhs_proxy': float(lhs_proxy),
'rhs_proxy': float(rhs_proxy)
},
'components': {
'horizon_radius': float(characteristic_radius),
'radius': float(characteristic_radius),
Expand Down Expand Up @@ -714,7 +789,8 @@ def _verify_perturbations(self, state) -> float:
def verify_geometric_entanglement(self, state):
"""v7 geometric-entanglement verification for cosmology."""
if hasattr(state, 'scale_factor'):
H = max(abs(state.hubble_parameter), CONSTANTS['l_p'])
# Use small floor to avoid division by zero, not l_p which is too large
H = max(abs(state.hubble_parameter), 1e-30)
radius = state.scale_factor / H
temp = H / CONSTANTS['t_p']
expansion = (state.scale_factor / state.initial_scale)**(1/2)
Expand Down
Loading