Creating a Model with Assemblies

This is an example of the flow used to create a model with assemblies. There is a video that walks through the steps shown here. There is an additional video that walks through using the aging chain with productivity assembly as well as one that demonstrates model building in the suggest view without adding any assemblies.

In this example we will create a simple infectious disease spread model using assemblies. This is often called an SIR( for Susceptible, Infected, Recovered) model. The model we develop here varies slightly from the more traditional construction that explicitly calls out contacts and contacts with susceptible as separate converters, though it has the same behavior. Using assemblies, the formulation we will use is somewhat easier to conceptualize and understand as the distinction between contacts and infections, as well as their related units of measure, is something many struggle with. The analogous contact based model is shown at the end for comparison.

Set things up

  1. Start with an empty model (select New from the File Menu if you already have a model open).
  2. Open the assembly panel by selecting Open Assemblies Panel from the Window Menu.
  3. Select Suggest view () from the Mode Toolbar.
  4. Change the model so it runs from 0 to 100 days in the Model Settings Properties Panel

Find an appropriate assembly

We are looking for a process of infected people causing more infections by coming in contact and transmitting a disease. This is positive feedback, and the assembly that does just that is called compounding. You can scroll through the list of assemblies on the Assemblies Panel (it is under Flows) or type compounding into the search box to filter out other assemblies.

  1. Click on Compounding.
  2. In the example dropdown select Population.
  3. The example should look like this:
  4. Click on the Add to Model button.

Customize and add the assembly

In the Assembly Customization Dialog that comes up after you click on the add to model button above, change Stock to infected and Compounding fraction to infection rate (leave the Stock units as people):

Click on OK to add the assembly. The cursor will change to . Since the model is empty click roughly in the middle to place the assembly.

When the assembly is placed, you will be able to see its behavior.

Adjust Parameters

Infections can occur very rapidly. We want to change the infection rate from 0.01 per day (the assembly setting) to 0.5 per day. To do this right click on infection rate, move to the Suggest Equation menu item and then click 0.5 in the submenu.

Do the same thing to infected setting its value to 1 (it is a stock so this will set the initial value). The model has the same behavior, but if you hover over infected you will see a very big number:

Clearly that is not a reasonable number of infected people. The flow into this level must stop when there are no more susceptible people. To show this click on the stock tool in the Model Build Toolbar and place the stock on the cloud at the left. Depending on your settings for stock or non-negative stock you will see something like:

Use the dimensionless multiplier assembly

While this is more reasonable, the abrupt cutoff is not right. As the number of susceptible people goes down, it drops the number adding to infected. The dimensionless multiplier is an assembly that can be used to show this diminishing effect. Select it in the assembly panel and choose crowding as the example Than click on add to model and set action to infection rate, base to reference, characteristic to susceptible, action units as per day and characteristic units as person:

Then you add it to the model you will see two of the variable names are changed to prevent conflict.

Replace Variables

  1. Hold down the Ctrl/⌘ key and drag infection rate onto reference infection rate. A menu will appear:

    Select the first item.
  2. Hold down the Ctrl/⌘ key and drag susceptible onto susceptible 1. Again select the first item in the menu - replace.
  3. Hold down the Ctrl/⌘ key and drag infection rate 1 onto infection rate:

    This time select the second it - replace uses.
    . Again select the first item in the menu - replace uses.

Your model should look something like:

Define, Rename and rearrange

  1. Select the connector tool and drag from Infected to maximum susceptible.
  2. Select the connector tool and drag from Susceptible to maximum susceptible. A menu will appear

    Select Infected + Susceptible.
  3. Rename infection rate to reference infection rate.
  4. Rename infection rate 1 to infection rate.
  5. Rearrange the diagram to look nice. You should have something like:

Add in Recovered

  1. Select the flow (or biflow ) tool and drag from Infected to the right. Name the flow recovering.
  2. Select the non-negative stock or stock tool and click on the cloud at the right. Name the stock Recovered.
  3. Right click on Recovered and set the value to 0.
  4. Select the converter tool and click below the flow recovering. Name the converter disease duration.
  5. Right click on disease duration and set its value to 5.
  6. Select the connector tool and drag from disease duration to recovering.
  7. Select the connector tool and drag from Infected to recovering. In the menu that appears select Infected/disease_duration.

Your model should look like:

Experiment

That's it - you have created a simple SIR model. Click on in the toolbar and spin disease duration till it is less than 2. What happens to the epidemic?

Traditional SIR Form

The below model generates the same behavior but explicitly identifies contact between infected and susceptible individuals as the way in which the disease spreads.