5 Building Dynamic Models
Population Model
This example shows you how to develop and use a simple model of population growth. No prerequisite knowledge is assumed. Mouse clicks are usually done with the left button and are usually single clicks, unless otherwise noted in the text. You will be building the model shown below:

Ø Select the Vensim Development Environment from the main menu.
Ø Click on the New Model button on the Main Toolbar, or select the menu File>New Model.
Ø Click OK to the Time Bounds dialog box.
Ø Click on the Box Variable sketch tool. The cursor will change to a bar with a box. Position the cursor in the upper middle of the window and click. An editing box will appear, type the word Population into the editing box then press Enter (on keyboard).
Ø Click on the Rate sketch tool. The cursor shape will change to a rate arrow. Click once (press and release the mouse button) 2 inches (5 cm) left of the box containing the word Population, then move the mouse over onto the box Population and click once on it. An editing box will appear, type the word births and press Enter.
Ø With the Rate tool still selected, click once on the box Population, then move the mouse 2 inches (5 cm) to the right and click again. An editing box will appear, type the word deaths and press Enter.
Ø Now select the Variable sketch tool, the cursor will change to a bar. Click below births (on a blank part of the screen) and type birth rate and press Enter. Click below deaths and type average lifetime and press Enter.
Ø Now select the Arrow sketch tool. Click on birth rate, move the cursor onto births and click again. Click on average lifetime, move the cursor onto deaths and click again.
Ø Click on the box containing Population, move the cursor to an empty point on the diagram a little below Population and births and click once, then move the cursor onto births and click again. A curved arrow should join Population and births; you can move this arrow around by using the pointing tool to drag the circle (handle) appearing in its middle.
· Click on the box containing Population, move the cursor to an empty point on the diagram a little below Population and deaths and click once, then click once onto deaths and click again.
Ø You can change fonts and colors by using the Pointer tool, selecting a sketch object, and clicking on the Status Bar (at the bottom), or by clicking with the right mouse button on a sketch object, changing the options and clicking OK.
You have now completely specified the structure for the model. Next you need to specify the equations precisely defining that structure.
Ø Click on the Equations sketch tool. The variable names will all change appearance (shaded black).
Ø Click on the variable births.
The Equation Editor opens. The top of the editor has the name of the variable we clicked on: births. The drop-down list box on the left shows the type of variable: Auxiliary. Vensim considers Rates and Auxiliaries to be the same Type of variable. Click on the drop-down arrow to see the other types. Make sure that Auxiliary is still selected when you leave the list. The cursor is positioned in the equation editing box (next to the = sign).
Ø Complete the equation for births as below (in the editing box)
EITHER
Ø By typing Population * birth rate
OR
Ø Click on the variable Population in the Variables list (in the middle of the Equation Editor), then type the * symbol (or click on it in the Equation Editor keypad), then click on birth rate in the Variables list.
Spaces and new lines can be added to the equation for increased clarity, but are not necessary.
Now we will add the units of measurement for births.
Ø Type in the units of measurement rabbit/week in the Units: box. This indicates that we measure the Rate of births in rabbits per week. Click on OK (or press Enter).
If the model structure and equation agree and there are no syntax errors in the equation, the dialog box will disappear. If there are problems with the structure or equations, you will receive an error message indicating what is wrong.
· Click on Population.
Ø The Equation Editor opens and is slightly different from what we saw with the variable births.
The drop-down list box on the left shows the type of variable: Level. Left of the equation editing box is the INTEG function that defines a Level (integrating the variable over time). An equation is already present in the equation editing box. Because we connected Rates with the names births and deaths to the Level, Vensim automatically enters the Rates to the Level equation. Rates constructed by clicking first outside, and then on the Level are considered positive (inwards) flows; Rates constructed by clicking on the Level, and then outside the Level are considered negative (draining) flows. If the rates are drawn in the a different direction the sign can be changed in the equation editor. The equation for this Level is correct, births add to Population, deaths subtract from Population, so we need not change them.
The Equation Editor for a Level has an extra editing box to set the starting or initial value; the cursor is placed there.
· In the Initial Value editing box, type in 500.
This value is the initial number of rabbits at the start of the simulation (time zero).
· Type in the units of rabbit in the Units: box. Click on OK (or press Enter).
· Click on birth rate. Type in the numbers 0.04 in the editing box.
· Type in the units fraction/week. Click OK.
This means that the fractional birth rate is measured in fraction (of rabbits) per week. Another way of saying this is (rabbits born / rabbit population) / week (rabbit/rabbit)/week (rabbit cancels out).
· Complete the remaining two equations as they are shown in the Equations listing below.
All model variables should appear clear in the sketch after all the equations are entered. Units that have been previously entered can be selected again by clicking on the arrow in the units box and selecting from the drop-down list.
average lifetime = 25
Units: week
birth rate = 0.04
Units: fraction/week
births = Population * birth rate
Units: rabbit/week
deaths = Population / average lifetime
Units: rabbit/week
Population = INTEG(
births - deaths,
500)
Units: rabbit
Before we simulate the model, we should check it for errors in equations and units.
· Select Model>Check Model from the menu; you should get an information box saying "Model is OK."
If the model has errors, the Equation Editor will open with the variable containing the error. Check that the equation uses all the inputs and looks the same as in the listing above. Check that the structure of your model is the same as in the diagram above.
· Select Model>Units Check from the menu (or press Ctrl + U); you should get an information box saying "Units are AOK."
If a units error is generated, read the Output window to see which variables are failing the check. Open the Equation Editor on each variable and check the units against the list above. Units that do not check out often indicate poor or incorrect equation formulation.
· Double click on the Runname editing box on the Main Toolbar and type equilib for the first run name.
· Click on the Simulate button.
The model will simulate, showing a work-in-progress window until completion. Note that on a fast computer the simulation may be so quick that the work-in-progress window may not be noticeable.
This model has been designed to show equilibrium conditions in the rabbit population. The Constants birth rate and average lifetime are both set to generate a rate of flow of 4 % of Population, therefore each feedback loop is balanced numerically, allowing no change in the value of Population.
· Double click on the Level Population in the sketch.
This selects it as the Workbench Variable; another way to do this is to choose Population from the Variable Selection Control. Check the Title Bar at the top of the Vensim window to see that Population is selected.
· Click on the Graph tool. A graph of Population is generated.
Population appears unchanging from 500 rabbits. To check that no change is occurring:
· Click on the Table tool.
An Output window shows that Population is unchanging. Scroll the window to confirm that late in the simulation, Population is still 500.
A key feature of Vensim is the ability to do multiple simulations on a model under different conditions, to test the impact that changes in Constants (or Lookups) have on the model behavior. Vensim also stores all the data for all variables for each simulation run, so that you can easily access information about the behavior of any variable in any run. Experiments are performed by temporarily changing Constant or Lookup values then simulating the model. This way, your underlying model stays the same, an unchanging reference point.
Now that we are satisfied that we have equilibrium conditions, let us make changes to the model Constants to generate unconstrained growth. This is one of the simplest possible dynamic behaviors, known as exponential growth.
· Click on the Set Up a Simulation button.
The Main Toolbar changes to the Simulation Toolbar. This toolbar enables you to change the integration technique, and features a Stop button to return you to the Main Toolbar if you want to return before simulating the model. You will also notice that Constants in the sketch of the model turn into yellow words with blue background (similar to when we were constructing equations for each variable). Also, the Sketch tools are grayed out, preventing work in the Sketch window.
· Click on the Runname editing box and replace equilib with the name growth.
· Click on the variable birth rate (appearing in black in the sketch) and in the editing box type the value 0.08. This is a temporary change for this run only and does not permanently alter the value in your model. Press the Enter key.
· Click the Simulate button and the model will simulate.
· Click on the Control Panel button to bring the Control Panel to the front. Click the Datasets tab to open the Datasets Control and check that both runs are loaded in the right hand column.
The last run you made (growth) is loaded last (at the bottom of the dialog). Most Analysis tools act on both datasets, allowing comparison of behavior from both runs.
· Click on the Graph tool.
A graph will be generated showing both runs.
· Now click on the Causes Strip tool.
A strip graph is generated showing Population and its causes births and deaths. Now let's change the workbench variable and create a graph showing only births.
· Double click on births appearing in either a graph or in the model diagram. Check that the variable births is now the workbench variable by looking at the Title Bar at the top of the Vensim window.
· Click on the Graph tool.
A graph will be generated showing both runs for the variable births.
To find out what the differences are between the first and second runs, we will use a tool that compares all Constant (and Lookup) differences. This tool acts on the first two loaded runs (check in the Datasets Control).
· Click on the Runs Compare analysis tool. The text report below shows the differences in the Constant birth rate for runs equilib and growth.
Population grew in the growth run because the birth rate was set to a higher value than the equilibrium value. This made the positive feedback loop through births stronger than the negative feedback loop through deaths, resulting in Population growth over time.
· Select the menu item Windows>Close All Output.
All of the windows you have created using the analysis tools will be closed. If you wish, continue to examine the model with other analysis tools, try each in turn and observe the output.
Sales Diffusion Model
This example shows you how to develop and use a simple model of sales diffusion. No prerequisite knowledge is assumed. Mouse clicks are usually done with the left button and are usually single clicks, unless otherwise noted in the text. You will create the model shown below:

· Select the Vensim development environment from the main menu.
· Click on the New Model button on the Main Toolbar, or select the menu File>New Model.
· Type 50 into the Final Time box then click the OK button to close the Time Bounds dialog.
· Click on the Box Variable sketch tool at the top of the window. Position the cursor in the left side of the sketch window and click. An editing box will appear, type the word Potential Customers into the editing box then press Enter (on keyboard).
· With the Box Variable sketch tool still selected, click about four inches (10 cm) to the right of Potential Customers, enter the word Customers in the text edit box and press Enter.
· Click on the Rate sketch tool. Click once on the box Potential Customers, then move the mouse over to the box Customers and click once on it. An editing box will appear, type the word conversions and press Enter.
· Any errors you make in the sketch can be deleted with the Delete sketch tool (the Pacman symbol).
· Now select the Variable sketch tool, the cursor will change to a bar. Click on blank screen just above conversions, type FRACTION BUYING and press Enter. Click just below conversions, type Total Market Size and press Enter. Click and enter the variables WOM CONTACT RATE, Potential Customer Contacts, Word of Mouth Contacts, and Customer Prevalence in the positions they appear in the figure above.
· For long variable names, click on the name with the right mouse button. An options dialog box will appear, click the radio button Clear Box (under Shape) and click OK. You can resize this box by dragging the handle around with the pointing tool.
· Now select the Arrow sketch tool. Click on Potential Customers, move the cursor to Potential Customer Contacts and click again. A straight arrow will connect the two. Click on Potential Customer Contacts, click once on empty space above and right, then click on Word Of Mouth Contacts. A curved arrow will connect the two variables. Continue joining the other elements of the diagram, except Total Market Size to Customer Prevalence.
· Vensim structural elements (like arrows, boxes, valves etc.) are all created with handles, little circles that allow you to move or change the element. Select the Pointer sketch tool, click and hold with the left mouse button and move the handle some distance to resize or move elements. When connecting arrows to the variable conversions, you can either click on the variable name or on the valve symbol, whichever looks clearer on your diagram.
· Click with the right mouse button on the Arrow tool, select the Type: Perpendicular then click OK. Click on Total Market Size, click to the right under Customer Prevalence, then click on Customer Prevalence. You can change fonts and colors by selecting an element (variable, arrow, etc.) using the Pointer tool and the choosing a selection from the attribute bar across the bottom.
You have now completely specified the structure for the model. Next you need to specify the equations that precisely define the structure.
· Click on the Equations sketch tool. The variable names will all change appearance (shaded black).
· Click on each highlighted variable and complete the equation as it appears in the list below:
conversions = word of mouth contacts * FRACTION BUYING
Units: Person/Year
customer prevalence = Customers/total market size
Units: Dmnl
Customers = INTEG(
conversions,
10)
Units: Person
FRACTION BUYING = 0.005
Units: Dmnl
potential customer contacts = Potential Customers * WOM CONTACT RATE
Units: Person/Year
Potential Customers = INTEG(
-conversions,
1e+007)
Units: Person
total market size = Potential Customers + Customers
Units: Person
WOM CONTACT RATE = 100
Units: 1/Year
word of mouth contacts = potential customer contacts * customer prevalence
Units: Person/Year
Before we simulate the model, we should check it for errors in equations and units.
· Select Model>Check Model from the menu; you should get an information box saying "Model is OK."
· Select Model>Units Check from the menu (or press Ctrl + U); you should get an information box saying "Units are AOK."
· Double click on the Runname editing box on the Main Toolbar and type run1 for the first run name.
· Click on the Simulate button.
The model will simulate, showing a work-in-progress window until completion. Note that on a fast computer the simulation may be so quick that the work-in-progress window may not be noticeable.
This model shows a growth in Customers until market saturation (depletion of Potential Customers).
· Double click on the Level Customers in the sketch.
This selects it as the Workbench Variable; another way to do this is to choose Customers from the Variable Selection Control. Check the Title Bar at the top of the Vensim window to see that Customers is selected.
· Click on the Graph tool. A graph of Customers is generated.
· Double click on the Level Potential Customers in the sketch and click on the Graph tool.
Note how the behavior of Potential Customers is opposite to that of Customers.
· Double click on the variable conversions in the sketch and click on the Graph tool.
Note the growth and decay of the rate conversions. Continue to examine the behavior, and make further simulations while with different intial values for the constants (see section "Setting Up a Simulation Experiment" in the Population example).