Double Slit
A wave packet passes through two openings and forms an interference pattern. A simplified quantum model showing probabilities, not individual particle hits.
Published
No video preview yet
Source
use "@hyle/maths";
use models { Wave };
// 56 x 40 x 22 genuine spatial cells, not a stack of independent 2D slices.
// hbar=m=dx=1; dt=0.4. Momentum kx=0.8. The wall is at world X=0,1.
// Two apertures: 4 cells wide, 8 high, with centers separated by 12 cells.
// Fixed-grid Gaussian normalization is checked independently in verify.py.
let normalization = 31.077314401341074;
fn absorber(x: Int, y: Float, z: Float) -> Float {
if x >= 36 {
let ramp = (x - 35) / 20.0;
return maths::exp(-0.65 * ramp * ramp * 0.4 / 2.0);
}
let edge = maths::maximum(0.0, maths::maximum((6 - x) / 6.0,
maths::maximum((maths::abs(y) - 11.5) / 8.0, (maths::abs(z) - 6.5) / 4.0)));
return maths::exp(-0.65 * edge * edge * 0.4 / 2.0);
}
fn aperture(x: Int, y: Float, z: Float) -> Float {
if x < 18 || x >= 20 { return 1.0; }
if (maths::abs(y - 6.0) < 2.0 || maths::abs(y + 6.0) < 2.0)
&& maths::abs(z) < 4.0 { return 1.0; }
return 0.0;
}
fn envelope(x: Int, y: Float, z: Float) -> Float {
if x >= 18 { return 0.0; }
let dx = (x - 9) / 2.5;
let dy = y / 9.0;
let dz = z / 2.8;
return maths::exp(-(dx * dx + dy * dy + dz * dz) / 4.0);
}
fn detector(x: Int) -> Float {
if x >= 36 { return 1.0; }
return 0.0;
}
place Wave in box([-18, -20, -11], [38, 20, 11]) {
let x = position.x + 18;
let j = position.y + 20;
let k = position.z + 11;
let y = position.y + 0.5;
let z = position.z + 0.5;
let packet = envelope(x, y, z) / normalization;
set target.psi = Complex { real: packet * maths::cos(0.8 * x), imag: packet * maths::sin(0.8 * x) };
set target.absorb = absorber(x, y, z);
set target.detector = detector(x);
set target.open = aperture(x, y, z);
set target.xEven = 1.0 - (x % 2);
set target.yEven = 1.0 - (j % 2);
set target.zEven = 1.0 - (k % 2);
}