How a Flame Simulator Works

After reading this you can explain how a rising sheet of hot gas is turned into a flickering flame on a grid, predict how fuel, cooling, wind and turbulence reshape it, and reproduce the demo frame by hand.

A real flame is hot gas rising. It has no solid parts. What you see is glowing soot and gas moving upward because it is less dense than the cool air around it. This simulation copies that idea with a single number stored at every point of a grid: temperature. Feed heat in at the bottom, push it upward each frame, let it spread sideways, and drain it away. Colour the temperature with a blackbody palette and the field looks like fire.

The hook: a candle flame is not steady. It flickers about 10 times per second because buoyant hot gas is unstable and keeps breaking into rising puffs. The simulation reproduces that flicker not by physics alone but by carving the field with a scrolling noise map, which splits the sheet of heat into separate tongues. Watch one tongue detach, rise, and fade. That is the model working exactly as designed.

What the model is and what it is not

This is a temperature field on a two-dimensional grid, updated once per frame by simple local rules. It is a toy in the honest sense. It does not solve the Navier-Stokes equations for the air, it does not track oxygen or fuel molecules, and it does not compute combustion chemistry. There is no pressure, no vorticity solver, no radiative transfer.

What it does capture is the visual grammar of fire: heat rises, heat spreads, heat dies, and the whole thing flickers. Those four behaviours are enough to fool your eye. The value at a cell is a scalar you can read as "how hot, from 0 to 1", and the color you see is a direct lookup from that scalar.

Real combustion has structure this model omits. The blue at a candle's base is chemiluminescence from CH and C₂ radicals, not thermal glow, so no blackbody palette can produce it from temperature alone. Treat the output as an animation that behaves like fire, not as a measurement of one.

When to reach for it

Use this when you want to understand advection, diffusion and buoyancy as coupled operations on a field, or when you want a controllable fire animation for a project. It is a clean example of how a few local rules produce organic-looking global motion. The flicker in particular is a lesson: order (a smooth rising column) plus noise (the cooling carve) gives you structure that neither would produce alone.

Do not use it to predict flame height for a given fuel flow, to estimate temperatures in Celsius, or to model how a fire spreads through a room. The grid units are arbitrary, the timestep is one frame, and the constants are tuned for looks, not for matching a burner. If you want quantitative combustion, this is the wrong tool.

The update rule

Let T(x, y) be the temperature at grid cell (x, y), scaled so 0 is cold and 1 is white-hot. Each frame runs four steps in order.

First, injection along the burner at the bottom row. The burner strength flickers with slow noise:

T(x, y_0) \mathrel{+}= F \cdot \big(0.6 + 0.4 \, n(x, t)\big)

Here F is the fuel setting, y_0 is the bottom row, and n(x, t) is low-frequency noise in [0, 1] that drifts with time t. The 0.6 is a steady floor; the 0.4 is the flicker amplitude.

Second, advection: move each cell's heat upward, and sideways by the wind. Reading from the source cell below and upwind:

T'(x, y) = T\big(x - w, \; y + 1\big)

Here w is the wind in cells per frame, and y + 1 is one row down, so heat from below rises into (x, y). Non-integer shifts use linear interpolation between neighbours.

Third, turbulent sideways spread. Blend each cell with its left and right neighbours, with a jitter set by turbulence \tau:

T''(x, y) = (1 - s)\,T'(x, y) + \tfrac{s}{2}\big(T'(x-1, y) + T'(x+1, y)\big)

The spread fraction s grows with \tau and is perturbed cell by cell so the diffusion is uneven, which roughens the edges.

Fourth, cooling through a scrolling noise map c(x, y, t):

T_{\text{new}}(x, y) = \max\!\big(0, \; T''(x, y) - C \cdot c(x, y, t)\big)

Here C is the cooling setting and c is a noise field in [0, 1] that scrolls upward each frame. Where c is high, heat drains fast, cutting a dark gap. That carving is what breaks the column into tongues.

A worked example from the demo defaults

Following one cell for four frames

The demo button uses field defaults. Take fuel F = 0.9, cooling C = 0.12, wind w = 0 and turbulence spread s = 0.2. Track a single column of cells straight above one burner point, and assume the noise terms sit at their mid values (n = 0.5, c = 0.5) so you can check the arithmetic.

  1. Injection at the burner: T = 0.9 \times (0.6 + 0.4 \times 0.5) = 0.9 \times 0.8 = 0.72.
  2. Frame 1, one row up: advection lifts 0.72 into the cell. With neighbours also near 0.72, the turbulent blend leaves it at 0.72. Cooling subtracts 0.12 \times 0.5 = 0.06, giving 0.66.
  3. Frame 2, two rows up: the 0.66 rises, blends flat, then loses 0.06 to reach 0.60.
  4. Each further row up subtracts another 0.06: 0.54, 0.48, 0.42, and so on.

The heat falls by 0.06 per row. Starting from 0.72 it reaches 0 after about 12 rows. That is the flame height in this simplified column: raise fuel and it climbs, raise cooling and it shrinks.

