Tutorials
Two towns, one outbreak
Updated 3 November 2026 · 4 min read
One town’s outbreak is a model you already have. Two towns joined by people travelling between them is the same model twice, plus one flow. In this tutorial you put the outbreak example inside a new model twice, start the second town with nobody ill, and connect them. The second outbreak follows the first, and how far behind depends on one number.
What you will build#
Two copies of the outbreak, called North and South, each in its own box with its own constants. North starts with 10 people ill, as in the example. South starts with none. A Travel flow carries a small share of North’s ill people to South each day, and that is the only way the disease can get there.
Nothing in either town’s model changes. That is the reason to build this way: you reuse a model you have already checked, instead of drawing six stocks and four flows again and hoping you copied every formula right.
Build it#
Start a new model that counts in days
Press New model. In Simulation, set Start to 0, End to 160 and Time unit to
day, to match the outbreak example. A submodel’s rates are read in the outer model’s time unit, so the two must agree.Put the outbreak in, as North
In the components list, under Advanced, click Submodel. The dialog lists templates, the worked examples, and your own models. Choose Outbreak in a town, change Name in this model to North, and press Add North.
- 1The models you can put in: templates, worked examples and your own.
- 2The name it gets here. Every name inside starts with it.
- 3Adds it in its own box.
The outbreak arrives in a box labelled North. Its stocks are now North: Susceptible, North: Infected and North: Recovered, and in formulas
NorthSusceptible,NorthInfectedandNorthRecovered. Its constants came with it, with the same values.Put it in again, as South
Click Submodel again, choose the outbreak again, name it South, and add it. A second box appears below the first.
Start South with nobody ill
Select the constant South: Infected on day 0. Its range starts at 1, so set Lowest to 0 first, then set the value to 0. South now has no outbreak of its own: run the model and its three stocks stay flat.
Add the travel rate
Place a Constant between the boxes. Name it Travel rate, unit
per day, value 0.002, and give it a range of 0 to 0.02. It is the share of North’s ill people who travel to South each day: 0.002 is one in five hundred.Draw the Travel flow
Click Flow, click North: Infected, then click South: Infected. Name the flow Travel, unit
people/day, with the formulaTravelRate * NorthInfected- 1North: the outbreak example, unchanged.
- 2South: the same model, starting with nobody ill.
- 3Travel moves ill people from North to South.
Run it
Press Run. North’s outbreak runs as before. South’s starts a couple of weeks later, once enough travellers have arrived to set it going.
Read the result#
- North, ill
- South, ill
Show the numbers
| day | North, ill | South, ill |
|---|---|---|
| 0 | 10 | 0 |
| 10 | 76 | 2 |
| 20 | 517 | 24 |
| 30 | 1862 | 240 |
| 40 | 1983 | 1370 |
| 50 | 1006 | 2342 |
| 60 | 401 | 1411 |
| 70 | 148 | 587 |
| 80 | 54 | 219 |
| 90 | 19 | 79 |
| 100 | 7 | 28 |
| 110 | 2 | 10 |
| 120 | 1 | 4 |
North peaks at 2,213 people on day 35. South peaks at 2,359 on day 49, two weeks later.
Two things here are not obvious, and both come from the one flow you drew. North’s peak is lower than the example’s 2,265 on its own, because some of its ill people leave. And South’s peak is the higher of the two, because South gets two sources of infection: its own cases, and a steady trickle of arrivals all through its outbreak.
Try this#
- Set Travel rate to 0. South stays clear. The only way in was the flow.
- Set it to 0.01, one in a hundred a day. South now peaks on day 42, a week earlier, at 2,597. More travel brings the second outbreak forward and makes it bigger. It doesn’t make it smaller.
- Lower South’s contact rate to 0.2, as if South took precautions. Its outbreak comes later and smaller, peaking at 574 on day 81, but it still comes. At 0.12 it never takes off: the most ill at once is 71, and 642 people catch it in all, nearly all in short chains that travellers start. The line between the two is 1/7, about 0.143. Below it, each ill person infects fewer than one other in the seven days they are ill, and every chain dies out.
- Make it a module. Open the outbreak example, tick Output on Infected and Input on Contact rate, and put it in with Module instead of Submodel. Each town then goes in folded, as one block showing only those two values. Make a model reusable as a module shows how.
What you learned#
You reused a model as a submodel, twice, and connected the copies with a flow. Names inside a submodel get its name in front, so two copies never clash. The module guide goes one step further: marking a model’s inputs and outputs so that it goes in as a single block with only those showing.
See also
- An oil field from pressure historyBuild a material balance from objects, match it to twelve pressure surveys, and forecast with wells.
- SubmodelA whole model inside this one, in its own box.
- Make a model reusable as a moduleMark inputs and outputs, then drop the model into others as a single block.
- Feedback loopsWhere behaviour comes from: loops that reinforce and loops that balance.