← Module 5 · Modeling Assignment M5 (OpenHydroQual)

A tracer moving through a chain of cells: advection, dispersion, and a spill

An illustrated, step-by-step worked example · about 60 minutes · the latest OpenHydroQual · uses Module 5, Sections 3–6 (the ADE, dispersivity, the erfc and Gaussian solutions, numerical dispersion) and the tanks in series of Module 4

What you will build

An 80 m long flow path through sand, cut into 80 cells of 1 m. Each cell is a small Reactor holding the pore water of that metre, and Fixed flow links pass the water from cell to cell at a seepage velocity of 1 m/day. You will feed a tracer continuously at the inlet, first with no dispersion and then with a dispersivity of 2 m, and finally follow a spill. Every stage is checked against the formulas of Module 5. The same chain could just as well be a pipe or a river reach: only the volume, flow and dispersivity would change.

StageWhat changesWhat to look forSaved as
1step input of 100 g/m³ at the inlet, dispersivity 0a smeared front anyway: tanks in series, \(\alpha_{\text{num}} = \Delta x/2 = 0.5\) mM5_stage1_advection.ohq
2+ dispersivity \(\alpha = 2\) m\(C/C_0 = \tfrac12\operatorname{erfc}\big[(x - vt)/(2\sqrt{Dt})\big]\) with \(\alpha + \Delta x/2 = 2.5\) mM5_stage2_dispersion.ohq
3no inflow tracer; a spill of 1000 g/m³ in Cell(10:1)a Gaussian moving at 1 m/day, peak falling as \(1/\sqrt t\)M5_stage3_pulse.ohq

The system

