# Drainage formula (Water Overlay)

Depending on whether the drainage is passive or active, the formula for either passive or active drainage is used.

## Drainage passive

First the flow capacity is calculated

$Q_{p}=\Delta t\cdot q_{t}$ $Q_{b}=A_{d}\cdot f_{s}\cdot {\frac {||w_{d}-w_{w}||\cdot A_{w}}{A_{d}\cdot f_{s}+A_{w}}}$ if $w_{d}>w_{w}$ then:

$Q_{d}=A_{d}\cdot (w_{d}-z_{d})\cdot f_{s}$ $Q_{t}=min(Q_{p},Q_{b},Q_{d})$ else:

$Q_{w}=A_{w}\cdot (w_{w}-z_{w})$ $Q_{t}=min(Q_{p},Q_{b},Q_{w})$ Where:

$q_{t}$ is the DRAINAGE_Q of the Drainage at time t.
$\Delta t$ is the computational timestep.
$w_{d}$ is the ground water level, above the drainage, in meters.
$w_{w}$ is the water level in the waterway.
$z_{d}$ is the drainage datum height in meters.
$z_{w}$ is the max waterway height.
$A_{d}$ is the drainage area size in square meters.
$A_{w}$ is the waterway area size in square meters.
$f_{s}$ is the average storage percentage of the ground above the drainage.
$Q_{p}$ is the possible amount of water drained, or pumped back when negative, based on the DRAINAGE_Q of the Drainage and timestep Δt.
$Q_{b}$ is the amount transferred for a balanced ground and surface water level.
$Q_{d}$ is the amount of water available in the ground above the drainage.
$Q_{w}$ is the amount of water available in the waterway.
$Q_{t}$ is the actual drained, or infiltrated backwards, volume at time t.

## Drainage active

Case 1: Active Draining:

If a positive DRAINAGE_Q is defined:

$Q_{p}=\Delta t\cdot q_{t}$ $Q_{d}=(w_{d}-z_{d})\cdot f_{s}$ If an overflow threshold $T_{o,t}$ is defined as well:

$Q_{o}=max(0,T_{o,t}-w_{w})$ The actual water pumped out of the drainage system is calculated. If any of the terms are undefined, they are not included.

$Q_{t}=max(0,min(Q_{d},Q_{o},Q_{p}))$ Case 2: Active Reverse Draining:

If a negative DRAINAGE_Q is defined:

$Q_{p}=\Delta t\cdot q_{t}$ $Q_{w}=min(0,z_{w}-w_{t,w})$ If an overflow threshold $T_{o,t}$ is defined as well:

$Q_{o}=min(0,T_{o,t}-w_{t,w})$ The actual water pumped into the drainage system is calculated. If any of the terms are undefined, they are not included.

$Q_{t}=max(0,max(Q_{p},Q_{w},Q_{o}))$ Where:

$q_{t}$ is the DRAINAGE_Q of the Drainage at time t.
$\Delta t$ is the computational timestep.
$Q_{p}$ is the possible amount of water drained, or pumped back when negative, based on the DRAINAGE_Q of the Drainage and timestep Δt.
$w_{d}$ is the ground water level, above the drainage, in meters.
$w_{w}$ is the water level in the waterway.
$z_{d}$ is the drainage datum height in meters.
$z_{w}$ is the waterway's datum height.
$f_{s}$ is the average storage percentage of the ground above the drainage.
$Q_{d}$ is the amount of water available in the ground above the drainage.
$T_{o,t}$ is the overflow threshold in meters at time t.
$Q_{o}$ is the possible amount of water at time t, that can be added to the waterway until the overflow threshold is reached.
$Q_{w}$ is the amount of water available in the waterway.
$Q_{t}$ is the actual drained (or pumped) volume at time t.