The system dynamics plug-in for Cool Modes enables modelling of dynamic processes like the growth of a population. As a very general modelling language, system dynamics allows many types of domains, e.g. ecology or biology (growth of population), physics (radio active decay or water rocket simulation), social science (urban dynamics, i.e. simulation of a whole city with health insurances, economic data etc.), medicine (spread of diseases).
Required Tools and Materials¶
Freestyler with the plug-ins system dynamics and functions.
Tutorial by Example¶
Simulate the growth of a population¶
1. Start Freestyler and open the plugins "System Dynamics" and Functions.
2. First you need the palette of "System Dynamics". Create two stock nodes and a rate node by dragging them into the workspace.
3. Edit a stock note: Open the settings dialog of one of the stocks by clicking on reactangle with the screwdriver. Change the name of the stock to “source” and check the “Infinite stock?” box. Click “OK”. Notice the value of this node changing to “infinite”. This node will resemble the source of our persons – in our simulation it is “infinite”. This means, we can “create” as much people as we want to.
4. Edit the other stock node: Open the settings dialog of the other stock node. Name this stock “population”. Change the initvalue to 10.0. Click “OK” to confirm these settings. This stock node will count and accumulate the number of persons in our “growth of population”- example. When the settings dialog has closed, click the “Reset”-button in the plug-in windows. Notice the value of the “population” node changing to 10.0 – this is the initial value you just entered.
5. Now edit the rate node: Change the name to “births” and enter “5” in the field “calculation rule” and click “OK”. In our first simulation, we add 5 persons to the “population” node each step.
6. Connect these three nodes with two FlowEdges: source -> births -> population.
Simulating¶Let’s do a first simulation. You can control System Dynamics simulations by manipulating the “Step Control” and “Timeline” in the palette.
- “Reset” will reset all stock nodes to their initial value. (It is recommended to reset your model before simulating.)
- “1 Step” will do one step in the simulation.
- Use the slider (between “Step” and “Reset”) to set the number of steps that will be done.
- Use the slider “Timeline” to jump directly to a specific number of steps in the simulation.
Now, press “Reset” and then “1 Step” five times. You can see how the population increases by 5 each time you press the button, up to 35.0. Notice the value of “source” remaining “infinite”. To change this, uncheck the “Infinite stock?” box in the settings of the “source” node. Pressing “Reset” and five times “1 Step” again in the plug-in window, you will see that “source” is decreasing down to -25.0, which is exactly the value added to “population”. Please make “source” an “infinite stock” again.
To have a nice overview of what has happened in the simulation, you can add a “graph display” to the workspace and connect it with nodes of interest. Switch to the Functions plugin and draw the empty graph into the workspace. Click on “Colored Edge” in the same plugin and connect the “births”-node and the “population”-node with this graph node. (If you did a “Reset”, simulate five steps again.) Two lines will appear in the graph display – a horizontal one and an ascending one. If you cannot see them properly, try zooming out and change the view port( + / - and arrow buttons). The horizontal line represents the development of the “births” node; the ascending line shows the development of the “population”. Since the number of “births” is constant in our first example, the respective line is horizontal. To change the color of the edge, click on the circle and choose a color.
Have a look at figure below to see what it should look like.
Bringing in more Realism: Exponential Growth¶
Since a constant growth of a population is not very realistic, we will improve our model and bring in exponential growth.
The number of births usually depends on the number of fertile individuals. So we have to feed this information into the calculation of the number of births. To this purpose, draw an “InfoEdge” from “population” to “births”. Antarget="_top" arrowed, bowed, black edge will appear. Create a “Constant” node, name it “birthrate”, set its value to 0.1 and draw another “InfoEdge” from “birthrate” to “births”. This will be our birth rate – a factor needed to calculate the births.
The difference between “InfoEdge” and “FlowEdge” is, that “InfoEdge” only brings in knowledge about the value of one node to another. An “InfoEdge” does never transfer ”material”. A “FlowEdge” subtracts a value from one stock node and adds this value to another stock node, according to the calculated rate in between.
Enter the settings dialogue of “births” now. In the field “variables”, “birthrate” and “population” will appear, since these nodes are connected to “births” via “InfoEdges”. These variables can be used for calculations, now. Do this by entering “population*birthrate” in the field called “calculation rule”. You can double-click on a variable to have its name copied into the calculation rule.) Click “OK”. This formula means, that 10% of the value of the population(0.1*population) will be born(and added) each step. You should see now, how the number of births is calculated according to the values of “population” and “birthrate”: Press “Reset” and do some simulation steps. You will see a more interesting and realistic development in the graph plotter than before. Try changing the birth rate (the value of “birthrate”) and exploring the model.
Births and Deaths¶
To make our model even more realistic, we need people dying. This feature can be added in our model simply by adding another flow to the “population” node. Create another rate node, constant node and another rate node and connect them:
- Rate node: name it “deaths”
- Stock node: name it “graveyard” and set it to “infinite”
- Constant node: name it “deathrate” and enter the value 0.08
- Draw a FlowEdge from “population” to “deaths” and from “deaths” to “graveyard”
- Draw an InfoEdge from “deathrate” to “deaths” and from “population” to “deaths”.
- Enter the calculation rule “deathrate*population” in the Rate node's settings.
Try to do some simulations: Click “Reset” and do some steps or draw the “Timeline” slider. Notice the lines in the plotter becoming more flat now, since there are people dying now (see figure below).