ITK 115
Vensim and Simple Systems


Objectives

  • Learn fundamentals of using Vensim to develop a systems dynamics model.
  • Learn to run a simulation.
  • Learn to display a graph of simulation results.
  • Demonstrate the behavior of a system

Lab Basics

  • How to turn on a computer in the ITK computer Lab
  • How to login to a computer

What is Vensim?

Vensim is a visual modeling tool that allows you to conceptualize, document, simulate, analyze and optimize models of dynamic systems. Vensim provides a simple and flexible way of building simulation models from stock and flow diagrams.

To build a model with Vensim you first draw a stock and flow diagram. It is very important that the diagram be drawn correctly since it will be used in specifying the equations. In other words, the diagram is a pictorial representation of the model and you can only specify equations that are consistent with the diagram.

After the stock and flow diagram has been drawn, you specify equations and the values of variables. Then you run a simulation and view graphs of the behavior over time of the variables.

Where can I download Vensim?

ITK Server
or
http://www.vensim.com/freedownload.html

How to open Vensim in the lab.

  • Double click on the Misc Applications folder on the desktop.
  • Double click on the Vensim icon.

Introduction to Vensim
vensim screen

  • Vensim's Window
    • Title Bar
    • Menu Bar
    • Main Toolbar
    • Sketch Tools
    • Analysis Tools
    • Drawing Area
    • Status Bar

Vensim files

  • Vensim uses two types of files for each model
    • Files with the extension mdl are used to store the definition of the model (diagram and equations).
    • Files with the extension vdf are used to store the results of a simulation run (called a dataset).
    • Since you may run a simulation model many times you may have many vdf files associated with a single mdl file.
  • The mdl file must be on a hard disk in order to run the model. Put the file on C:/temp
  • You must copy the model and dataset files from C:/temp to a floppy disk, flash drive or your datastore01.

Demonstration - Drawing a stock and flow diagram

  • Objective: Gain experience in creating and running a model
  • To begin, set up your computer screen with Vensim in the top portion and this Lab document underneath.

              screen set up

  • Now let's create a model of bank balance growth.
  • settings window

    • Click on the New Model icon new model icon
    • Set FINAL TIME to 20
    • Set Units for Time to Year
    • Click OK

     
    • Now let's draw a Stock and Flow Diagram...
    • Always Draw Stocks First!
    • Click the Box Variable - Level (Stock) icon stock icon
    • Position the cursor in the middle of the Drawing Area and Click. A rectangle will appear.
    • Type the stock name, "Account Balance," in the box and press the Enter key.
    • To resize the box, click on the small circle at the corner of the box and drag.
    • Click inside the box to drag the box to another location.

    • Before we go any further let's learn how to correct mistakes!
      • If you want to cancel something your are in the process of adding to the Stock and Flow Diagram, press the Esc key.
        For example, if you are typing the name of a stock you are creating and decide to not add the stock, press Esc instead of the Enter key.
      • If you want to erase something you have just added to the diagram, Click on EDIT in the Menu Bar and then Click on Undo.
            undo icon
        Each time you Click Undo a previous action will be erased. (Boy is this handy!)
      • Or, to erase a piece of the diagram, Click on the Delete icon delete icon
        and then Click on the item you want to erase.

    • Always draw Flows second!
    • Click the Rate (Flow) icon flow icon
    • Move the cursor to the left of the stock box and Click once. A Cloud will be drawn. Move the cursor until it is over the stock box and Click once again. A box will appear. Type the name of the flow, "Depositing", in the box and press the Enter key.
    • A double line arrow will be drawn by Vensim connecting the "Cloud" and the box. The word "Depositing" will be written under a "flow valve" in the center of the arrow.

    • Now if your diagram does not look like the one above you need to stop here and correct your diagram.

    • Third, add Variables!
    • Click on the Variable - Auxiliary/Constant icon variable icon
    • Move the cursor to a point below the flow arrow and click once. A box will be displayed. Type the name of the variable, "Deposits", and press the Enter key.
    • The diagram should now look like ...

    • Forth, draw information Arrows!
    • Click on the Arrow icon arrow icon
    • Move the cursor to the name, "Deposits", and click once. Then move the cursor to "Depositing" and click once again. A blue arrow will be drawn. (It is important that the cursor be on the variable names when you click. Otherwise the arrow's terminus will be "in the middle of nowhere" and the variables will not be connected.)
    • Position the cursor on the circle on the blue arrow and click and drag to "bend" the arrow.

    • Fifth, enter the equations and/or the values for each variable.
    • It is very important that the stock and flow diagram be complete before you begin entering equations.
    • Vensim only allows you to enter equations that are consistent with the stock and flow diagram!
    • Click on the Equations icon equation icon
    • All variables that do not have a value or equation defined for them will be highlighted.

    • Move the cursor to "Deposits" and Click once.
      window for deposits
      A pop-up window will be displayed. Enter 1000 for the value and Click OK. You can type the number directly into the equation's box or you can enter it just by Clicking. To do the latter, Click in the Equation's box to set the cursor's position. Then Click on the decimal point in the calculator pad in the middle of the window. Then Click on the zero and then the five. That's it--Click on OK.
      Note that the type of this variable is Constant.

    • Move the cursor to "Depositing" and Click once.
      window for depositiing equation
      A pop-up window will be displayed.
      Notice that the variable name 'Deposits' appear in the Variables box in the right middle of the window. This is the variable that is linked to the flow valve by an information arrow in the stock and flow diagram. The equation for controlling the flow is thus expected to contain the variable.

      Enter the calculation Deposits and Click OK. You can type this directly into the equation's box or you can enter it just by Clicking. To do that, Click in the Equation's box to set the cursor's position. Click on "Deposits" in the Variables box in the right middle of the window.
      Note that the type of this variable is Auxiliary.


    • Move the cursor to "Account Balance" and Click once.
      window for account balance
      A pop-up window will be displayed. Enter an Initial Value of 500 and Click OK. Note that the type of this variable is a Level and its relationship to Depositing has already been filled in by Vensim. In general, you will only have to fill in an initial value for a stock (in Vensim a stock is called a level). Vensim fills in the rest of the equation from the stock and flow diagram.

     
    • OK, the entire model has been entered. Let's save the Model before we run a simulation.
    • Models must be saved on a hard drive to run them.
    • Click on File in the Menu bar and then Click on Save As.
    • Save the model as Savings1 on your secondary storage (floppy, etc.)

  • Move the cursor to the box next to the Set icon and enter a name, "run1", for this run of the model.
    This name will be used as the name of a file that contains the data generated by this run (the vdf file).
              window for run name

  • Now run a simulation by Clicking on the Run icon run icon

  • Click on the Lock icon lock icon

  • Then click on the "Depositing" flow variable to select it. When a variable is selected like this it is the Work Bench variable.

  • Click on the Graph icon graph icon
    A graph of the Work Bench variable will be displayed. The Work Bench variable is the last selected variable--"Depositing" in this case.
              graph
    The flow Depositing is constant over time. This is because it is simply equal to "Deposits" that are constant at $1,000 per year.
  • Now click on the "Account Balance" stock box to select it, making it the Work Bench variable.

  • Click on the Graph icon graph icon
    A graph of the Work Bench variable, "Account Balance," will be displayed. Remember the Work Bench variable is the last selected variable.
              graph
  • Since there is no flow out of the stock, the behavior of "Account Balance" reflects directly the accumulated behavior of the flow into the stock, i.e. "Depositing". Since the inflow is at a constant rate, the stock, "Account Balance" exhibits a constant rate of growth beginning at $500 and increasing by $1,000 each year.

Quick Check: A constant rate of flow into a stock with no flow out produces what behavior in the stock?
    straight line going downward
    straight line going upward
    increasing level at an increasing rate
    the level of the stock is constant

Modifying a Model

  • Adding variables
    • Click on the Variable - Auxiliary/Constant icon variable icon
    • Move the cursor to a point below the flow arrow and click once. A box will be displayed. Type the name of the variable, "Interest", and press the Enter key.
    • The diagram should now look like ...


     
    • Move the cursor to a point below the "Interest" variable and click once. A box will be displayed. Type the name of the variable, "Interest Rate", and press the Enter key.
    • The diagram should now look like ...

    • Adding Information Arrows to the Stock and Flow Diagram
      • Click on the Arrow icon arrow icon
      • Move the cursor to the name, "Interest Rate", and click once. Then move the cursor to "Interest" and click once again. A blue arrow will be drawn. (It is important that the cursor be on the variable names when you click. Otherwise the arrow's terminus will be "in the middle of nowhere" and the variables will not be connected.)
      • Position the cursor on the circle on the blue arrow and click and drag to "bend" the arrow.
      • Move the cursor to the name, "Interest", and click once. Then move the cursor to "Depositing" and click once again. A blue arrow will be drawn.
      • Move the cursor to the stock, "Account Balance", and click once. Then move the cursor to "Interest" and click once again. A blue arrow will be drawn.

    • Modify the model's equations
      • Assign Interest Rate a value of .02.
      • Set Interest equal to Account Balance times Interest Rate.
      • Set Depositing equal to Deposits + Interest.

    • Run the new model
      • Save this model as Savings2.
      • Name this run "run2"
      • Run the simulation
      • Set the work bench variable to "Account Balance."
      • See the result by clicking on the Graph icon.
                  graph

    • The stock Account Balance increases at a faster and faster rate over time. This is because the balance is compounding. That is, the balance earns interest and then, in the next period, more interest is earned on the original balance plus new interest is earned on the interest earned the previous period. This creates an increasing rate of change in "run2" as compared to the constant rate of change in "run1".
    • Quick Check: Why does the blue line in the above graph begin to curve upward as time increases?
        the dollars in interest earned each year increases
        the flow in is composed of two values added together
        their is no flow out of the stock

    • Open Loop and Closed Loop Systems
      • The model "Savings1" is called an "open loop" system because there is no feedback loop in the system.
      • The model "Savings2" is a "closed loop" system. It contains a feedback loop beginning with the stock "Account Balance" going to "Interest," then to "Depositing," and finally back to "Account Balance" closing the loop.
        This loop is a reinforcing loop because an increase in "Account Balance" causes an increase in "Interest" which, in turn, increases "Depositing." Since "Depositing" is the inflow into "Account Balance" the stock will be increased. Thus an increase in the stock works through the feedback loop to ultimately further increase or "reinforce" the original stock.

    • Now let's build another model.
      • The system to be modelled is for getting into a shower and adjusting the water to a desired temperature. When the water is first turned on it is a chilly 60 degrees. The hot water is adjusted to bring the temperture to 100 degrees.
      • Click on the New Model icon new model icon
      • Set FINAL TIME to 120
      • Set Units for Time to Second
      • Click OK
      • Now let's draw the Stock and Flow Diagram...
      • Remember we draw Stocks first!
      • Draw Flows second!
      • Third, add Variables!
      • Forth, draw information Arrows!
      • Fifth, enter the equations and/or the values for each variable.
        • The initial value for Temperature is 60.
        • Assign 100 to "Desired Temperature"
        • Set "Gap" equal to "Desired Temperature" minus "Temperature".
        • Set "Change in Temperature" equal to "Gap" divided by 10.
      • OK, the entire model has been entered. Let's save the Model before we run a simulation.
      • Save the model as Shower.

      • Move the cursor to the box next to the Set icon and enter a name, "run3", for this run of the model.
      • Now run a simulation by Clicking on the Run icon run icon

      • Click on the Lock icon lock icon

      • Then click on the "Temperature" stock to select it.

      • Click on the Graph icon graph icon
        A graph of the Work Bench variable will be displayed.
                  graph
        The stock Temperature rises from 60 to 100 and then stops changing. This behavior is called "goal seeking."
      • Now click on the "Change in Temperature" flow to select it, making it the Work Bench variable.

      • Click on the Graph icon graph icon
        A graph of the Work Bench variable, "Change in Temperature," will be displayed. Remember the Work Bench variable is the last selected variable.
                  graph
      • The flow's behavior shows a decreasing rate of change as compared to the increasing rate of change of the flow in the model "Savings2".
      • The feedback loop in this "closed loop" system is said to be a "balancing loop" because the loop acts to counter balance a change in the system. In this case, the loop acts to make the actual "Temperature" equal to the "Desired Temperature."

     
  • Let's review these last three models:
      Model Structure Flow Stock
      Savings1 Open Loop Constant Rate Constant Rate of Change
      Savings2 Reinforcing Loop Increasing Rate Increasing Rate of Change
      Shower Balancing Loop Decreasing Rate Decreasing Rate of Change
  • Quick Check:
    An open loop system...
      interacts with its environment
      contains at least one reinforcing loop
      contains at least balancing loop
      contains no feedback loops

    A reinforcing loop acts to...
      increase the level of a stock
      decrease the level of a stock
      accentuate the change in the level of a stock

    A balancing loop acts to...
      increase the level of a stock
      decrease the level of a stock
      diminish the change in the level of a stock

  •  
  • Save a copy of the models you have built before you logoff the computer.

  End of Lab! Submit Saving2.mdl and Shower.mdl to blackboard.