Reference: components

Spatial stock

Updated 3 November 2026 · 2 min read

A spatial stock is a stock spread along a line and cut into cells that pass it to their neighbours. It solves a one-dimensional diffusion equation, a partial differential equation, alongside the rest of the model.

The equation#

For the value u at position x and time t:

The diffusion term spreads the stock from where there is more of it to where there is less; the source adds or removes it in each cell. The builder cuts the line into equal cells and writes one equation per cell, so the solver integrates them with everything else in the model.

Settings#

SettingWhat it is
CellsHow many pieces the line is cut into: 3 to 60.
Length, Length unitHow long the line is.
Diffusion DHow fast it spreads, in length² per time unit. A formula that may use t and constants.
SourceWhat is added in each cell per time unit. A formula that may use u (the cell’s own value), x (its position) and the rest of the model.
Starting profileThe value along the line at the start: a formula in x, like Exp(-50 * Pow(x - 0.5, 2)) for a bump in the middle.
Left end, Right endClosed, so nothing crosses it, or Held at a value, like a rod with one end in ice.

Reading it#

The panel shows the profile along the line at the time on the time bar, and a heat map of the whole run: position across, time down. Elsewhere in the model the spatial stock’s name means its average along the line, so formulas can use it like any stock.

Choosing the number of cells#

More cells give a smoother, more accurate answer and a slower run. Twenty is a sound start. Double it and run again: if the answer barely changes, you had enough. Very many cells with fast diffusion make the model stiff; a stiff solver helps.

Use it for#

Heat along a rod, a pollutant carried down a river, a drug diffusing through tissue, moisture moving through a wall.