From Quantum Double Slit · v2. Edit this definition in its source simulation.
Source
// A normalized incident Gaussian packet on a 192 x 160 lattice.
// Coordinates here match scene.json: x = position.x + 96, j = position.y + 80.
// Fixed-grid normalization, validated against the independent numerical reference.
use models { Wave };
let normalization = 37.27485898801376;
fn absorber(x: Int, j: Int) -> Float {
if x >= 152 {
let ramp = (x - 151) / 40.0;
return exp(-0.3 * ramp * ramp * 0.4 / 2.0);
}
let edge = max(0.0, max((16 - x) / 16.0, max((16 - j) / 16.0, (j - 143) / 16.0)));
return exp(-0.3 * edge * edge * 0.4 / 2.0);
}
fn aperture(x: Int, y: Float) -> Float {
if x < 56 || x >= 58 || abs(y - 14.0) < 4.0 || abs(y + 14.0) < 4.0 { return 1.0; }
return 0.0;
}
fn envelope(x: Int, y: Float) -> Float {
if x >= 56 { return 0.0; }
let dx = (x - 32) / 7.0;
let dy = y / 32.0;
return exp(-(dx * dx) / 4.0 - (dy * dy) / 4.0);
}
fn detector(x: Int) -> Float {
if x >= 152 { return 1.0; }
return 0.0;
}
place Wave in box([-96, -80, 0], [96, 80, 1]) {
let x = position.x + 96;
let j = position.y + 80;
let y = j - 79.5;
let packet = envelope(x, y);
set target.absorb = absorber(x, j);
set target.detector = detector(x);
set target.open = aperture(x, y);
set target.real = packet * cos(0.55 * x) / normalization;
set target.imag = packet * sin(0.55 * x) / normalization;
set target.xEven = 1.0 - (x % 2);
set target.yEven = 1.0 - (j % 2);
}
Building blocks
These exact versions are included when you reuse this artifact.