Cross-Sectional Models#

This notebook demonstrates how to build and solve cross-sectional (1D) models in timflow, including examples with strip inhomogeneities and infinitely long line elements.

import matplotlib.pyplot as plt
import numpy as np

import timflow.steady as tfs

plt.rcParams["figure.figsize"] = (4, 3)
plt.rcParams["figure.autolayout"] = True

Two-layer model with head-specified line-sink#

Two-layer aquifer bounded on top by a semi-confined layer. Head above the semi-confining layer is 5. Head line-sink located at \(x=0\) with head equal to 2, cutting through layer 0 only.

ml = tfs.ModelMaq(
    kaq=[1, 2], z=[4, 3, 2, 1, 0], c=[1000, 1000], topboundary="semi", hstar=5
)
ls = tfs.River1D(ml, xls=0, hls=2, layers=0)
ml.solve()

x = np.linspace(-200, 200, 101)
h = ml.headalongline(x, np.zeros_like(x))
plt.plot(x, h[0], label="layer 0")
plt.plot(x, h[1], label="layer 1")
plt.legend(loc="best")
plt.grid()
Number of elements, Number of equations: 2 , 1
.
.

solution complete
../../_images/3bc38719b0915d2d59edafec661bbbc1301ed6fcab63737ea7244b66bc072bed.png

Xsection elements#

Three strips with semi-confined conditions on top of all three can be modeled with the XsectionMaq element.

Note

A ModelXsection may consist of an arbitrary number of Xsection3D or XsectionMaq sections. The combined domain of all sections must span from \(x = -\infty\) to \(x = +\infty\), with no gaps.

ml = tfs.ModelXsection(naq=2)
tfs.XsectionMaq(
    ml,
    x1=-np.inf,
    x2=-50,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=5,
)
tfs.XsectionMaq(
    ml,
    x1=-50,
    x2=50,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=4.5,
)
tfs.XsectionMaq(
    ml,
    x1=50,
    x2=np.inf,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=4,
)
ml.solve()
Number of elements, Number of equations: 7 , 8
.
.
.
.
.
.
.

solution complete
fig, ax = plt.subplots(1, 1, figsize=(10, 3))
ml.plots.xsection(
    xy=[(-150, 0), (150, 0)], ax=ax, params=True, units={"kaq": "m/d", "c": "d"}
)
<Axes: xlabel='x', ylabel='elevation'>
../../_images/01881351b141a5cfb53ee3a6dbec1d452d1ba1c295cbe36bb7411dbedb5cd38b.png
x = np.linspace(-200, 200, 101)
h = ml.headalongline(x, np.zeros(101))
plt.plot(x, h[0], label="layer 0")
plt.plot(x, h[1], label="layer 1")
plt.xlabel("x (m)")
plt.ylabel("head (m)")
plt.legend(loc="best")
plt.grid()
../../_images/444a64a7ce9dc04bf43de26082a689d88bbe04ea780ea3d547ee0435f373fa79.png
ml.plots.vcontour_stream_function(
    x1=-200, x2=200, nx=100, levels=20, color="C0", figsize=(10, 3)
);
../../_images/f23980351301a3b0bdad46defb10d623c49f8dffb60d2bd20de81dc0dd601110.png

Three strips with semi-confined conditions at the top of the strip in the middle only. The head is specified in the strip on the left and in the strip on the right.

ml = tfs.ModelXsection(naq=2)
tfs.XsectionMaq(
    ml,
    x1=-np.inf,
    x2=-50,
    kaq=[1, 2],
    z=[3, 2, 1, 0],
    c=[1000],
    npor=0.3,
    topboundary="conf",
)
tfs.XsectionMaq(
    ml,
    x1=-50,
    x2=50,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=4,
)
tfs.XsectionMaq(
    ml,
    x1=50,
    x2=np.inf,
    kaq=[1, 2],
    z=[3, 2, 1, 0],
    c=[1000],
    npor=0.3,
    topboundary="conf",
)
rf1 = tfs.Constant(ml, -100, 0, 5)
rf2 = tfs.Constant(ml, 100, 0, 5)

ml.solve()

ax = ml.plots.xsection(xy=[(-100, 0), (100, 0)])
Number of elements, Number of equations: 7 , 10
.
.
.
.
.
.
.

solution complete
../../_images/c7d10ffd857086383c883b91c0cc7247efb2dd24ee9a0208b7e7fd4bf940d42b.png
x = np.linspace(-200, 200, 101)
h = ml.headalongline(x, np.zeros_like(x))
Qx, _ = ml.disvecalongline(x, np.zeros_like(x))

plt.figure(figsize=(10, 3))
plt.subplot(121)
plt.plot(x, h[0], label="layer 0")
plt.plot(x, h[1], label="layer 1")
plt.plot([-100, 100], [5, 5], "k.", label="fixed heads")
plt.xlabel("x (m)")
plt.ylabel("head (m)")
plt.legend(loc="best")
plt.grid()
plt.subplot(122)
plt.plot(x, Qx[0], label="layer 0")
plt.plot(x, Qx[1], label="layer 1")
plt.xlabel("x (m)")
plt.ylabel("$Q_x$ (m$^2$/d)")
plt.grid()
../../_images/4391c367e7e1b0f8b9ee22384e5e9fb2f6c73aa1ce9700fe03e5fd1fe5afe107.png
ml.plots.vcontour_stream_function(
    x1=-200, x2=200, nx=100, levels=20, color="C0", figsize=(10, 3)
);
../../_images/f34ee6f4838c469546b9d7d5c9d7ef9a34fb3946e40ad5ac3166c1420a72e26f.png

Impermeable wall#

Flow from left to right in three-layer aquifer with impermeable wall in bottom 2 layers

# need ModelMaq here since Uflow requires a confined background aquifer
ml = tfs.ModelMaq(kaq=[1, 2, 4], z=[5, 4, 3, 2, 1, 0], c=[5000, 1000])
uf = tfs.Uflow(ml, 0.002, 0)
rf = tfs.Constant(ml, 100, 0, 20)
ld1 = tfs.ImpermeableWall1D(ml, xld=0, layers=[0, 1])

ml.solve()
Number of elements, Number of equations: 3 , 3
.
.
.

solution complete
x = np.linspace(-100, 100, 101)
h = ml.headalongline(x, np.zeros_like(x))
Qx, _ = ml.disvecalongline(x, np.zeros_like(x))

plt.figure(figsize=(10, 3))
plt.subplot(121)
plt.title("head")
plt.plot(x, h[0], label="layer 0")
plt.plot(x, h[1], label="layer 1")
plt.plot(x, h[2], label="layer 2")
plt.xlabel("x (m)")
plt.ylabel("head (m)")
plt.legend(loc="best")
plt.grid()
plt.subplot(122)
plt.title("Qx")
plt.plot(x, Qx[0], label="layer 0")
plt.plot(x, Qx[1], label="layer 1")
plt.plot(x, Qx[2], label="layer 2")
plt.xlabel("x (m)")
plt.ylabel("$Q_x$ (m$^2$/d)")
plt.legend(loc="best")
plt.grid()
../../_images/70a01a48fbb7f10e071fc44350442c8e8e5e702fa37d3e35a58b9f8e15708e94.png
ax = ml.plots.vcontour_stream_function(
    x1=-200, x2=200, nx=100, levels=20, color="C0", figsize=(10, 3), horizontal_axis="x"
)
ld1.plot(ax);  # plot wall
../../_images/d3aa551a69ac78853d65656aeedda5ccf9146e24e89d81dd1816c688a71df2cc.png

Plot velocity quiver near the wall.

x = np.linspace(-5, 5, 30)
y = np.array([0])
z = np.array([[4.5, 3.5, 2.5, 1.5, 0.5]]).T
fig, ax = plt.subplots(1, 1, figsize=(10, 3))
ml.plots.xsection(xy=[(x[0], 0), (x[-1], 0)], horizontal_axis="x", labels=False, ax=ax)

npts = 31
ml.plots.tracelines(
    -5 * np.ones(npts),
    np.zeros(npts),
    np.linspace(0, 5, npts),
    ax=ax,
    linewidth=1,
    hstepmax=1.0,
    vstepfrac=0.1,
    orientation="ver",
    silent=True,
)
ld1.plot(ax)  # plot wall
ml.plots.quiver_z(x, y, z, ax=ax, normalize=True, scale=30, zorder=10);
  0%|          | 0/150 [00:00<?, ?it/s]
100%|██████████| 150/150 [00:00<00:00, 16924.80it/s]
../../_images/3fc62ff29f6a74ca91768dcf869bf76d218e1386c4d9fa4063339b3dae1a0f07.png

Infiltration#

Comparing solution with Xsection inhomogeneities to XsectionAreaSink solution.

ml = tfs.ModelXsection(naq=2)
tfs.XsectionMaq(
    ml,
    x1=-np.inf,
    x2=-50,
    kaq=[1, 2],
    z=[3, 2, 1, 0],
    c=[1000],
    npor=0.3,
    topboundary="conf",
)
tfs.XsectionMaq(
    ml,
    x1=-50,
    x2=50,
    kaq=[1, 2],
    z=[3, 2, 1, 0],
    c=[1000],
    npor=0.3,
    topboundary="conf",
    N=0.001,
)
tfs.XsectionMaq(
    ml,
    x1=50,
    x2=np.inf,
    kaq=[1, 2],
    z=[3, 2, 1, 0],
    c=[1000],
    npor=0.3,
    topboundary="conf",
)
tfs.Constant(ml, -100, 0, 10)
tfs.Constant(ml, 100, 0, 10)
ml.solve()

ml.plots.vcontour_stream_function(
    x1=-100, x2=100, nx=100, levels=20, color="C0", figsize=(10, 3)
);
Number of elements, Number of equations: 7 , 10
.
.
.
.
.
.
.

solution complete
../../_images/0c26b145f5b572e9f9b079eda699e8486b926c2df14b30f773d8f297c6396d7f.png
ml2 = tfs.ModelMaq(kaq=[1, 2], z=[3, 2, 1, 0], c=[1000], topboundary="conf")
tfs.XsectionAreaSink(ml2, -50, 50, 0.001)
tfs.Constant(ml2, -100, 0, 10)
ml2.solve()
ml2.plots.vcontour_stream_function(
    x1=-100, x2=100, nx=100, levels=20, color="C0", figsize=(10, 3), horizontal_axis="x"
);
Number of elements, Number of equations: 2 , 1
.
.

solution complete
/tmp/ipykernel_1676/3351714403.py:2: DeprecationWarning: XsectionAreaSink is only for testing purposes. It is recommended to add infiltration through XsectionMaq or Xsection3D and specifying 'N'.
  tfs.XsectionAreaSink(ml2, -50, 50, 0.001)
