Advertisement
Guest User

Gravity

a guest
Jun 5th, 2025
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.81 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Gravity from Phase Modulation</title>
  7. <style>
  8. body {
  9. margin: 0;
  10. padding: 20px;
  11. font-family: Arial, sans-serif;
  12. background: #0a0a0a;
  13. color: #ffffff;
  14. }
  15. .container {
  16. max-width: 1200px;
  17. margin: 0 auto;
  18. }
  19. .controls {
  20. background: #1a1a1a;
  21. padding: 20px;
  22. border-radius: 10px;
  23. margin-bottom: 20px;
  24. display: grid;
  25. grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  26. gap: 15px;
  27. }
  28. .control-group {
  29. display: flex;
  30. flex-direction: column;
  31. gap: 5px;
  32. }
  33. label {
  34. font-size: 12px;
  35. color: #cccccc;
  36. }
  37. input[type="range"] {
  38. width: 100%;
  39. }
  40. button {
  41. background: #2563eb;
  42. color: white;
  43. border: none;
  44. padding: 10px 20px;
  45. border-radius: 5px;
  46. cursor: pointer;
  47. font-size: 14px;
  48. }
  49. button:hover {
  50. background: #1d4ed8;
  51. }
  52. .simulation-area {
  53. display: grid;
  54. grid-template-columns: 1fr 1fr;
  55. gap: 20px;
  56. margin-bottom: 20px;
  57. }
  58. .canvas-container {
  59. background: #1a1a1a;
  60. border-radius: 10px;
  61. padding: 15px;
  62. }
  63. .canvas-title {
  64. text-align: center;
  65. margin-bottom: 10px;
  66. font-weight: bold;
  67. }
  68. canvas {
  69. border: 1px solid #333;
  70. display: block;
  71. margin: 0 auto;
  72. }
  73. .info-panel {
  74. background: #1a1a1a;
  75. padding: 20px;
  76. border-radius: 10px;
  77. font-family: monospace;
  78. font-size: 12px;
  79. line-height: 1.4;
  80. }
  81. .status {
  82. color: #10b981;
  83. margin-bottom: 10px;
  84. }
  85. </style>
  86. </head>
  87. <body>
  88. <div class="container">
  89. <h1>Gravity Emergence from Phase Modulation</h1>
  90. <p>Testing if gravitational curvature emerges from phase modulation of a complex wavefunction through higher dimensions.</p>
  91.  
  92. <div class="controls">
  93. <div class="control-group">
  94. <label>Mass (M): <span id="massValue">10</span></label>
  95. <input type="range" id="mass" min="1" max="50" value="10" step="1">
  96. </div>
  97. <div class="control-group">
  98. <label>Phase Coupling (α): <span id="couplingValue">0.5</span></label>
  99. <input type="range" id="coupling" min="0.1" max="2" value="0.5" step="0.1">
  100. </div>
  101. <div class="control-group">
  102. <label>Extra Dimension Scale (λ): <span id="scaleValue">1.0</span></label>
  103. <input type="range" id="scale" min="0.5" max="3" value="1" step="0.1">
  104. </div>
  105. <div class="control-group">
  106. <label>Particle Speed: <span id="speedValue">2</span></label>
  107. <input type="range" id="speed" min="0.5" max="5" value="2" step="0.1">
  108. </div>
  109. <div class="control-group">
  110. <label>Launch Angle: <span id="angleValue">0°</span></label>
  111. <input type="range" id="angle" min="0" max="360" value="0" step="5">
  112. </div>
  113. <div class="control-group">
  114. <button id="launchParticle">Launch Test Particle</button>
  115. <button id="reset">Reset Simulation</button>
  116. </div>
  117. </div>
  118.  
  119. <div class="simulation-area">
  120. <div class="canvas-container">
  121. <div class="canvas-title">Phase Field & Curvature</div>
  122. <canvas id="phaseCanvas" width="400" height="400"></canvas>
  123. </div>
  124. <div class="canvas-container">
  125. <div class="canvas-title">Particle Path (Top-Down View)</div>
  126. <canvas id="trajectoryCanvas" width="400" height="400"></canvas>
  127. </div>
  128. </div>
  129.  
  130. <div class="info-panel">
  131. <div class="status" id="status">Ready to simulate</div>
  132. <div id="info">
  133. <strong>Theory:</strong> ψ(r,w) = A exp[i(kr + φ(r,w))]<br>
  134. <strong>Phase Modulation:</strong> φ(r,w) = -α·M/r · sin(w/λ)<br>
  135. <strong>Curvature:</strong> Calculated from phase gradient<br>
  136. <strong>Force:</strong> F = -ℏ∇(∇φ) (emergent gravitational force)<br><br>
  137. <div id="measurements"></div>
  138. </div>
  139. </div>
  140. </div>
  141.  
  142. <script>
  143. // Canvas setup
  144. const phaseCanvas = document.getElementById('phaseCanvas');
  145. const trajectoryCanvas = document.getElementById('trajectoryCanvas');
  146. const phaseCtx = phaseCanvas.getContext('2d');
  147. const trajCtx = trajectoryCanvas.getContext('2d');
  148.  
  149. // Controls
  150. const massSlider = document.getElementById('mass');
  151. const couplingSlider = document.getElementById('coupling');
  152. const scaleSlider = document.getElementById('scale');
  153. const speedSlider = document.getElementById('speed');
  154. const angleSlider = document.getElementById('angle');
  155. const launchButton = document.getElementById('launchParticle');
  156. const resetButton = document.getElementById('reset');
  157.  
  158. // Simulation parameters
  159. let M = 10; // Mass
  160. let alpha = 0.5; // Phase coupling
  161. let lambda = 1.0; // Extra dimension scale
  162. let particleSpeed = 2;
  163. let launchAngle = 0; // Launch angle in degrees
  164. let w = 0; // Extra dimension coordinate (oscillates)
  165. let time = 0;
  166.  
  167. // Particle state
  168. let particle = {
  169. x: 50,
  170. y: 200,
  171. vx: 2,
  172. vy: 0,
  173. trail: []
  174. };
  175.  
  176. let animationId;
  177. let isRunning = false;
  178.  
  179. // Update control values
  180. function updateControls() {
  181. document.getElementById('massValue').textContent = massSlider.value;
  182. document.getElementById('couplingValue').textContent = couplingSlider.value;
  183. document.getElementById('scaleValue').textContent = scaleSlider.value;
  184. document.getElementById('speedValue').textContent = speedSlider.value;
  185. document.getElementById('angleValue').textContent = angleSlider.value + '°';
  186.  
  187. M = parseFloat(massSlider.value);
  188. alpha = parseFloat(couplingSlider.value);
  189. lambda = parseFloat(scaleSlider.value);
  190. particleSpeed = parseFloat(speedSlider.value);
  191. launchAngle = parseFloat(angleSlider.value);
  192. }
  193.  
  194. // Phase function: φ(r,w) = -α·M/r · sin(w/λ)
  195. function getPhase(x, y, w) {
  196. const r = Math.sqrt((x - 200)**2 + (y - 200)**2) + 1; // +1 to avoid singularity
  197. return -alpha * M / r * Math.sin(w / lambda);
  198. }
  199.  
  200. // Calculate phase gradient (force field)
  201. function getForce(x, y, w) {
  202. const dx = 2;
  203. const dy = 2;
  204.  
  205. const phi_x1 = getPhase(x + dx, y, w);
  206. const phi_x2 = getPhase(x - dx, y, w);
  207. const phi_y1 = getPhase(x, y + dy, w);
  208. const phi_y2 = getPhase(x, y - dy, w);
  209.  
  210. const fx = -(phi_x1 - phi_x2) / (2 * dx);
  211. const fy = -(phi_y1 - phi_y2) / (2 * dy);
  212.  
  213. return { fx, fy };
  214. }
  215.  
  216. // Calculate curvature measure
  217. function getCurvature(x, y, w) {
  218. const d = 3;
  219. const phi_center = getPhase(x, y, w);
  220. const phi_right = getPhase(x + d, y, w);
  221. const phi_left = getPhase(x - d, y, w);
  222. const phi_up = getPhase(x, y - d, w);
  223. const phi_down = getPhase(x, y + d, w);
  224.  
  225. // Discrete Laplacian as curvature measure
  226. const laplacian = (phi_right + phi_left + phi_up + phi_down - 4 * phi_center) / (d * d);
  227. return Math.abs(laplacian);
  228. }
  229.  
  230. // Render phase field and curvature
  231. function renderPhaseField() {
  232. const imageData = phaseCtx.createImageData(400, 400);
  233. const data = imageData.data;
  234.  
  235. for (let i = 0; i < 400; i++) {
  236. for (let j = 0; j < 400; j++) {
  237. const x = i;
  238. const y = j;
  239. const phase = getPhase(x, y, w);
  240. const curvature = getCurvature(x, y, w);
  241.  
  242. const index = (j * 400 + i) * 4;
  243.  
  244. // Color based on phase and curvature
  245. const phaseColor = Math.sin(phase) * 127 + 128;
  246. const curvatureColor = Math.min(curvature * 1000, 255);
  247.  
  248. data[index] = curvatureColor; // Red = curvature
  249. data[index + 1] = phaseColor * 0.3; // Green = phase
  250. data[index + 2] = phaseColor; // Blue = phase
  251. data[index + 3] = 255; // Alpha
  252. }
  253. }
  254.  
  255. phaseCtx.putImageData(imageData, 0, 0);
  256.  
  257. // Draw mass position
  258. phaseCtx.fillStyle = '#ffffff';
  259. phaseCtx.beginPath();
  260. phaseCtx.arc(200, 200, 8, 0, 2 * Math.PI);
  261. phaseCtx.fill();
  262.  
  263. // Draw force field vectors (sample)
  264. phaseCtx.strokeStyle = '#ffff00';
  265. phaseCtx.lineWidth = 1;
  266. for (let i = 40; i < 400; i += 40) {
  267. for (let j = 40; j < 400; j += 40) {
  268. const force = getForce(i, j, w);
  269. const scale = 1000;
  270. phaseCtx.beginPath();
  271. phaseCtx.moveTo(i, j);
  272. phaseCtx.lineTo(i + force.fx * scale, j + force.fy * scale);
  273. phaseCtx.stroke();
  274. }
  275. }
  276. }
  277.  
  278. // Update particle physics
  279. function updateParticle() {
  280. if (!isRunning) return;
  281.  
  282. // Get force at particle position
  283. const force = getForce(particle.x, particle.y, w);
  284.  
  285. // Apply force (F = ma, assume m = 1)
  286. const dt = 0.1;
  287. particle.vx += force.fx * dt;
  288. particle.vy += force.fy * dt;
  289.  
  290. // Update position
  291. particle.x += particle.vx * dt;
  292. particle.y += particle.vy * dt;
  293.  
  294. // Store trail
  295. particle.trail.push({ x: particle.x, y: particle.y });
  296. if (particle.trail.length > 500) {
  297. particle.trail.shift();
  298. }
  299.  
  300. // Boundary conditions
  301. if (particle.x < 0 || particle.x > 400 || particle.y < 0 || particle.y > 400) {
  302. isRunning = false;
  303. document.getElementById('status').textContent = 'Particle left simulation area';
  304. }
  305. }
  306.  
  307. // Render particle trajectory
  308. function renderTrajectory() {
  309. trajCtx.fillStyle = '#0a0a0a';
  310. trajCtx.fillRect(0, 0, 400, 400);
  311.  
  312. // Draw grid for reference
  313. trajCtx.strokeStyle = '#333333';
  314. trajCtx.lineWidth = 0.5;
  315. for (let i = 0; i <= 400; i += 40) {
  316. trajCtx.beginPath();
  317. trajCtx.moveTo(i, 0);
  318. trajCtx.lineTo(i, 400);
  319. trajCtx.moveTo(0, i);
  320. trajCtx.lineTo(400, i);
  321. trajCtx.stroke();
  322. }
  323.  
  324. // Draw mass (central attractor)
  325. trajCtx.fillStyle = '#ffffff';
  326. trajCtx.beginPath();
  327. trajCtx.arc(200, 200, 12, 0, 2 * Math.PI);
  328. trajCtx.fill();
  329.  
  330. // Add mass label
  331. trajCtx.fillStyle = '#cccccc';
  332. trajCtx.font = '12px Arial';
  333. trajCtx.fillText('M', 210, 205);
  334.  
  335. // Draw particle trail with gradient (older parts fade)
  336. if (particle.trail.length > 1) {
  337. for (let i = 1; i < particle.trail.length; i++) {
  338. const alpha = i / particle.trail.length;
  339. trajCtx.strokeStyle = `rgba(0, 255, 136, ${alpha})`;
  340. trajCtx.lineWidth = 2;
  341. trajCtx.beginPath();
  342. trajCtx.moveTo(particle.trail[i-1].x, particle.trail[i-1].y);
  343. trajCtx.lineTo(particle.trail[i].x, particle.trail[i].y);
  344. trajCtx.stroke();
  345. }
  346. }
  347.  
  348. // Draw starting position
  349. if (particle.trail.length > 0) {
  350. trajCtx.fillStyle = '#0099ff';
  351. trajCtx.beginPath();
  352. trajCtx.arc(particle.trail[0].x, particle.trail[0].y, 6, 0, 2 * Math.PI);
  353. trajCtx.fill();
  354. trajCtx.fillStyle = '#ffffff';
  355. trajCtx.font = '10px Arial';
  356. trajCtx.fillText('START', particle.trail[0].x - 15, particle.trail[0].y - 10);
  357. }
  358.  
  359. // Draw current particle position
  360. if (isRunning) {
  361. trajCtx.fillStyle = '#ff4444';
  362. trajCtx.beginPath();
  363. trajCtx.arc(particle.x, particle.y, 5, 0, 2 * Math.PI);
  364. trajCtx.fill();
  365.  
  366. // Draw velocity vector
  367. trajCtx.strokeStyle = '#ffaa00';
  368. trajCtx.lineWidth = 2;
  369. trajCtx.beginPath();
  370. trajCtx.moveTo(particle.x, particle.y);
  371. trajCtx.lineTo(particle.x + particle.vx * 20, particle.y + particle.vy * 20);
  372. trajCtx.stroke();
  373. }
  374.  
  375. // Draw distance circles for reference
  376. trajCtx.strokeStyle = '#444444';
  377. trajCtx.lineWidth = 1;
  378. trajCtx.setLineDash([2, 2]);
  379. for (let r of [50, 100, 150]) {
  380. trajCtx.beginPath();
  381. trajCtx.arc(200, 200, r, 0, 2 * Math.PI);
  382. trajCtx.stroke();
  383. }
  384. trajCtx.setLineDash([]);
  385. }
  386.  
  387. // Update measurements
  388. function updateMeasurements() {
  389. const r = Math.sqrt((particle.x - 200)**2 + (particle.y - 200)**2);
  390. const speed = Math.sqrt(particle.vx**2 + particle.vy**2);
  391. const force = getForce(particle.x, particle.y, w);
  392. const forceStrength = Math.sqrt(force.fx**2 + force.fy**2);
  393. const expectedGrav = M / (r * r + 1); // Expected 1/r² force
  394.  
  395. document.getElementById('measurements').innerHTML = `
  396. <strong>Current Measurements:</strong><br>
  397. Distance from mass: ${r.toFixed(1)}<br>
  398. Particle speed: ${speed.toFixed(2)}<br>
  399. Force strength: ${forceStrength.toFixed(4)}<br>
  400. Expected 1/r² force: ${expectedGrav.toFixed(4)}<br>
  401. Ratio (measured/expected): ${(forceStrength/expectedGrav).toFixed(2)}<br>
  402. Extra dimension w: ${w.toFixed(2)}
  403. `;
  404. }
  405.  
  406. // Animation loop
  407. function animate() {
  408. time += 0.05;
  409. w = Math.sin(time) * 2; // Oscillate through extra dimension
  410.  
  411. updateParticle();
  412. renderPhaseField();
  413. renderTrajectory();
  414. updateMeasurements();
  415.  
  416. if (isRunning) {
  417. animationId = requestAnimationFrame(animate);
  418. }
  419. }
  420.  
  421. // Event listeners
  422. massSlider.addEventListener('input', updateControls);
  423. couplingSlider.addEventListener('input', updateControls);
  424. scaleSlider.addEventListener('input', updateControls);
  425. speedSlider.addEventListener('input', updateControls);
  426. angleSlider.addEventListener('input', updateControls);
  427.  
  428. launchButton.addEventListener('click', () => {
  429. if (!isRunning) {
  430. // Convert angle to radians
  431. const angleRad = launchAngle * Math.PI / 180;
  432.  
  433. // Set starting position (left side of screen)
  434. particle.x = 50;
  435. particle.y = 200;
  436.  
  437. // Set velocity components based on angle and speed
  438. particle.vx = particleSpeed * Math.cos(angleRad);
  439. particle.vy = particleSpeed * Math.sin(angleRad);
  440.  
  441. particle.trail = [];
  442. isRunning = true;
  443. document.getElementById('status').textContent = `Particle launched at ${launchAngle}° - observing trajectory...`;
  444. animate();
  445. }
  446. });
  447.  
  448. resetButton.addEventListener('click', () => {
  449. isRunning = false;
  450. if (animationId) {
  451. cancelAnimationFrame(animationId);
  452. }
  453. particle.trail = [];
  454. time = 0;
  455. w = 0;
  456. document.getElementById('status').textContent = 'Simulation reset';
  457. renderPhaseField();
  458. renderTrajectory();
  459. });
  460.  
  461. // Initialize
  462. updateControls();
  463. renderPhaseField();
  464. renderTrajectory();
  465. </script>
  466. </body>
  467. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement