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#

  1. 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.

  2. 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.

    1. 1The models you can put in: templates, worked examples and your own.
    2. 2The name it gets here. Every name inside starts with it.
    3. 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, NorthInfected and NorthRecovered. Its constants came with it, with the same values.

  3. 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.

  4. 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.

  5. 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.

  6. Draw the Travel flow

    Click Flow, click North: Infected, then click South: Infected. Name the flow Travel, unit people/day, with the formula

    TravelRate * NorthInfected
    
    1. 1North: the outbreak example, unchanged.
    2. 2South: the same model, starting with nobody ill.
    3. 3Travel moves ill people from North to South.
  7. 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
05001K1.5K2K2.5K020406080100120daypeople ill
Show the numbers
dayNorth, illSouth, ill
0100
10762
2051724
301862240
4019831370
5010062342
604011411
70148587
8054219
901979
100728
110210
12014
People ill in each town, travel rate 0.002 a day. Hover to compare the two on any day.

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.