Repository navigation
Infiltration: Green-Ampt and curve number - #14
Merged
Merged
Conversation
Two loss models as sources, acting after the rain and before the friction (flume.infiltration.type = green_ampt or curve_number), with per-cell parameters from one value or an ESRI ASCII grid. - Green-Ampt for one storm after Rossman and Huber (2016, section 4.4): saturation at F_s = K M / (i - K), then the integrated equation solved by Newton's method in double precision from an upper bound. - Curve number as a loss on the rain (NRCS NEH 630 ch. 10; Woodward et al., 2003), with flume.infiltration.cn.ia_ratio (default 0.2, [0, 1)). - Impervious by value (K = 0, CN = 100); building cells infiltrate nothing. A cell never loses more water than it holds; the discharge is scaled with the depth and zeroed at or below the dry depth. - The infiltrated depth and the rain total are compensated sums; the infiltrated depth is written to the plotfiles (infiltrated_depth). - Rain: a negative rounding carry no longer takes a dry cell below 0; the cell keeps its depth and the carry is kept (path added in 1880669, reached only once cells empty while it rains). Ghost cells: the infiltration kernels read and write valid cells only; no ghost fill is added. NaN guards: the Newton step stops on a non-positive or NaN residual or slope; the curve-number loss returns P when S overflows (Ia infinite or NaN). Tests: ponded Green-Ampt against its implicit solution, the curve-number loss against its formula, the infiltrated volume in the mass balance, the depth cap, a rain burst for the carry fix and the input aborts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to the development plan: infiltration.
Summary
Rain that falls on soil partly soaks in. Until now FLUME kept all of it on the surface. This PR adds two infiltration models that take water out of each cell:
flume.infiltration.type = green_ampt): a physical model of a wetting front moving down into the soil, as in the EPA SWMM Reference Manual, Volume I (Rossman and Huber, 2016, section 4.4). It acts on rain and on ponded water.flume.infiltration.type = curve_number): the NRCS runoff curve number (NEH Part 630, chapter 10; Woodward et al., 2003), used as a loss on the rain. Water that runs onto a cell from its neighbours is not infiltrated.The soil parameters come from one value or from an ESRI ASCII map, per cell. Impervious cells are given by value (K = 0 or CN = 100); building cells infiltrate nothing. A cell never loses more water than it holds. The depth each cell has lost is written to the plotfiles as
infiltrated_depth, so the water of a run can be balanced.The PR also changes one line of the rain source (
add_rain_depth): when the rounding carry is negative and larger than the depth of a dry cell, the cell is left at its depth and the carry is kept. Before, the cell could go below 0. This path was added with prescribed rain in commit 1880669. It is not reached ondevelopment, because a cell there never empties while it rains; infiltration empties cells, and the single-precision suite reached it at step 5706. The new testinfiltration_green_ampt_burstreaches it in three steps.Bit identity: runs without infiltration are bit-identical to
development, except a rain run in which a dry cell would have gone below 0 (none of the existing tests). All existing tests pass unchanged; no gold changes.Theory
Green-Ampt. With$K$ the saturated hydraulic conductivity (m/s), $\psi$ the suction head at the wetting front (m), $\theta$ the moisture deficit, $M = \psi,\theta$ (m), $F$ the cumulative infiltration of the cell (m) and $W$ the water the cell holds at the end of the step (m), the step of length $\Delta t$ uses $i = W/\Delta t$ . The surface is saturated once
Below$F_s$ the cell loses $W$ (or reaches $F_s$ at the rate $i$ ). From $F_s$ on, $F$ follows the integrated equation over the rest of the step $\tau$ :
What: the root$x = F_2 - F_1$ is found by Newton's method in double precision, from the bound $K\tau + \sqrt{2MK\tau}$ , so the iterates fall to the root from above. Why: the integrated equation is exact for any step, so the ponded result does not depend on $\Delta t$ .
Curve number. With$P$ the rain fallen on the cell since the start (m), $CN$ the curve number, $S = 25.4,(1000/CN - 10)$ mm the potential retention and $I_a = \lambda S$ the initial abstraction ($\lambda$ =
ia_ratio), the cumulative loss iswhich is$P - Q(P)$ written without cancellation. Each step the cell loses $L(P_{\mathrm{end}}) - L(P_{\mathrm{start}})$ , never more than it holds. Why compensated sums: $P$ and $F$ add one small increment per step over many steps; both are kept as compensated sums, so the loss does not drift (279217 steps: 1.4e-17 m, against 1.2e-5 m with a plain sum).
The user gives a curve number that matches$\lambda$ ; FLUME does not convert. The documentation gives the conversion of Woodward et al. (2003) for $\lambda = 0.05$ .
Changes
Source/FLUME_Infiltration.H,Source/FLUME_Infiltration.cpp(new): the classesInfiltration,GreenAmptandCurveNumber. Each owns its fields (parameters,infiltrated_depthand the carries of its sums) and its plotfile output. OneParallelForkernel per model. Values out of range abort and name the key and the file.Source/FLUME_Source.cpp,Source/FLUME_Flood.cpp: the infiltration source is built after the rain and before the friction, and gets the building map.Source/FLUME_Inputs.H,Source/FLUME_Inputs.cpp: the new keys, read and range-checked; they join the check for unknownflumekeys, and a key of the model not selected aborts.Source/FLUME_Rain.cpp:add_rain_depth,Source/FLUME_Rain.H: a negative carry never takes a dry cell below 0 (see Summary).Source/FLUME_IO.cpp:infiltrated_depthin the plotfiles.Tests/Infiltration/(new): decks, synthetic grids (make_infiltration_grids.pywrites them),check_infiltration.py,README.mdandInfiltrationTests.cmake.Inputs.rst(table below),theory/SourceTerms.rst(models, limits),Verification.rst,TestCatalog.rst,Running.rst,References.rst.flume.infiltration.typenonenone,green_amptorcurve_number(needs rain)flume.infiltration.green_ampt.conductivity/_fileflume.infiltration.green_ampt.suction/_fileflume.infiltration.green_ampt.deficit/_fileflume.infiltration.cn.number/_fileflume.infiltration.cn.ia_ratio0.2Results
In the closed-form cases each cell's depth plus its infiltrated depth equals the water it received to 4 machine epsilons, in double and in single precision.
Test(s)
New (38 tests, all pass in double and single precision):
infiltration_green_ampt_ponded,infiltration_green_ampt_ponded_moving: the implicit ponded solution.infiltration_green_ampt_rain: saturation time and the integrated equation under rain.infiltration_curve_number_rain,infiltration_curve_number_ia_ratio,infiltration_curve_number_many_steps,infiltration_curve_number_map: the curve-number formula.infiltration_green_ampt_balance: infiltrated volume in the mass balance, on a map with buildings and impervious columns, 2 ranks.infiltration_green_ampt_cap,infiltration_green_ampt_cap_moving: a cell never loses more than it holds.infiltration_green_ampt_burst: the rain carry fix, 2 ranks.abort_infiltration_*: every range check and key conflict aborts with the key name.Each test was shown to fail on a one-line mutant (or, for the burst test, without the rain fix) before it was committed.
Full suite, local (macOS, MPI, 4 processes):
lake_at_rest_second_order_np1failed once; it has no rain or infiltration, and it passed in 11 later runs (10 repeats under-j 4and the full suite).amrex.init_snan=1,amrex.fpe_trap_invalid=1,amrex.the_arena_init_size=0fabarray.mfiter_tile_size = 1024 1024 1024) and with 4 x 4 tilesNot in this PR
References
🤖 Generated with Claude Code