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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Advanced Particle Accelerator</title>
|
7 |
+
<style>
|
8 |
+
* {
|
9 |
+
margin: 0;
|
10 |
+
padding: 0;
|
11 |
+
box-sizing: border-box;
|
12 |
+
}
|
13 |
+
|
14 |
+
body {
|
15 |
+
background: #000;
|
16 |
+
color: #00ff00;
|
17 |
+
font-family: monospace;
|
18 |
+
overflow: hidden;
|
19 |
+
}
|
20 |
+
|
21 |
+
canvas {
|
22 |
+
position: fixed;
|
23 |
+
}
|
24 |
+
|
25 |
+
.controls {
|
26 |
+
position: fixed;
|
27 |
+
top: 10px;
|
28 |
+
left: 10px;
|
29 |
+
background: rgba(0, 20, 0, 0.8);
|
30 |
+
padding: 15px;
|
31 |
+
border: 1px solid #00ff00;
|
32 |
+
z-index: 100;
|
33 |
+
}
|
34 |
+
|
35 |
+
.data {
|
36 |
+
position: fixed;
|
37 |
+
top: 10px;
|
38 |
+
right: 10px;
|
39 |
+
background: rgba(0, 20, 0, 0.8);
|
40 |
+
padding: 15px;
|
41 |
+
border: 1px solid #00ff00;
|
42 |
+
z-index: 100;
|
43 |
+
}
|
44 |
+
|
45 |
+
button {
|
46 |
+
background: #001400;
|
47 |
+
color: #00ff00;
|
48 |
+
border: 1px solid #00ff00;
|
49 |
+
padding: 5px 10px;
|
50 |
+
margin: 5px;
|
51 |
+
cursor: pointer;
|
52 |
+
font-family: monospace;
|
53 |
+
transition: all 0.3s;
|
54 |
+
}
|
55 |
+
|
56 |
+
button:hover {
|
57 |
+
background: #00ff00;
|
58 |
+
color: #000;
|
59 |
+
}
|
60 |
+
|
61 |
+
.separator {
|
62 |
+
height: 1px;
|
63 |
+
background: #00ff00;
|
64 |
+
margin: 10px 0;
|
65 |
+
}
|
66 |
+
|
67 |
+
.detector {
|
68 |
+
position: fixed;
|
69 |
+
border: 1px solid #00ff00;
|
70 |
+
pointer-events: none;
|
71 |
+
}
|
72 |
+
</style>
|
73 |
+
</head>
|
74 |
+
<body>
|
75 |
+
<canvas id="mainCanvas"></canvas>
|
76 |
+
<canvas id="effectCanvas"></canvas>
|
77 |
+
|
78 |
+
<div class="controls">
|
79 |
+
<button onclick="initializeAccelerator()">Initialize</button>
|
80 |
+
<button onclick="injectParticles()">Inject Particles</button>
|
81 |
+
<button onclick="toggleAcceleration()">Toggle Acceleration</button>
|
82 |
+
<button onclick="toggleCollisions()">Toggle Collisions</button>
|
83 |
+
<div class="separator"></div>
|
84 |
+
<div>Energy Level: <span id="energyLevel">0</span> TeV</div>
|
85 |
+
<div>Collisions: <span id="collisionCount">0</span></div>
|
86 |
+
<div>Particles: <span id="particleCount">0</span></div>
|
87 |
+
</div>
|
88 |
+
|
89 |
+
<div class="data">
|
90 |
+
<div>Detector Data:</div>
|
91 |
+
<div id="detectorData"></div>
|
92 |
+
</div>
|
93 |
+
|
94 |
+
<script>
|
95 |
+
const mainCanvas = document.getElementById('mainCanvas');
|
96 |
+
const effectCanvas = document.getElementById('effectCanvas');
|
97 |
+
const mainCtx = mainCanvas.getContext('2d');
|
98 |
+
const effectCtx = effectCanvas.getContext('2d');
|
99 |
+
|
100 |
+
// Set canvas sizes
|
101 |
+
function resizeCanvases() {
|
102 |
+
mainCanvas.width = window.innerWidth;
|
103 |
+
mainCanvas.height = window.innerHeight;
|
104 |
+
effectCanvas.width = window.innerWidth;
|
105 |
+
effectCanvas.height = window.innerHeight;
|
106 |
+
}
|
107 |
+
resizeCanvases();
|
108 |
+
window.addEventListener('resize', resizeCanvases);
|
109 |
+
|
110 |
+
// Simulation state
|
111 |
+
const state = {
|
112 |
+
particles: [],
|
113 |
+
detectors: [],
|
114 |
+
collisions: [],
|
115 |
+
acceleratorActive: false,
|
116 |
+
collisionsEnabled: false,
|
117 |
+
collisionCount: 0,
|
118 |
+
maxEnergy: 13, // TeV
|
119 |
+
centerX: window.innerWidth / 2,
|
120 |
+
centerY: window.innerHeight / 2,
|
121 |
+
ringRadius: Math.min(window.innerWidth, window.innerHeight) * 0.35,
|
122 |
+
time: 0
|
123 |
+
};
|
124 |
+
|
125 |
+
class Particle {
|
126 |
+
constructor(clockwise = true) {
|
127 |
+
this.clockwise = clockwise;
|
128 |
+
this.angle = clockwise ? 0 : Math.PI;
|
129 |
+
this.energy = 0.1;
|
130 |
+
this.velocity = 0.01;
|
131 |
+
this.radius = state.ringRadius;
|
132 |
+
this.size = 3;
|
133 |
+
this.trail = [];
|
134 |
+
this.maxTrailLength = 50;
|
135 |
+
this.collided = false;
|
136 |
+
this.updatePosition();
|
137 |
+
this.detectedBy = new Set();
|
138 |
+
}
|
139 |
+
|
140 |
+
updatePosition() {
|
141 |
+
this.x = state.centerX + Math.cos(this.angle) * this.radius;
|
142 |
+
this.y = state.centerY + Math.sin(this.angle) * this.radius;
|
143 |
+
|
144 |
+
this.trail.push({ x: this.x, y: this.y });
|
145 |
+
if (this.trail.length > this.maxTrailLength) {
|
146 |
+
this.trail.shift();
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
accelerate() {
|
151 |
+
if (state.acceleratorActive && this.energy < state.maxEnergy) {
|
152 |
+
this.energy += 0.01;
|
153 |
+
this.velocity = 0.01 + (this.energy / state.maxEnergy) * 0.04;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
update() {
|
158 |
+
this.accelerate();
|
159 |
+
this.angle += this.clockwise ? this.velocity : -this.velocity;
|
160 |
+
this.updatePosition();
|
161 |
+
this.checkDetectors();
|
162 |
+
}
|
163 |
+
|
164 |
+
checkDetectors() {
|
165 |
+
state.detectors.forEach(detector => {
|
166 |
+
if (!this.detectedBy.has(detector) &&
|
167 |
+
this.x > detector.x &&
|
168 |
+
this.x < detector.x + detector.width &&
|
169 |
+
this.y > detector.y &&
|
170 |
+
this.y < detector.y + detector.height) {
|
171 |
+
|
172 |
+
this.detectedBy.add(detector);
|
173 |
+
detector.detect(this);
|
174 |
+
}
|
175 |
+
});
|
176 |
+
}
|
177 |
+
|
178 |
+
draw(ctx) {
|
179 |
+
// Draw trail
|
180 |
+
ctx.beginPath();
|
181 |
+
ctx.strokeStyle = this.clockwise ?
|
182 |
+
`rgba(0, ${155 + this.energy * 10}, 255, 0.5)` :
|
183 |
+
`rgba(255, ${155 + this.energy * 10}, 0, 0.5)`;
|
184 |
+
ctx.lineWidth = 2;
|
185 |
+
|
186 |
+
for (let i = 0; i < this.trail.length; i++) {
|
187 |
+
if (i === 0) {
|
188 |
+
ctx.moveTo(this.trail[i].x, this.trail[i].y);
|
189 |
+
} else {
|
190 |
+
ctx.lineTo(this.trail[i].x, this.trail[i].y);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
ctx.stroke();
|
194 |
+
|
195 |
+
// Draw particle
|
196 |
+
ctx.beginPath();
|
197 |
+
ctx.fillStyle = this.clockwise ? '#00ffff' : '#ff9900';
|
198 |
+
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
|
199 |
+
ctx.fill();
|
200 |
+
|
201 |
+
// Energy indicator
|
202 |
+
ctx.beginPath();
|
203 |
+
ctx.strokeStyle = `rgba(255, 255, 255, ${this.energy / state.maxEnergy})`;
|
204 |
+
ctx.arc(this.x, this.y, this.size + 3, 0, Math.PI * 2);
|
205 |
+
ctx.stroke();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
class Detector {
|
210 |
+
constructor(x, y, width, height) {
|
211 |
+
this.x = x;
|
212 |
+
this.y = y;
|
213 |
+
this.width = width;
|
214 |
+
this.height = height;
|
215 |
+
this.detections = [];
|
216 |
+
this.element = document.createElement('div');
|
217 |
+
this.element.className = 'detector';
|
218 |
+
this.element.style.left = `${x}px`;
|
219 |
+
this.element.style.top = `${y}px`;
|
220 |
+
this.element.style.width = `${width}px`;
|
221 |
+
this.element.style.height = `${height}px`;
|
222 |
+
document.body.appendChild(this.element);
|
223 |
+
}
|
224 |
+
|
225 |
+
detect(particle) {
|
226 |
+
this.detections.push({
|
227 |
+
time: state.time,
|
228 |
+
energy: particle.energy,
|
229 |
+
direction: particle.clockwise ? 'clockwise' : 'counterclockwise'
|
230 |
+
});
|
231 |
+
this.element.style.backgroundColor = 'rgba(0, 255, 0, 0.2)';
|
232 |
+
setTimeout(() => {
|
233 |
+
this.element.style.backgroundColor = 'transparent';
|
234 |
+
}, 100);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
function createDetectors() {
|
239 |
+
const detectorSize = 40;
|
240 |
+
const positions = [
|
241 |
+
{ angle: 0, label: 'East' },
|
242 |
+
{ angle: Math.PI / 2, label: 'South' },
|
243 |
+
{ angle: Math.PI, label: 'West' },
|
244 |
+
{ angle: 3 * Math.PI / 2, label: 'North' }
|
245 |
+
];
|
246 |
+
|
247 |
+
positions.forEach(pos => {
|
248 |
+
const x = state.centerX + Math.cos(pos.angle) * state.ringRadius - detectorSize/2;
|
249 |
+
const y = state.centerY + Math.sin(pos.angle) * state.ringRadius - detectorSize/2;
|
250 |
+
state.detectors.push(new Detector(x, y, detectorSize, detectorSize));
|
251 |
+
});
|
252 |
+
}
|
253 |
+
|
254 |
+
function drawAccelerator() {
|
255 |
+
mainCtx.beginPath();
|
256 |
+
mainCtx.strokeStyle = '#333';
|
257 |
+
mainCtx.lineWidth = 20;
|
258 |
+
mainCtx.arc(state.centerX, state.centerY, state.ringRadius, 0, Math.PI * 2);
|
259 |
+
mainCtx.stroke();
|
260 |
+
|
261 |
+
// Energy sections
|
262 |
+
for (let i = 0; i < 8; i++) {
|
263 |
+
const angle = (i / 8) * Math.PI * 2;
|
264 |
+
mainCtx.beginPath();
|
265 |
+
mainCtx.strokeStyle = '#0f0';
|
266 |
+
mainCtx.lineWidth = 2;
|
267 |
+
const x = state.centerX + Math.cos(angle) * state.ringRadius;
|
268 |
+
const y = state.centerY + Math.sin(angle) * state.ringRadius;
|
269 |
+
mainCtx.arc(x, y, 10, 0, Math.PI * 2);
|
270 |
+
mainCtx.stroke();
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
function checkCollisions() {
|
275 |
+
if (!state.collisionsEnabled) return;
|
276 |
+
|
277 |
+
for (let i = 0; i < state.particles.length; i++) {
|
278 |
+
for (let j = i + 1; j < state.particles.length; j++) {
|
279 |
+
const p1 = state.particles[i];
|
280 |
+
const p2 = state.particles[j];
|
281 |
+
|
282 |
+
if (p1.clockwise !== p2.clockwise) {
|
283 |
+
const dx = p1.x - p2.x;
|
284 |
+
const dy = p1.y - p2.y;
|
285 |
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
286 |
+
|
287 |
+
if (distance < 10 && p1.energy > 1 && p2.energy > 1) {
|
288 |
+
createCollisionEffect(p1.x, p1.y, p1.energy + p2.energy);
|
289 |
+
p1.collided = true;
|
290 |
+
p2.collided = true;
|
291 |
+
state.collisionCount++;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
state.particles = state.particles.filter(p => !p.collided);
|
298 |
+
}
|
299 |
+
|
300 |
+
function createCollisionEffect(x, y, energy) {
|
301 |
+
const particles = 50;
|
302 |
+
const speed = 5;
|
303 |
+
|
304 |
+
for (let i = 0; i < particles; i++) {
|
305 |
+
const angle = (i / particles) * Math.PI * 2;
|
306 |
+
const velocity = {
|
307 |
+
x: Math.cos(angle) * speed * (Math.random() + 0.5),
|
308 |
+
y: Math.sin(angle) * speed * (Math.random() + 0.5)
|
309 |
+
};
|
310 |
+
state.collisions.push({
|
311 |
+
x, y,
|
312 |
+
velocity,
|
313 |
+
life: 1,
|
314 |
+
color: `hsl(${Math.random() * 60 + 30}, 100%, 50%)`
|
315 |
+
});
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
function updateCollisionEffects() {
|
320 |
+
state.collisions.forEach(p => {
|
321 |
+
p.x += p.velocity.x;
|
322 |
+
p.y += p.velocity.y;
|
323 |
+
p.life -= 0.02;
|
324 |
+
});
|
325 |
+
|
326 |
+
state.collisions = state.collisions.filter(p => p.life > 0);
|
327 |
+
}
|
328 |
+
|
329 |
+
function drawCollisionEffects() {
|
330 |
+
effectCtx.clearRect(0, 0, effectCanvas.width, effectCanvas.height);
|
331 |
+
|
332 |
+
state.collisions.forEach(p => {
|
333 |
+
effectCtx.beginPath();
|
334 |
+
effectCtx.fillStyle = p.color.replace(')', `, ${p.life})`);
|
335 |
+
effectCtx.arc(p.x, p.y, 2, 0, Math.PI * 2);
|
336 |
+
effectCtx.fill();
|
337 |
+
});
|
338 |
+
}
|
339 |
+
|
340 |
+
function updateUI() {
|
341 |
+
document.getElementById('energyLevel').textContent =
|
342 |
+
state.particles.length > 0 ?
|
343 |
+
state.particles[0].energy.toFixed(2) : '0.00';
|
344 |
+
document.getElementById('collisionCount').textContent = state.collisionCount;
|
345 |
+
document.getElementById('particleCount').textContent = state.particles.length;
|
346 |
+
|
347 |
+
// Update detector data
|
348 |
+
const detectorData = state.detectors.map((detector, i) => {
|
349 |
+
const recent = detector.detections.slice(-3);
|
350 |
+
return `Detector ${i + 1}: ${recent.length} recent detections`;
|
351 |
+
}).join('<br>');
|
352 |
+
document.getElementById('detectorData').innerHTML = detectorData;
|
353 |
+
}
|
354 |
+
|
355 |
+
// Control functions
|
356 |
+
function initializeAccelerator() {
|
357 |
+
state.particles = [];
|
358 |
+
state.collisions = [];
|
359 |
+
state.collisionCount = 0;
|
360 |
+
state.detectors.forEach(d => d.detections = []);
|
361 |
+
}
|
362 |
+
|
363 |
+
function injectParticles() {
|
364 |
+
state.particles.push(new Particle(true));
|
365 |
+
state.particles.push(new Particle(false));
|
366 |
+
}
|
367 |
+
|
368 |
+
function toggleAcceleration() {
|
369 |
+
state.acceleratorActive = !state.acceleratorActive;
|
370 |
+
}
|
371 |
+
|
372 |
+
function toggleCollisions() {
|
373 |
+
state.collisionsEnabled = !state.collisionsEnabled;
|
374 |
+
}
|
375 |
+
|
376 |
+
function animate() {
|
377 |
+
state.time++;
|
378 |
+
|
379 |
+
// Clear main canvas
|
380 |
+
mainCtx.fillStyle = 'rgba(0, 0, 0, 0.1)';
|
381 |
+
mainCtx.fillRect(0, 0, mainCanvas.width, mainCanvas.height);
|
382 |
+
|
383 |
+
drawAccelerator();
|
384 |
+
|
385 |
+
state.particles.forEach(particle => {
|
386 |
+
particle.update();
|
387 |
+
particle.draw(mainCtx);
|
388 |
+
});
|
389 |
+
|
390 |
+
checkCollisions();
|
391 |
+
updateCollisionEffects();
|
392 |
+
drawCollisionEffects();
|
393 |
+
updateUI();
|
394 |
+
|
395 |
+
requestAnimationFrame(animate);
|
396 |
+
}
|
397 |
+
|
398 |
+
// Initialize and start
|
399 |
+
createDetectors();
|
400 |
+
animate();
|
401 |
+
</script>
|
402 |
+
</body>
|
403 |
+
</html>
|