GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — unified-lqg/angular_perturbation.py at main · arcticoder/unified-lqg Expand file tree/ Copy pathangular_perturbation.pyMore file actions 526 lines (405 loc) · 20.6 KB / Copy pathangular_perturbation.pyFile metadata and controls526 lines (405 loc) · 20.6 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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 #!/usr/bin/env python3 """ Angular Perturbation Extension for LQG Midisuperspace This module extends the spherically symmetric LQG framework to include small angular perturbations via spherical harmonics Y_l^m(θ,φ). Key features: - Extended kinematical Hilbert space with angular modes - Perturbative Hamiltonian including angular-radial coupling - Memory-efficient basis truncation schemes - Integration with existing radial LQG quantization """ import numpy as np import scipy.sparse as sp import scipy.sparse.linalg as spla from typing import Dict, List, Tuple, Optional, Any from dataclasses import dataclass from enum import Enum class AngularTruncationScheme(Enum): """Schemes for truncating the angular sector basis.""" MAX_L = "max_l" # Truncate at maximum l value MAX_TOTAL_J = "max_total_j" # Truncate based on total angular momentum ENERGY_CUTOFF = "energy_cutoff" # Truncate based on energy scale FIXED_DIMENSION = "fixed_dimension" # Fixed total dimension @dataclass class SphericalHarmonicMode: """ Configuration for a single spherical harmonic perturbation mode. Represents angular perturbations of the form: δg_μν ∼ amplitude * Y_l^m(θ,φ) * α(r) """ l: int # Angular momentum quantum number (l ≥ 0) m: int # Magnetic quantum number (|m| ≤ l) amplitude: float # Perturbation amplitude alpha_max: int # Maximum quantum number for radial mode amplitude def __post_init__(self): assert self.l >= 0, f"l must be non-negative, got {self.l}" assert abs(self.m) <= self.l, f"|m| must be ≤ l, got m={self.m}, l={self.l}" assert self.amplitude >= 0, f"amplitude must be non-negative, got {self.amplitude}" assert self.alpha_max >= 0, f"alpha_max must be non-negative, got {self.alpha_max}" class ExtendedFluxBasisState: """ Extended flux basis state including angular perturbations. State structure: |μ₁,ν₁,...,μₙ,νₙ; {α_lm}⟩ where {α_lm} are quantum numbers for angular modes. """ def __init__(self, radial_flux_state, angular_quantum_numbers: Dict[Tuple[int,int], int]): """ Args: radial_flux_state: Base radial flux state (μ,ν configuration) angular_quantum_numbers: Dict mapping (l,m) → α_lm quantum number """ self.radial_flux_state = radial_flux_state self.angular_quantum_numbers = angular_quantum_numbers.copy() # Compute total quantum numbers for efficient comparison self.total_angular_quantum = sum(angular_quantum_numbers.values()) def __repr__(self): radial_part = repr(self.radial_flux_state) angular_part = ", ".join([f"α_{l}{m}={alpha}" for (l,m), alpha in self.angular_quantum_numbers.items()]) return f"ExtendedFluxState({radial_part}; {angular_part})" def __eq__(self, other): if not isinstance(other, ExtendedFluxBasisState): return False return (self.radial_flux_state == other.radial_flux_state and self.angular_quantum_numbers == other.angular_quantum_numbers) def __hash__(self): radial_hash = hash(repr(self.radial_flux_state)) angular_items = tuple(sorted(self.angular_quantum_numbers.items())) angular_hash = hash(angular_items) return hash((radial_hash, angular_hash)) class ExtendedKinematicalHilbertSpace: """ Extended kinematical Hilbert space including angular perturbations. Combines the radial flux basis with angular harmonic modes: H_extended = H_radial ⊗ H_angular """ def __init__(self, lattice_config, lqg_params, angular_modes: List[SphericalHarmonicMode]): """ Args: lattice_config: Radial lattice configuration lqg_params: LQG parameters including basis truncation angular_modes: List of angular modes to include """ self.lattice_config = lattice_config self.lqg_params = lqg_params self.angular_modes = angular_modes # Initialize radial sector from lqg_fixed_components import KinematicalHilbertSpace self.radial_hilbert_space = KinematicalHilbertSpace(lattice_config, lqg_params) # Build extended basis self.extended_basis_states = [] self.dim = 0 self._build_extended_basis() print(f"🌍 Extended Kinematical Hilbert Space") print(f" Radial dimension: {self.radial_hilbert_space.dim}") print(f" Angular modes: {len(self.angular_modes)}") print(f" Extended dimension: {self.dim}") print(f" Memory estimate: {self.dim * self.dim * 16 / (1024**3):.2f} GB") def _build_extended_basis(self): """Build the extended basis including angular degrees of freedom.""" print(f" Building extended basis with angular modes...") # Generate all combinations of angular quantum numbers angular_configs = self._generate_angular_configurations() print(f" Angular configurations: {len(angular_configs)}") # Apply basis truncation if hasattr(self.lqg_params, 'basis_truncation') and self.lqg_params.basis_truncation > 0: max_states = self.lqg_params.basis_truncation else: max_states = 10000 # Default limit # Combine radial and angular sectors total_combinations = len(self.radial_hilbert_space.basis_states) * len(angular_configs) if total_combinations > max_states: print(f" ⚠️ Truncating extended basis: {total_combinations} → {max_states}") # Truncate by limiting angular sector first angular_limit = max_states // len(self.radial_hilbert_space.basis_states) angular_configs = angular_configs[:angular_limit] # Build extended states for radial_state in self.radial_hilbert_space.basis_states: for angular_config in angular_configs: extended_state = ExtendedFluxBasisState(radial_state, angular_config) self.extended_basis_states.append(extended_state) self.dim = len(self.extended_basis_states) print(f" Extended basis generated: {self.dim} states") def _generate_angular_configurations(self) -> List[Dict[Tuple[int,int], int]]: """Generate all valid combinations of angular quantum numbers.""" angular_configs = [] if not self.angular_modes: # No angular modes - return empty configuration return [{}] # Build configurations recursively def build_configs(mode_index, current_config): if mode_index >= len(self.angular_modes): angular_configs.append(current_config.copy()) return mode = self.angular_modes[mode_index] key = (mode.l, mode.m) # Try all values of α_lm from 0 to alpha_max for alpha in range(mode.alpha_max + 1): current_config[key] = alpha build_configs(mode_index + 1, current_config) del current_config[key] build_configs(0, {}) # Sort by total angular quantum number for consistent ordering angular_configs.sort(key=lambda config: sum(config.values())) return angular_configs class ExtendedMidisuperspaceHamiltonianConstraint: """ Extended Hamiltonian constraint including angular perturbations. H_extended = H_radial + H_angular + H_interaction where H_interaction couples radial and angular sectors. """ def __init__(self, extended_hilbert_space, lattice_config, lqg_params): """ Args: extended_hilbert_space: ExtendedKinematicalHilbertSpace instance lattice_config: Lattice configuration lqg_params: LQG parameters """ self.extended_hilbert_space = extended_hilbert_space self.lattice_config = lattice_config self.lqg_params = lqg_params # Cached operators self.H_radial_extended = None self.H_angular = None self.H_interaction = None self.H_total = None print(f"🔧 Extended Hamiltonian Constraint initialized") print(f" Extended Hilbert space dimension: {extended_hilbert_space.dim}") def build_extended_hamiltonian(self) -> sp.csr_matrix: """ Build the complete extended Hamiltonian matrix. Returns: H_extended = H_radial ⊗ I_angular + I_radial ⊗ H_angular + H_interaction """ print(f"🔨 Building Extended Hamiltonian Constraint") print("-" * 50) dim = self.extended_hilbert_space.dim # Build radial Hamiltonian extended to full space print(f" Building radial Hamiltonian component...") self.H_radial_extended = self._build_radial_hamiltonian_extended() # Build angular Hamiltonian print(f" Building angular Hamiltonian component...") self.H_angular = self._build_angular_hamiltonian() # Build interaction terms print(f" Building radial-angular interaction...") self.H_interaction = self._build_interaction_hamiltonian() # Total Hamiltonian print(f" Assembling total Hamiltonian...") self.H_total = self.H_radial_extended + self.H_angular + self.H_interaction print(f" ✅ Extended Hamiltonian built:") print(f" Matrix size: {dim}×{dim}") print(f" Non-zero elements: {self.H_total.nnz}") print(f" Sparsity: {self.H_total.nnz / (dim*dim):.6f}") return self.H_total def _build_radial_hamiltonian_extended(self) -> sp.csr_matrix: """ Build radial Hamiltonian extended to act on the full extended space. This is H_radial ⊗ I_angular in tensor product notation. """ radial_hilbert = self.extended_hilbert_space.radial_hilbert_space # Build base radial Hamiltonian try: from lqg_fixed_components import MidisuperspaceHamiltonianConstraint radial_constraint = MidisuperspaceHamiltonianConstraint(self.lattice_config, self.lqg_params, radial_hilbert) # Mock classical data for Hamiltonian construction n_sites = self.lattice_config.n_sites E_x = np.ones(n_sites) * 1.2 E_phi = np.ones(n_sites) * 0.8 K_x = np.zeros(n_sites) K_phi = np.zeros(n_sites) scalar_field = np.zeros(n_sites) scalar_momentum = np.zeros(n_sites) H_radial = radial_constraint.construct_full_hamiltonian( E_x, E_phi, K_x, K_phi, scalar_field, scalar_momentum ) except Exception as e: print(f" Using mock radial Hamiltonian due to: {e}") # Mock radial Hamiltonian radial_dim = radial_hilbert.dim H_radial = sp.diags(np.random.randn(radial_dim), format='csr') # Extend to full space: H_radial ⊗ I_angular extended_dim = self.extended_hilbert_space.dim radial_dim = radial_hilbert.dim angular_dim = extended_dim // radial_dim if angular_dim * radial_dim != extended_dim: print(f" Warning: Dimension mismatch in tensor product") # Fallback: use diagonal extension diag_elements = np.zeros(extended_dim) for i in range(extended_dim): radial_index = i % radial_dim if radial_index < H_radial.shape[0]: diag_elements[i] = H_radial[radial_index, radial_index] return sp.diags(diag_elements, format='csr') # Proper tensor product extension H_extended = sp.kron(H_radial, sp.identity(angular_dim, format='csr'), format='csr') print(f" Radial Hamiltonian extended: {H_extended.nnz} non-zeros") return H_extended def _build_angular_hamiltonian(self) -> sp.csr_matrix: """ Build angular Hamiltonian component. For small perturbations: H_angular ≈ ∑_lm ω_lm α̂_lm† α̂_lm where ω_lm is the angular mode frequency. """ dim = self.extended_hilbert_space.dim # Build diagonal angular Hamiltonian diag_elements = np.zeros(dim) for i, state in enumerate(self.extended_hilbert_space.extended_basis_states): angular_energy = 0.0 for mode in self.extended_hilbert_space.angular_modes: key = (mode.l, mode.m) if key in state.angular_quantum_numbers: alpha = state.angular_quantum_numbers[key] # Angular mode frequency: ω_lm ∼ l(l+1) + perturbation omega_lm = mode.l * (mode.l + 1) * 0.01 # Small angular energy scale angular_energy += omega_lm * alpha diag_elements[i] = angular_energy H_angular = sp.diags(diag_elements, format='csr') print(f" Angular Hamiltonian: {H_angular.nnz} non-zeros") print(f" Angular energy range: [{np.min(diag_elements):.3e}, {np.max(diag_elements):.3e}]") return H_angular def _build_interaction_hamiltonian(self) -> sp.csr_matrix: """ Build radial-angular interaction Hamiltonian. For weak coupling: H_int ≈ ∑_lm g_lm (radial operators) × α̂_lm """ dim = self.extended_hilbert_space.dim # For simplicity, use diagonal interaction terms # In a full treatment, this would include off-diagonal coupling diag_elements = np.zeros(dim) for i, state in enumerate(self.extended_hilbert_space.extended_basis_states): interaction_energy = 0.0 # Coupling strength proportional to radial flux quantum numbers radial_state = state.radial_flux_state if hasattr(radial_state, 'mu_config') and hasattr(radial_state, 'nu_config'): # Sum of radial quantum numbers radial_scale = sum(abs(mu) + abs(nu) for mu, nu in zip(radial_state.mu_config, radial_state.nu_config)) else: radial_scale = 1.0 # Angular coupling for mode in self.extended_hilbert_space.angular_modes: key = (mode.l, mode.m) if key in state.angular_quantum_numbers: alpha = state.angular_quantum_numbers[key] # Weak coupling: g_lm ∼ amplitude * sqrt(l(l+1)) coupling_strength = mode.amplitude * np.sqrt(mode.l * (mode.l + 1) + 1) interaction_energy += coupling_strength * radial_scale * alpha diag_elements[i] = interaction_energy H_interaction = sp.diags(diag_elements, format='csr') print(f" Interaction Hamiltonian: {H_interaction.nnz} non-zeros") print(f" Interaction energy range: [{np.min(diag_elements):.3e}, {np.max(diag_elements):.3e}]") return H_interaction def solve_extended_eigenvalue_problem(self, k: int = 5) -> Tuple[np.ndarray, np.ndarray]: """ Solve eigenvalue problem for extended Hamiltonian. Returns: Tuple of (eigenvalues, eigenvectors) """ if self.H_total is None: self.build_extended_hamiltonian() print(f"🔍 Solving extended eigenvalue problem...") print(f" Matrix size: {self.H_total.shape[0]}×{self.H_total.shape[1]}") print(f" Seeking {k} lowest eigenvalues...") try: eigenvals, eigenvecs = spla.eigs(self.H_total, k=k, which='SR') eigenvals = np.real(eigenvals) # Sort by eigenvalue sort_indices = np.argsort(eigenvals) eigenvals = eigenvals[sort_indices] eigenvecs = eigenvecs[:, sort_indices] print(f" ✅ Eigenvalues computed:") for i, eval in enumerate(eigenvals): print(f" λ_{i} = {eval:.6e}") return eigenvals, eigenvecs except Exception as e: print(f" ❌ Eigenvalue computation failed: {e}") # Return mock results eigenvals = np.arange(k) * 0.01 eigenvecs = np.random.randn(self.H_total.shape[0], k) return eigenvals, eigenvecs def demo_angular_perturbation(): """ Demonstration of angular perturbation extension. Shows how to set up and solve the extended LQG system with angular perturbations around spherical symmetry. """ print("🌍 ANGULAR PERTURBATION EXTENSION DEMO") print("=" * 80) # Mock components for demonstration class MockLatticeConfig: def __init__(self): self.n_sites = 3 self.throat_radius = 1.0 class MockLQGParams: def __init__(self): self.gamma = 0.2375 self.mu_max = 1 self.nu_max = 1 self.basis_truncation = 200 # Keep manageable for demo lattice_config = MockLatticeConfig() lqg_params = MockLQGParams() # Define angular modes print(f"🌀 Setting up angular perturbation modes") print("-" * 50) angular_modes = [ SphericalHarmonicMode(l=1, m=0, amplitude=0.1, alpha_max=1), # Dipole mode SphericalHarmonicMode(l=2, m=0, amplitude=0.05, alpha_max=1), # Quadrupole mode ] for mode in angular_modes: print(f" Mode: l={mode.l}, m={mode.m}, amplitude={mode.amplitude}, α_max={mode.alpha_max}") # Build extended Hilbert space print(f"\n🏗️ Building Extended Hilbert Space") print("-" * 50) extended_space = ExtendedKinematicalHilbertSpace(lattice_config, lqg_params, angular_modes) # Build extended Hamiltonian print(f"\n⚙️ Building Extended Hamiltonian") print("-" * 50) extended_constraint = ExtendedMidisuperspaceHamiltonianConstraint( extended_space, lattice_config, lqg_params ) H_extended = extended_constraint.build_extended_hamiltonian() # Solve eigenvalue problem print(f"\n🔍 Solving Extended Eigenvalue Problem") print("-" * 50) eigenvals, eigenvecs = extended_constraint.solve_extended_eigenvalue_problem(k=3) # Compare with purely radial case print(f"\n📊 Comparing with Radial-Only Case") print("-" * 50) # Build radial-only case for comparison radial_only_modes = [] # No angular modes radial_space = ExtendedKinematicalHilbertSpace(lattice_config, lqg_params, radial_only_modes) radial_constraint = ExtendedMidisuperspaceHamiltonianConstraint( radial_space, lattice_config, lqg_params ) H_radial = radial_constraint.build_extended_hamiltonian() eigenvals_radial, _ = spla.eigs(H_radial, k=3, which='SR') eigenvals_radial = np.real(eigenvals_radial) eigenvals_radial.sort() print(f" Radial-only eigenvalues:") for i, eval in enumerate(eigenvals_radial): print(f" λ_{i}^(radial) = {eval:.6e}") print(f" Extended (radial+angular) eigenvalues:") for i, eval in enumerate(eigenvals): print(f" λ_{i}^(extended) = {eval:.6e}") print(f" Angular shifts:") for i in range(min(len(eigenvals), len(eigenvals_radial))): shift = eigenvals[i] - eigenvals_radial[i] relative_shift = shift / max(abs(eigenvals_radial[i]), 1e-12) print(f" Δλ_{i} = {shift:.6e} ({relative_shift:.1%})") # Analysis summary angular_analysis = { "radial_dimension": radial_space.dim, "extended_dimension": extended_space.dim, "angular_modes_count": len(angular_modes), "lowest_eigenvalue_radial": float(eigenvals_radial[0]), "lowest_eigenvalue_extended": float(eigenvals[0]), "angular_shift": float(eigenvals[0] - eigenvals_radial[0]), "relative_angular_shift": float((eigenvals[0] - eigenvals_radial[0]) / max(abs(eigenvals_radial[0]), 1e-12)) } print(f"\n✅ Angular Perturbation Demo Complete") print(f" Angular shift in ground state: {angular_analysis['angular_shift']:.2e}") print(f" Relative angular shift: {angular_analysis['relative_angular_shift']:.1%}") return angular_analysis if __name__ == "__main__": demo_angular_perturbation() |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |