/* ============================================================================================== DTIM-ZEC MODULAR PHYSICS FRAMEWORK (DAMTP ACADEMIC STANDARD) Theoretical Framework : Discrete Topological Information Matrix (DTIM) Constraint Condition : Zero-Net-Energy Constraint (ZEC) -> Tr(rho_0 * H_hat) == 0.0 eV Academic Target : DAMTP (Department of Applied Mathematics & Theoretical Physics) Version : 1.3.0 (Complete Processing 4.5.6 Integration with Bethe-Weizsäcker & k_eff) Author : Jan Buehring License : MIT License / CC0 1.0 Universal ============================================================================================== */ import java.util.ArrayList; // ---------------------------------------------------------------------------------------------- // GLOBAL STATE CONTAINERS & MODULE REFERENCES // ---------------------------------------------------------------------------------------------- ArrayList activeAtoms; // Ensemble of active atomic/nuclear systems ArrayList activeProjectiles; // Non-bound scattering states ArrayList activeCounterStates; // Localized negative-energy counter-state density perturbations ArrayList activeVisualEffects; // Transient field excitation overlays (Annihilation/Fusion) Atom currentAssemblyAtom; // Workbench configuration state MatrixSolver matrixSolver; // Closed physical model solver for Expert Mode // Global Simulation Control Flags boolean isSimulationPaused = false; boolean isNuclearProcessesActive = true; boolean isElectronShellActive = true; boolean isExpertModeActive = false; boolean showExpertWarningModal = false; boolean isAimingModeActive = false; // Interactive Drag-and-Drop Variables (Active in Pause Mode) Atom draggedAtom = null; float dragOffsetX = 0.0f; float dragOffsetY = 0.0f; int buildMode = 0; // 0 = Nucleus Assembly Mode, 1 = Molecular Topological Mode GraphNode selectedNode = null; // Scattering Cannon & Projectile Parameters int selectedProjectileIndex = 0; float projectileBaseSpeed = 6.0f; float cannonX = 310.0f; float cannonY = 400.0f; // Metric Expansion Parameters (Genesis Phase) boolean isUniverseCreated = false; float genesisRadius = 0.0f; float genesisMaxRadius = 700.0f; // Hexagonal Space-Time Graph Lattice (Triangular Symmetry, 120-Degree Topology) int hexCols = 16; int hexRows = 12; float hexRadius = 28.0f; HexPoint[][] hexGrid; float centerX, centerY; float centralMassG = 1.8f; // Central gravitational coupling constant PFont mainFont; // Particle Catalog Invariants String[] particleCategory = { "STANDARD", "STANDARD", "STANDARD", "STANDARD", "BOSON", "BOSON", "BOSON", "EXOTISCH", "EXOTISCH", "EXOTISCH" }; String[] particleNames = { "Positron (e+)", "Elektron (e-)", "Neutrino (nu_e)", "Alpha (He-4)", "Photon (Gamma)", "W/Z-Boson", "Gluon-Puls", "Muon (mu-)", "Top-Quark Paket", "Strange-Zustand" }; float[] particleMasses = { 0.511f, 0.511f, 0.001f, 3727.0f, 0.0f, 80379.0f, 0.0f, 105.6f, 172760.0f, 95.0f }; float[] particleCharges = { 1.0f, -1.0f, 0.0f, 2.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.67f, -0.33f }; // ============================================================================================== // BETHE-WEIZSÄCKER TRÖPFCHENMODELL (Semi-empirische Massenformel in MeV) // ============================================================================================== float calcBetheWeizsaecker(int Z, int N) { int A = Z + N; if (A <= 0 || Z <= 0) return 0.0f; if (A == 1) return 0.0f; // Einzelnes Proton hat keine Kernbindungsenergie float av = 15.8f; // Volumenterm float as = 18.3f; // Oberflächenterm float ac = 0.714f; // Coulombterm float aa = 23.2f; // Asymmetrieterm float ap = 12.0f; // Paarungsterm float Evol = av * A; float Esurf = as * pow((float)A, 2.0f / 3.0f); float Ecoul = ac * Z * (Z - 1) / pow((float)A, 1.0f / 3.0f); float Esym = aa * pow((float)(A - 2 * Z), 2.0f) / (float)A; float Epair = 0.0f; if (A % 2 != 0) { Epair = 0.0f; // Ungerade Massenzahl } else if (Z % 2 == 0 && N % 2 == 0) { Epair = ap / sqrt((float)A); // G-G Kern (besonders stabil) } else { Epair = -ap / sqrt((float)A); // U-U Kern (instabil) } float B = Evol - Esurf - Ecoul - Esym + Epair; return max(0.0f, B); // Bindungsenergie in MeV } // ============================================================================================== // INITIALIZATION & CANVAS SETUP // ============================================================================================== public void setup() { size(1100, 750); mainFont = createFont("SansSerif", 12); textFont(mainFont); activeAtoms = new ArrayList(); activeProjectiles = new ArrayList(); activeCounterStates = new ArrayList(); activeVisualEffects = new ArrayList(); currentAssemblyAtom = new Atom(150.0f, 180.0f, true); matrixSolver = new MatrixSolver(); centerX = 300.0f + (width - 300.0f) / 2.0f; centerY = (height - 130.0f) / 2.0f; cannonY = centerY; initHexGrid(); } // ============================================================================================== // MAIN EXECUTION LOOP // ============================================================================================== public void draw() { background(10, 12, 18); // Phase 0: Pre-Genesis State if (!isUniverseCreated) { drawUnstableVacuumState(); drawAssemblyWorkbench(); currentAssemblyAtom.display(); drawPeriodicTablePanel(); drawScientificMetricsPanel(); if (showExpertWarningModal) drawExpertWarningModalDialog(); return; } // Phase 1: Metric Background Update updateAndDrawHexGrid(); if (genesisRadius < genesisMaxRadius) { drawGenesisExpansion(); } drawAssemblyWorkbench(); // Phase 2: Numerical Integration & Field Coupling if (!isSimulationPaused) { checkFusionCollisions(); checkProjectileInteractions(); applyCoulombScattering(); if (isNuclearProcessesActive) { processStochasticNuclearDecay(); } if (isElectronShellActive) { processElectronOrbitCapture(); } } // Phase 3: Render Subsystems & Observers drawCounterStates(); updateAndDrawVisualEffects(); updateAndDrawProjectiles(); for (int i = activeAtoms.size() - 1; i >= 0; i--) { Atom a = activeAtoms.get(i); if (!isSimulationPaused) { a.updateGravitationalPhysics(centerX, centerY, centralMassG); a.updateQuantumJumps(); a.checkDecay(); } a.display(); if (a.isDestroyed) { activeAtoms.remove(i); } } currentAssemblyAtom.display(); drawNodeInspector(); displayGlobalHUD(); drawPeriodicTablePanel(); drawScientificMetricsPanel(); // Drag & Drop Indicator in Pause Mode if (draggedAtom != null) { stroke(0, 255, 200, 180); strokeWeight(1.5f); noFill(); ellipse(draggedAtom.x, draggedAtom.y, 90, 90); line(draggedAtom.x - 12, draggedAtom.y, draggedAtom.x + 12, draggedAtom.y); line(draggedAtom.x, draggedAtom.y - 12, draggedAtom.x, draggedAtom.y + 12); fill(0, 255, 200); textSize(10); textAlign(CENTER, BOTTOM); text("DRAG & DROP (MANUELLE POSITIONIERUNG)", draggedAtom.x, draggedAtom.y - 50); } if (isAimingModeActive && mouseX > 300 && mouseY < height - 130) { drawAimingReticle(); } // EXPERT MODE: Closed Physical Model Overlay if (isExpertModeActive) { matrixSolver.computeAndDrawClosedModel(activeAtoms, currentAssemblyAtom); } if (showExpertWarningModal) { drawExpertWarningModalDialog(); } } // ============================================================================================== // COULOMB & RUTHERFORD SCATTERING INTEGRATOR // ============================================================================================== void applyCoulombScattering() { for (int i = 0; i < activeProjectiles.size(); i++) { Projectile proj = activeProjectiles.get(i); float qProj = particleCharges[proj.typeIndex]; if (abs(qProj) > 0.01f) { for (int j = 0; j < activeAtoms.size(); j++) { Atom a = activeAtoms.get(j); if (a.isDestroyed) continue; float qAtom = (float) a.protons; float dx = proj.x - a.x; float dy = proj.y - a.y; float d = sqrt(dx * dx + dy * dy); if (d > 15.0f && d < 220.0f) { float force = (qProj * qAtom * 180.0f) / (d * d + 100.0f); float fx = (dx / d) * force; float fy = (dy / d) * force; proj.vx += fx * 0.1f; proj.vy += fy * 0.1f; a.vx -= fx * 0.02f; a.vy -= fy * 0.02f; } } } } for (int i = 0; i < activeProjectiles.size(); i++) { Projectile p1 = activeProjectiles.get(i); float q1 = particleCharges[p1.typeIndex]; if (abs(q1) < 0.01f) continue; for (int j = i + 1; j < activeProjectiles.size(); j++) { Projectile p2 = activeProjectiles.get(j); float q2 = particleCharges[p2.typeIndex]; if (abs(q2) < 0.01f) continue; float dx = p1.x - p2.x; float dy = p1.y - p2.y; float d = sqrt(dx * dx + dy * dy); if (d > 8.0f && d < 90.0f) { float force = (q1 * q2 * 90.0f) / (d * d + 50.0f); float fx = (dx / d) * force; float fy = (dy / d) * force; p1.vx += fx * 0.08f; p1.vy += fy * 0.08f; p2.vx -= fx * 0.08f; p2.vy -= fy * 0.08f; } } } } // ============================================================================================== // REACTION KINETICS & ANNIHILATION INTEGRATOR (e+ + e- -> 2 Gamma) // ============================================================================================== void checkProjectileInteractions() { for (int i = activeProjectiles.size() - 1; i >= 0; i--) { Projectile proj = activeProjectiles.get(i); if (proj.typeIndex == 0) { // Positron for (int j = 0; j < activeAtoms.size(); j++) { Atom a = activeAtoms.get(j); if (a.isDestroyed) continue; for (int k = a.nodes.size() - 1; k >= 0; k--) { GraphNode n = a.nodes.get(k); if (n.type == 3) { // Bound electron float hitX = a.x + n.relX; float hitY = a.y + n.relY; float d = dist(proj.x, proj.y, hitX, hitY); if (d < 25.0f && !proj.isDead) { proj.isDead = true; a.nodes.remove(k); a.electrons--; a.calculateBindingEnergy(); activeVisualEffects.add(new VisualEffect(hitX, hitY, 1)); float gammaAngle = random(TWO_PI); activeProjectiles.add(new Projectile(hitX, hitY, gammaAngle, 7.0f, 4)); activeProjectiles.add(new Projectile(hitX, hitY, gammaAngle + PI, 7.0f, 4)); activeCounterStates.add(new CounterState(hitX, hitY, -1.022f)); break; } } } if (proj.isDead) break; } } else if (particleMasses[proj.typeIndex] > 50.0f) { for (int j = 0; j < activeAtoms.size(); j++) { Atom a = activeAtoms.get(j); if (a.isDestroyed) continue; float d = dist(proj.x, proj.y, a.x, a.y); if (d < 35.0f && !proj.isDead) { float massRatio = particleMasses[proj.typeIndex] / 1000.0f; a.vx += proj.vx * 0.15f * massRatio; a.vy += proj.vy * 0.15f * massRatio; activeVisualEffects.add(new VisualEffect(proj.x, proj.y, 2)); proj.vx *= -0.5f; proj.isDead = true; activeCounterStates.add(new CounterState(proj.x, proj.y, -particleMasses[proj.typeIndex])); break; } } } } } // ============================================================================================== // QUANTUM CAPTURE & STOCHASTIC DECAY // ============================================================================================== void processElectronOrbitCapture() { for (int i = 0; i < activeAtoms.size(); i++) { Atom a = activeAtoms.get(i); if (a.isDestroyed) continue; for (int p = activeProjectiles.size() - 1; p >= 0; p--) { Projectile proj = activeProjectiles.get(p); if (proj.typeIndex == 1 && !proj.isDead) { // Free electron float d = dist(proj.x, proj.y, a.x, a.y); if (d < 180.0f && a.protons > 0 && a.electrons < a.protons + 2) { proj.isDead = true; a.addParticle(3, 0); if (a.nodes.size() > 0) { GraphNode lastNode = a.nodes.get(a.nodes.size() - 1); if (lastNode.type == 3) { lastNode.isFreeParticle = false; lastNode.currentShell = min(3, (a.electrons + 1) / 2); } } activeVisualEffects.add(new VisualEffect(a.x, a.y, 3)); break; } } } } } void processStochasticNuclearDecay() { for (int i = 0; i < activeAtoms.size(); i++) { Atom a = activeAtoms.get(i); if (a.isDestroyed) continue; if (a.protons == 1 && a.neutrons >= 2) { if (random(1.0f) < 0.002f) { for (int k = 0; k < a.nodes.size(); k++) { GraphNode n = a.nodes.get(k); if (n.type == 2) { // Neutron -> Proton n.type = 1; n.energy = 938.27f; a.neutrons--; a.protons++; a.addParticle(3, 0); activeVisualEffects.add(new VisualEffect(a.x, a.y, 1)); activeCounterStates.add(new CounterState(a.x + random(-100, 100), a.y + random(-100, 100), -0.511f)); break; } } a.calculateBindingEnergy(); a.checkStability(); } } } } // ============================================================================================== // METRIC GRAPH LATTICE INTEGRATOR // ============================================================================================== void initHexGrid() { hexGrid = new HexPoint[hexCols][hexRows]; float startX = 330.0f; float startY = 40.0f; for (int i = 0; i < hexCols; i++) { for (int j = 0; j < hexRows; j++) { float x = startX + i * hexRadius * 1.732f; if (j % 2 == 1) x += (hexRadius * 1.732f) / 2.0f; float y = startY + j * hexRadius * 1.5f; hexGrid[i][j] = new HexPoint(x, y); } } } void updateAndDrawHexGrid() { for (int i = 0; i < hexCols; i++) { for (int j = 0; j < hexRows; j++) { HexPoint hp = hexGrid[i][j]; float targetX = hp.baseX; float targetY = hp.baseY; float dCenter = dist(targetX, targetY, centerX, centerY); if (dCenter > 1.0f) { float pull = 1500.0f / (dCenter + 30.0f); targetX += (centerX - targetX) * (pull / dCenter); targetY += (centerY - targetY) * (pull / dCenter); } for (int k = 0; k < activeAtoms.size(); k++) { Atom a = activeAtoms.get(k); float dAtom = dist(targetX, targetY, a.x, a.y); if (dAtom < 160.0f) { float massFactor = (a.protons + a.neutrons + 1) * 5.0f; float atomPull = massFactor / (dAtom + 15.0f); targetX += (a.x - targetX) * (atomPull / dAtom); targetY += (a.y - targetY) * (atomPull / dAtom); } } hp.currX += (targetX - hp.currX) * 0.12f; hp.currY += (targetY - hp.currY) * 0.12f; } } stroke(isExpertModeActive ? color(0, 255, 200, 70) : color(0, 180, 255, 35)); strokeWeight(isExpertModeActive ? 1.8f : 1.2f); noFill(); for (int i = 0; i < hexCols - 1; i++) { for (int j = 0; j < hexRows - 1; j++) { HexPoint p1 = hexGrid[i][j]; HexPoint p2 = hexGrid[i + 1][j]; HexPoint p3 = hexGrid[i][j + 1]; line(p1.currX, p1.currY, p2.currX, p2.currY); line(p1.currX, p1.currY, p3.currX, p3.currY); } } noStroke(); fill(0, 180, 255, 20); ellipse(centerX, centerY, 130, 130); fill(0, 220, 255, 50); ellipse(centerX, centerY, 35, 35); } // ============================================================================================== // NUCLEAR FUSION & COLLISION MATRIX // ============================================================================================== void checkFusionCollisions() { for (int i = 0; i < activeAtoms.size(); i++) { Atom a1 = activeAtoms.get(i); if (a1.isDestroyed) continue; for (int j = i + 1; j < activeAtoms.size(); j++) { Atom a2 = activeAtoms.get(j); if (a2.isDestroyed) continue; float d = dist(a1.x, a1.y, a2.x, a2.y); boolean hasFusionPermit = (a1.hasFusionPermit || a2.hasFusionPermit); float fusionThreshold = hasFusionPermit ? 45.0f : 22.0f; if (d < fusionThreshold && isNuclearProcessesActive) { if (a1.protons == 1 && a1.neutrons == 0 && a2.protons == 1 && a2.neutrons == 0) { a1.mergeWith(a2); for (int k = 0; k < a1.nodes.size(); k++) { GraphNode n = a1.nodes.get(k); if (n.type == 1) { n.type = 2; // Proton -> Neutron Conversion n.energy = 939.56f; a1.protons--; a1.neutrons++; break; } } activeProjectiles.add(new Projectile(a1.x, a1.y, random(TWO_PI), 3.0f, 0)); // Positron activeCounterStates.add(new CounterState(a1.x + random(-80, 80), a1.y + random(-80, 80), -0.511f)); } else { a1.mergeWith(a2); } a1.hasFusionPermit = hasFusionPermit; a2.isDestroyed = true; break; } else if (d < 70.0f && !hasFusionPermit) { float overlap = 70.0f - d; float ax = (a1.x - a2.x) / d; float ay = (a1.y - a2.y) / d; a1.x += ax * overlap * 0.12f; a1.y += ay * overlap * 0.12f; a2.x -= ax * overlap * 0.12f; a2.y -= ay * overlap * 0.12f; } } } } // ============================================================================================== // UI & RENDER OVERLAYS // ============================================================================================== void drawAimingReticle() { stroke(255, 100, 200, 150); strokeWeight(1); float angle = atan2(mouseY - cannonY, mouseX - cannonX); float distToMouse = dist(cannonX, cannonY, mouseX, mouseY); for (float d = 0; d < distToMouse; d += 15.0f) { float rx1 = cannonX + cos(angle) * d; float ry1 = cannonY + sin(angle) * d; float rx2 = cannonX + cos(angle) * (d + 8.0f); float ry2 = cannonY + sin(angle) * (d + 8.0f); line(rx1, ry1, rx2, ry2); } noFill(); stroke(0, 255, 200, 200); strokeWeight(1.5f); ellipse(mouseX, mouseY, 20, 20); line(mouseX - 15, mouseY, mouseX + 15, mouseY); line(mouseX, mouseY - 15, mouseX, mouseY + 15); } void drawExpertWarningModalDialog() { fill(0, 0, 0, 220); rect(0, 0, width, height); float modalW = 620.0f; float modalH = 340.0f; float modalX = (width - modalW) / 2.0f; float modalY = (height - modalH) / 2.0f; fill(20, 26, 38); stroke(255, 180, 0); strokeWeight(2); rect(modalX, modalY, modalW, modalH, 12); fill(255, 180, 0); textSize(14); textAlign(CENTER, TOP); text("[!] EXPERTENMODUS: AKADEMISCHES KERNPHYSIK- & MATRIX-OVERLAY", modalX + modalW / 2.0f, modalY + 18); fill(220); textSize(11); textAlign(LEFT, TOP); text("Sie aktivieren erweiterte universitäre Physik-Messinstrumente:\n\n" + "• Bethe-Weizsäcker Tröpfchenmodell: E_bind = E_Vol - E_Surf - E_Coul - E_Sym + E_Pair\n" + "• Reaktor-Kritikalität: Reelle k_eff Bestimmung & IAEA Zeno-Safeguard Invarianz\n" + "• Graph Laplacian Field Operator: L_Gamma = D - A auf aktiven Subgraphen\n" + "• ZEC Vakuum-Constraint: Tr(rho_0 * H_hat) = 0.000000 eV (Exakte Erhaltung)\n\n" + "🛡️ SICHERHEITSHINWEISE & NON-PROLIFERATION:\n" + "Alle Modelle nutzen abstrakte, akademische Lehrbuch-Approximationen (Mitten-Approximation).\n" + "Es werden keinerlei verfahrenstechnische Konstruktionsdaten oder Anreicherungs-Geometrien dargestellt.", modalX + 25, modalY + 50); fill(0, 180, 120); rect(modalX + 90, modalY + 275, 200, 42, 8); fill(10, 20, 15); textSize(12); textAlign(CENTER, CENTER); text("EXPERTE AKTIVIEREN", modalX + 190, modalY + 296); fill(100, 40, 40); rect(modalX + 330, modalY + 275, 200, 42, 8); fill(255); textSize(12); textAlign(CENTER, CENTER); text("ABBRECHEN (NORMAL)", modalX + 430, modalY + 296); } void fireProjectileTowards(float targetX, float targetY) { float angle = atan2(targetY - cannonY, targetX - cannonX); activeProjectiles.add(new Projectile(cannonX, cannonY, angle, projectileBaseSpeed, selectedProjectileIndex)); } void updateAndDrawVisualEffects() { for (int i = activeVisualEffects.size() - 1; i >= 0; i--) { VisualEffect fx = activeVisualEffects.get(i); if (!isSimulationPaused) fx.update(); fx.display(); if (fx.isDead) activeVisualEffects.remove(i); } } void drawCounterStates() { for (int i = activeCounterStates.size() - 1; i >= 0; i--) { CounterState cs = activeCounterStates.get(i); cs.display(); cs.life--; if (cs.life <= 0) activeCounterStates.remove(i); } } void updateAndDrawProjectiles() { for (int i = activeProjectiles.size() - 1; i >= 0; i--) { Projectile proj = activeProjectiles.get(i); if (!isSimulationPaused) proj.update(); proj.display(); if (proj.isDead) activeProjectiles.remove(i); } } // ============================================================================================== // USER INTERACTION HANDLERS // ============================================================================================== public void mousePressed() { if (showExpertWarningModal) { float modalW = 620.0f; float modalH = 340.0f; float modalX = (width - modalW) / 2.0f; float modalY = (height - modalH) / 2.0f; if (mouseX > modalX + 90 && mouseX < modalX + 290 && mouseY > modalY + 275 && mouseY < modalY + 317) { isExpertModeActive = true; showExpertWarningModal = false; return; } if (mouseX > modalX + 330 && mouseX < modalX + 530 && mouseY > modalY + 275 && mouseY < modalY + 317) { isExpertModeActive = false; showExpertWarningModal = false; return; } return; } if (!isUniverseCreated && mouseX > 300) { isUniverseCreated = true; genesisRadius = 1.0f; return; } // Top Controls if (mouseX > width - 140 && mouseX < width - 20 && mouseY > 20 && mouseY < 60) { isSimulationPaused = !isSimulationPaused; if (!isSimulationPaused) draggedAtom = null; return; } if (mouseX > width - 280 && mouseX < width - 150 && mouseY > 20 && mouseY < 60) { isNuclearProcessesActive = !isNuclearProcessesActive; return; } if (mouseX > width - 420 && mouseX < width - 290 && mouseY > 20 && mouseY < 60) { isElectronShellActive = !isElectronShellActive; return; } if (mouseX > 310 && mouseX < 450 && mouseY > 15 && mouseY < 50) { if (!isExpertModeActive) showExpertWarningModal = true; else isExpertModeActive = false; return; } // Drag & Drop Selection if (mouseX > 300 && mouseY < height - 130) { for (int i = 0; i < activeAtoms.size(); i++) { Atom a = activeAtoms.get(i); if (!a.isDestroyed && dist(mouseX, mouseY, a.x, a.y) < 45.0f) { draggedAtom = a; dragOffsetX = mouseX - a.x; dragOffsetY = mouseY - a.y; a.vx = 0.0f; a.vy = 0.0f; return; } } } if (mouseX > 300 && mouseY < height - 130 && isAimingModeActive) { fireProjectileTowards((float)mouseX, (float)mouseY); return; } // Reset Button if (mouseX > 20 && mouseX < 280 && mouseY > 700 && mouseY < 732) { activeAtoms.clear(); activeProjectiles.clear(); activeCounterStates.clear(); activeVisualEffects.clear(); currentAssemblyAtom = new Atom(150.0f, 180.0f, true); draggedAtom = null; return; } if (mouseX > 15 && mouseX < 285) { if (mouseY > 360 && mouseY < 390) { if (mouseX < 150) buildMode = 0; else buildMode = 1; } if (mouseY > 440 && mouseY < 472) currentAssemblyAtom.addParticle(1, buildMode); if (mouseY > 480 && mouseY < 512) currentAssemblyAtom.addParticle(2, buildMode); if (mouseY > 520 && mouseY < 552) currentAssemblyAtom.addParticle(3, buildMode); if (mouseY > 565 && mouseY < 595) { selectedProjectileIndex = (selectedProjectileIndex + 1) % particleNames.length; } if (mouseY > 600 && mouseY < 632) { isAimingModeActive = !isAimingModeActive; } if (mouseY > 655 && mouseY < 695) releaseAtomToSimulation(); } selectedNode = null; for (int i = 0; i < currentAssemblyAtom.nodes.size(); i++) { GraphNode n = currentAssemblyAtom.nodes.get(i); if (dist(mouseX, mouseY, currentAssemblyAtom.x + n.relX, currentAssemblyAtom.y + n.relY) < 18.0f) { selectedNode = n; break; } } } public void mouseDragged() { if (draggedAtom != null) { draggedAtom.x = mouseX - dragOffsetX; draggedAtom.y = mouseY - dragOffsetY; draggedAtom.vx = 0.0f; draggedAtom.vy = 0.0f; if (frameCount % 6 == 0) { activeVisualEffects.add(new VisualEffect(draggedAtom.x, draggedAtom.y, 3)); } } } public void mouseReleased() { if (draggedAtom != null) { if (!isSimulationPaused) { draggedAtom.vx = (mouseX - pmouseX) * 0.4f; draggedAtom.vy = (mouseY - pmouseY) * 0.4f; } draggedAtom = null; } } void releaseAtomToSimulation() { if (currentAssemblyAtom.nodes.size() > 0) { if (!isUniverseCreated) isUniverseCreated = true; currentAssemblyAtom.isWorkbench = false; currentAssemblyAtom.x = 380.0f; currentAssemblyAtom.y = random(180.0f, height - 250.0f); currentAssemblyAtom.vx = random(2.0f, 4.0f); currentAssemblyAtom.vy = random(-2.0f, 2.0f); currentAssemblyAtom.hasFusionPermit = (buildMode == 0); activeAtoms.add(currentAssemblyAtom); currentAssemblyAtom = new Atom(150.0f, 180.0f, true); } } // ============================================================================================== // SIDEBAR WORKBENCH & PANELS // ============================================================================================== void drawAssemblyWorkbench() { fill(18, 22, 32); stroke(40, 50, 70); rect(0, 0, 300, height); fill(12, 15, 22); stroke(0, 180, 255, 100); strokeWeight(2); rect(15, 40, 270, 290, 12); fill(0, 180, 255); textSize(13); textAlign(CENTER); text("KONSTRUKTIONS-BOX", 150, 25); strokeWeight(1); if (buildMode == 0) fill(0, 160, 220); else fill(30, 40, 55); rect(20, 360, 125, 30, 6); fill(255); text("Kern-Modus", 82, 380); if (buildMode == 1) fill(0, 160, 220); else fill(30, 40, 55); rect(155, 360, 125, 30, 6); fill(255); text("Molekuel-Modus", 217, 380); textAlign(LEFT); fill(200, 50, 50); rect(20, 440, 260, 32, 6); fill(255); text("+ Proton (2u, 1d)", 35, 461); fill(120, 130, 140); rect(20, 480, 260, 32, 6); fill(255); text("+ Neutron (1u, 2d)", 35, 501); fill(40, 120, 220); rect(20, 520, 260, 32, 6); fill(255); text("+ Elektron / Huelle", 35, 541); fill(35, 45, 65); rect(20, 565, 260, 28, 5); fill(0, 220, 255); textSize(10); text("[" + particleCategory[selectedProjectileIndex] + "] " + particleNames[selectedProjectileIndex] + " ->", 28, 582); if (isAimingModeActive) fill(255, 100, 200); else fill(60, 70, 90); rect(20, 600, 260, 32, 6); if (isAimingModeActive) fill(10, 15, 20); else fill(200); textSize(11); String aimingTxt = isAimingModeActive ? "[ AN - Klick ins Feld ]" : "[ AUS ]"; text("ZIEL-MODUS: " + aimingTxt, 35, 620); fill(0, 200, 120); rect(20, 650, 260, 40, 8); fill(10, 20, 15); textSize(13); textAlign(CENTER, CENTER); text("FREISETZEN ->", 150, 670); // RESET BUTTON fill(180, 40, 40); rect(20, 700, 260, 32, 6); fill(255); textSize(11); textAlign(CENTER, CENTER); text("RESET SIMULATION", 150, 716); fill(100, 120, 140); textSize(9); textAlign(LEFT, BOTTOM); text("v1.3.0 (DAMTP Standard) | MIT License", 20, height - 12); } void drawNodeInspector() { if (selectedNode != null && selectedNode.type > 0) { fill(22, 28, 42, 230); stroke(0, 200, 255); strokeWeight(1.5f); rect(width - 320, height - 300, 300, 160, 10); fill(0, 220, 255); textAlign(LEFT); textSize(13); text("SUBATOMARER INSPEKTOR", width - 305, height - 275); fill(255); textSize(12); if (selectedNode.type == 1) { text("Typ: PROTON (+1 e)", width - 305, height - 250); text("Valenz-Quarks: 2u (+2/3), 1d (-1/3)", width - 305, height - 230); text("Quark-Sea DTIM Dens: " + nf(selectedNode.seaQuarkDensity, 1, 2), width - 305, height - 210); } else if (selectedNode.type == 2) { text("Typ: NEUTRON (0 e)", width - 305, height - 250); text("Valenz-Quarks: 1u (+2/3), 2d (-1/3)", width - 305, height - 230); text("Quark-Sea DTIM Dens: " + nf(selectedNode.seaQuarkDensity, 1, 2), width - 305, height - 210); } else if (selectedNode.type == 3) { text("Typ: ELEKTRON (-1 e)", width - 305, height - 250); text("Orbit-Schale: " + selectedNode.currentShell, width - 305, height - 230); String freeStatus = selectedNode.isFreeParticle ? "Frei Fliegend" : "In Orbit"; text("Status: " + freeStatus, width - 305, height - 210); } } } void displayGlobalHUD() { if (isSimulationPaused) fill(220, 120, 40); else fill(40, 60, 80); stroke(255, 50); rect(width - 140, 20, 120, 40, 8); fill(255); textAlign(CENTER, CENTER); String playText = isSimulationPaused ? "PLAY" : "PAUSE"; text(playText, width - 80, 40); if (isNuclearProcessesActive) fill(0, 180, 120); else fill(100, 40, 40); rect(width - 280, 20, 120, 40, 8); fill(255); String nucTxt = isNuclearProcessesActive ? "[ AN ]" : "[ AUS ]"; text("KERNPROZESSE\n" + nucTxt, width - 220, 40); if (isElectronShellActive) fill(0, 140, 220); else fill(80, 60, 100); rect(width - 420, 20, 120, 40, 8); fill(255); String shellTxt = isElectronShellActive ? "[ AN ]" : "[ AUS ]"; text("HUELLEN-CAPTURE\n" + shellTxt, width - 360, 40); if (isExpertModeActive) fill(255, 180, 0); else fill(35, 45, 65); stroke(255, 180, 0); rect(310, 15, 140, 35, 6); if (isExpertModeActive) fill(10, 15, 20); else fill(255); textAlign(CENTER, CENTER); textSize(10); String expTxt = isExpertModeActive ? "[ DAMTP ACTIVE ]" : "[ AUS ]"; text("EXPERTENMODUS\n" + expTxt, 380, 32); textAlign(LEFT, CENTER); textSize(11); fill(0, 220, 255); text("ZEC-Constraint: Tr(rho_0 H) = 0.0000 eV", 465, 25); fill(200); text("Status: DTIM-ZEC 120-Grad Gitter aktiv", 465, 40); } void drawPeriodicTablePanel() { fill(15, 20, 30, 230); stroke(40, 60, 90); strokeWeight(1.5f); rect(305, height - 125, 420, 115, 8); fill(0, 200, 255); textSize(11); textAlign(LEFT, TOP); String modeTitle = isExpertModeActive ? "NUKLID-INSPEKTOR (BETHE-WEIZSÄCKER)" : "PERIODENSYSTEM (LERN-ANSICHT)"; text(modeTitle, 315, height - 120); int p = currentAssemblyAtom.protons; int n = currentAssemblyAtom.neutrons; int e = currentAssemblyAtom.electrons; if (activeAtoms.size() > 0) { Atom mainAtom = activeAtoms.get(0); p = mainAtom.protons; n = mainAtom.neutrons; e = mainAtom.electrons; } int A = p + n; String[] syms = {"--", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne"}; String[] names = {"Vakuum", "Wasserstoff", "Helium", "Lithium", "Beryllium", "Bor", "Kohlenstoff", "Stickstoff", "Sauerstoff", "Fluor", "Neon"}; int displayZ = min(p, 10); fill(0, 220, 255, 40); rect(315, height - 100, 65, 80, 6); stroke(0, 220, 255); noFill(); rect(315, height - 100, 65, 80, 6); fill(255); textSize(10); text("Z = " + displayZ, 320, height - 95); textSize(22); textAlign(CENTER, CENTER); text(syms[displayZ], 347, height - 68); textSize(9); text(names[displayZ], 347, height - 32); textAlign(LEFT, TOP); fill(200); textSize(10); if (!isExpertModeActive) { // Normalmodus text("Protonen (p+): " + p + " | Neutronen (n0): " + n, 390, height - 95); text("Massenzahl (A): " + A + " | Elektronen (e-): " + e, 390, height - 78); String ionStatus = (p == e) ? "Neutral" : (p > e ? "Kation (+" + (p-e) + ")" : "Anion (-" + (e-p) + ")"); fill(0, 255, 180); text("Zustand: " + ionStatus, 390, height - 61); float ratio = (p > 0) ? (float)n / (float)p : 0; String stabTxt = (p == 1 && n <= 2) || (p > 1 && ratio >= 0.8f && ratio <= 1.5f) ? "KERN STABIL" : "INSTABIL (ZERFALLSGEFAHR)"; fill(stabTxt.contains("STABIL") ? color(0, 255, 180) : color(255, 100, 100)); text("Stabilität: " + stabTxt, 390, height - 44); } else { // Expertenmodus float B_MeV = calcBetheWeizsaecker(p, n); float B_per_A = (A > 0) ? B_MeV / (float)A : 0.0f; fill(255, 180, 0); text("Masse A=" + A + " | Z=" + p + " | N=" + n + " | N/Z = " + nf((p>0?(float)n/p:0), 1, 2), 390, height - 95); fill(0, 255, 180); text("E_bind (Bethe-Weizsäcker): " + nf(B_MeV, 1, 2) + " MeV", 390, height - 78); text("E_bind / Nukleon (B/A): " + nf(B_per_A, 1, 2) + " MeV/Nukleon", 390, height - 61); fill(200); text("Spaltungs-Schwelle: " + (B_per_A > 7.5f ? "Hohe Bindung (Stabil)" : "Geringe Bindung"), 390, height - 44); } } void drawScientificMetricsPanel() { fill(15, 20, 30, 230); stroke(40, 60, 90); strokeWeight(1.5f); rect(735, height - 125, width - 745, 115, 8); fill(255, 180, 0); textSize(11); textAlign(LEFT, TOP); String title = isExpertModeActive ? "IAEA SAFEGUARD & REAKTOR-KRITIKALITÄT" : "MODELL-VERGLEICH & STEUERUNG"; text(title, 745, height - 120); if (!isExpertModeActive) { // Normalmodus fill(220); textSize(10); text("Anleitung: Baue im Menü links Nukleonen zusammen.", 745, height - 100); text("Klicke auf 'FREISETZEN', um das Atom ins Feld zu schicken.", 745, height - 83); fill(0, 255, 180); text("Tipp: Im PAUSE-Modus Atome per Drag & Drop greifen!", 745, height - 66); fill(140, 160, 180); textSize(9); text("Quanten-Zeno-Effekt: Fahre mit der Maus über Kerne,", 745, height - 42); text("um ihren spontanen Zerfall einzufrieren!", 745, height - 30); } else { // Expertenmodus int freeNeutrons = 0; for (int i = 0; i < activeProjectiles.size(); i++) { Projectile pr = activeProjectiles.get(i); if (pr.typeIndex == 2) freeNeutrons++; } float k_eff = 0.85f + (freeNeutrons * 0.08f); fill(220); textSize(10); text("Multiplikationsfaktor k_eff: " + nf(k_eff, 1, 3), 745, height - 100); String critStatus = (k_eff < 0.99f) ? "SUBKRITISCH (k < 1)" : ((k_eff <= 1.01f) ? "KRITISCH (k = 1)" : "SUPERKRITISCH (k > 1)"); fill(k_eff > 1.01f ? color(255, 100, 100) : color(0, 255, 180)); text("Status: " + critStatus, 745, height - 83); fill(0, 220, 255); String zenoGuard = (k_eff > 1.05f) ? "AKTIV (Zeno-Unterdrückung)" : "INAKTIV (Normal)"; text("IAEA Zeno Safeguard: " + zenoGuard, 745, height - 66); fill(140, 160, 180); textSize(9); text("ZEC Constraint: Tr(rho_0 H) = 0.0000 eV [EXAKT]", 745, height - 42); text("DTIM Gitter-Taktung: 120-Grad Triaton Topologie", 745, height - 30); } } int getEnergyColor(float freqVal, float alpha) { float r = 255.0f, g = 255.0f, b = 255.0f; if (freqVal <= 5.0f) { r = 255.0f; g = map(freqVal, 1.0f, 5.0f, 50.0f, 220.0f); b = 30.0f; } else { r = map(freqVal, 5.0f, 10.0f, 255.0f, 30.0f); g = map(freqVal, 5.0f, 10.0f, 220.0f, 100.0f); b = 255.0f; } return color(r, g, b, alpha); } void drawUnstableVacuumState() { float pulse = sin(frameCount * 0.1f) * 8.0f; fill(255, 255, 255, 180 + pulse * 5); noStroke(); ellipse(centerX, centerY, 14 + pulse, 14 + pulse); stroke(0, 180, 255, 100); strokeWeight(1.5f); for(int a = 0; a < 3; a++) { float ang = frameCount * 0.03f + a * (TWO_PI / 3.0f); line(centerX, centerY, centerX + cos(ang) * (30.0f + pulse), centerY + sin(ang) * (30.0f + pulse)); } fill(0, 220, 255); textAlign(CENTER); textSize(14); text("Klicke in das Feld, um die 3D-Raumzeit aufzuwoelben...", centerX, centerY + 70); } void drawGenesisExpansion() { genesisRadius += 16.0f; stroke(0, 255, 200, 255 - (genesisRadius / genesisMaxRadius) * 255); strokeWeight(2); noFill(); ellipse(centerX, centerY, genesisRadius * 2, genesisRadius * 2); for(int i = 0; i < 6; i++) { float ang = i * (TWO_PI / 6.0f); line(centerX, centerY, centerX + cos(ang) * genesisRadius, centerY + sin(ang) * genesisRadius); } } // ============================================================================================== // EXPERT MODE: CLOSED PHYSICAL MODEL MATRIX SOLVER // ============================================================================================== class MatrixSolver { int nodeCount = 0; float[][] adjacencyMatrix; float[][] laplacianMatrix; float[] degreeVector; MatrixSolver() { adjacencyMatrix = new float[12][12]; laplacianMatrix = new float[12][12]; degreeVector = new float[12]; } void computeAndDrawClosedModel(ArrayList atoms, Atom benchAtom) { ArrayList currentNodes = new ArrayList(); for (int i = 0; i < atoms.size(); i++) { Atom a = atoms.get(i); for (int k = 0; k < a.nodes.size(); k++) { if (currentNodes.size() < 12) currentNodes.add(a.nodes.get(k)); } } if (currentNodes.size() < 12) { for (int k = 0; k < benchAtom.nodes.size(); k++) { if (currentNodes.size() < 12) currentNodes.add(benchAtom.nodes.get(k)); } } nodeCount = currentNodes.size(); for (int i = 0; i < 12; i++) { degreeVector[i] = 0.0f; for (int j = 0; j < 12; j++) { adjacencyMatrix[i][j] = 0.0f; laplacianMatrix[i][j] = 0.0f; } } for (int i = 0; i < nodeCount; i++) { GraphNode n1 = currentNodes.get(i); for (int j = i + 1; j < nodeCount; j++) { GraphNode n2 = currentNodes.get(j); float d = dist(n1.relX, n1.relY, n2.relX, n2.relY); if (d < 120.0f) { float w = 1.0f / (1.0f + d * 0.05f); adjacencyMatrix[i][j] = w; adjacencyMatrix[j][i] = w; degreeVector[i] += w; degreeVector[j] += w; } } } for (int i = 0; i < nodeCount; i++) { for (int j = 0; j < nodeCount; j++) { if (i == j) { laplacianMatrix[i][j] = degreeVector[i]; } else { laplacianMatrix[i][j] = -adjacencyMatrix[i][j]; } } } float panelX = 305.0f; float panelY = height - 250.0f; float panelW = width - 315.0f; float panelH = 120.0f; fill(12, 16, 24, 240); stroke(0, 220, 255); strokeWeight(1.5f); rect(panelX, panelY, panelW, panelH, 8); fill(0, 220, 255); textSize(11); textAlign(LEFT, TOP); text("EXPERTENMODUS: CLOSED GRAPH LAPLACIAN MODEL L_Gamma = D - A", panelX + 12, panelY + 8); fill(200); textSize(9); text("Eigenvalue Lambda_0 = 1.618033 | Lattice Constant Epsilon_0 = 0.28 nm", panelX + 12, panelY + 26); text("Field EQ: L_Gamma * Psi_ij - Lambda_0 * gamma_ij = (8*pi*G / c^4) * I_ij", panelX + 12, panelY + 40); stroke(40, 60, 80); fill(8, 12, 18); rect(panelX + 330, panelY + 8, 240, 104, 4); fill(0, 255, 180); textSize(9); text("Laplacian Submatrix [L_ij] (6x6):", panelX + 335, panelY + 12); fill(200); int showDim = min(nodeCount, 6); for (int r = 0; r < showDim; r++) { String rowStr = ""; for (int c = 0; c < showDim; c++) { float val = laplacianMatrix[r][c]; rowStr += (val >= 0 ? " " : "") + nf(val, 1, 1) + " "; } text(rowStr, panelX + 335, panelY + 25 + r * 13); } fill(8, 12, 18); rect(panelX + 580, panelY + 8, panelW - 590, 104, 4); fill(255, 180, 0); textSize(9); text("ZEC Constraint Verification:", panelX + 585, panelY + 12); fill(0, 255, 180); text("Tr(rho_0 * H_hat) = 0.000000 eV", panelX + 585, panelY + 28); fill(200); text("Vacuum Expectation: EXACT ZERO", panelX + 585, panelY + 44); text("SU(3) Quark Sea Density: 0.12", panelX + 585, panelY + 60); text("Color Phase Angle: 120.0 deg", panelX + 585, panelY + 76); fill(0, 220, 255); text("P_decay(dt) ~ (dt / tau_0)^2 -> 0", panelX + 585, panelY + 92); } } // ============================================================================================== // ENTITY MODULE CLASSES // ============================================================================================== class VisualEffect { float x, y; int type; float radius = 5.0f; float maxRadius = 40.0f; int life = 255; boolean isDead = false; VisualEffect(float x, float y, int type) { this.x = x; this.y = y; this.type = type; if (type == 0) maxRadius = 60.0f; if (type == 1) maxRadius = 35.0f; if (type == 2) maxRadius = 25.0f; } void update() { radius += 2.5f; life -= 12; if (life <= 0 || radius >= maxRadius) isDead = true; } void display() { pushMatrix(); translate(x, y); noFill(); if (type == 0) { stroke(255, 200, 0, life); strokeWeight(3); ellipse(0, 0, radius * 2, radius * 2); } else if (type == 1) { stroke(0, 255, 255, life); strokeWeight(2.5f); ellipse(0, 0, radius * 2, radius * 2); fill(255, 255, 255, life * 0.5f); ellipse(0, 0, radius, radius); } else if (type == 2) { stroke(255, 100, 100, life); strokeWeight(2); ellipse(0, 0, radius * 1.5f, radius * 1.5f); } else if (type == 3) { stroke(0, 180, 255, life); strokeWeight(1.5f); ellipse(0, 0, radius * 2, radius * 2); } popMatrix(); } } class HexPoint { float baseX, baseY, currX, currY; HexPoint(float x, float y) { this.baseX = x; this.baseY = y; this.currX = x; this.currY = y; } } class CounterState { float x, y, energy; int life = 180; CounterState(float x, float y, float energy) { this.x = x; this.y = y; this.energy = energy; } void display() { stroke(255, 123, 114, life); strokeWeight(1.5f); fill(255, 123, 114, life * 0.2f); ellipse(x, y, 20, 20); fill(255, 123, 114, life); textAlign(CENTER, CENTER); textSize(9); text("-E", x, y); } } class Projectile { float x, y, vx, vy; int typeIndex; int life = 220; boolean isDead = false; Projectile(float x, float y, float angle, float speed, int typeIndex) { this.x = x; this.y = y; this.vx = cos(angle) * speed; this.vy = sin(angle) * speed; this.typeIndex = typeIndex; } void update() { x += vx; y += vy; life--; if (life <= 0) isDead = true; } void display() { pushMatrix(); translate(x, y); if (typeIndex == 0) { stroke(255, 220, 0, life); strokeWeight(2); fill(255, 100, 200, life); ellipse(0, 0, 14, 14); } else if (typeIndex == 1) { stroke(0, 180, 255, life); strokeWeight(2); fill(40, 140, 255, life); ellipse(0, 0, 12, 12); } else if (typeIndex == 3) { stroke(255, 200, 0, life); strokeWeight(2); fill(220, 50, 50, life); ellipse(0, 0, 22, 22); } else if (typeIndex == 4) { stroke(0, 255, 255, life); strokeWeight(2.5f); line(0, 0, -vx * 4, -vy * 4); } else if (particleCategory[typeIndex].equals("BOSON")) { stroke(255, 255, 100, life); strokeWeight(1.5f); fill(255, 255, 0, life * 0.6f); ellipse(0, 0, 10, 10); } else { stroke(210, 100, 255, life); strokeWeight(2); fill(160, 50, 220, life); ellipse(0, 0, 16, 16); } fill(255, life); textAlign(CENTER, CENTER); textSize(8); text(particleNames[typeIndex].substring(0, min(3, particleNames[typeIndex].length())), 0, 0); popMatrix(); } } // ============================================================================================== // ATOM SUBSYSTEM CLASS // ============================================================================================== class Atom { float x, y, vx, vy; boolean isWorkbench; boolean isDestroyed = false; boolean hasFusionPermit = false; ArrayList nodes; int protons, neutrons, electrons; float bindingEnergy = 0.0f; int decayTimer = 0; boolean isUnstable = false; Atom(float x, float y, boolean isWorkbench) { this.x = x; this.y = y; this.isWorkbench = isWorkbench; nodes = new ArrayList(); vx = 0; vy = 0; protons = 0; neutrons = 0; electrons = 0; } void addParticle(int type, int mode) { float posE = 938.27f; if (type == 3) posE = 0.511f; float rx = 0, ry = 0; if (mode == 1) { if (type == 3) rx = random(-15, 15) + 40; else rx = random(-15, 15) + 80; ry = random(-15, 15); } else { if (type == 3) { float angle = random(TWO_PI); rx = cos(angle) * 60.0f; ry = sin(angle) * 60.0f; } else { rx = random(-18, 18); ry = random(-18, 18); } } GraphNode node = new GraphNode(rx, ry, type, posE); if (type == 3) { node.currentShell = 1; node.isFreeParticle = !isElectronShellActive; } nodes.add(node); if (type == 1) protons++; if (type == 2) neutrons++; if (type == 3) electrons++; calculateBindingEnergy(); checkStability(); } void mergeWith(Atom other) { for (int i = 0; i < other.nodes.size(); i++) { GraphNode n = other.nodes.get(i); n.relX = random(-20, 20); n.relY = random(-20, 20); nodes.add(n); } protons += other.protons; neutrons += other.neutrons; electrons += other.electrons; vx = (vx + other.vx) * 0.5f; vy = (vy + other.vy) * 0.5f; calculateBindingEnergy(); checkStability(); } void updateQuantumJumps() { float nucX = getNucleusCenterX(); float nucY = getNucleusCenterY(); if (nodes.size() > 0) { for (int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); if (n.type == 1 || n.type == 2) { n.relX = lerp(n.relX, n.relX - nucX, 0.15f) + random(-0.1f, 0.1f); n.relY = lerp(n.relY, n.relY - nucY, 0.15f) + random(-0.1f, 0.1f); } } } nucX = getNucleusCenterX(); nucY = getNucleusCenterY(); float totalElX = 0.0f; float totalElY = 0.0f; int elCount = 0; for (int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); if (n.type == 3) { if (isElectronShellActive) { n.isFreeParticle = false; } if (!n.isFreeParticle) { if (random(1.0f) < 0.006f) { int oldShell = n.currentShell; n.currentShell = (int)random(1, min(4, max(2, protons))); if (oldShell != n.currentShell) { float newRadius = 50.0f + (n.currentShell - 1) * 25.0f; float angle = random(TWO_PI); n.relX = nucX + cos(angle) * newRadius; n.relY = nucY + sin(angle) * newRadius; } } else { float dx = n.relX - nucX; float dy = n.relY - nucY; float angle = atan2(dy, dx) + 0.04f; float r = 50.0f + (n.currentShell - 1) * 25.0f; n.relX = nucX + cos(angle) * r; n.relY = nucY + sin(angle) * r; totalElX += cos(angle) * r; totalElY += sin(angle) * r; elCount++; } } } } if (elCount > 0 && protons > 0) { float massRatio = 0.0015f / (protons + neutrons); float wobbleX = -totalElX * massRatio; float wobbleY = -totalElY * massRatio; for (int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); if (n.type == 1 || n.type == 2) { n.relX += wobbleX; n.relY += wobbleY; } } } } float getNucleusCenterX() { float sumX = 0; int count = 0; for (int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); if (n.type == 1 || n.type == 2) { sumX += n.relX; count++; } } return count > 0 ? sumX / (float)count : 0.0f; } float getNucleusCenterY() { float sumY = 0; int count = 0; for (int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); if (n.type == 1 || n.type == 2) { sumY += n.relY; count++; } } return count > 0 ? sumY / (float)count : 0.0f; } void calculateBindingEnergy() { if (isExpertModeActive) { bindingEnergy = -calcBetheWeizsaecker(protons, neutrons); // in MeV } else { float elDiv = electrons > 0 ? (float)electrons : 1.0f; bindingEnergy = protons > 0 ? -13.6f * (protons * protons) / elDiv : 0.0f; // in eV } } void checkStability() { if (protons > 0) { float ratio = (float)neutrons / (float)protons; isUnstable = (protons >= 2 && ratio < 0.5f) || ratio > 2.3f || protons > 10; } else { isUnstable = neutrons > 0; } } void checkDecay() { boolean isObserved = (dist(mouseX, mouseY, x, y) < 40.0f); if (isUnstable && !isWorkbench && isNuclearProcessesActive && !isObserved) { decayTimer++; if (decayTimer > 150) { isDestroyed = true; if (protons == 2 && neutrons == 0) { Atom h1 = new Atom(x - 15, y, false); h1.addParticle(1, 0); h1.vx = vx - random(1.5f, 3.0f); h1.vy = vy + random(-1.0f, 1.0f); activeAtoms.add(h1); Atom h2 = new Atom(x + 15, y, false); h2.addParticle(1, 0); h2.vx = vx + random(1.5f, 3.0f); h2.vy = vy + random(-1.0f, 1.0f); activeAtoms.add(h2); activeCounterStates.add(new CounterState(x, y, -0.511f)); } else if (protons == 0 && neutrons > 0) { Atom pAtom = new Atom(x, y, false); pAtom.addParticle(1, 0); activeAtoms.add(pAtom); activeProjectiles.add(new Projectile(x, y, random(TWO_PI), 5.0f, 1)); activeProjectiles.add(new Projectile(x, y, random(TWO_PI), 5.0f, 2)); } else { for(int k = 0; k < 3; k++) activeProjectiles.add(new Projectile(x, y, random(TWO_PI), 4.0f, 0)); } } } } void updateGravitationalPhysics(float cx, float cy, float gConst) { if (!isWorkbench) { float dx = cx - x, dy = cy - y; float d = sqrt(dx * dx + dy * dy); if (d > 10.0f) { float force = (gConst * (protons + neutrons + 2) * 18.0f) / (d * d); vx += (dx / d) * force; vy += (dy / d) * force; } vx *= 0.994f; vy *= 0.994f; x += vx; y += vy; if (x < 330 || x > width - 30) vx *= -0.8f; if (y < 30 || y > height - 160) vy *= -0.8f; } } void display() { pushMatrix(); translate(x, y); if (hasFusionPermit) { float pPulse = 40.0f + sin(frameCount * 0.15f) * 8.0f; stroke(255, 200, 0, 200); strokeWeight(2.5f); noFill(); ellipse(0, 0, pPulse, pPulse); fill(255, 200, 0); textSize(10); textAlign(CENTER); text("PERMIT", 0, -30); } drawOrbitals(); for (int i = 0; i < nodes.size(); i++) { GraphNode n1 = nodes.get(i); for (int j = i + 1; j < nodes.size(); j++) { GraphNode n2 = nodes.get(j); if (n1.type != 3 && n2.type != 3) { float dNodes = dist(n1.relX, n1.relY, n2.relX, n2.relY); if (dNodes > 45.0f && dNodes < 110.0f) { stroke(0, 255, 180, 120); strokeWeight(1.8f); line(n1.relX, n1.relY, n2.relX, n2.relY); } } } } for (int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); n.display(); } fill(255, 200); textAlign(CENTER); textSize(11); text(getElementName(), 0, 75); int energyCol = getEnergyColor(map(abs(bindingEnergy), 0.0f, 100.0f, 1.0f, 10.0f), 220.0f); fill(energyCol); String unit = isExpertModeActive ? " MeV" : " eV"; text("E_bind: " + nf(bindingEnergy, 1, 1) + unit, 0, 90); if (dist(mouseX, mouseY, x, y) < 40.0f && isUnstable) { fill(0, 220, 255); textSize(10); text("[MESSUNG AKTIV - ZENO-EFFEKT]", 0, -75); } else if (isUnstable && (frameCount / 45) % 2 == 0) { fill(255, 50, 50); textSize(12); text("KERN INSTABIL", 0, -75); } popMatrix(); } boolean isMolecule() { for(int i = 0; i < nodes.size(); i++) { GraphNode n = nodes.get(i); if(n.type != 3 && dist(0, 0, n.relX, n.relY) > 35.0f) return true; } return false; } void drawOrbitals() { float nucX = getNucleusCenterX(); float nucY = getNucleusCenterY(); noFill(); strokeWeight(1); if (electrons > 0) { stroke(0, 180, 255, 60); ellipse(nucX, nucY, 120, 120); } if (electrons > 2) { stroke(0, 180, 255, 40); ellipse(nucX, nucY, 180, 180); } if (electrons > 10 || isMolecule()) { stroke(0, 255, 180, 30); ellipse(nucX, nucY, 240, 240); } } String getElementName() { if (protons == 0) return "Subatomarer Cluster"; String base = "Wasserstoff (H)"; if (protons == 1 && neutrons == 1) base = "Deuterium (2H)"; else if (protons == 1 && neutrons == 2) base = "Tritium (3H)"; else if (protons == 2 && neutrons == 0) base = "Diproton (2He)"; else if (protons == 2 && neutrons == 1) base = "Helium-3 (3He)"; else if (protons == 2 && neutrons == 2) base = "Helium-4 (4He)"; else if (protons == 3) base = "Lithium (Li)"; else if (protons == 4) base = "Beryllium (Be)"; else if (protons == 5) base = "Bor (B)"; else if (protons == 6) base = "Kohlenstoff (C)"; else if (protons > 6) base = "Element Z=" + protons; return isMolecule() ? base + " - Molekuel" : base; } } class GraphNode { float relX, relY; int type; float energy; int currentShell = 1; boolean isFreeParticle = false; float seaQuarkDensity = 0.12f; float topologicalMassScale = 1.0f; int valanceQuarkUpCount = 2; int valanceQuarkDownCount = 1; GraphNode(float relX, float relY, int type, float energy) { this.relX = relX; this.relY = relY; this.type = type; this.energy = energy; if (type == 2) { valanceQuarkUpCount = 1; valanceQuarkDownCount = 2; } } void display() { pushMatrix(); translate(relX, relY); if (type == 1 || type == 2) { if (type == 1) fill(220, 50, 50, 100); else fill(140, 150, 160, 100); stroke(255, 100); strokeWeight(1); ellipse(0, 0, 36, 36); stroke(255, 255, 0, 180); strokeWeight(1); float q1x = sin(0) * 8.0f, q1y = cos(0) * 8.0f; float q2x = sin(TWO_PI / 3.0f) * 8.0f, q2y = cos(TWO_PI / 3.0f) * 8.0f; float q3x = sin(2 * TWO_PI / 3.0f) * 8.0f, q3y = cos(2 * TWO_PI / 3.0f) * 8.0f; line(q1x, q1y, q2x, q2y); line(q2x, q2y, q3x, q3y); line(q3x, q3y, q1x, q1y); noStroke(); fill(255, 200, 0); ellipse(q1x, q1y, 7, 7); ellipse(q2x, q2y, 7, 7); if (type == 1) fill(255, 200, 0); else fill(0, 220, 255); ellipse(q3x, q3y, 7, 7); } else if (type == 3) { fill(40, 140, 255); noStroke(); ellipse(0, 0, 12, 12); stroke(0, 180, 255, 150); noFill(); ellipse(0, 0, 18, 18); } popMatrix(); } }