#!/usr/bin/env python3
"""
Nuclear Scale Geometric Dominance Verification

This script demonstrates the corrected calculation showing that geometric binding
dominates over QCD confinement at nuclear scales when proper nuclear radii are used.

Key insight from human collaborator: Use actual nuclear dimensions (~1 fm)
rather than scaled atomic radii.

Author: Andre Heinecke & AI Collaborators  
Date: June 2025
License: CC BY-SA 4.0
"""

import numpy as np

def verify_nuclear_geometric_dominance():
    """Verify geometric dominance at nuclear scales with proper radii"""
    
    print("NUCLEAR SCALE GEOMETRIC DOMINANCE VERIFICATION")
    print("="*60)
    print("Testing F = ℏ²/(γm_q r³) vs F = σr at nuclear scales")
    print("Key insight: Use proper nuclear radii (~1 fm), not scaled atomic radii")
    print()
    
    # Physical constants (from scipy.constants or CODATA)
    hbar = 1.054571817e-34  # J·s (reduced Planck constant)
    c = 299792458           # m/s (speed of light, exact)
    eV_to_J = 1.602176634e-19  # J/eV (exact)
    
    # Nuclear parameters (PDG 2022)
    m_up_MeV = 2.16         # MeV/c² (up quark current mass)
    m_down_MeV = 4.67       # MeV/c² (down quark current mass)
    m_q_avg_MeV = (m_up_MeV + m_down_MeV) / 2
    m_q_kg = m_q_avg_MeV * 1e6 * eV_to_J / c**2  # Convert to kg
    
    # QCD string tension (Lattice QCD, FLAG 2021)
    sigma_GeV2_fm = 0.18    # GeV²/fm
    sigma_SI = sigma_GeV2_fm * (1e9 * eV_to_J)**2 / 1e-15  # Convert to N
    
    print("PARAMETERS:")
    print(f"  Average light quark mass: {m_q_avg_MeV:.2f} MeV/c²")
    print(f"  Quark mass in kg: {m_q_kg:.2e} kg")
    print(f"  QCD string tension: {sigma_GeV2_fm:.2f} GeV²/fm")
    print(f"  String tension in SI: {sigma_SI:.2e} N")
    print()
    
    # Test at different nuclear scales
    radii_fm = np.array([0.1, 0.5, 1.0, 2.0, 3.0])  # fm
    
    print("FORCE COMPARISON AT NUCLEAR SCALES:")
    print(f"{'r (fm)':<8} {'F_geom (N)':<12} {'F_conf (N)':<12} {'Ratio':<10} {'Dominant':<10}")
    print("-" * 60)
    
    for r_fm in radii_fm:
        r_m = r_fm * 1e-15  # Convert fm to meters
        
        # Geometric force: F = ℏ²/(m_q r³)
        F_geometric = hbar**2 / (m_q_kg * r_m**3)
        
        # Confinement force: F = σr  
        F_confinement = sigma_SI * r_m
        
        # Calculate ratio
        ratio = F_geometric / F_confinement
        dominant = "Geometric" if ratio > 1 else "Confinement"
        
        print(f"{r_fm:<8.1f} {F_geometric:<12.2e} {F_confinement:<12.2e} {ratio:<10.1e} {dominant:<10}")
    
    print()
    
    # Calculate crossover point
    # F_geom = F_conf when ℏ²/(m_q r³) = σr
    # Solving: r⁴ = ℏ²/(m_q σ)
    r_crossover_m = (hbar**2 / (m_q_kg * sigma_SI))**(1/4)
    r_crossover_fm = r_crossover_m * 1e15
    
    print("CROSSOVER ANALYSIS:")
    print(f"  Crossover radius: {r_crossover_fm:.1f} fm")
    print(f"  Crossover radius: {r_crossover_m:.2e} m")
    print()
    
    if r_crossover_fm > 1000:
        print("  ⚠️  Crossover at unphysically large scale!")
        print("     This means geometric binding dominates at ALL nuclear scales")
    elif r_crossover_fm > 10:
        print("  ⚠️  Crossover beyond typical nuclear scales")
        print("     Geometric binding dominates within nucleons")
    else:
        print("  ✓  Crossover within nuclear range")
        print("     Both effects important at nuclear scales")
    
    print()
    
    # Test at typical nucleon size
    r_nucleon_fm = 0.8  # fm (proton charge radius)
    r_nucleon_m = r_nucleon_fm * 1e-15
    
    F_geom_nucleon = hbar**2 / (m_q_kg * r_nucleon_m**3)
    F_conf_nucleon = sigma_SI * r_nucleon_m
    ratio_nucleon = F_geom_nucleon / F_conf_nucleon
    
    print("AT TYPICAL NUCLEON SIZE:")
    print(f"  Nucleon radius: {r_nucleon_fm} fm")
    print(f"  Geometric force: {F_geom_nucleon:.2e} N")
    print(f"  Confinement force: {F_conf_nucleon:.2e} N")
    print(f"  Geometric/Confinement ratio: {ratio_nucleon:.1e}")
    print()
    
    if ratio_nucleon > 1e10:
        print("  🚀 GEOMETRIC BINDING DOMINATES BY 10+ ORDERS OF MAGNITUDE!")
        print("     This suggests the 'strong force' may actually be geometric binding")
        print("     with confinement as a boundary condition preventing escape")
    elif ratio_nucleon > 100:
        print("  ✓ Geometric binding clearly dominates")
        print("    Confinement acts as secondary effect")
    else:
        print("  ≈ Both effects are comparable")
        print("    True competition between geometric and confining forces")
    
    print()
    print("IMPLICATIONS:")
    print("1. Geometric binding F = ℏ²/(m_q r³) dominates at nuclear scales")
    print("2. QCD confinement F = σr prevents escape but doesn't provide primary binding")
    print("3. 'Strong force' may be same geometric principle as electromagnetic force")
    print("4. Force hierarchy (strong >> EM) explained by geometric scaling r⁻³")
    print("5. All binding forces could be unified as centripetal requirements")
    
    return {
        'crossover_fm': r_crossover_fm,
        'nucleon_ratio': ratio_nucleon,
        'geometric_dominates': ratio_nucleon > 1e3
    }

if __name__ == "__main__":
    result = verify_nuclear_geometric_dominance()
    
    print("\n" + "="*60)
    print("BOTTOM LINE:")
    if result['geometric_dominates']:
        print("🎯 Geometric binding dominates at nuclear scales!")
        print("   The geometric principle may be truly universal")
        print("   from quarks to planets via the same F = ℏ²/(γmr³)")
    else:
        print("📊 Mixed regime - both geometric and confinement important")
        print("   Nuclear physics requires careful treatment of both effects")
