[From Bill Powers (980922.1536 MDT)]
Bruce Gregory (980922.1302 EDT)]
Let's work up a Vensim model of a thermostat. This would make a good
project for everyone just starting to do simulations. I'll go through this
as a lesson for everyone, starting with excruciating detail for those
really starting from scratch. If I violate conventions too much, I hope the
Vensim experts will speak up. But I won't do anything actually wrong, so it
would be better to defer such corrections until we all have working models
on our screens.
I suggest starting with a model of the furnace and the temperature of the
house. The physics you need to know is this:
1. The furnace adds heat to the house at a constant rate while it is on.
The furnace output can be called just that: "furnace output" with units of
BTU (British Thermal Units) per hour. We'll actually fill in the units later.
2. Heat, again in BTU per hour, is lost from the house at a rate that
depends on the difference between inside and outside temperature and on the
amount of insulation. So with T standing for temperature, the formula for
"heat loss rate" is
heat loss rate = (T inside - T outside)/insulation
3. The temperature inside the house in degrees depends on the BTUs of heat
the house contains divided by its "heat capacity" in BTUs per degree.
T inside = heat content of house/heat capacity
The total heat content of the house is a "level" variable because it is an
accumulation of a flow of heat BTUs. There will be two flows, which are
rates of heat flow in BTUs per hour, one entering and one leaving a single
level variable, the heat content of the house in BTUs.
I'll help you draw this first diagram. If you're having a problem at any
stage just speak up (anyone) and I or someone else will help you through it.
First start Vensim. I assume everyone can do that by now, either through
"Start ... Programs ... Vensim" or by clicking on an icon. You will get
either a blank screen with rows of buttons above and to the left, or a
screen with a previous model on it (which may take a while to appear).
Click on Files in the upper left corner, then on New Model. This will
create a blank screen for drawing a new model.
When you first start a new model, a window comes up asking you about time
variables. Just click OK to accept the default settings.
First let's create a box representing the heat content of the house, in the
middle of the screen. Since this variable is an accumulation, it's a "box
variable", or a Level variable, by Vensim conventions. There's a row of
icons just above the blank part of the screen, with two "var" buttons. The
one with a box around "var" is the one to click. If you put the tip of the
arrow on it and hold it still for a second or two, you'll see the
identification of the icon, in this case the legend "Box variable - Level."
When you click with the left mouse button, the arrow turns into a little
box with a vertical line in it. With the mouse, move this box to the center
of the screen and click. A rectangular window opens up. Type in, "Heat
content of house" and Enter. A box will appear with that legend in it.
Now move to the row of icons and select the "pointer" icon, the fat arrow
pointing up and left.
By the way, if you make a mistake placing variables or arrows, you can move
them later, or erase them and draw them again. The eraser is the "Pacman"
symnbol, the black circle with a segment missing. Click on that, then move
the Pacman to the item to be removed and click. Move to the original button
and click to go back to what you were doing. To move something, use the
Pointer button, point to the item to be moved, and click-drag it.
At the lower right corner of the new box is a little circle. Put the tip of
the arrowhead on the circle, hold down the left mouse button, and drag it.
The box will change size, so you can adjust it to make the legend look
right (without any word broken in the middle). It probably looks OK but
experiment anyway to see what happens.
We now have a Level variable representing the heat content of the house
(we'll convert that to a temperature later). Now we need to represent two
flows of heat, one into the house (from the furnace) and the other out of
the house (through the walls).
In the row of icons just above the drawing area, find the "rate" icon,
which looks sort of like ==X==>. If you hold the tip of the pointer arrow
still on the icon you can confirm that it is the "rate" symbol. Click on
this button. The arrow will turn into a movable imitation of the icon.
Let's do the furnace output first. The furnace grabs energy from some
un-named place (a fuel tank, perhaps) and converts it into a flow of BTUs,
which we want to go into the house. So place the tip of the arrow about an
inch and a half to the left of the box variable and click once. A little
cloud will appear, indicating some indefinite source of the flow. Now,
without clicking any more, move the mouse to stretch an arrow that comes
out of the cloud and put its tip on the words inside the box variable, and
then click once. A rectangular window will appear. Type the words "furnace
output" and Enter. You now have a Flow Variable putting something into the
Box Variable.
While the symbol you're moving around is still the "flow" symbol (as it
will be until you click a different button), let's put in the heat losses.
Click on the words "heat content of house." That becomes the source of the
flow (not a cloud now, because you've picked a specific source). Use the
mouse to stretch the arrow to the right about an inch and a half, and click
to create a cloud showing some indefinite place where the heat goes. In the
rectangle that appears, type "heat losses to outside", and Enter. Go click
on the first icon in the row of buttons, the arrow pointing up and left, so
you won't accidentally start another flow variable without meaning to.
We now have what is known in Vensim as a "sketch", a diagram of causes and
effects without any details in it. Heat comes out of the furnace on the
left and goes into the house; it comes out of the house to the right and is
lost. In the middle, the house contains a certain quantity of heat, which
we will convert to temperature later by dividing by the heat capacity of
the house.
Now we want to indicate how much the furnace output is. So we need to
indicate a value for the flow variable called "furnace output." Let's say
we want to set the furnace output to 10,000 BTUs per hour. How do we assign
a value?
There is a button in that same row we've been using labeled "Y=X2". Click
on this button, the "Equations" button. This is the button we use to put
the details into the model. You will notice that all our variables turn
into white-on-black legends.
Click on the "Furnace output" flow variable. Voila, a big window. Near its
top it says "furnace output," and just below that, "=". To the right of the
equal sign is a big sub-window, into which we will now type, "10000" with
no commas marking off the thousands. If you then hit "Enter," this window
will close and you will see that "furnace output" has gone back to
black-on-white. This means it has an acceptable value. Vensim has cleverly
taken care of some details which we don't need to worry about now -- for
instance, it has recognized that this variable is now a "constant" and has
given it that type designation.
That was easy. Now click on the box variable, "heat content of house."
Vensim has made life even easier -- the box to the right of the equal sign
is already filled in for us. Vensim has figured out that the level variable
is the integral ("INTEG") of an expression, "furnace output - heat losses
to outside". It has written in the right equation all by itself. It wants
you to type in an initial heat content, so type in 0. Then click on OK to
close the window.
Now we have to do some work. The heat losses depend on the difference
between inside and outside temperature, and on the amount of insulation. We
don't have any inside or outside temperature in the diagram, or any
insulation, or any temperature. So we have to put them there. First,
temperature.
In our row of useful icons, click on the "VAR" buttom _without_ a box. This
is the "auxiliary" variable, or constant, designator. All that means is
that the new variable will not normally be shown in a box, and it will not
represent an accumulation of something. The arrow has changed into a
vertical bar. Move it to a blank area of the screen and click.
A rectangle will appear, into which you can now type, "inside temperature."
Do the same thing again in different blank places on the screen, and create
three more "auxiliary/constant" variables: "heat capacity," "outside
temperature", and "insulation."
Now go click on the pointer button, the arrow pointing up and left. This is
always a good idea when you've finished using another button for a while,
to avoid accidents that are a pain to undo. But now we do it because we
want to move things, and the pointer button can do that.
Click and drag the new variables (the words themselves) so you end up with
the screen looking like this (except that I've left out the box around
"heat content of house" and abbreviated some words).
========X==========> Heat cont of house =========X==========>
Furnace output heat losses to outside
inside temp outside temp insulation
heat capacity
Now we're going to use the curved arrow button, the one that shows causal
influences that are NOT flows. Click on it; the pointer arrow turns into a
copy of that "arrow" icon (the exact active place is the tip of the curved
arrow).
Now click (on-off) on the words "Heat content of house" and move the mouse
to drag the arrowhead to "inside temperature." Click again, and that arrow
will become permanent. Click on "heat capacity" and drag the arrow to
"inside temperature," clicking to finish that arrow connection.
Now click on the Equations button (Y=X2) and then click on "inside
temperature". We get that big window again. There is a small window with
two variable names in it -- the two variables that are connected by arrows
to "inside temperature." Click on "heat content of house" and that label
will appear in the window above next to the equal sign. Type a "/" for
"divided by," and click on "heat capacity". Now the equation is shown as
inside temperature
heat content of house/heat capacity
···
=
which is a funny way to write equations, but complain to Bob :-).
Under a label "type" you will see "Auxiliary", which is correct for the
variable "inside temperature." Vensim figured that out, too. The units box
is unfilled, and we will leave it that way. Just click on OK. We can fix
the units later.
The "Y=X2" button, the equations button, is still pressed, so click on
"heat capacity" and set it to 200, exiting with the Enter key.
Now using the curved arrow key, connect FROM "inside temperature", "outside
temperature", and "insulation" TO "heat losses to outside" (but not to each
other). Using the Equation button, set "outside temp" to 0, and
"insulation" to 0.015.
Click on "heat losses to outside" and set the equation to
heat losses to outside
(inside temperature - outside temperature)/insulation
This is now a runnable model.
The last step is to run it.
In the second row of icons above the model screen, there is a button called
SET with a runner poised at the start line. Click it. Ignore the window
that comes up. Next to it is a button with the runner running. Click it. A
window may appear saying that "Dataset Current already exists" and asking
if you want to overwrite it. Click on Yes, or type "Y". The model will run
briefly and invisibly, storing the results in a "dataset" that you can't
see. The name of the dataset is probably "Current", shown in a box next to
the "run" icon. Then click on what looks like a meter face at the end of
the same row of icons. This opens up the "control panel" window. Click on
the tab "Graph", which opens the graphing window.
If this is the first time a graph has been run for this model (it is),
click on "New..." over on the right side of the window. From then on, to
modify the graphics settings for this model, choose "Modify..." on the left
side.
A big complex window opens up. Find the SET buttons, and click the first
one. A list of the variables in this model will appear. Click on "Inside
temperature." To the right in the same line, click on the space in the
width column and type in "2". This determines the width of the trace on the
plot.
Click on the second SET button and choose "heat losses to outside", setting
width to 2, then click on the third button and select "furnace output",
again setting width to 2. Click OK. The Graph window comes back.
Now, at last, you can run the model. Click on "display". A plot of the
three variables you have selected shows up. On the left there is a separate
scale for each variable. The "inside temperature" rises to 150, and the
heat losses to outside rises to 10000, while the furnace output stays
constant at 10000.
Time to pause and troubleshoot. Please check in with me concerning any
problems you have, so everyone participating in this will end up with the
same model and the same plots. It's worthwhile to play around with this
model a bit to understand it, and we'll do that. Then we can go on to add
the control system.
Best,
Bill P.