ItemValue
Flow path80 m long, cross-section \(A = 1\) m², porosity \(n = 0.4\); 80 cells of \(\Delta x = 1\) m
Water in one cellpore volume \(nA\Delta x = 0.4\) m³ (the Reactor's Initial Storage)
Flowseepage velocity \(v = 1\) m/day, so \(Q = vnA = 0.4\) m³/day through every link; each cell's residence time is \(\tau_c = 0.4/0.4 = 1\) day
InletCell(1:1) receives the inflow, 0.4 m³/day, at 100 g/m³ (Stages 1–2) or 0 (Stage 3)
Outleta very large Reactor that collects what leaves Cell(80:1)
PositionCell(\(j\):1) is compared with \(x = j\) m: its water has passed through \(j\) cells
Simulation0 to 60 days (Stage 3: 0 to 40 days); each run takes 30–70 seconds

OpenHydroQual writes the mass balance of every cell, exactly as for the tank in Module 1. Between neighbouring cells it adds a dispersive exchange \(\dfrac{D\,\text{area} + \alpha Q}{\text{length}}\,(C_i - C_{i+1})\), the finite-difference form of Fick's law (Module 5, Section 6).

Why 1 m cells? In a Fixed flow link the "length" in that formula is fixed at 1 m and the "area" at a negligible \(10^{-9}\) m², and neither can be changed. So the dispersivity you type is the real \(\alpha\) only if the cells are 1 m long (with other cell lengths you would type \(\alpha \times 1\,\text{m}/\Delta x\)), and molecular diffusion is left out, which Module 5, Example 3 shows is fine in flowing water.

1Load the Mass Transfer plugin

Start a new model and add the Mass Transfer plugin, as in Module 1 (Step 1): File → Preferences → Add plugin.

File menu: Preferences, Add plugin
1 File → 2 Preferences → 3 Add plugin.
Select Plugin: Mass Transfer
1 Mass Transfer, 2 OK.

2Create the tracer and look at its transport properties

Add a Chemical constituent (Add Objects → Chemistry → Chemical constituent) and rename it Tracer, as in Module 1, Step 2. This time look at two properties you left alone in Module 1:

Add Objects, Chemistry, Chemical constituent
1 Add Objects → 2 Chemistry → 3 Chemical constituent.
Tracer properties: diffusion coefficient, dispersivity, name
The constituent's properties. 1 Diffusion Coefficient: leave at 0 (a Fixed flow link ignores it anyway). 2 Dispersivity: 0 for Stage 1; you will set it to 2 m in Stage 2. 3 Name Tracer.

3Create the 80 cells with the Array Generator

Eighty Reactors and seventy-nine links are far too many to draw one at a time. OpenHydroQual can generate a row of identical blocks joined by identical links. Open Add Objects → Create 2D Array.

Add Objects menu: Create 2D Array
1 Add Objects → 2 Create 2D Array.

3a · Select Components

Array generator, Select Components tab
1 Block type Reactor; 2 link type Fixed flow; 3 80 cells horizontally and 4 1 vertically. The generator accepts at most 99 per direction. Then open 5 the Block Properties tab.

3b · Block Properties

Array generator, Block Properties tab
Properties given to every cell. Left: the top of the list; right: the same tab scrolled down to Constant Inflow and Name.
PropertyValueMeaning
1Initial Storage0.4 m³pore water in one metre: \(nA\Delta x = 0.4 \times 1 \times 1\)
2Tracer:Concentration0 g/m³the cells start clean
3Constant Inflow0only Cell(1:1) gets an inflow (Step 4)
4NameCellthe cells become Cell(1:1) … Cell(80:1)

With the pointer over a unit box, the mouse wheel changes the unit (m³ becomes ft³) without telling you. Scroll with the pointer over the property names.

3c · Link Properties (x-x)

Array generator, Link Properties tab
1 Link Properties (x-x) tab: 2 Flow rate 0.4 m³/day, 3 Name Link. Leave the y-y tab empty (there is only one row). 4 Generate.
The row of 80 cells on the canvas
1 The 80 cells and 79 links appear as one long row, with the links pointing from Cell(1:1) toward Cell(80:1), the direction of flow. Zoom with the mouse wheel over the canvas; drag the scroll bar to move along it.
Why is each cell a Reactor with only 0.4 m³ in it?
A Reactor is a completely mixed volume, and the tracer is dissolved in the pore water, so each Reactor holds only the water of its metre of sand: 40 % of 1 m³. The sand grains themselves play no part until sorption (Module 6). The cell residence time is \(\tau_c = 0.4/0.4 = 1\) day, the time the water needs to cross 1 m at 1 m/day.

4Feed the inlet: Cell(1:1)

Expand Blocks in the Object Browser and click Cell(1:1). Give it the inflow, exactly as you gave the tank its inflow in Module 1.

Cell(1:1) properties
1 Tracer:Constant Inflow concentration 100 g/m³ (\(C_0\)); 2 Constant Inflow 0.4 m³/day.

This is a "continuous source" (Module 5, Section 5b): from \(t = 0\) the water entering the column carries 100 g/m³.

5Add the Outlet and the last link

Add a Reactor named Outlet with an Initial Storage of 1e+06 m³, as in Module 1, Step 4, and drag it just past the right end of the row. Then choose Fixed flow and drag from Cell(80:1) to Outlet; set its flow rate to 0.4 m³/day.

Reactor icon
1 Reactor.
Fixed flow icon
1 Fixed flow.
Cell(80:1), the last link and the Outlet
1 Cell(80:1), 2 the link Cell(80:1) → Outlet, 3 Outlet. Check the status bar or the link's name: it must go from the cell to the Outlet.
Draw links in the direction of flow. OpenHydroQual multiplies the dispersivity by the link's flow. A link drawn backwards carries the water the wrong way, and once dispersion is switched on its "dispersion" is negative, which makes the model blow up.

6Simulation time and time step

As in Module 1, Step 6: in Settings → General Settings set the end time to 60 days, and in Solver Settings keep the initial time-step at 0.01 and set the Maximum allowable time-step increase factor to 5.

Solver Settings
1 Initial time-step 0.01; 2 maximum time-step increase factor 5. The largest step is then 0.05 day.

The time step matters more here than in Module 1. In one step the water moves \(v\Delta t\); a long step smears the front over that distance, which looks just like extra dispersion (about \(v\Delta t/2 = 0.025\) m here, small next to the 0.5 m from the cells).

Stage 1Advection only

Save the model as M5_stage1_advection.ohq, close it and open it again, then press Run Model and confirm. The run takes about a minute.

Run Model button
1 Run Model.
Running Model window
Close the window when it says Finished!

Right-click Cell(40:1) (zoom in on the row to find it) → Results → Tracer:Concentration. Do the same for Cell(20:1).

Tracer concentration in Cell(40:1), Stage 1
Cell(40:1), 40 m from the inlet. With pure advection the tracer would arrive as a sharp step at \(t = x/v = 40\) days. The model shows an S-curve instead: 5 g/m³ at 30 days, 52 at 40 days, 93 at 50 days.

Why is the front smeared when the dispersivity is zero?

Each cell is completely mixed, so tracer entering it reaches its outlet at once: the chain is the tanks-in-series reactor of Module 4. For a step input the concentration in the 40th tank, with \(\tau_c = 1\) day, is

\[ \frac{C_{40}}{C_0} = 1 - e^{-t}\sum_{k=0}^{39}\frac{t^k}{k!} \qquad\Rightarrow\qquad 4.6,\ 52.1,\ 93.5\ \text{g/m}^3 \text{ at } 30, 40, 50 \text{ days}, \]

which the model reproduces. Module 5, Section 6 showed that this is the same as the ADE with a numerical dispersivity \(\alpha_{\text{num}} = \Delta x/2 = 0.5\) m: \(C/C_0 = \tfrac12\operatorname{erfc}\big[(40 - t)/(2\sqrt{0.5\,t})\big]\) gives 3.4, 50.0 and 92.1. The lesson for every model you build: cutting space into mixed cells adds dispersion of its own.

Stage 2Add dispersion

Click Tracer under Constituents and set its Dispersivity to 2 m. Save as M5_stage2_dispersion.ohq and run. Plot Cell(20:1) and Cell(40:1) again.

Tracer dispersivity set to 2 m
1 Dispersivity 2 m.
Tracer concentration in Cell(40:1), Stage 2
Cell(40:1) with dispersion. The front is much wider: 21 g/m³ at 30 days, still 51 at 40 days, 75 at 50 days. The middle of the front still arrives at \(x/v = 40\) days. If the curve looks exactly like Stage 1, the dispersivity is still 0.
Check it by hand: Cell(40:1) at 30 days

The model's dispersivity is the one you entered plus the cells' own: \(\alpha + \Delta x/2 = 2.5\) m, so \(D = 2.5 \times 1 = 2.5\) m²/day. The first term of the continuous-source solution:

\[ \frac{C}{C_0} = \frac12\operatorname{erfc}\!\left(\frac{40 - 30}{2\sqrt{2.5 \times 30}}\right) = \frac12\operatorname{erfc}(0.577) = 0.207 \quad\Rightarrow\quad 20.7\ \text{g/m}^3 \]

The model gives 21.0 g/m³. With the 2 m you entered, without the numerical part, the formula gives 18.1 g/m³.

Why only the first erfc term? The second term of the Ogata–Banks solution belongs to an inlet held at exactly \(C_0\). The model's inlet instead adds mass at the rate \(QC_0\) (a flux inlet), for which the first term alone is the better approximation; it matches the model to within 1.5 g/m³ at all times.

Also read the times when Cell(40:1) reaches 15.9 and 84.1 g/m³ (\(t_{16}\) and \(t_{84}\)), and estimate \(D\) as in Module 5, Section 5c: \(\sigma_t = (t_{84} - t_{16})/2\), \(D = \sigma_t^2v^3/(2x)\). The model gives \(t_{16} = 28.0\) and \(t_{84} = 56.0\) days, so \(\sigma_t = 14.0\) days and \(D = 2.44\) m²/day: close to the 2.5 m²/day the model "really" has.

Stage 3A spill

Save a copy as M5_stage3_pulse.ohq. Now the inflow is clean and the tracer starts in one cell, the computer's version of the instantaneous release of Module 5, Section 5a.

Cell(10:1) with an initial concentration of 1000
1 Cell(10:1) selected; 2 Tracer:Concentration 1000 g/m³ (the initial value).

Save and run. Then open Model → Visualize, choose Tracer:Concentration, and move the time slider to 10, 20 and 30 days. Hover over a cell to read its value.

Visualize window: the spill at 20 days
1 Property Tracer:Concentration, 2 time slider at 20 days, 3 legend maximum (type 60) and 4 minimum (0). The spill is centred on Cell(30:1), 20 m downstream of where it started. (The "Mid" box does not update when you change the maximum; ignore it.)
Tracer concentration in Cell(40:1), Stage 3
Cell(40:1) over time: the cloud passes with a peak of 33 g/m³ at about 28 days, slightly before the advective arrival at 30 days (Module 5, Section 5a explains why).
Check it by hand: the spill at 20 days

Centre: \(x_0 + vt = 10 + 20 = 30\) m (model: 30.0 m, peak in Cell(30:1)). With the model's dispersivity, \(D = 2.5\) m²/day:

\[ C_{\max} = \frac{M/(nA)}{\sqrt{4\pi D t}} = \frac{1000}{\sqrt{4\pi(2.5)(20)}} = 39.9\ \text{g/m}^3, \qquad \sigma = \sqrt{2Dt} = 10.0\ \text{m} \]

The model gives 39.8 g/m³ and a spread (standard deviation of the cell values) of 9.96 m. With \(\alpha = 2\) m alone the formula would give 44.6 g/m³. The total mass stays at 1000 g/m² until the cloud reaches the outlet.

The three stages against the formulas
The three stages (blue and coloured lines and dots: model) against the Module 5 formulas. Black dashed: the formula with \(\alpha + \Delta x/2\), on top of the model every time. Orange dotted: the formula with the dispersivity you typed.

Checkpoints

Read these from your own runs; small differences in the last digit are normal.

StageQuantityModelFormula
1Cell(40:1) C at 30 / 40 / 50 days (g/m³)5.0 / 51.9 / 93.1tanks in series 4.6 / 52.1 / 93.5
1Cell(20:1) C at 15 / 20 / 25 days (g/m³)13.0 / 52.8 / 86.0tanks in series 12.5 / 53.0 / 86.6
2Cell(40:1) C at 30 / 40 / 50 days (g/m³)21.0 / 50.9 / 74.8erfc, α + Δx/2: 20.7 / 50.0 / 73.7
2Cell(20:1) C at 15 / 20 / 25 days (g/m³)28.3 / 50.9 / 68.7erfc, α + Δx/2: 28.2 / 50.0 / 67.3
2D from \(t_{16}\), \(t_{84}\) at Cell(40:1) (m²/day)2.442.5
3Peak C at 10 / 20 / 30 days (g/m³)56.4 / 39.8 / 32.5Gaussian, α + Δx/2: 56.4 / 39.9 / 32.6
3Cell with the peak at 10 / 20 / 30 daysCell(20:1) / (30:1) / (40:1)\(x_0 + vt\) = 20 / 30 / 40 m
3Cell(40:1): highest C and when33.1 g/m³ at 27.8 daysadvective arrival 30 days

Explore

Save a copy with File → Save as and change one thing at a time.

Troubleshooting

Stage 2 looks exactly like Stage 1.The Tracer's dispersivity is still 0: set it to 2 m and run again.
The concentrations explode once dispersion is on.A link was drawn against the flow (from the Outlet to Cell(80:1), for example). Delete it and draw it in the flow direction.
The tracer never gets past Cell(1:1).The link flow rate is 0: set 0.4 m³/day on every link (Array Generator, Link Properties).
Cell(1:1) overflows or empties.The inflow and the link flows differ. Plot Storage of a few cells: it should stay at 0.4 m³.
The front arrives at the wrong time.Check Initial Storage 0.4 m³ (not ft³) and the flow 0.4 m³/day in every link: \(\tau_c = 1\) day per cell.
The Array Generator will not take 150 cells.It accepts at most 99 in each direction.
The run is slow.80 cells for 60 days takes about a minute. Close other programs; do not lower the time step further.

What to submit