# Lesson 10 - Summing Flows (and Other Variables) Using the Sum Element

When simulating the flow of materials (such as water or money or people) through a system, we have seen how to split or allocate a flow at a particular point and redirect it to multiple destinations using either a Splitter element (Unit 7, Lesson 6) or an Allocator element (Unit 7, Lesson 8). However, it is just as common to combine (sum) flows at a particular location.

For example, suppose that flows from multiple locations were all being collected by a sump or drainage ditch, and the collected (combined) water was then pumped to several different locations. To model that we could add these various flows to a Splitter that then subsequently redirected the water. Such a model might look like this:

The Splitter would look like this:

Although there is nothing technically incorrect about this, as the number of flows increase, this structure could become error-prone and difficult to manage (e.g., you would have a long expression in the Amount field).  A better alternative is to use a Sum element.  A Sum element is quite simple.  It simply allows you to create a list of items to sum.  In order to better understand this, insert a Sum element now (you will find it in the “Functions” category):

Sum elements have a single output, which must be a value. You add an item to the Sum by pressing the Add Input button. A browser tree showing all of the elements in the model will then be displayed. Note that this tree is organized by containment in the same manner as the main browser. To insert a link from this dialog, you select a specific output (or an element having a primary output), and then press OK. The inputs to the Sum must all have the same attributes (e.g., dimensions). You can add as many inputs as you wish (scroll bars appear when the number of entries can no longer fit in the dialog).

So for the example mentioned above, we could reorganize the model using a Sum element to look like this:

The Sum element for inflows to the sump would look like this:

The Splitter would look like this:

Such a structure has the advantage of organizing the flows in a clear and concise way (e.g., so it will be more obvious if something was omitted).

Of course, you could have accomplished the same thing by just using an Expression element to add up the various flows.  However, the Sum element is much more effective at this for two reasons: 1) it is easier to create and to view a Sum than it is to write a long summation equation; and 2) when viewing the model in the graphics pane, the icon for the Sum element makes it very clear what it is doing: it is adding things together. If you used an Expression to do the sum, the fact that the Expression is adding the items cannot be surmised from simply looking at the graphics pane.

Another obvious place to use a Sum element would be in a situation where you have multiple inflows and/or outflows to a Reservoir.  As we will see in the next several Lessons, however, GoldSim provides a more powerful way to do this than using a Sum.

Finally, it is worth noting that although in the example above we are using a Sum to add together flows, the Sum element itself is completely generic.  It can be used to add together anything.  It simply provides an easy and clear way to add together any number of variables.