DOC

# Tutorial 1 in doc - Computational Science

By Jennifer Adams,2014-09-30 06:58
11 views 0
Tutorial 1 in doc - Computational Science

3.1 System Dynamics Tool:

Vensim PLE Tutorial 1

Introduction to Computational Science:

Modeling and Simulation for the Sciences

Angela B. Shiflet and George W. Shiflet

Wofford College

? 2011 by Princeton University Press

Introduction

We can use the software Vensim? PLE from Ventana Systems, Inc.

(http://www.vensim.com/) to model dynamic systems. Dynamic systems are usually very

complex, having many components with involved relationships. For example, we can use Vensim to model the competition among different species for limited resources or the chemical reactions of enzyme kinetics.

To understand the material of this tutorial sufficiently, we recommend that you do everything that is requested. While working through the tutorial, answer Quick Review Questions in a separate document.

In the first tutorial on Vensim PLE, we consider an example on unconstrained

growth. In this example, the rate of change of the population is equal to 10% of the number of individuals in the population, and the initial population is 100 individuals. Thus, we have the following differential equation, or equation involving a derivative:

dP 0.1P,Pdt 1000

). Start running the software, perhaps by double-clicking the Vensim PLE icon (

If a window does not appear as in Figure 3.1.1, select New from the File menu. A Model

Settings popup menu appears (see Figure 3.1.10). Usually, when starting a new model, we change some of the values in this window. However, until we have had time to consider some of Vensim's features, accept the default settings by clicking OK. A window

appears as in Figure 3.1.1. In this window, we can construct a diagram model with equations.

;；

Vensim PLE Tutorial 1 2

Figure 3.1.1 Vensim PLE window

The title bar, which is at the top of Figure 3.1.1, contains the text "Vensim-Unnamed Var-FINAL TIME." The main toolbar is beneath the title bar and contains typical icons for Open Model, Save, Print, Cut, Copy, and Paste, among others. The most

important icons for building a model, the sketch tools, appear towards the left, below the main tool bar, and immediately above the large, currently blank Build (Sketch) Window.

Table 3.1.1 lists the sketch tools, and the following sections describe the meanings of

these building blocks.

Table 3.1.1 Basic building blocks of Vensim

Building Block Icon Meaning

converts, stores equation or constant, does Variable - Auxiliary/Constant or

not accumulate Converter

noun, represents something that accumulates Box Variable or Stock

transmits inputs and information Arrow or Connector

verb, changes magnitude of a box variable Rate or Flow (stock)

Box Variable or Stock

In Vensim PLE terminology, a box variable or stock is a noun and represents something

that accumulates. Some examples of stocks are population, radioactivity, enzyme concentration, self-esteem, and money. At any instant, the magnitudes of the stocks give

us a snapshot of the system.

Vensim PLE Tutorial 1 3

Quick Review Question 1 In Vensim, click on the rectangular stock icon. Without

holding down the mouse button, move the cursor towards the top-middle of the

window. What is the shape of the cursor?

Click in the Build Window to insert a stock object. Without clicking again, type the name of the stock, population. The contents of the window should be similar to Figure 3.1.2. To change the name later, click once on the stock with the box variable icon and type the new name and press RETURN or ENTER.

Figure 3.1.2 Contents of window after insertion of stock called population

Quick Review Question 2 Select the hand tool () on the left of the sketch toolbar and

then click on the stock's name, population, and attempt to drag the name around the

screen. Describe what happens.

Under the File menu, select Save (or ctrl-s on a PC or command-s on a Macintosh)

or click the Save icon on the main toolbar to save your work to a disk. Use a meaningful name for the file, such as "Vensim for Tutorial 1." Save your work frequently. Thus, if

there is a power interruption, you will not lose much of your work. Also, sometimes if you make a mistake, it is easier to close the file without saving and open the recently saved version.

Rate or Flow

While a stock is a noun in the language of Vensim, a rate or flow is a verb. A rate is an

activity that changes magnitude of a box variable (stock). Some examples of such

Vensim PLE Tutorial 1 4

activities are births in a population, decay of radioactivity, formation of an enzyme, improvement of self-esteem, or growth of money. The rate (flow) icon represents a directed pipe with a valve.

Click on the rate icon. Click a couple of inches to the left of the stock, population;

and then without dragging, click the stock so that a rectangular with a cursor appears. Type its name, growth, in the rectangle and press RETURN or ENTER. The diagram

should appear similar to Figure 3.1.3 with the flow beginning in a cloud, the ether, which in this example is a source.

Figure 3.1.3 Diagram after addition of growth rate (flow)

Quick Review Question 3 Drag the population stock around the right of the screen.

What happens to the diagram?

If moving the population stock does not result in the flow arrow moving, too, but

reveals another cloud, you need to delete the flow and create another that attaches to the stock.

We can change the direction of flow from being only into population to being into

and out of this reservoir so that population can increase or decrease. Thus, we are changing the flow from a uniflow having one direction to a biflow going in two directions. To change the direction, we first select the hand tool. Then, on the small circle to the left of the valve for growth, right click with a Windows computer or ctrl-click with a

Macintosh computer. Should we wish to allow values to flow in both directions through the arrow, we click the top left checkbox for Arrowhead and then OK in the popup menu

(Figure 3.1.4). In this case, the flow would appear as in Figure 3.1.5 with arrowheads at both ends representing the possibilities of addition to and removal from the population.

Vensim PLE Tutorial 1 5

Figure 3.1.4 Popup menu for the arrow

Figure 3.1.5 Biflow for growth

If you changed the flow to be a biflow, restore the arrow to be uniflow as in Figure 3.1.3 by right clicking (Windows) or ctrl-clicking (Macintosh) and unchecking Arrowhead

in the arrow popup menu (Figure 3.1.4).

Variable - Auxiliary/Constant or Converter

We can use an auxiliary variable or constant (converter) to modify an activity. A

variable - auxiliary/constant can store an equation or a constant. For example, with the population model a variable might store the constant growth rate, say 10% = 0.1.

As an example for radioactive decay, radioactive substance bismuth-210 decays to radioactive substance polonium-210. With A representing the amount of bismuth-210 and

B the amount of polonium-210, the ratio B/A is significant in the model of decay. An

auxiliary variable can store this ratio.

Select the Variable - Auxiliary/Constant icon, which has "VAR" and a pencil but

no box. Click below and to the left of the flow name, growth. Name this constant growth

rate. Blanks are permissible. The diagram should appear similar to Figure 3.1.6.

Vensim PLE Tutorial 1 6

Figure 3.1.6 Diagram after insertion of variable - auxiliary/constant growth rate

Arrow or Connector

An arrow or connector transmits an input or an output. For example, in a population model, an arrow can transmit the growth rate value from the growth rate constant (converter) to the growth flow.

In a radioactive decay model, arrows from the bismuth-210 (A) stock and from the

polonium-210 (B) stock to an auxiliary variable for the ratio of B over A transmit the

respective amounts of radioactivity for use by the auxiliary variable.

In the population model, both the growth rate and the current population affect the current growth. For example, if the growth rate is higher, so is the growth. Moreover, a larger population exhibits a greater change in population. We indicate these relationships by connecting the growth rate constant and the population stock (box variable) to the

flow (rate) growth. After selecting the arrow icon, click growth rate and then growth.

The resulting diagram is as in Figure 3.1.7a. Without selecting another tool, we can use the same tool again. Connect population to growth as in Figure 3.1.7b by clicking

population, clicking below and between population and growth to create an arch, and then

growth. Small circles indicate anchors that we can drag to create arches. Save your work. Figure 3.1.7 Arrows (connectors) drawn to growth flow

a b

Vensim PLE Tutorial 1 7

Quick Review Question 4 For the arrow from the stock to the flow, select the hand tool

and then click on the small circle on the arrow and drag it around. What happens to

the arrow?

Quick Review Question 5 What happens to the arrow as you drag box variable

population around the screen?

Delete

To remove a component from the diagram, we use the delete tool () or Cut from the

File menu. Using the delete key does not completely eliminate the item from the model. Select the delete icon, which is the second-to-the-last icon on the right in the sketch toolbar.

Quick Review Question 6 With the delete tool, click on population to remove the box

variable. What is eliminated?

When we remove an item with delete tool, the process eliminates the item and all connected connectors and flows. Restore the model to its previous form by closing the current document without saving and reopening the document. If a component is missing, recreate the model to appear as in Figure 3.1.7b.

Equations and Initial Values

We are now ready to enter equations and initial values. To begin defining an initial population, click on the equation tool (), which is next-to-the last icon on the right of

the sketch tools toolbar. The three items that can have values or equations (population,

growth, and growth rate) turn black. Click the population variable, and view a popup

menu as in Figure 3.1.8. For an initial population of 100 bacteria, type 100 at the location of the cursor in the Initial Value text box. Click the Check Syntax button at the bottom

left of the panel. In the Errors: box immediately above the button, Vensim responds

Equation OK.

Vensim PLE Tutorial 1 8

Figure 3.1.8 Popup menu after clicking the equation icon and population

The dropdown menu for Units: lists several alternatives, including Dmnl for

dimensionless, which we should use when a value has no units. Because the appropriate unit for population is not in the list, we type bacteria after Units:.

The boxes and text of the equation panel (Figure 3.1.8) indicate that population is

the integral (INTEG) of growth and the initial value of population is 100 bacteria. Hence,

Vensim is saying the following, where time (t) goes from a to b: bPgrowthdt a

We do not need to understand integration to use Vensim. As we discuss in detail in

Module 3.2 on "Unconstrained Growth," in computer simulation terms, the statement is equivalent to the following:

;；

(new population) = (old population) + (change in population)

= (old population) + growth * dt

= (old population) + (growth over 1 unit) * (length of time step)

To complete input for population, click OK on the bottom left of the panel.

Quick Review Question 7 To establish the growth rate as 10% = 0.1, first, click the

constant growth rate with the equation tool. What precedes the text box containing

the cursor?

Type 0.1 in the text box. In the Units: text box, type 1/Hour, and click OK. Notice

that after entering a growth rate and an initial population, the diagram elements no longer appear black.

We often employ replacement of blanks with underscores in the text to avoid confusion with component names. Thus, growth rate is equivalent to growth_rate in this

tutorial and the text.

Unlike growth_rate, the flow growth is not a constant; but the growth in the

population changes with time as the population changes. For our example, at any instant,

Vensim PLE Tutorial 1 9

the rate of change in the population, or growth, is 10% (growth_rate) of the current population (population). In calculus terminology, the instantaneous rate of change of

population is the derivative of population with respect to time t, so that we have the following formula:

d(population)growth_ratepopulation

dt

0.1population

Clicking on growth, we see a popup menu as in Figure 3.1.9. Figure 3.1.9 Popup menu for growth

Quick Review Question 8 The submenu Choose Initial Variable… of the Popup menu

for growth (Figure 3.1.9) lists the items that have arrows to growth, namely

population and growth_rate. We include these variables in the formula for growth.

For our example, this instantaneous rate of change of population is (0.1)(population)

bacteria per hour. Using * for multiplication and clicking on the appropriate

variables in Choose Initial Variable…, enter the formula for growth. What is the

resulting formula? For the units, type bacteria/Hour. Click OK.

;；

We can verify that our units are consistent from the Model menu by selecting Units Check. Unfortunately, Vensim indicates that we have one error. The Units Checking

popup menu displays the following analysis:

Error in units for the following equation:

population =

INTEG( growth ,

100)

population --> bacteria

growth --> bacteria/Hour

Vensim PLE Tutorial 1 10

Analysis of units error:

Right hand and left hand units do not match

population

Has units: bacteria

INTEG( growth ,

100)

Has units: Month*bacteria/Hour

An inconsistency (in boldface here) in the time units between Hour and Month exists.

The problem arises from the fact that Vensim uses a default unit of Month for time. To

override the default, from the Model menu we select Settings.... In the resulting Model

Settings popup menu (Figure 3.1.10), we change the Units for Time to be Hours. This

change should correct the inconsistent units, so click OK.

Figure 3.1.10 Model Settings popup menu

Quick Review Question 9 After making the change of units, perform a units check from

the Model menu. Give the displayed message.

For this example, let us also change the length of the simulation and the time

between steps of the simulation. Once more, select Settings... from the Model menu. In

the Model Settings popup menu (Figure 3.1.10), leave the INITIAL TIME as 0 Hours,

but change the FINAL TIME to be 12 Hours so that the simulation does not run as long. Also, in the dropdown menu for TIME STEP, select 0.125. Thus, calculations for the simulation will be every 0.125 Hours instead of every hour. Usually, a smaller TIME

STEP generates more accurate results but causes the simulation to take longer. Click OK.

Clicking the Document All icon (Doc with multiple lines on the icon) to the left side of the Build Window reveals the formulas, which Equation Set 1 displays. We established values for the FINAL TIME (12), INITIAL TIME (0), TIME STEP (0.125), and units for

Report this document

For any questions or suggestions please email
cust-service@docsford.com