🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.sci.physik
Article #20

Re: Leuchtdiode

#20
From: Stefan Ram
Date: Mon, 12 Oct 2026 14:03
295 lines
9928 bytes
ram@zedat.fu-berlin.de (Stefan Ram) schrieb oder zitierte:
>|Eine LED besteht aus einem Halbleiterkristall, der in zwei Bereiche
>|aufgeteilt ist: den n-leitenden Bereich (dort gibt es viele frei
>|bewegliche, negativ geladene Elektronen) und den p-leitenden Bereich
>|(dort fehlen Elektronen, was man als positive /Löcher/ oder
>|/Defektelektronen/ bezeichnet).

  Hier eine Animation. Um sie zu sehen, die Animation als 
  "LED.html" abspeichern und in einem nicht zu alten Browser
  öffnen. Dann die gewünschte Spannung einstellen.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="US-ASCII">
  <title>LED Simulation</title>
  <style>
    body {
      background: #111;
      color: #eee;
      font-family: sans-serif;
      margin: 20px;
      text-align: center;
    }
    #controls {
      margin-bottom: 15px;
    }
    input[type=range] {
      width: 250px;
    }
    canvas {
      border: 1px solid #444;
      background: #000;
      display: block;
      margin: 0 auto;
    }
    .info {
      font-size: 14px;
      color: #aaa;
      margin-top: 10px;
    }
  </style>
