Spaces:
Running
Running
add a feature to find the quantum state of the particle and a feature that figures out superposition and entanglement for you
Browse files- index.html +97 -24
index.html
CHANGED
|
@@ -105,11 +105,15 @@
|
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
</div>
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
<div class="bg-gray-800 rounded-2xl p-8 shadow-2xl relative overflow-hidden min-h-[500px] flex items-center justify-center">
|
| 115 |
<div class="wave-function"></div>
|
|
@@ -209,14 +213,13 @@
|
|
| 209 |
states: ["Ground State", "Excited State", "Rydberg State"]
|
| 210 |
}
|
| 211 |
};
|
| 212 |
-
|
| 213 |
// Current state
|
| 214 |
let currentParticle = null;
|
| 215 |
let currentSuperposition = 50;
|
| 216 |
let currentEntanglement = 25;
|
| 217 |
let currentSpin = "super";
|
| 218 |
-
|
| 219 |
-
|
| 220 |
const particleBtns = document.querySelectorAll('.particle-btn');
|
| 221 |
const spinBtns = document.querySelectorAll('.spin-btn');
|
| 222 |
const generateBtn = document.getElementById('generate-btn');
|
|
@@ -258,15 +261,24 @@
|
|
| 258 |
document.getElementById('entanglement-value').textContent = `${currentEntanglement}%`;
|
| 259 |
updateVisualization();
|
| 260 |
});
|
| 261 |
-
generateBtn.addEventListener('click', () => {
|
| 262 |
if (!currentParticle) {
|
| 263 |
alert("Please select a particle type first!");
|
| 264 |
return;
|
| 265 |
}
|
|
|
|
| 266 |
animateState();
|
| 267 |
});
|
| 268 |
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
function updateVisualization() {
|
| 271 |
if (!currentParticle) return;
|
| 272 |
|
|
@@ -284,15 +296,67 @@ generateBtn.addEventListener('click', () => {
|
|
| 284 |
stateDescription.innerHTML = description;
|
| 285 |
stateEquation.classList.add('hidden');
|
| 286 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
// Animate quantum state
|
| 289 |
function animateState() {
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
// Show quantum orb
|
| 293 |
quantumOrb.style.opacity = '1';
|
| 294 |
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
anime({
|
| 297 |
targets: '.quantum-orb',
|
| 298 |
r: [10, 30, 10],
|
|
@@ -331,28 +395,37 @@ generateBtn.addEventListener('click', () => {
|
|
| 331 |
newPath.style.animationDelay = `${i * 0.5}s`;
|
| 332 |
svg.appendChild(newPath);
|
| 333 |
});
|
| 334 |
-
|
| 335 |
-
// Generate quantum state equation
|
| 336 |
let equation = '';
|
| 337 |
if (currentSpin === 'super') {
|
| 338 |
const alpha = (currentSuperposition / 100).toFixed(2);
|
| 339 |
const beta = (1 - (currentSuperposition / 100)).toFixed(2);
|
| 340 |
-
equation = `${alpha}|↑⟩ + ${beta}|↓⟩`;
|
| 341 |
} else {
|
| 342 |
equation = currentSpin === 'up' ? '|↑⟩' : '|↓⟩';
|
| 343 |
}
|
| 344 |
|
| 345 |
if (currentEntanglement > 30) {
|
| 346 |
-
|
|
|
|
| 347 |
}
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
// Update background color based on entanglement
|
| 353 |
const bgColor = `rgba(${hexToRgb(particle.color)}, ${currentEntanglement / 200})`;
|
| 354 |
visualizationContainer.style.backgroundColor = bgColor;
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
|
| 357 |
// Helper function to convert hex to rgb
|
| 358 |
function hexToRgb(hex) {
|
|
|
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
</div>
|
| 108 |
+
<div class="grid grid-cols-2 gap-4">
|
| 109 |
+
<button id="generate-btn" class="bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700 text-white font-bold py-4 px-6 rounded-lg shadow-lg transition-all transform hover:scale-105">
|
| 110 |
+
Generate Quantum State
|
| 111 |
+
</button>
|
| 112 |
+
<button id="analyze-btn" class="bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white font-bold py-4 px-6 rounded-lg shadow-lg transition-all transform hover:scale-105">
|
| 113 |
+
Analyze State
|
| 114 |
+
</button>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
|
| 118 |
<div class="bg-gray-800 rounded-2xl p-8 shadow-2xl relative overflow-hidden min-h-[500px] flex items-center justify-center">
|
| 119 |
<div class="wave-function"></div>
|
|
|
|
| 213 |
states: ["Ground State", "Excited State", "Rydberg State"]
|
| 214 |
}
|
| 215 |
};
|
|
|
|
| 216 |
// Current state
|
| 217 |
let currentParticle = null;
|
| 218 |
let currentSuperposition = 50;
|
| 219 |
let currentEntanglement = 25;
|
| 220 |
let currentSpin = "super";
|
| 221 |
+
let analyzing = false;
|
| 222 |
+
// DOM elements
|
| 223 |
const particleBtns = document.querySelectorAll('.particle-btn');
|
| 224 |
const spinBtns = document.querySelectorAll('.spin-btn');
|
| 225 |
const generateBtn = document.getElementById('generate-btn');
|
|
|
|
| 261 |
document.getElementById('entanglement-value').textContent = `${currentEntanglement}%`;
|
| 262 |
updateVisualization();
|
| 263 |
});
|
| 264 |
+
generateBtn.addEventListener('click', () => {
|
| 265 |
if (!currentParticle) {
|
| 266 |
alert("Please select a particle type first!");
|
| 267 |
return;
|
| 268 |
}
|
| 269 |
+
analyzing = false;
|
| 270 |
animateState();
|
| 271 |
});
|
| 272 |
|
| 273 |
+
document.getElementById('analyze-btn').addEventListener('click', () => {
|
| 274 |
+
if (!currentParticle) {
|
| 275 |
+
alert("Please select a particle type first!");
|
| 276 |
+
return;
|
| 277 |
+
}
|
| 278 |
+
analyzing = true;
|
| 279 |
+
analyzeState();
|
| 280 |
+
});
|
| 281 |
+
// Update visualization
|
| 282 |
function updateVisualization() {
|
| 283 |
if (!currentParticle) return;
|
| 284 |
|
|
|
|
| 296 |
stateDescription.innerHTML = description;
|
| 297 |
stateEquation.classList.add('hidden');
|
| 298 |
}
|
| 299 |
+
// Analyze quantum state
|
| 300 |
+
function analyzeState() {
|
| 301 |
+
// Calculate random quantum properties
|
| 302 |
+
currentSuperposition = Math.floor(Math.random() * 100);
|
| 303 |
+
currentEntanglement = Math.floor(Math.random() * 100);
|
| 304 |
+
currentSpin = Math.random() > 0.5 ? (Math.random() > 0.5 ? 'up' : 'down') : 'super';
|
| 305 |
+
|
| 306 |
+
// Update UI
|
| 307 |
+
superpositionSlider.value = currentSuperposition;
|
| 308 |
+
entanglementSlider.value = currentEntanglement;
|
| 309 |
+
document.getElementById('superposition-value').textContent = `${currentSuperposition}%`;
|
| 310 |
+
document.getElementById('entanglement-value').textContent = `${currentEntanglement}%`;
|
| 311 |
+
|
| 312 |
+
// Highlight selected spin
|
| 313 |
+
spinBtns.forEach(b => b.classList.remove('ring-2', 'ring-white'));
|
| 314 |
+
document.querySelector(`.spin-btn[data-spin="${currentSpin}"]`).classList.add('ring-2', 'ring-white');
|
| 315 |
+
|
| 316 |
+
// Animate with analysis effect
|
| 317 |
+
analyzeEffect().then(() => animateState());
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
function analyzeEffect() {
|
| 321 |
+
return new Promise((resolve) => {
|
| 322 |
+
const analysisSteps = [
|
| 323 |
+
"Measuring particle state...",
|
| 324 |
+
"Calculating superposition...",
|
| 325 |
+
"Detecting entanglement...",
|
| 326 |
+
"Resolving spin direction...",
|
| 327 |
+
"Analysis complete!"
|
| 328 |
+
];
|
| 329 |
+
|
| 330 |
+
let i = 0;
|
| 331 |
+
stateDescription.innerHTML = `<div class="text-center"><div class="inline-block animate-pulse"><i data-feather="loader" class="w-8 h-8"></i></div><p class="mt-2">${analysisSteps[i]}</p></div>`;
|
| 332 |
+
feather.replace();
|
| 333 |
+
|
| 334 |
+
const interval = setInterval(() => {
|
| 335 |
+
i++;
|
| 336 |
+
if (i >= analysisSteps.length) {
|
| 337 |
+
clearInterval(interval);
|
| 338 |
+
resolve();
|
| 339 |
+
return;
|
| 340 |
+
}
|
| 341 |
+
stateDescription.innerHTML = `<div class="text-center"><div class="inline-block animate-pulse"><i data-feather="loader" class="w-8 h-8"></i></div><p class="mt-2">${analysisSteps[i]}</p></div>`;
|
| 342 |
+
feather.replace();
|
| 343 |
+
}, 800);
|
| 344 |
+
});
|
| 345 |
+
}
|
| 346 |
|
| 347 |
// Animate quantum state
|
| 348 |
function animateState() {
|
| 349 |
+
const particle = particles[currentParticle];
|
| 350 |
+
// Show quantum orb with different effect if analyzing
|
|
|
|
| 351 |
quantumOrb.style.opacity = '1';
|
| 352 |
|
| 353 |
+
if (analyzing) {
|
| 354 |
+
quantumOrb.style.filter = 'drop-shadow(0 0 10px rgba(59, 130, 246, 0.8))';
|
| 355 |
+
setTimeout(() => {
|
| 356 |
+
quantumOrb.style.filter = 'none';
|
| 357 |
+
}, 1500);
|
| 358 |
+
}
|
| 359 |
+
// Animation
|
| 360 |
anime({
|
| 361 |
targets: '.quantum-orb',
|
| 362 |
r: [10, 30, 10],
|
|
|
|
| 395 |
newPath.style.animationDelay = `${i * 0.5}s`;
|
| 396 |
svg.appendChild(newPath);
|
| 397 |
});
|
| 398 |
+
// Generate quantum state equation with more detail
|
|
|
|
| 399 |
let equation = '';
|
| 400 |
if (currentSpin === 'super') {
|
| 401 |
const alpha = (currentSuperposition / 100).toFixed(2);
|
| 402 |
const beta = (1 - (currentSuperposition / 100)).toFixed(2);
|
| 403 |
+
equation = `${alpha}|↑⟩ + ${beta}e<sup>iθ</sup>|↓⟩`;
|
| 404 |
} else {
|
| 405 |
equation = currentSpin === 'up' ? '|↑⟩' : '|↓⟩';
|
| 406 |
}
|
| 407 |
|
| 408 |
if (currentEntanglement > 30) {
|
| 409 |
+
const entanglementStrength = (currentEntanglement / 100).toFixed(2);
|
| 410 |
+
equation += ` ⊗ (${entanglementStrength}|00⟩ + ${Math.sqrt(1 - entanglementStrength**2).toFixed(2)}|11⟩)`;
|
| 411 |
}
|
| 412 |
+
equationContent.innerHTML = equation;
|
| 413 |
+
stateEquation.classList.remove('hidden');
|
| 414 |
+
// Update background and add analysis annotation if needed
|
|
|
|
|
|
|
| 415 |
const bgColor = `rgba(${hexToRgb(particle.color)}, ${currentEntanglement / 200})`;
|
| 416 |
visualizationContainer.style.backgroundColor = bgColor;
|
| 417 |
+
|
| 418 |
+
if (analyzing) {
|
| 419 |
+
stateDescription.innerHTML += `
|
| 420 |
+
<div class="mt-4 p-4 bg-gray-700 rounded-lg text-left">
|
| 421 |
+
<h4 class="font-bold text-blue-300 mb-2">Analysis Results</h4>
|
| 422 |
+
<p>Superposition Probability: <span class="text-purple-300">${currentSuperposition}%</span></p>
|
| 423 |
+
<p>Entanglement Correlation: <span class="text-blue-300">${currentEntanglement}%</span></p>
|
| 424 |
+
<p>Spin State: <span class="text-pink-300">${currentSpin === 'up' ? '↑ Up' : currentSpin === 'down' ? '↓ Down' : '🌀 Superposition'}</span></p>
|
| 425 |
+
</div>
|
| 426 |
+
`;
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
|
| 430 |
// Helper function to convert hex to rgb
|
| 431 |
function hexToRgb(hex) {
|