Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Gravity from Phase Modulation</title>
- <style>
- body {
- margin: 0;
- padding: 20px;
- font-family: Arial, sans-serif;
- background: #0a0a0a;
- color: #ffffff;
- }
- .container {
- max-width: 1200px;
- margin: 0 auto;
- }
- .controls {
- background: #1a1a1a;
- padding: 20px;
- border-radius: 10px;
- margin-bottom: 20px;
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: 15px;
- }
- .control-group {
- display: flex;
- flex-direction: column;
- gap: 5px;
- }
- label {
- font-size: 12px;
- color: #cccccc;
- }
- input[type="range"] {
- width: 100%;
- }
- button {
- background: #2563eb;
- color: white;
- border: none;
- padding: 10px 20px;
- border-radius: 5px;
- cursor: pointer;
- font-size: 14px;
- }
- button:hover {
- background: #1d4ed8;
- }
- .simulation-area {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 20px;
- margin-bottom: 20px;
- }
- .canvas-container {
- background: #1a1a1a;
- border-radius: 10px;
- padding: 15px;
- }
- .canvas-title {
- text-align: center;
- margin-bottom: 10px;
- font-weight: bold;
- }
- canvas {
- border: 1px solid #333;
- display: block;
- margin: 0 auto;
- }
- .info-panel {
- background: #1a1a1a;
- padding: 20px;
- border-radius: 10px;
- font-family: monospace;
- font-size: 12px;
- line-height: 1.4;
- }
- .status {
- color: #10b981;
- margin-bottom: 10px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>Gravity Emergence from Phase Modulation</h1>
- <p>Testing if gravitational curvature emerges from phase modulation of a complex wavefunction through higher dimensions.</p>
- <div class="controls">
- <div class="control-group">
- <label>Mass (M): <span id="massValue">10</span></label>
- <input type="range" id="mass" min="1" max="50" value="10" step="1">
- </div>
- <div class="control-group">
- <label>Phase Coupling (α): <span id="couplingValue">0.5</span></label>
- <input type="range" id="coupling" min="0.1" max="2" value="0.5" step="0.1">
- </div>
- <div class="control-group">
- <label>Extra Dimension Scale (λ): <span id="scaleValue">1.0</span></label>
- <input type="range" id="scale" min="0.5" max="3" value="1" step="0.1">
- </div>
- <div class="control-group">
- <label>Particle Speed: <span id="speedValue">2</span></label>
- <input type="range" id="speed" min="0.5" max="5" value="2" step="0.1">
- </div>
- <div class="control-group">
- <label>Launch Angle: <span id="angleValue">0°</span></label>
- <input type="range" id="angle" min="0" max="360" value="0" step="5">
- </div>
- <div class="control-group">
- <button id="launchParticle">Launch Test Particle</button>
- <button id="reset">Reset Simulation</button>
- </div>
- </div>
- <div class="simulation-area">
- <div class="canvas-container">
- <div class="canvas-title">Phase Field & Curvature</div>
- <canvas id="phaseCanvas" width="400" height="400"></canvas>
- </div>
- <div class="canvas-container">
- <div class="canvas-title">Particle Path (Top-Down View)</div>
- <canvas id="trajectoryCanvas" width="400" height="400"></canvas>
- </div>
- </div>
- <div class="info-panel">
- <div class="status" id="status">Ready to simulate</div>
- <div id="info">
- <strong>Theory:</strong> ψ(r,w) = A exp[i(kr + φ(r,w))]<br>
- <strong>Phase Modulation:</strong> φ(r,w) = -α·M/r · sin(w/λ)<br>
- <strong>Curvature:</strong> Calculated from phase gradient<br>
- <strong>Force:</strong> F = -ℏ∇(∇φ) (emergent gravitational force)<br><br>
- <div id="measurements"></div>
- </div>
- </div>
- </div>
- <script>
- // Canvas setup
- const phaseCanvas = document.getElementById('phaseCanvas');
- const trajectoryCanvas = document.getElementById('trajectoryCanvas');
- const phaseCtx = phaseCanvas.getContext('2d');
- const trajCtx = trajectoryCanvas.getContext('2d');
- // Controls
- const massSlider = document.getElementById('mass');
- const couplingSlider = document.getElementById('coupling');
- const scaleSlider = document.getElementById('scale');
- const speedSlider = document.getElementById('speed');
- const angleSlider = document.getElementById('angle');
- const launchButton = document.getElementById('launchParticle');
- const resetButton = document.getElementById('reset');
- // Simulation parameters
- let M = 10; // Mass
- let alpha = 0.5; // Phase coupling
- let lambda = 1.0; // Extra dimension scale
- let particleSpeed = 2;
- let launchAngle = 0; // Launch angle in degrees
- let w = 0; // Extra dimension coordinate (oscillates)
- let time = 0;
- // Particle state
- let particle = {
- x: 50,
- y: 200,
- vx: 2,
- vy: 0,
- trail: []
- };
- let animationId;
- let isRunning = false;
- // Update control values
- function updateControls() {
- document.getElementById('massValue').textContent = massSlider.value;
- document.getElementById('couplingValue').textContent = couplingSlider.value;
- document.getElementById('scaleValue').textContent = scaleSlider.value;
- document.getElementById('speedValue').textContent = speedSlider.value;
- document.getElementById('angleValue').textContent = angleSlider.value + '°';
- M = parseFloat(massSlider.value);
- alpha = parseFloat(couplingSlider.value);
- lambda = parseFloat(scaleSlider.value);
- particleSpeed = parseFloat(speedSlider.value);
- launchAngle = parseFloat(angleSlider.value);
- }
- // Phase function: φ(r,w) = -α·M/r · sin(w/λ)
- function getPhase(x, y, w) {
- const r = Math.sqrt((x - 200)**2 + (y - 200)**2) + 1; // +1 to avoid singularity
- return -alpha * M / r * Math.sin(w / lambda);
- }
- // Calculate phase gradient (force field)
- function getForce(x, y, w) {
- const dx = 2;
- const dy = 2;
- const phi_x1 = getPhase(x + dx, y, w);
- const phi_x2 = getPhase(x - dx, y, w);
- const phi_y1 = getPhase(x, y + dy, w);
- const phi_y2 = getPhase(x, y - dy, w);
- const fx = -(phi_x1 - phi_x2) / (2 * dx);
- const fy = -(phi_y1 - phi_y2) / (2 * dy);
- return { fx, fy };
- }
- // Calculate curvature measure
- function getCurvature(x, y, w) {
- const d = 3;
- const phi_center = getPhase(x, y, w);
- const phi_right = getPhase(x + d, y, w);
- const phi_left = getPhase(x - d, y, w);
- const phi_up = getPhase(x, y - d, w);
- const phi_down = getPhase(x, y + d, w);
- // Discrete Laplacian as curvature measure
- const laplacian = (phi_right + phi_left + phi_up + phi_down - 4 * phi_center) / (d * d);
- return Math.abs(laplacian);
- }
- // Render phase field and curvature
- function renderPhaseField() {
- const imageData = phaseCtx.createImageData(400, 400);
- const data = imageData.data;
- for (let i = 0; i < 400; i++) {
- for (let j = 0; j < 400; j++) {
- const x = i;
- const y = j;
- const phase = getPhase(x, y, w);
- const curvature = getCurvature(x, y, w);
- const index = (j * 400 + i) * 4;
- // Color based on phase and curvature
- const phaseColor = Math.sin(phase) * 127 + 128;
- const curvatureColor = Math.min(curvature * 1000, 255);
- data[index] = curvatureColor; // Red = curvature
- data[index + 1] = phaseColor * 0.3; // Green = phase
- data[index + 2] = phaseColor; // Blue = phase
- data[index + 3] = 255; // Alpha
- }
- }
- phaseCtx.putImageData(imageData, 0, 0);
- // Draw mass position
- phaseCtx.fillStyle = '#ffffff';
- phaseCtx.beginPath();
- phaseCtx.arc(200, 200, 8, 0, 2 * Math.PI);
- phaseCtx.fill();
- // Draw force field vectors (sample)
- phaseCtx.strokeStyle = '#ffff00';
- phaseCtx.lineWidth = 1;
- for (let i = 40; i < 400; i += 40) {
- for (let j = 40; j < 400; j += 40) {
- const force = getForce(i, j, w);
- const scale = 1000;
- phaseCtx.beginPath();
- phaseCtx.moveTo(i, j);
- phaseCtx.lineTo(i + force.fx * scale, j + force.fy * scale);
- phaseCtx.stroke();
- }
- }
- }
- // Update particle physics
- function updateParticle() {
- if (!isRunning) return;
- // Get force at particle position
- const force = getForce(particle.x, particle.y, w);
- // Apply force (F = ma, assume m = 1)
- const dt = 0.1;
- particle.vx += force.fx * dt;
- particle.vy += force.fy * dt;
- // Update position
- particle.x += particle.vx * dt;
- particle.y += particle.vy * dt;
- // Store trail
- particle.trail.push({ x: particle.x, y: particle.y });
- if (particle.trail.length > 500) {
- particle.trail.shift();
- }
- // Boundary conditions
- if (particle.x < 0 || particle.x > 400 || particle.y < 0 || particle.y > 400) {
- isRunning = false;
- document.getElementById('status').textContent = 'Particle left simulation area';
- }
- }
- // Render particle trajectory
- function renderTrajectory() {
- trajCtx.fillStyle = '#0a0a0a';
- trajCtx.fillRect(0, 0, 400, 400);
- // Draw grid for reference
- trajCtx.strokeStyle = '#333333';
- trajCtx.lineWidth = 0.5;
- for (let i = 0; i <= 400; i += 40) {
- trajCtx.beginPath();
- trajCtx.moveTo(i, 0);
- trajCtx.lineTo(i, 400);
- trajCtx.moveTo(0, i);
- trajCtx.lineTo(400, i);
- trajCtx.stroke();
- }
- // Draw mass (central attractor)
- trajCtx.fillStyle = '#ffffff';
- trajCtx.beginPath();
- trajCtx.arc(200, 200, 12, 0, 2 * Math.PI);
- trajCtx.fill();
- // Add mass label
- trajCtx.fillStyle = '#cccccc';
- trajCtx.font = '12px Arial';
- trajCtx.fillText('M', 210, 205);
- // Draw particle trail with gradient (older parts fade)
- if (particle.trail.length > 1) {
- for (let i = 1; i < particle.trail.length; i++) {
- const alpha = i / particle.trail.length;
- trajCtx.strokeStyle = `rgba(0, 255, 136, ${alpha})`;
- trajCtx.lineWidth = 2;
- trajCtx.beginPath();
- trajCtx.moveTo(particle.trail[i-1].x, particle.trail[i-1].y);
- trajCtx.lineTo(particle.trail[i].x, particle.trail[i].y);
- trajCtx.stroke();
- }
- }
- // Draw starting position
- if (particle.trail.length > 0) {
- trajCtx.fillStyle = '#0099ff';
- trajCtx.beginPath();
- trajCtx.arc(particle.trail[0].x, particle.trail[0].y, 6, 0, 2 * Math.PI);
- trajCtx.fill();
- trajCtx.fillStyle = '#ffffff';
- trajCtx.font = '10px Arial';
- trajCtx.fillText('START', particle.trail[0].x - 15, particle.trail[0].y - 10);
- }
- // Draw current particle position
- if (isRunning) {
- trajCtx.fillStyle = '#ff4444';
- trajCtx.beginPath();
- trajCtx.arc(particle.x, particle.y, 5, 0, 2 * Math.PI);
- trajCtx.fill();
- // Draw velocity vector
- trajCtx.strokeStyle = '#ffaa00';
- trajCtx.lineWidth = 2;
- trajCtx.beginPath();
- trajCtx.moveTo(particle.x, particle.y);
- trajCtx.lineTo(particle.x + particle.vx * 20, particle.y + particle.vy * 20);
- trajCtx.stroke();
- }
- // Draw distance circles for reference
- trajCtx.strokeStyle = '#444444';
- trajCtx.lineWidth = 1;
- trajCtx.setLineDash([2, 2]);
- for (let r of [50, 100, 150]) {
- trajCtx.beginPath();
- trajCtx.arc(200, 200, r, 0, 2 * Math.PI);
- trajCtx.stroke();
- }
- trajCtx.setLineDash([]);
- }
- // Update measurements
- function updateMeasurements() {
- const r = Math.sqrt((particle.x - 200)**2 + (particle.y - 200)**2);
- const speed = Math.sqrt(particle.vx**2 + particle.vy**2);
- const force = getForce(particle.x, particle.y, w);
- const forceStrength = Math.sqrt(force.fx**2 + force.fy**2);
- const expectedGrav = M / (r * r + 1); // Expected 1/r² force
- document.getElementById('measurements').innerHTML = `
- <strong>Current Measurements:</strong><br>
- Distance from mass: ${r.toFixed(1)}<br>
- Particle speed: ${speed.toFixed(2)}<br>
- Force strength: ${forceStrength.toFixed(4)}<br>
- Expected 1/r² force: ${expectedGrav.toFixed(4)}<br>
- Ratio (measured/expected): ${(forceStrength/expectedGrav).toFixed(2)}<br>
- Extra dimension w: ${w.toFixed(2)}
- `;
- }
- // Animation loop
- function animate() {
- time += 0.05;
- w = Math.sin(time) * 2; // Oscillate through extra dimension
- updateParticle();
- renderPhaseField();
- renderTrajectory();
- updateMeasurements();
- if (isRunning) {
- animationId = requestAnimationFrame(animate);
- }
- }
- // Event listeners
- massSlider.addEventListener('input', updateControls);
- couplingSlider.addEventListener('input', updateControls);
- scaleSlider.addEventListener('input', updateControls);
- speedSlider.addEventListener('input', updateControls);
- angleSlider.addEventListener('input', updateControls);
- launchButton.addEventListener('click', () => {
- if (!isRunning) {
- // Convert angle to radians
- const angleRad = launchAngle * Math.PI / 180;
- // Set starting position (left side of screen)
- particle.x = 50;
- particle.y = 200;
- // Set velocity components based on angle and speed
- particle.vx = particleSpeed * Math.cos(angleRad);
- particle.vy = particleSpeed * Math.sin(angleRad);
- particle.trail = [];
- isRunning = true;
- document.getElementById('status').textContent = `Particle launched at ${launchAngle}° - observing trajectory...`;
- animate();
- }
- });
- resetButton.addEventListener('click', () => {
- isRunning = false;
- if (animationId) {
- cancelAnimationFrame(animationId);
- }
- particle.trail = [];
- time = 0;
- w = 0;
- document.getElementById('status').textContent = 'Simulation reset';
- renderPhaseField();
- renderTrajectory();
- });
- // Initialize
- updateControls();
- renderPhaseField();
- renderTrajectory();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement