This lecture is about writing equations, setting the units for This lecture is about writing equations, setting the units for the variables, defining the settings and running the simulation. 1 II will first explain the way to write equations that show how will first explain the way to write equations that show how variables in the stock‐and‐flow maps depend on each other. At the same time it is recommended to define the units in which the variables are measured. Before the simulation is performed it is good to check whether the model is correct and the units in the model are well defined. When both checks turn to be ok the simulation can be performed and BOTG analysed. 2 The equation for the components of the model can be written The equation for the components of the model can be written by selecting the equation tool on the sketch toolbar. At this point all the variables become black because no equation has been entered. By clicking on a variable a separate window where the equations are entered opens. For the stock variables th the equation is already written as integral of the difference ti i l d itt i t l f th diff between the inflow and the outflow. Only the initial value of the stock needs to be entered. On the left side of the window there is a space where you can enter the measurement units or select one of those available. At the bottom there is a space for entering comments that explain the formula. When entering formulas for the other variables, you can see variables that affect the current variable in the box with variables. Vensim inserts them when you draw the arrows. They can be selected when the formula is written can be selected when the formula is written. 3 When writing the equations it is recommended to define the When writing the equations it is recommended to define the units for esch of them. The units used for a stock depend on the definition of the stock. They can be persons, buildings, tasks, patients, etc. The flows increase or decrease the amount of certain entity in the stock. Hence, their units are expresed with the units used for the stock per some time unit. The time unit needs to be in complience with the time units for the simulation. Vensim will perform the simulation even if the units are set incorrectly However for the sake of having a correct model incorrectly. However, for the sake of having a correct model it is good to set the units correctly. 4 Before running the simulation it is important to set the Before running the simulation it is important to set the values for the initial and final time and the time step. They are set on the window that appears when a new model is started or when the Settings option is selected from the Model menu. 5 The value of the initial time is usually 0, since this is the time The value of the initial time is usually 0, since this is the time when the observation of the model starts. The final time is the time when the simulation stops. These two times can be set to a particular year if the behaviour of the model is to be observed in a particular time interval. The time step is the time interval at which the value of the variables is recalculated. It is chosen in such a way to be always smaller then the interval when the changes of the variables in the system occur. The Saveper is the time interval at which the values of the The Saveper is the time interval at which the values of the variables are saved. It should always be a multiple of the time step. Vensim gives possibility to choose among two integration types Euler or Runge‐Kutta. yp g 6 When the stock and flow map is sketched, the equations for When the stock and flow map is sketched, the equations for all variables entered together with the measurement units and the model settings for the simulation are defined, the simulation can be performed. However, before doing this it is always good to check the model and the units using Vesim options available in the Model menu. In case both check give OK as an answer you can proceed with simulation. If errors are discovered they should be corrected first. The errors in units are not that important since Vensim will The errors in units are not that important, since Vensim will produce the simulation results even when there are errors in the units. 7 The example with a bank balance will be used to present The example with a bank balance will be used to present how a stock‐and‐flow map is built and how equations are written in Vensim. In this example the stock is the money on the bank account. If you are saving account is in Sweden, the units for this stock will be SEK or Swedish crown. There is one inflow for this stock and that is the interest that increases it at the end of the year. Hence the units for the interest are SEK/Year. The interest depends on the interest rate and the amount of money on the bank account at the rate and the amount of money on the bank account at the start of the year. 8 This is a simple model of the bank balance. There is a single This is a simple model of the bank balance. There is a single positive feedback loop in the model. The interest rate is a constant and that is the exogenous variable. The other two variables, the bank balance and the interest are endogenous variables. There is a single feedback loop which is positive because the interest reinforces the bank balance and the bank balance reinforces the interest. The bank balance is integral of the interest earned and its initial value is 50000. The measurement units are Swedish crowns (SEK) crowns (SEK). 9 The interest earned is equal to the product of the bank The interest earned is equal to the product of the bank balance and the interest rate offered by the bank. It is measured in SEK/year. This is the rate at which the inflow flows into the stock. 10 The interest rate is a given by the bank (2% per year). Hence, The interest rate is a given by the bank (2% per year). Hence, it is a constant. The value entered is 0.02 and the measurement unit is 1/year. 11 Before running the simulation it is important to set the Before running the simulation it is important to set the values for the initial and final time and the time step. They are set on the window that appears when a new model is started or when the Settings option is selected from the Model menu. 12 When both the model and the units are correctly set, the When both the model and the units are correctly set, the simulation can be run by clicking on the running man icon on the main toolbar or by selecting Simulate from the Model menu. The data gathered will be stored in the file with extension .vdf and the name equal to the name in the field next to the simulation button. The default name for the file is “current”. After data are gathered they can be analyzed using the tools from the analysis toolbar. 13 The units for the simulation are set to years, the start time to The units for the simulation are set to years, the start time to 0 and the end time to 20, the time step is 1. The name of the file where the equations are stored is BankBalance.mdl. The data obtained with simulation are stored in the file BankBalance1.vdf. The results are presented as a graph showing how the bank balance changes and the horizontal table where the amount of money for each year are presented. 14
© Copyright 2025 Paperzz