../../_images/8eadbda8d3bbb473ee9e12e0f6ec9052a9762042a1954a2b2c43ac98e0372f81.png
x = np.linspace(-100, 100, 100)
plt.plot(x, ml.headalongline(x, 0)[0], "C0")
plt.plot(x, ml.headalongline(x, 0)[1], "C0")
plt.plot(x, ml2.headalongline(x, 0)[0], "--C1")
plt.plot(x, ml2.headalongline(x, 0)[1], "--C1")
plt.xlabel("x (m)")
plt.ylabel("head (m)")
plt.grid()
../../_images/3ef0db87b84b067dff9ddb60218d5f5e62871abc7ea91c396653a79a9cf7ad70.png
ml = tfs.ModelXsection(naq=50)
tfs.Xsection3D(ml, x1=-np.inf, x2=-5, kaq=1, z=np.arange(5, -0.1, -0.1), kzoverkh=0.1)
tfs.Xsection3D(
    ml,
    x1=-5,
    x2=5,
    kaq=1,
    z=np.arange(5, -0.1, -0.1),
    kzoverkh=0.1,
    topboundary="semi",
    hstar=5.5,
    topres=3,
    topthick=0.3,
)
tfs.Xsection3D(ml, x1=5, x2=np.inf, kaq=1, z=np.arange(5, -0.1, -0.1), kzoverkh=0.1)
rf1 = tfs.Constant(ml, -100, 0, 5.7)
rf2 = tfs.Constant(ml, 100, 0, 5.47)

ml.solve()

ml.plots.vcontour_stream_function(
    x1=-20, x2=20, nx=100, levels=20, color="C0", figsize=(10, 3)
);
Number of elements, Number of equations: 7 , 202
.
.
.
.
.
.
.

solution complete
../../_images/0a7e5d20f1044c56026919ba6658046a29725d39c67b6bb2efc3c499a741d7c4.png
ml = tfs.ModelXsection(naq=5)
tfs.Xsection3D(ml, x1=-np.inf, x2=-5, kaq=1, z=np.arange(5, -0.1, -1), kzoverkh=0.1)
tfs.Xsection3D(
    ml,
    x1=-5,
    x2=5,
    kaq=1,
    z=np.arange(5, -0.1, -1),
    kzoverkh=0.1,
    topboundary="semi",
    hstar=5.5,
    topres=3,
    topthick=0.3,
)
tfs.Xsection3D(ml, x1=5, x2=np.inf, kaq=1, z=np.arange(5, -0.1, -1), kzoverkh=0.1)
rf1 = tfs.Constant(ml, -100, 0, 5.7)
rf2 = tfs.Constant(ml, 100, 0, 5.47)

ml.solve()

ml.plots.vcontour_stream_function(
    x1=-20, x2=20, nx=100, levels=20, color="C0", figsize=(10, 3)
);
Number of elements, Number of equations: 7 , 22
.
.
.
.
.
.
.

solution complete
../../_images/8b950363afe356ede13f9c973b10cec851a94d3a5a1e85d58a75793bd4661fda.png
ml = tfs.ModelXsection(naq=2)
tfs.XsectionMaq(
    ml,
    x1=-np.inf,
    x2=-50,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=15,
)
tfs.XsectionMaq(
    ml,
    x1=-50,
    x2=50,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=13,
)
tfs.XsectionMaq(
    ml,
    x1=50,
    x2=np.inf,
    kaq=[1, 2],
    z=[4, 3, 2, 1, 0],
    c=[1000, 1000],
    npor=0.3,
    topboundary="semi",
    hstar=11,
)
ml.solve()
Number of elements, Number of equations: 7 , 8
.
.
.
.
.
.
.

solution complete
ml = tfs.ModelMaq(kaq=[10], z=[0, -10], topboundary="conf")
ls = tfs.River1D(ml, xls=0, hls=1, wh="H", layers=0)
ls = tfs.River1D(ml, xls=200, hls=0, wh="H", layers=0)
hd = tfs.linesink1d.HeadDiffLineSink1D(ml, xls=100)
fd = tfs.linesink1d.FluxDiffLineSink1D(ml, xls=100)
ml.solve()

x = np.linspace(0, 200, 101)
h = ml.headalongline(x, np.zeros_like(x))
plt.plot(x, h[0], label="layer 0")
# plt.plot(x, h[1], label="layer 1")
plt.legend(loc="best");
Number of elements, Number of equations: 2 , 2
.
.

solution complete
../../_images/117aab3357b4b1d5a8d06c389fb72faa4d08825859c4032be2652d8de95e8e1a.png