**2. Models of Pollutant Transport for Teaching Water Quality Modeling**

Many environmental engineering curricula include a course on mass-balance based surface water quality modeling. These courses build and expand upon the steady-state, one-dimensional dissolved oxygen/BOD modeling that is usually taught at the undergraduate level. The courses rely on process-based descriptions of fate and transport of constituents in surface water systems that are analyzed by solving mass balance equations for one or more of the constituents. The assignments in the courses typically are computationally intensive in keeping with the subject matter. A number of textbooks are available to teach such a course [30–34]; here we examine the use of Simulink in a graduate-level course that has been taught several times using the Chapra text.

An example problem from the Chapra text is used here to illustrate alternative means of model development for quantitative problem solving. In this particular problem (Problem 10.3), conservative dye is being flushed from a completely mixed pond into a channel by a river diversion (Figure 1). The dye exits the pond as an exponentially decaying source of mass to a downstream channel. No mixing occurs in the channel. After a travel period downstream in the channel, the diverted river water containing the dye is conservatively mixed back into the river. The student is asked to calculate the concentration time history at the pond exit, the channel exit, and after mixing into the river.

Students have typically solved this problem with a spreadsheet solution created using Microsoft Excel (Figure 2). Spreadsheet equations are used to calculate the three needed time histories; Excel charts are created to visualize the results. While not an onerous problem for the students, use of these spreadsheet solutions in the class can present several problems. Students generally know Excel, but they vary widely in their expertise with it. Complex problems can overwhelm their capabilities and their patience with cut and paste solutions, even when problem specific parameter names are used. Solutions often involve long complex equations that are difficult to impossible to debug. Solutions typically have no common look and feel and are therefore time consuming to grade. Finally, there is often little opportunity to reuse spreadsheet solutions from problem to problem.

The use of Simulink as a model development tool for problem solving in the graduate-level water quality modeling course was first piloted in an independent study version of the course. Two students who had previously taken the modeling course were offered an independent study to learn Simulink and demonstrate its use through problem-based model development. After a successful pilot program, Simulink was used as the primary means for student problem solving when the water quality modeling course was offered the following year. The course included one week of training in Simulink followed by another week in the computer lab solving some simple example problems from the Chapra text. Over the remainder of the semester, approximately two Simulink problems were assigned each week over the remainder of the fourteen-week semester. While not all textbook problems were amenable to Simulink solutions, there were sufficient problems available in all sections of the course that could be solved with a Simulink model.


**Figure 2.** Solution to pond-channel-river problem (Chapra 10.3) created in Excel.

As an example, the corresponding Simulink solution created by one of the students for the problem described earlier is shown in Figure 3. The Simulink solution couples constituent mass-balance based solutions for the pond, channel, and river. The model also includes a separate subsystem for the volume balance in the pond (Figure 3). Simulink "scope" blocks are used to visualize the concentration time histories at the three locations. The system parameters and concentration time histories are bundled into data buses and passed between the subsystems that need the particular data.

**Figure 3.** Solution to pond-channel-river problem (Chapra 10.3) created in Simulink.

Solution of the constituent mass balance in the pond uses a continuous time integration of the mass balance equation for a completely mixed reactor:

$$\frac{d(VC)}{dt} = \mathcal{W} + \mathcal{Q}\_{ln}\mathcal{C}\_{ln} - \mathcal{Q}\_{out}\mathcal{C} \pm X \tag{l}$$

where *C* and *C*in (g/m3 ) represent the constituent concentrations in the reactor and its inflow, *W* (g/day) is a mass load to the reactor, *X* (g/day) is the reaction term in the reactor, and *Q*in and *Q*out (m3 /day) are the inflow and outflow of the reactor, which has a volume V. The pond constituent mass balance uses a solution to Equation (1) that has as its basis a solution for an earlier problem having only a single completely stirred reactor (Figure 4). As compared with previous years where students used either handwritten analytical solutions or Excel spreadsheets, student solutions created in Simulink were found to be much easier to grade. Similarity between student solutions was aided by including with the problem assignment example figures showing a recommended overall model structure and some example *x*–*y* plots. Students liked the ability to use components from previous problems in their solution and in general caught on quickly to creating solutions in Simulink. Reuse of the mass balance solution for later problems was found to be straightforward. The solution served as the basis of several problems later in the course.

**Figure 4.** Simulink model of pond mass balance for a constituent.