</head>
<body>

  <h2>LED P-N Junction Simulation</h2>

  <div id="controls">
    <label for="vRange">Voltage (U): </label>
    <input type="range" id="vRange" min="0" max="3" step="0.05"
           value="1.0">
    <span id="vVal">1.00 V</span>
  </div>

  <canvas id="ledCanvas" width="600" height="300"></canvas>

  <div class="info">
    Left: N-Zone (Electrons) | Mid: Junction | Right: P-Zone (Holes)
    <br>
    Photons are emitted when electrons recombine with holes.
  </div>

  <script>
    // Configuration and constants
    const cvs = document.getElementById("ledCanvas");
    const ctx = cvs.getContext("2d");
    const vRange = document.getElementById("vRange");
    const vVal = document.getElementById("vVal");

    const W = cvs.width;
    const H = cvs.height;
    const MID = W / 2;
    const J_WIDTH = 100; // Junction zone width

    let voltage = 1.0;
    let electrons = [];
    let holes = [];
    let photons = [];

    // Initialize particles
    function init() {
      // Create N-zone electrons on the left
      for (let i = 0; i < 40; i++) {
        electrons.push({
          x: Math.random() * (MID - J_WIDTH / 2),
          y: Math.random() * H,
          vx: 0,
          vy: 0
        });
      }
      // Create P-zone holes on the right
      for (let i = 0; i < 30; i++) {
        holes.push({
          x: MID + J_WIDTH / 2 + Math.random() * (MID - J_WIDTH / 2),
          y: Math.random() * H,
          active: true
        });
      }
    }

    vRange.addEventListener("input", (e) => {
      voltage = parseFloat(e.target.value);
      vVal.textContent = voltage.toFixed(2) + " V";
    });

    // Update positions and handle physics
    function update() {
      // Potential barrier width decreases as voltage increases
      // High barrier at U=0, low barrier at U=2.5+
      let barrierHeight = Math.max(0, 2.5 - voltage) * 2.0;

      electrons.forEach(e => {
        // 1. Thermal energy (random jitter/wind)
        let therm = 0.4;
        e.vx += (Math.random() - 0.5) * therm;
        e.vy += (Math.random() - 0.5) * therm;

        // 2. Voltage drive (force towards the right)
        // More voltage = stronger drift push
        e.vx += voltage * 0.05;

        // 3. Potential barrier force in the junction zone
        if (e.x >= MID - J_WIDTH / 2 && e.x <= MID + J_WIDTH / 2) {
          // Barrier pushes electrons back to the left
          e.vx -= barrierHeight * 0.08;
        }

        // Apply friction/drag to maintain terminal speed
        e.vx *= 0.92;
        e.vy *= 0.92;

        // Move
        e.x += e.vx;
        e.y += e.vy;

        // Boundaries for N-zone wall or looping
        if (e.x < 5) { e.x = 5; e.vx *= -1; }
        if (e.y < 5 || e.y > H - 5) { e.vy *= -1; }

        // Wrap around if they pass the right side entirely
        if (e.x > W) {
          e.x = Math.random() * (MID - J_WIDTH / 2);
          e.y = Math.random() * H;
        }

        // 4. Check recombination with active holes
        if (e.x > MID - J_WIDTH / 2) {
          holes.forEach(h => {
            if (h.active) {
              let dx = e.x - h.x;
              let dy = e.y - h.y;
              let dist = Math.sqrt(dx * dx + dy * dy);
              if (dist < 12) {
                // Recombination event!
                h.active = false;

                // Determine energy and color
                // Base energy around 2.0 eV + thermal contribution
                let thermalBonus = Math.max(0, e.vx * 0.2);
                let totalEnergy = 1.8 + thermalBonus;

                let color = "#ff3333"; // Red default
                if (totalEnergy > 2.2) color = "#ffcc00"; // Orange/Yellow
                if (totalEnergy > 2.5) color = "#33ff33"; // Green

                // Spawn a photon
                photons.push({
                  x: h.x,
                  y: h.y,
                  r: 4,
                  maxR: 25,
                  color: color,
                  alpha: 1.0
                });

                // Reset electron to the left
                e.x = Math.random() * (MID - J_WIDTH / 2);
                e.y = Math.random() * H;
                e.vx = 0;

                // Respawn the hole after a delay
                setTimeout(() => { h.active = true; }, 1500);
              }
            }
          });
        }
      });

      // Update photons (expanding light circles)
      for (let i = photons.length - 1; i >= 0; i--) {
        let p = photons[i];
        p.r += 0.8;
        p.alpha -= 0.04;
        if (p.alpha <= 0) {
          photons.splice(i, 1);
        }
      }
    }

    // Render loop
    function draw() {
      ctx.clearRect(0, 0, W, H);

      // 1. Draw potential background gradient
      // N-zone (high energy electrons, high potential reference)
      // P-zone (low potential)
      let grad = ctx.createLinearGradient(0, 0, W, 0);

      // Calculate mid barrier color shifts dynamically with voltage
      let bIntensity = Math.floor(Math.max(0, 2.5 - voltage) * 20);

      grad.addColorStop(0, "#1a1a2e"); // N-zone background
      grad.addColorStop(
        (MID - J_WIDTH / 2) / W,
        "#1a1a2e"
      );
      grad.addColorStop(
        MID / W,
        "rgb(" + (26 + bIntensity) + ",26,46)"
      );
      grad.addColorStop(
        (MID + J_WIDTH / 2) / W,
        "#112211"
      );
      grad.addColorStop(1, "#112211"); // P-zone background

      ctx.fillStyle = grad;
      ctx.fillRect(0, 0, W, H);

      // Draw Zone dividers
      ctx.strokeStyle = "#333";
      ctx.lineWidth = 1;
      ctx.beginPath();
      ctx.moveTo(MID - J_WIDTH / 2, 0);
      ctx.lineTo(MID - J_WIDTH / 2, H);
      ctx.moveTo(MID + J_WIDTH / 2, 0);
      ctx.lineTo(MID + J_WIDTH / 2, H);
      ctx.stroke();

      // 2. Draw Holes (P-zone targets)
      holes.forEach(h => {
        if (h.active) {
          ctx.strokeStyle = "#44aa44";
          ctx.lineWidth = 2;
          ctx.beginPath();
          ctx.arc(h.x, h.y, 6, 0, Math.PI * 2);
          ctx.stroke();
          // Plus sign inside hole
          ctx.beginPath();
          ctx.moveTo(h.x - 3, h.y); ctx.lineTo(h.x + 3, h.y);
          ctx.moveTo(h.x, h.y - 3); ctx.lineTo(h.x, h.y + 3);
          ctx.stroke();
        }
      });

      // 3. Draw Electrons
      ctx.fillStyle = "#4488ff";
      electrons.forEach(e => {
        ctx.beginPath();
        ctx.arc(e.x, e.y, 4, 0, Math.PI * 2);
        ctx.fill();
      });

      // 4. Draw Photons (Flash of light)
      photons.forEach(p => {
        ctx.save();
        ctx.globalAlpha = p.alpha;
        ctx.strokeStyle = p.color;
        ctx.lineWidth = 3;
        ctx.beginPath();
        ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2);
        ctx.stroke();

        // Solid core
        ctx.fillStyle = p.color;
        ctx.beginPath();
        ctx.arc(p.x, p.y, p.r * 0.3, 0, Math.PI * 2);
        ctx.fill();
        ctx.restore();
      });
    }

    function loop() {
      update();
      draw();
      requestAnimationFrame(loop);
    }

    init();
    loop();
  </script>
</body>
</html>

Technical Details
Message-ID: <Anim-20261012150146@ram.dialup.fu-berlin.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!uni-berlin.de!not-for-mail
References: <6ACCD565.49D483C8@proton.me> <LED-20261012140823@ram.dialup.fu-berlin.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: de.sci.physik
Subject: Re: Leuchtdiode
Date: 12 Oct 2026 14:03:47 GMT
Organization: Stefan Ram
Lines: 295
Expires: 1 Sep 2027 11:59:58 GMT
Message-ID: <Anim-20261012150146@ram.dialup.fu-berlin.de>
References: <6ACCD565.49D483C8@proton.me> <LED-20261012140823@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de XunlwEjzqpKZYl0E6j36CA9U4Ry/9TA/ZNyy5apLfObClQ
Cancel-Lock: sha1:TwrFNLphwReHp7iVdohiO/Zgfss= sha256:qL0CMdP+QuObJyi91/K3+Kq2M7c7JPQZacMXa56wnKM=
X-Copyright: (C) Copyright 2026 Stefan Ram. All rights reserved.
	Distribution through any means other than regular usenet
	channels is forbidden. It is forbidden to publish this
	article in the Web, to change URIs of this article into links,
        and to transfer the body without this notice, but quotations
        of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
	services to mirror the article in the web. But the article may
	be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: de