Courses: The GoldSim Contaminant Transport Module:

Unit 5 - Building a Simple Model of a Well-Mixed Environmental Compartment

Lesson 9 - Understanding the Equations for a Well-Mixed Tank

As we mentioned in Unit 3, as a general rule, you should not use “black boxes” to build models.  If you don’t understand how a tool works, you should not use it. Hence, throughout the Course we will provide the actual equations that are incorporated into the Contaminant Transport Module elements, and will also discuss (in general terms) how GoldSim solves the equations numerically.

Understanding in general terms how GoldSim solves the equations is important because it provides insight into the errors introduced by the numerical approximations used to solve the equations.

This is a good problem to start this process with because it is so simple. So let’s first examine the equations associated with our well-mixed tank example.

We will start with how GoldSim solves for mass in the pathway. The two governing equations (one for each species) are as follows:

In these equations, Mrepresents the mass of X, MY represents the mass of Y, and λis the decay rate of Y.  Recall that λ is equal to ln(2) divided by the half-life. Note also that there is no ingrowth from decaying species.

Obviously, the equation for MX simply indicates that the mass of X stays constant.  Although the second equation actually can be solved analytically (it is just exponential decay), GoldSim solves the equation numerically (for most problems, an analytical solution would not be possible).  As discussed in Unit 3, Lesson 7, GoldSim solves an equation like this using a finite-difference approximation for the time derivative.  In this case, it looks like this:

where the superscript k refers to the current timestep, k-1 refers to the previous timestep, and Δt is the timestep length. This particular representation is a fully implicit approach (the right-side of the equation refers to the current mass, not the previous timestep’s mass).

Since at any given time k we know what the value was at time k-1, we can easily solve this equation.  That is, for any given timestep, we can express the value of Min terms of its value at a previous timestep:

In fact, if you wanted to, you could easily program this into a spreadsheet to test if that is indeed how GoldSim is solving the equation. A comparison of GoldSim and spreadsheet results are shown side-by-side below (for the first ten days):

Note: As discussed in Unit 3, Lesson 8 of the Basic Course, to view a table of result values like this for a time history, simply press the Table button when viewing a time history result.  You can return to a chart by pressing the Chart button.

If you look closely, you will note that these are not actually the same.  So what is going on here? To carry out the spreadsheet calculation, we assumed a value for Δt of 1 day (since that was the GoldSim timestep). However, this is not actually the value of Δt that GoldSim used to solve this equation. In order to solve the contaminant transport equations involving Cells more accurately, GoldSim actually subdivides the computational timestep (into what are referred to as fractional timesteps). That is, it uses a smaller timestep than the specified timestep to solve these equations.  (As we will discuss further in Unit 7, this smaller timestep is used only for solving the contaminant transport equations; it is not applied to other variables or calculations in the model; hence results are still only saved and plotted using the specified timestep).

The manner in which GoldSim subdivides the timestep is determined via a setting that you can control. The setting can be found on the Contaminant Transport tab of the Options dialog (accessed by selecting Model | Options… from the main menu):

At the top of the dialog, you will see an option for Solution precision. The three options are Low, Medium (the default) and High. If this is set to Low, GoldSim does not subdivide the timestep for the solving the contaminant transport equations; if it is set to Medium, it subdivides the timestep by a factor of 4; if it is set to High, it subdivides the timestep by a factor of 10. The default setting for the Solution precision is Medium (4 fractional steps), so if we were to redo the spreadsheet calculation based on a 0.25 day timestep, we would see that it matches the GoldSim results exactly.

For this particular example, the results (for the mass in the Cell after one half-life of 50 days) for runs at different precision settings are summarized below:

Precision Mass at 50 days (g)
Low Precision 50.24
Medium Precision 50.06
High Precision 50.02

The analytical result is 50.00.  As can be seen, the solution improves as the precision setting increases. Even with low precision, the error in this particular example is less than 1% (and for medium precision, it is about 0.1%).

 In most cases, you will not need to be concerned about the Solution precision (and can keep it at the default setting).  However, the setting also has other impacts on the calculation that can be important in some situations.  Hence, we will revisit the Solution precision in later Units.

While we are looking at this Options dialog, it is worthwhile to briefly discuss the other settings we see here:

  • Log warning messages: If this box is checked, GoldSim writes warning messages associated with the Contaminant Transport Module to the Run Log.  This box is defaulted on, and generally, you should not clear it, as it can be dangerous to ignore warning messages.
  • Log cell-network details: If this box is checked, a large number of detailed messages regarding the cell net calculations are written to the Run Log.  This is an advanced debugging option (and is therefore defaulted off), and generally should not be checked.
  • Disable decay of species: If this box is checked all decay rates are ignored (obviously, it is defaulted off).  This, however, is often of value when first trying to build, test and debug a model.
  • The Source Term options are associated with use of the Source element (available only with the RT Module).  We will discuss this element in Unit 11.
  • The Display Units options determine the units used for displaying results.  Recall that the results we viewed above for mass, fluid concentration and solid concentration were displayed in g, mg/l and g/kg, respectively.  These can be modified here.

Returning to our discussion of how GoldSim solved the equations, now that we understand how the mass in the Cell was computed, we also need to discuss how the concentration was computed. As discussed in Unit 3, Lesson 5, assuming equilibrium partitioning with a single solid, the dissolved concentration of a species in the water is computed as:

where V is the volume of water, G is the mass of solid, and K is the partition coefficient.

The corresponding concentration of the species associated with the solid is computed as follows:

Finally, the total concentration in the water (accounting for the suspended solid) is computed as:

In this simple example (in which there is only one solid and all of it is suspended), this reduces to: