Courses: The GoldSim Contaminant Transport Module:

# Unit 2 - Using Arrays in GoldSim

# Lesson 10 - Unit 2 Summary

In this Unit, we described a key feature that the Contaminant Transport Module depends upon: the use of * arrays*. This is actually a feature of the basic GoldSim framework. However, the Contaminant Transport Module utilizes this feature extensively, and therefore a good understanding of the feature is required to use the Contaminant Transport Module.

- In many models, you will want to create and manipulate elements that represent collections, rather than individual items. To address these kinds of problems, GoldSim allows you to create and manipulate
and*vectors*(collectively referred to as*matrices*). We only focused only on vectors, as these are the types of arrays that are used by the Contaminant Transport Module.*arrays* - When you define a vector, it must be defined relative to a particular set of
. A set of Array Labels is simply a collection of labels for the items of the vector. The labels can be numbers (e.g., 1, 2, …, 10) or names (e.g., apples, oranges, peaches, pears).*Array Labels* - There are two ways to create vectors: using a Data element or using a
function.**vector constructor** - You can reference a single item of a vector using the syntax
*OutputName[ItemName]*. This single item is a scalar. - Standard operators (+, -, *, /) can be used to manipulate vectors.
- The addition (+) and subtraction (-) operators can be used between vectors if and only if the two vectors are defined using the same set of Array Labels. GoldSim carries out the operation term-by-term and produces a vector with the same Array Label set. Note that you cannot add or subtract a vector to/from a scalar.
- The multiplication (*) and division (/) operators can be used between vectors and a scalar. The multiplication (*) and division (/) operators can be used between vectors if and only if the two vectors are defined using the same set of Array Labels. GoldSim carries out the operation term-by-term and produces a vector with the same set of Array Labels as the original vectors.
- Relational operators (e.g., >, <, =, ==, >=) can be used between vectors if and only if the two vectors are defined using the same set of Array Labels. GoldSim carries out the operation term-by-term.
- In addition to using mathematical operators, most of the built-in functions in GoldSim can also operate on arrays. In most cases, these functions carry out the operation term-by-term and produce an array of the same order as the input argument. Several functions (e.g., max, min, mod) accept multiple vector arguments. In this case, the arguments must be defined using the same set of Array Labels. GoldSim carries out the operation term-by-term and produces an array of the same order.
- In addition to the standard functions, GoldSim also provides a wide variety of special
which allow you to manipulate arrays.*array functions* - Many of the GoldSim elements can manipulate (and output) arrays. For example, you can add a number of vectors using the Sum element, or compute the peak value of each item of a vector using the Extrema element. Other elements such as Stochastics and Reservoirs can also be vectors.
- Many inputs for the Contaminant Transport Module will be vectors (of the different contaminant species being simulated). Moreover, many of these inputs will be uncertain and hence represented by different probability distributions. As a result, it is not uncommon to build a vector of probability distributions using a Data element to represent these vector inputs.

Now that we have covered this use of vectors in GoldSim, we are ready to learn about the Contaminant Transport Module. In the next Unit, we will start to do so.