dcrest-course / session-07.html
hydros-ou's picture
Add a narrated video to every session
bf47225 verified
Raw History Blame Contribute Delete
14.8 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Session 7 · Groundwater: drainage, spill, baseflow — dCREST, step by step</title>
<meta name="description" content="The aquifer store that keeps rivers flowing between storms: drainage from the soil, fill-and-spill, and nonlinear baseflow.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400&family=Source+Sans+3:wght@400;600;700&display=swap">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uplot@1.6.31/dist/uPlot.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/codemirror.min.css">
<link rel="stylesheet" href="assets/course.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/uplot@1.6.31/dist/uPlot.iife.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/codemirror.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/mode/python/python.min.js"></script>
<script defer src="assets/dcrest.js"></script>
<script defer src="assets/course.js"></script>
</head>
<body>
<main>
<div class="kicker">Session 7 · Inside one day</div>
<h1>Groundwater: drainage, spill, baseflow</h1>
<p class="lede">Session 1 noticed that the Leaf River never stops flowing, even after weeks without rain. That water comes from groundwater. This session follows water from the soil down into dCREST's aquifer store and back out as baseflow, and shows why the shape of the baseflow rule controls how a river recedes in a drought.</p>
<div class="meta"><span><b>Time</b> about 25 minutes</span><span><b>Needs</b> Sessions 5 and 6</span></div>
<figure class="video"><video controls preload="none" playsinline poster="video/s07.jpg"><source src="video/s07.mp4" type="video/mp4"></video>
<figcaption>Watch this session first: a 5-minute narrated video with English subtitles. The page below goes further and lets you try each step yourself.</figcaption></figure>
<div class="goals"><h4>You will be able to</h4><ul>
<li>compute drainage from the soil to the aquifer;</li>
<li>apply the aquifer's fill-and-spill rule;</li>
<li>compute baseflow from the exponential rule and explain what <var data-v="gwc">gwc</var>, <var data-v="gwe">gwe</var> and <var data-v="hmaxaq">hmaxaq</var> do;</li>
<li>explain how the baseflow rule shapes dry-weather recessions.</li>
</ul></div>
<figure class="wide"><div class="plate"><svg id="map" role="img" aria-label="Model diagram with the aquifer store highlighted"></svg></div>
<figcaption>Where we are: the aquifer receives drainage from the soil and releases baseflow (and spill) to the river; on dry days it also supplies some evaporation (Session 6).</figcaption></figure>
<h2>Drainage: from soil to aquifer</h2>
<p>After the soil step, a small fraction of the soil water seeps downward every day, wet or dry, to the groundwater below:</p>
<div class="eq">\[ D_s = \min(\mathit{ksoil}\cdot \mathit{SM}',\; \mathit{SM}'), \qquad \mathit{SM} \leftarrow \mathit{SM}' - D_s, \qquad G \leftarrow G + D_s \]</div>
<p><var data-v="ksoil">ksoil</var> is a rate per day: the fraction of the soil water that drains each day. The minimum only guards against draining more than is there, which cannot happen while <var>ksoil</var> is below 1. For the Leaf River <var>ksoil</var> = 0.00423 per day: about 0.42% of the soil water drains each day, so on its own the soil would lose half its water in about 163 days. On 15 August 1993, with 159.0 mm in the soil after evaporation, 0.67 mm drained to the aquifer.</p>
<h2>The aquifer fills and spills</h2>
<p>The aquifer, holding <var data-v="G">G</var> mm, has a capacity <var data-v="hmaxaq">hmaxaq</var>. Water drained into a full aquifer cannot be stored and leaves at once as <strong>spill</strong>:</p>
<div class="eq">\[ Q_{sp} = \max(G - \mathit{hmaxaq},\; 0), \qquad G \leftarrow \min(G,\; \mathit{hmaxaq}) \]</div>
<p>Spill is treated as part of baseflow. In very wet periods it lets groundwater respond quickly once the aquifer is full. For the Leaf River <var>hmaxaq</var> = 106.9 mm; spill provides 24% of the groundwater contribution over 1989–1999, most of it (84%) from February to May, when the aquifer is full.</p>
<h2>Baseflow</h2>
<p>The aquifer then releases baseflow. dCREST does not use a linear reservoir here; it uses an exponential rule in the aquifer's relative fullness \(G/\mathit{hmaxaq}\):</p>
<div class="eq">\[ Q_b = \min\!\Big( \mathit{gwc}\,\Big[\exp\!\Big(\mathit{gwe}\,\frac{G}{\mathit{hmaxaq}}\Big) - 1\Big],\;\; G \Big), \qquad G \leftarrow G - Q_b \]</div>
<p>Three properties make this a good choice:</p>
<ul>
<li>It is exactly zero when the aquifer is empty (\(e^0 - 1 = 0\)) and grows smoothly as it fills, so there is no threshold where the gradient would vanish.</li>
<li>It is strongly nonlinear: a full aquifer drains far faster than a half-full one. For the Leaf River, a full aquifer releases 0.54 mm/day and a half-full one only 0.090 mm/day, about 6 times less. Recessions are steep at first and then very slow, which is how most rivers behave.</li>
<li><var data-v="gwc">gwc</var> sets the overall size (mm/day) and <var data-v="gwe">gwe</var> how sharply baseflow rises near full storage.</li>
</ul>
<div class="widget wide" id="bf">
<div class="whead"><span class="wtag">Try it</span><span class="wtitle">The baseflow rule and the recession it makes</span></div>
<div class="controls" id="bf_ctl"></div>
<div class="grid2" style="margin:0">
<div><div class="note">Baseflow against aquifer fullness</div><div class="chart" id="bf_curve"></div></div>
<div><div class="note">A drought: aquifer starts full, no input for 365 days (log scale)</div><div class="chart" id="bf_rec"></div></div>
</div>
<p class="note">Grey: a linear reservoir that releases the same amount when the aquifer is full. Under the dCREST rule the flow falls steeply at first, because outflow shrinks faster than the store, and the remaining water then drains very slowly. With the Leaf River values, after a year without input the dCREST aquifer has released 61 mm and still holds 46 mm of its 107; the linear one has released 90 mm and holds 17 mm. Raise <var>gwe</var> to make that contrast stronger.</p>
</div>
<h2>The aquifer at the Leaf River</h2>
<div class="widget wide" id="aq">
<div class="whead"><span class="wtag">Data</span><span class="wtitle">Ten years of groundwater, from the model</span></div>
<div class="chart" id="aq_chart1"></div>
<div class="chart" id="aq_chart2"></div>
<p class="note">Top: aquifer storage <var>G</var> with its capacity dashed. Bottom: baseflow, spill and the observed river flow on a log scale. In late summer the observed flow falls to a few tenths of a millimetre per day; in the model that flow is almost all baseflow.</p>
</div>
<p>The aquifer fills in winter, when evaporation is low and drainage outpaces baseflow, and empties slowly through summer, when baseflow and aquifer evaporation (Session 6) exceed the small drainage from a drying soil. Over 1989–1999 groundwater supplies 25% of the model's runoff. That is a small share of the total, but on most late-summer days (90% of August and September days) it is almost all of the river.</p>
<div class="callout code"><span class="label">In the code: src/dcrest/kernels/soil.py (end, shortened)</span>
<pre><code># soil drainage to the aquifer
soil2gw = torch.minimum(KSOIL * kd * drainable, drainable)
Wo = Wo - soil2gw
gw = gw + soil2gw
# fill-and-spill aquifer, exponential baseflow
spill = torch.clamp(gw - HMAX, min=0.0)
gw = torch.minimum(gw, HMAX)
base = torch.minimum(GWC * kd * torch.expm1(GWE * torch.clamp(gw, min=0.0) / HMAX), gw)
gw = gw - base
return over, inter, base + spill, Wo, gw</code></pre>
<p><code>torch.expm1(x)</code> computes \(e^x - 1\) accurately even when \(x\) is tiny, which matters when the aquifer is nearly empty. Spill is returned together with baseflow. The aquifer step follows CRESTPhys, an extension of CREST that exists only in a fork of EF5 (github.com/mchen15ouedu/EF5), not in the official EF5; it added a groundwater store to CREST's single soil store. (In CRESTPhys the excess water within the interflow cap also recharges that store; dCREST v1.0, like the official CREST, makes it interflow.) The code above is shortened: <code>drainable</code> is the soil water after the day's infiltration or evaporation, \(\mathit{SM}'\), with the default options.</p>
</div>
<h2>In Python</h2>
<div class="pycell" data-title="Baseflow and a drought recession">
<textarea>
from dcrest_course import *
case = load_case()
p = case.params
h, gwc, gwe = p["hmaxaq"], p["gwc"], p["gwe"]
for frac in (1.0, 0.75, 0.5, 0.25, 0.1):
print(f"aquifer {frac:4.0%} full: baseflow {gwc * math.expm1(gwe * frac):.4f} mm/day")
G, flow = h, [] # start full, no rain, no drainage
for day in range(365):
Qb = min(gwc * math.expm1(gwe * G / h), G)
G -= Qb
flow.append(Qb)
print(f"\nafter 30 days {flow[29]:.3f} mm/day, after 180 days {flow[179]:.4f}, after 365 days {flow[364]:.5f}")
plot(np.arange(1, 366), flow, labels=["baseflow (mm/day)"], title="A year without input", xlabel="day", ylog=True)
</textarea>
</div>
<h2>Check your understanding</h2>
<div class="quiz">
<details><summary>The soil holds 200 mm after the soil step and <var>ksoil</var> = 0.01. How much drains to the aquifer today?</summary><div class="ans"><p>\(0.01 \times 200 = 2\) mm.</p></div></details>
<details><summary>The aquifer holds 100 mm with <var>hmaxaq</var> = 100 mm, and 3 mm drain into it. What happens?</summary><div class="ans"><p>G becomes 103 mm, so 3 mm spill and G is set back to 100 mm. Then baseflow is computed from the full aquifer.</p></div></details>
<details><summary>Why does a river with exponential baseflow recede quickly at first and then very slowly?</summary><div class="ans"><p>Because baseflow grows exponentially with storage: at high storage it is large and drains the aquifer fast; as storage falls, baseflow drops sharply and the remaining water drains slowly.</p></div></details>
<details><summary>Why use \(e^{x} - 1\) instead of \(e^{x}\)?</summary><div class="ans"><p>So that an empty aquifer gives exactly zero baseflow, smoothly, with no threshold.</p></div></details>
</div>
<div class="remember"><h4>What to remember</h4><ul>
<li>Each day a fraction <var>ksoil</var> of the soil water drains to the aquifer.</li>
<li>The aquifer holds at most <var>hmaxaq</var>; anything above it spills.</li>
<li>Baseflow is \(\mathit{gwc}\,[\exp(\mathit{gwe}\,G/\mathit{hmaxaq}) - 1]\): zero when empty, steep when full.</li>
<li>Groundwater carries only part of the yearly runoff but almost all of the dry-season flow.</li>
</ul></div>
</main>
<script>
window.pageInit = async function () {
Course.modelDiagram(document.getElementById("map"), { highlight: "aquifer" });
const c = await Course.data(), css = Course.css;
const st = { gwc: c.params.gwc, gwe: c.params.gwe, h: c.params.hmaxaq };
let uc = null, ur = null;
function drawBf() {
const x = Float64Array.from({ length: 101 }, (_, i) => i / 100);
const qb = Float64Array.from(x, (f) => st.gwc * Math.expm1(st.gwe * f));
const k = qb[100] / st.h; // linear reservoir with the same outflow when full
const lin = Float64Array.from(x, (f) => k * f * st.h);
if (uc) uc.setData([x, qb, lin]); else uc = Course.xyChart(document.getElementById("bf_curve"), { x, height: 240, xlabel: "G / hmaxaq", ylabel: "baseflow (mm/day)",
series: [{ label: "dCREST rule", values: qb, color: css("--aquifer"), width: 2.4 }, { label: "linear reservoir", values: lin, color: css("--faint"), dash: [5, 4] }] });
const days = Float64Array.from({ length: 365 }, (_, i) => i + 1);
const a = new Float64Array(365), l = new Float64Array(365);
let G = st.h, G2 = st.h;
for (let i = 0; i < 365; i++) { const q = Math.min(st.gwc * Math.expm1(st.gwe * G / st.h), G); G -= q; a[i] = Math.max(q, 1e-6); const q2 = k * G2; G2 -= q2; l[i] = Math.max(q2, 1e-6); }
if (ur) ur.setData([days, a, l]); else ur = Course.xyChart(document.getElementById("bf_rec"), { x: days, height: 240, xlabel: "days without input", ylabel: "baseflow (mm/day)", ylog: true,
series: [{ label: "dCREST rule", values: a, color: css("--aquifer"), width: 2.4 }, { label: "linear reservoir", values: l, color: css("--faint"), dash: [5, 4] }] });
}
const ctl = document.getElementById("bf_ctl");
Course.slider(ctl, { label: "baseflow coefficient gwc", min: c.bounds.gwc[0], max: c.bounds.gwc[1], value: st.gwc, log: true, fmt: (v) => v.toFixed(4) + " mm/d" }, (v) => { st.gwc = v; drawBf(); });
Course.slider(ctl, { label: "baseflow exponent gwe", min: c.bounds.gwe[0], max: c.bounds.gwe[1], step: 0.01, value: st.gwe, fmt: (v) => v.toFixed(2) }, (v) => { st.gwe = v; drawBf(); });
Course.slider(ctl, { label: "aquifer capacity hmaxaq", min: c.bounds.hmaxaq[0], max: 1000, value: st.h, log: true, fmt: (v) => v.toFixed(0) + " mm" }, (v) => { st.h = v; drawBf(); });
drawBf();
// ten years of groundwater
const run = c.protocolRun("test", null, true), R = run.rec;
const a = c.idx("1989-10-01") - run.i0, t = run.time.subarray(a), sl = (arr) => arr.subarray(a);
const cap = new Float64Array(t.length).fill(c.params.hmaxaq);
Course.tsChart(document.getElementById("aq_chart1"), { time: t, height: 220, ylabel: "aquifer G (mm)",
series: [{ label: "aquifer G", values: sl(R.G), color: css("--aquifer"), width: 1.6 }, { label: "capacity hmaxaq", values: cap, color: css("--aquifer"), dash: [6, 4], width: 1 }] });
const pos = (arr) => Float64Array.from(arr, (v) => (v > 1e-4 ? v : NaN));
Course.tsChart(document.getElementById("aq_chart2"), { time: t, height: 240, ylabel: "mm/day (log)", ylog: true,
series: [{ label: "observed river flow", values: pos(sl(run.obs)), color: css("--obs"), width: 1 },
{ label: "baseflow", values: pos(sl(R.Qb)), color: css("--aquifer"), width: 1.8 }, { label: "spill", values: Float64Array.from(sl(R.spill), (v) => (v > 0.02 ? v : NaN)), color: css("--fast"), width: 1.4 }] });
};
</script>
</body>
</html>