The chart below plots that decay. Each step is a linear drop of 0.06, because with mid-value noise the cooling is constant. In the live sim the noise varies, so real tongues end at ragged heights instead of a clean line.

A straight decline from 0.72 to 0 over 12 rows, one 0.06 step per row, giving the idealized flame height at the demo defaults.

Why the balance of fuel and cooling sets the height

The height where temperature hits 0 follows from the two constants directly. Injection sets the top of the column at F \times 0.8 for mid noise. Cooling removes C \times 0.5 per row. So the number of rows before the heat vanishes is roughly:

H \approx \frac{0.8 \, F}{0.5 \, C}

With the demo values, H \approx (0.8 \times 0.9) / (0.5 \times 0.12) = 0.72 / 0.06 = 12 rows, matching the worked example. Double the fuel to 1.8 (not possible in the tool, but useful for the ratio) and the height doubles. Double the cooling to 0.24 and the height halves to 6 rows. The flame responds to the ratio of fuel to cooling, not to either alone.

With fuel 0.9 and cooling 0.12 the idealized flame reaches about 12 rows. Raising fuel to 1.2 lifts it to about 16 rows; raising cooling to 0.24 drops it to about 6 rows. Height scales as (0.8 x fuel) divided by (0.5 x cooling).

Reading the flame you see

The palette maps temperature to color through a blackbody ramp: black at 0, deep red near 0.2, orange near 0.5, yellow near 0.75, white-hot near 1.0. So color is a thermometer. A yellow tongue is hotter than a red one, and a white core is the hottest part.

Read the shape as a record of the four steps. Vertical stretch is advection. Sideways lean is wind. Ragged edges are turbulent spread. Dark gaps splitting the tongues are the cooling carve. Detached embers are cells whose heat survived after the column below them cooled, then drifted up with the wind.

Tongue
A connected strand of hot cells that the cooling map has separated from its neighbours.
Ember
A small hot cell that detaches from the main body and rises independently, seeded occasionally near the top of the flame.
Bloom
A soft glow spread around bright cells in the render, purely a display effect that does not change the temperature field.

Common mistakes

Turning cooling to zero does not give a taller flame; it gives a solid rising slab with no flicker. The carve that splits the column into tongues is the cooling noise. Without it the whole grid slowly fills with heat and the fire stops looking like fire.

A second mistake is pushing wind so high that the flame lies flat and thins to nothing. Each frame the advection reads from a cell w columns upwind. When w exceeds one cell per frame, heat skips past cells before it can rise, so the column shears apart. Small wind bends the flame; large wind erases it.

A third mistake is expecting the colors to mean real temperatures. The white-hot core is temperature 1.0 in grid units, an arbitrary ceiling. Do not read it as any number of degrees. A candle's yellow soot glow sits near 1,000 to 1,400 °C in reality, but this model never computes a physical temperature, so the mapping is purely aesthetic.

Related simulations

If the idea of a field updated by local rules interests you, three neighbours here run on the same principle with different physics. Reaction-Diffusion Patterns uses two chemicals that diffuse and react to grow spots and stripes, the closest mathematical cousin to the advect-diffuse-cool loop above. Belousov-Zhabotinsky Reaction shows a real oscillating chemistry that organizes into spiral waves. For a particle view of heat instead of a field view, Molecular Dynamics: Phases of Matter cools individual atoms from gas to crystal. And Crystal Growth Simulator builds branching structure from wandering particles, the opposite of dissipating heat.

Frequently asked questions

Why does the flame flicker on its own?

Two noise sources drive it. The burner strength wobbles with slow noise, and the cooling map scrolls upward frame by frame. The scrolling carve is the main cause: it cuts moving dark gaps through the column, so the visible tongues appear and vanish. A real candle flickers near 10 Hz for a related reason, buoyant instability, but the simulation gets its flicker from the noise, not from fluid physics.

What does turbulence actually change?

It raises the sideways spread fraction s and adds cell-by-cell jitter to that spread and to the flicker. Low turbulence gives a smooth, near-symmetric flame. High turbulence roughens the edges and makes each frame differ more from the last, so the fire looks wilder without getting taller.

Can I read a temperature in degrees off the colors?

No. The field runs from 0 to 1 in arbitrary grid units, and the blackbody palette is a fixed lookup from that range. The colors match the sequence real hot objects follow (red, orange, yellow, white) but no Celsius or Kelvin value is computed anywhere in the model.

Why do embers drift up instead of falling?

Because the model has no gravity acting on particles, only buoyancy acting on heat. Embers are hot cells, and hot means "rising" in every rule here, so they follow the advection upward and lean with the wind. Real embers cool and fall; these do not, which is one honest limit of the toy.

How do I make a short, steady flame like a pilot light?

Lower the fuel and raise the cooling so the ratio 0.8F / 0.5C stays small, then keep turbulence low so the edges stay smooth. For example, fuel around 0.4 and cooling around 0.2 give a height near 3.2 rows, a stubby flame that barely flickers.