Light in a Medium: Refraction and Slow Light Simulator

A free simulator of light moving through a medium: paint glass, water or any refractive index and watch a live wave slow down, bend (Snell's law), focus in a lens, reflect inside a fibre or curve through a mirage. Compare the wave with rays, draw mirror walls for a double slit, or try a gravity-lens analogue.

Drag on the picture to paint a medium
Under the pointern = 1.00light moves at 1.00 c
Wavelength there–shorter in a slow medium
Time0.0wave periods
Light source–

Medium to paint: refractive index
Light moves at in this medium. Higher index = slower light.
Brush size: Edges are softened a little, so you can also paint smooth gradients (a mirage or a lens of slowly changing index).
Wavelength in empty space: Measured in grid cells. Short waves bend more crisply; long waves spread out (diffraction).
Brightness: Only changes how the picture is drawn, not the physics.
Source
Beam direction:
Beam width:
Emission
Detail
Speed

Light in a medium: what you are looking at

Light does not always move at c. In glass, water or air it is slower, by a factor called the refractive index: speed = c / n. This simulator lets you paint a medium of any index onto a flat sheet of space and watch a light wave move through it. It solves the wave equation on a grid, one tiny time step after another, so everything you see (the bending, the focusing, the reflections, the interference fringes) comes out of that single rule and was not drawn by hand.

wave equation ∂²u/∂t² = (c/n)² ∇²u
Snell's law n₁ sin θ₁ = n₂ sin θ₂

Here u is the height of the wave at each point (orange crests, blue troughs). The only thing that changes from place to place is n. Where n is bigger the wave crawls, its crests bunch up (the wavelength shrinks by the same factor n) and a wave front that arrives at an angle gets turned, because one end of it slows down before the other. That turning is refraction, and Snell's law is its summary. Switch on Rays to draw the geometric-optics prediction (a ray bends by the same law, and curves smoothly through a changing index) on top of the wave to compare them.

Things to try

  • Glass slab: aim the beam at an angle and watch it bend towards the normal inside the glass, then back out. The wavelength inside is 1/1.5 of the one outside.
  • Total internal reflection: light inside glass that meets the surface at a shallow angle cannot escape (above about 42° for n = 1.5). This is how optical fibre works; see the Fibre scenario.
  • Lens: the thick middle of a lens delays the middle of the wave more than its edges, so a flat wave curls into a converging one and focuses.
  • Mirage: a smooth slope of index (no edges at all) bends a straight beam into a curve. Paint your own gradient with a large brush.
  • Double slit: draw walls with two gaps and watch the two new waves interfere.
  • Gravity-lens analogue: a heavy mass slows light nearby as seen from far away, and the optical analogue n = 1 + k/r bends passing waves towards it. Real gravitational lensing bends light twice as much, because space is curved too; this scenario shows only the "slow light" half. (A Black Hole page is planned.)

How accurate is it?

It is a teaching-grade simulator. The wave is a single number (a scalar wave), so there is no polarisation, and the index is the same for every colour (no rainbow from a prism). It is two-dimensional, the grid is coarse (a wave is only 8 to 32 cells long, so a few percent of numerical error in the wave speed is normal), and the edges of the picture absorb waves instead of reflecting them. The speed of light in empty space is the fastest speed in the picture, so the index cannot go below 1 (the "Medium" brush only slows light down) and stops at 4. Rays follow the bending exactly but know nothing about interference or diffraction, which is why waves and rays disagree where features are only a few wavelengths wide.

Things people ask

  • Why does a wave front bend when it enters glass? The part of the front that enters first slows down first, while the rest is still fast, so the front pivots, like a marching line that hits mud at an angle.
  • Does light really slow down in glass? The wave does: its crests travel at c/n. What happens at the level of photons and atoms is more subtle (the light is absorbed and re-emitted in a coherent way by the atoms), but the crest speed and the wavelength are exactly what is shown here.
  • Can the speed of light change in empty space? In general relativity the coordinate speed of light changes near a mass, which is what the gravity-lens analogue mimics. Locally, light always passes you at c.
  • Can I use this for homework or a demo? Yes. It is free, runs offline once loaded, and the Copy link button saves your scenario (paint-your-own media are not stored in the link).

Everything runs on your device; nothing is uploaded. Michelson-Morley Experiment Simulator · Fluid Simulator · Photoelectric Effect Simulator · More MES tools

Comments
Advertisement