"""The old-water paradox on one hillslope, as a schematic (the README gives no profile to draw from). Rain (this storm's new water, sand) falls on the slope and has only wetted the top of the soil; the stream at the foot has already risen, and what fills it comes mostly from the saturated zone above the bedrock (old water, the field colour), pushed out along the flow lines. README.md: streams rise within minutes to hours of heavy rain, while much of the storm runoff is old water and typical mean transit times are years to decades. """ import math from pathlib import Path import kit X0, XS, X1 = 14, 470, 626 # top of the slope, the stream's left bank, the end of the floodplain CH = 64 # channel width smooth = lambda u: u * u * (3 - 2 * u) def surface(x): if x <= XS: return 58 + 132 * smooth((x - X0) / (XS - X0)) if x >= XS + CH: return 190 - 3 * (x - XS - CH) / (X1 - XS - CH) return 190 + 26 * math.sin(math.pi * (x - XS) / CH) # the channel def bedrock(x): u = min(1, (x - X0) / (XS - X0)) return 164 + 132 * smooth(u) - 50 * u + (x - XS) * 0.02 * (x > XS) def table(x): """The water table: halfway down the soil upslope, meeting the surface at the stream.""" u = min(1, (x - X0) / (XS - X0)) return surface(x) + 58 * (1 - u) ** 1.3 xs = [X0 + k * 2 for k in range((X1 - X0) // 2 + 1)] ground = [(x, surface(x)) for x in xs] sat = [(x, table(x) if x <= XS else min(surface(x), 200) if x < XS + CH else surface(x)) for x in xs] body = [kit.polygon(sat + [(x, bedrock(x)) for x in reversed(xs)], 'f-soft')] # stored old water body.append(kit.polyline([(x, bedrock(x)) for x in xs], 'faint-s', 2.5)) body.append(kit.polyline([(x, y) for x, y in sat if x <= XS], 'f-s', 2)) # flow lines through the saturated zone, rising into the stream bed bed = (XS + CH / 2, surface(XS + CH / 2) - 5) for f in (0.3, 0.68): pts = [] for x in range(36, int(bed[0]) + 1, 4): y = table(min(x, XS)) + f * (bedrock(x) - table(min(x, XS))) w = smooth(max(0, min(1, (x - (bed[0] - 190)) / 190))) pts.append((x, y * (1 - w) + bed[1] * w)) pts = pts[:-4] body.append(kit.polyline(pts, 'f-s', 3)) (ax, ay), (bx, by) = pts[-2], pts[-1] L = math.hypot(bx - ax, by - ay) ux, uy = (bx - ax) / L, (by - ay) / L body.append(kit.polygon([(bx + ux * 11, by + uy * 11), (bx - uy * 6.5, by + ux * 6.5), (bx + uy * 6.5, by - ux * 6.5)], 'f')) # the stream, filled mostly with old water water = [(x, max(surface(x), 196)) for x in range(XS, XS + CH + 1, 2)] body.append(kit.polygon(water, 'f')) # this storm's water: rain above the slope, and a shallow wetting front just under the surface for k in range(26): x = 34 + k * 17.5 + (k % 3) * 4 top = 12 + (k * 37) % 30 if top + 16 < surface(x) - 10: body.append(kit.line(x, top, x - 5, top + 16, 'sand-s', 3)) body.append(kit.polyline([(x, surface(x) + 11) for x in xs if table(x) - surface(x) > 20], 'sand-s', 4, ' stroke-dasharray="2 8"')) body.append(kit.polyline(ground, 'ink-s', 3)) kit.write(__file__, 'earth-environment', ''.join(body), label='rain in, years-old water out in hours ยท schematic', title='A hillslope in a storm: new rain wets only the topsoil while the stream fills with old groundwater')