a fully-implicit solution to the one-dimensional, unsteady Richards equation of variably saturated flow in porous media with vapour exchange, written in Go.
Following the solution of Bittelli, M., Campbell, G.S., and Tomei, F., (2015). Soil Physics with Python. Oxford University Press.
goHydro porousmedia
- a Go struct used to define the properties of a variable porous media profile
Flux through a porous medium is defined as:
where
When combined with the mass conservation equation, the result yields the transient vertical (1D) Richards (1931) equation:
which is often expressed in its so-called
where
and conductivity:
where
or conversely,
where
$$ \frac{\rho_l\left(\theta_i^{j+1}-\theta_i^j\right)\left(z_{i+1}-z_{i-1}\right)}{2\Delta t}=\frac{\overline{K}i\left(\psi{i+1}-\psi_i\right)}{z_{i+1}-z_i}-\frac{\overline{K}{i-1}\left(\psi_i-\psi{i-1}\right)}{z_i-z_{i-1}}+u_i $$
or in its
$$ \frac{\rho_lC_i\left(\psi_i^{j+1}-\psi_i^j\right)\left(z_{i+1}-z_{i-1}\right)}{2\Delta t}=\frac{\overline{K}i\left(\psi{i+1}-\psi_i\right)}{z_{i+1}-z_i}-\frac{\overline{K}{i-1}\left(\psi_i-\psi{i-1}\right)}{z_i-z_{i-1}}+u_i $$
The source term
Vapour flux density [kg m
where
where
where
where
Within a porous medium, assuming isobaric (i.e.,
By further assuming that the liquid and vapour phases are in equilibrium (i.e., have equal potential and the partial pressure of water has reached its vapour pressure,
where the gas constant
Combining the above equations, results in:
where
By combining the flux of water vapour, the Richards equation can be re-stated as (Nov'ak, 2012):
and further:
At the soil surface--atmosphere interface, the flux density to the atmosphere remains (Nov'ak, 2012):
Assuming that vertical fluxes do not change in the vicinity of the evaporating soil surface, integrating the above equation from the soil surface (
re-arranging:
Next, by defining a water vapour turbulent transport coefficient (
vapour flux density to the atmosphere from the gas-filled pores can be written as:
and
where
where
Alternatively, the Penman (1948)/Penman-Monteith (1965) relationship to aerodynamic resistance (
Lastly, the effective mass flux evaporating from the soil surface must account for the portion of the soil surface area exposed to gas-filled pores and the area of direct liquid exposure:
One solution to the 1D Richards equation is the cell-centered finite volume solution scheme following Bittelli et.al. (2015). The cell-centered finite-volume form to the above equations gives the mass-balance at node
where
$$ F_{ij}=-A_{ij}\overline{K}i\frac{h_i-h_j}{L{ij}}, $$
and
$$ \frac{\rho_lV_i\overline{C}i}{\Delta t}\left(h_i^{k+1}-h_i^k\right)=F_i\left(h_i^{k+1}-h{i+i}^{k+1}\right)-F_{i-1}\left(h_{i-1}^{k+1}-h_i^{k+1}\right)+u_i, $$
where
$$ F_i=-A_i\frac{\overline{K}i}{z{i+1}-z_i}. $$
and
The solution to the above equation is done implicitly, by solving a system equations, expanding the above and letting:
$$ \begin{align*} \varrho(i) &=\frac{\rho_l V_i\overline{C}_i}{\Delta t} \ f(i) &=\frac{A_i\overline{K}i}{z{i+1}-z_i} \ c(i) &= a(i+1) = -f(i) \ b(i) &= f(i-1)+f(i)+\varrho(i) \ d(i) &= \varrho(i)h_i^k+u_i \end{align*} $$
the finite-volume scheme for
which is a tri-diagonal matrix that is solved using the Thomas algorithm.
A finite-difference solution to the 1D Richards equation is solved using the Newton-Raphson solution scheme following Bittelli et.al. (2015). The water balance in cell
$$ \begin{align*} F_i= & \frac{\overline{K}i\left(\psi{i+1}-\psi_i\right)}{z_{i+1}-z_i}-\frac{\overline{K}{i-1}\left(\psi_i-\psi{i-1}\right)}{z_i-z_{i-1}} \ & \quad-g\left(\overline{K}i-\overline{K}{i-1}\right)-\frac{\rho_l}{2\Delta t}\left(\theta_i^{k+1}-\theta_i^k\right)\left(z_{i+1}-z_{i-1}\right), \end{align*} $$
where
$$ \overline{K}i=\frac{K{i+1}\psi_{i+1}-K_i\psi_i}{\left(1+3/b\right)\left(\psi_{i+1}-\psi_i\right)}. $$
The solution to the above equation is then considered a minimization problem, whereby Newton-Raphson:
or in a matrix-form for a
where
where
$$ f_i=-\frac{\overline{K}i\left(\psi{i+1}-\psi_i\right)}{z_{i+1}-z_i} = -\frac{K_{i+1}\psi_{i+1}-K_i\psi_i}{\left(1+3/b\right)\left(z_{i+1}-z_i\right)} $$
and letting
then substituting yields:
Differentiating
$$ \begin{align*} f'i &=\frac{\partial f_i}{\partial\psi_i}=\frac{K_i}{z{i+1}-z_i} \ u'i &=\frac{\partial u_i}{\partial\psi_i}=\frac{gK_i}{\psi_i}(2+3/b) \ \varrho'i &=\frac{\partial \varrho_i}{\partial\psi_i}=\rho_l\frac{\theta_i}{b\psi_i}\frac{z{i+1}-z{i-1}}{2\Delta t} \end{align*} $$
and thus
$$ \begin{align*} \frac{\partial F_i}{\partial\psi_i} &=\frac{K_i}{z_{i+1}-z_i}+\frac{K_{i-1}}{z_i-z_{i-1}}+u'i+\varrho'i \ \frac{\partial F_i}{\partial\psi{i-1}} &=\frac{-K{i-1}}{z_i-z_{i-1}}-u'{i-1} \ \frac{\partial F_i}{\partial\psi{i+1}} &=\frac{-K_i}{z_{i+1}-z_i} \end{align*} $$
Solving the Newton-Raphson system of equations is then accomplished like the linear methods described above.
Boundary conditions for the top of the vertical profile can either be a constant flux (e.g., evaporation) or constant potential:
- For constant flux, the source is added to
$F_1$ ; - For a constant potential,
$\psi_1^{j+1}$ is known and is set at the start of the time step (since the Newton-Raphson method computes changes in$\psi$ to bring$F$ to zero,$F_1$ and$\frac{\partial F_1}{\partial\psi_i}$ are set to zero before solving; therefore the value of$\psi_1$ will remain constant throughout the time step. For infiltration, set$\psi_1=\psi_e$ .
At the bottom of the profile, either a constant potential (i.e., water table) or a free drainage condition can be specified using a ghost below the profile that never becomes part of the solution. Free drainage is set by:
after each outer iteration, where
- considers only vapour flux at the soil surface
- isothermal and isobaric throughout the time-step
- uniform soil temperature (model meant for soil surface)
package main
import (
"math"
pm "github.com/maseology/goHydro/porousmedia"
vsf "github.com/maseology/goVSF"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/plotutil"
"gonum.org/v1/plot/vg"
)
func main() {
initialSe := 0.3 // initial degree of saturation
simulationLength := 24. // hours
dpth := []float64{0.2, 0.7, 1.} // profile depths
pm := []pm.PorousMedium{
{ // coarser (less clay) textured A horizon
Ts: 0.44,
Tr: 0.01,
Ks: 0.000167,
He: -2.08,
B: 4.74,
},
{ // clay loam B horizon
Ts: 0.45,
Tr: 0.01,
Ks: 0.000101,
He: -5.15,
B: 2.59,
},
{ // C horizon should be parent material; here sand is assumed
Ts: 0.37,
Tr: 0.01,
Ks: 0.002814,
He: -0.73,
B: 1.69,
},
}
var p vsf.Profile
p.New(pm, dpth)
var ps vsf.State
ps.Initialize(p, initialSe, true)
t, f, ok := ps.Solve(simulationLength)
logt := make([]float64, len(t))
for i, v := range t {
logt[i] = math.Log10(v)
}
linePoints("flux.png", "infiltration rate", "log time (s)", "rate (m/s)", logt, f)
if ok {
w, z := ps.WaterContentProfile()
linePoints("wcp.png", "water content", "water content (-)", "Depth below surface (m)", w, z)
}
}
func linePoints(fp, nam, xnam, ynam string, x, y []float64) {
p := plot.New()
p.Title.Text = "3-layer soil moisture profile example"
p.X.Label.Text = xnam
p.Y.Label.Text = ynam
err := plotutil.AddLinePoints(p, nam, points(x, y))
if err != nil {
panic(err)
}
// Save the plot to a PNG file.
if err := p.Save(5*vg.Inch, 4*vg.Inch, fp); err != nil {
panic(err)
}
}
func points(x, y []float64) plotter.XYs {
if len(x) != len(y) {
panic("error: unequal points array sizes")
}
pts := make(plotter.XYs, len(x))
for i := range pts {
if !math.IsNaN(y[i]) {
pts[i].X = x[i]
pts[i].Y = y[i]
} else {
pts[i].X = x[i]
pts[i].Y = 0.
}
}
return pts
}
output:
Bittelli, M., Campbell, G.S., and Tomei, F., 2015. Soil Physics with Python. Oxford University Press.
Campbell, G.S., 1974. A simple method for determining unsaturated conductivity from moisture retention data. Soil Science, 117: 311--387.
Monteith, J.L.,1965. Evaporation and environment. Symposia of the Society for Experimental Biology 19: 205–-224.
Nov'ak, V., 2012. Evapotranspiration in the Soil-Plant-Atmosphere System. Springer. 253pp.
Penman, H.L., 1940. Gas and vapour movements in the soil: I. The diffusion of vapours through porous solids. Journal of Agricultural Science 30(3): 437--462.
Penman, H.L., 1948. Natural evaporation from open water, bare soil and grass. Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences 193(1032): 120--145.
Philip, J.R., 1957. Evaporation, and moisture and heat fields in the soil. Journal of Meteorology 14: 354--366.
Richards, L.A., 1931. Capillary conduction of liquids through porous media. Physics 1: 318--333.