Reference: language and settings
Formulas
Updated 3 November 2026 · 2 min read
What a formula can contain, and what each part of a model is allowed to use.
The parts of a formula#
| Part | Examples |
|---|---|
| Numbers | 7, 0.35, 1.5e-6 |
| Names of stocks, constants and variables | Infected, ContactRate |
| Time | t |
| Operators | + - * /, and brackets ( ) |
| Functions | Exp, Log, Pow, Sqrt, Min, Max, Abs, Step |
| Your lookup tables | Effect(Crowding) |
A name in a formula is the label made into one word: Room temperature becomes RoomTemperature. The name is shown under the title in each block’s settings. Formulas are limited to 400 characters; past that, part of it wants to be a variable.
There is no ^ for powers: write Pow(x, 2). There is no if: see below.
Functions#
| Function | Gives | Example |
|---|---|---|
Exp(x) | e to the power x | Exp(-t / Tau) |
Log(x) | Natural logarithm | Log(Price / BasePrice) |
Pow(x, y) | x to the power y | Pow(Size, 0.75) |
Sqrt(x) | Square root | Sqrt(Area) |
Min(a, b) | The smaller | Min(Demand, Capacity) |
Max(a, b) | The larger | Max(0, Profit) |
Abs(x) | The size, without sign | Abs(Error) |
Step(x) | 1 when x is above 0, else 0 | Step(t - 10) |
Switching and limiting without if#
- From a time on:
Step(t - 10) * Vaccinationis 0 before time 10 and the full rate after. - For a window:
(Step(t - 10) - Step(t - 20)) * Campaignis on from 10 to 20. - Never below zero:
Max(0, Inflow - Outflow). - Never more than what is there:
Min(Orders, Inventory / ShippingTime). - A real rule with branches: a C# block.
What each part may use#
| In | May use |
|---|---|
| A stock’s starting value | Numbers and constants |
| A flow | t, stocks, constants, variables, tables, blocks |
| A variable | t, stocks, constants, other variables that don’t depend on it, tables, blocks |
| A nonlinear function or integral | All of a variable’s names, plus x, the unknown or the variable of integration |
| A spatial stock’s starting profile | x, the position, and constants |
| A spatial stock’s diffusion | t and constants |
| A spatial stock’s source | x, u (the cell’s own value), and the rest of the model |