# Demo 1: Flow

## Background/Motivation

Flow is a fundamental driver of processes in the surface and subsurface. In this set of demonstrations we will introduce

  * Richards Model for variably saturated subsurface flow
  * Diffusion Wave model for overland flow (surface flow)
  * A fully coupled (integrated hydrology) model

For each model we will provide the mathematical equations, highlight information about the discretization and provide tips on setting boundary conditions, initial conditions, source terms and key parameters.

## Subsurface Flow (Richards Equation)

We can provide the essentials of the mathematical models using LaTeX.  For example, Richards (1931) model for variably saturated flow:

$\newcommand{porosity}{\phi}$
$\newcommand{dens}{n_l}$
$\newcommand{sat}{s}$
$\newcommand{flux}{\mathbf{q}}$
$\newcommand{krel}{k_r}$
$\newcommand{kabs}{\kappa}$
$\newcommand{viscosity}{\mu}$

$$
\begin{align}
  \frac{\partial}{\partial t} (\porosity \dens \sat) &+ \nabla \cdot \flux = 0 \\
  \flux &= - \dens \frac{\krel \kabs}{\viscosity} (\nabla p + \rho \mathbf{g})
\end{align}
$$

**Note that this uses latex macros defined in this cell.**
Water retention models



Blah, Blah, lots more about the model and equations ...


These tests demonstrate solution of Richards equation on a single column. A single column of cells, oriented vertically, and are initialized as the hydrostatic solution. Infilitration is turned on, and water fills the domain.



```python
%matplotlib inline
```


```python
import sys,os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'],'tools', 'utils'))
import ats_xdmf
import plot_column_data
import numpy as np
from matplotlib import pyplot as plt
```


```python
def plot(dirname, title):
    """A generic plotting function that plots saturation as a function of depth."""
    fig = plt.figure()

    vis = ats_xdmf.VisFile(dirname, time_unit='d')
    vis.loadMesh(columnar=True)
    
    # plot the solution
    ax = fig.subplots(1,1)
    plot_column_data.plot_subsurface(vis, ['saturation_liquid',], ax, None, cmap='jet')
    ax.set_title(title)
    ax.set_xlabel('saturation [-]')
    ax.set_ylabel('z [m]')
```


```python
plot("./richards/run/", "infiltration example")
```

## Overland Flow (Diffusion Wave Equation)

## Integrated Hydrology

c607c4a7afa6ba2fecf0e61bde1051cafc53f6cb
ipynb
Jupyter Notebook
01_flow/flow.ipynb
pinshuai/ats-short-course
4fb9cd06b7d633bb31f5a25fe52359e091f9faf5
BSD-2-Clause
01_flow/flow.ipynb
pinshuai/ats-short-course
4fb9cd06b7d633bb31f5a25fe52359e091f9faf5
BSD-2-Clause
01_flow/flow.ipynb
pinshuai/ats-short-course
4fb9cd06b7d633bb31f5a25fe52359e091f9faf5
BSD-2-Clause
Qwen/Qwen-72B
1. YES
2. YES