Used in hydrogeology, the groundwater flow equation is the mathematical relationship which is used to describe the flow of groundwater through an aquifer. The transient flow of groundwater is described by a form of the diffusion equation, similar to that used in heat transfer to describe the flow of heat in a solid (heat conduction). The steady-state flow of groundwater is described by a form of the Laplace equation, which is a form of potential flow and has analogs in numerous fields.
The groundwater flow equation is often derived for a small representative elemental volume (REV), where the properties of the medium are assumed to be effectively constant. A mass balance is done on the water flowing in and out of this small volume, the flux terms in the relationship being expressed in terms of head by using the constitutive equation called Darcy's law, which requires that the flow is laminar. Other approaches are based on Agent Based Models to incorporate the effect of complex aquifers such as karstic or fractured rocks (i.e. volcanic) 
A mass balance must be performed, and used along with Darcy's law, to arrive at the transient groundwater flow equation. This balance is analogous to the energy balance used in heat transfer to arrive at the heat equation. It is simply a statement of accounting, that for a given control volume, aside from sources or sinks, mass cannot be created or destroyed. The conservation of mass states that, for a given increment of time (Δt), the difference between the mass flowing in across the boundaries, the mass flowing out across the boundaries, and the sources within the volume, is the change in storage.
Mass can be represented as density times volume, and under most conditions, water can be considered incompressible (density does not depend on pressure). The mass fluxes across the boundaries then become volume fluxes (as are found in Darcy's law). Using Taylor series to represent the in and out flux terms across the boundaries of the control volume, and using the divergence theorem to turn the flux across the boundary into a flux over the entire volume, the final form of the groundwater flow equation (in differential form) is:
This is known in other fields as the diffusion equation or heat equation, it is a parabolic partial differential equation (PDE). This mathematical statement indicates that the change in hydraulic head with time (left hand side) equals the negative divergence of the flux (q) and the source terms (G). This equation has both head and flux as unknowns, but Darcy's law relates flux to hydraulic heads, so substituting it in for the flux (q) leads to
Now if hydraulic conductivity (K) is spatially uniform and isotropic (rather than a tensor), it can be taken out of the spatial derivative, simplifying them to the Laplacian, this makes the equation
Dividing through by the specific storage (Ss), puts hydraulic diffusivity (α = K/Ss or equivalently, α = T/S) on the right hand side. The hydraulic diffusivity is proportional to the speed at which a finite pressure pulse will propagate through the system (large values of α lead to fast propagation of signals). The groundwater flow equation then becomes
Where the sink/source term, G, now has the same units but is divided by the appropriate storage term (as defined by the hydraulic diffusivity substitution).
Especially when using rectangular grid finite-difference models (e.g. MODFLOW, made by the USGS), we deal with Cartesian coordinates. In these coordinates the general Laplacian operator becomes (for three-dimensional flow) specifically
MODFLOW code discretizes and simulates an orthogonal 3-D form of the governing groundwater flow equation. However, it has an option to run in a "quasi-3D" mode if the user wishes to do so; in this case the model deals with the vertically averaged T and S, rather than k and Ss. In the quasi-3D mode, flow is calculated between 2D horizontal layers using the concept of leakage.
Another useful coordinate system is 3D cylindrical coordinates (typically where a pumping well is a line source located at the origin — parallel to the z axis — causing converging radial flow). Under these conditions the above equation becomes (r being radial distance and θ being angle),
This equation represents flow to a pumping well (a sink of strength G), located at the origin. Both this equation and the Cartesian version above are the fundamental equation in groundwater flow, but to arrive at this point requires considerable simplification. Some of the main assumptions which went into both these equations are:
Despite these large assumptions, the groundwater flow equation does a good job of representing the distribution of heads in aquifers due to a transient distribution of sources and sinks.
If the aquifer has recharging boundary conditions a steady-state may be reached (or it may be used as an approximation in many cases), and the diffusion equation (above) simplifies to the Laplace equation.
This equation states that hydraulic head is a harmonic function, and has many analogs in other fields. The Laplace equation can be solved using techniques, using similar assumptions stated above, but with the additional requirements of a steady-state flow field.
A common method for solution of this equations in civil engineering and soil mechanics is to use the graphical technique of drawing flownets; where contour lines of hydraulic head and the stream function make a curvilinear grid, allowing complex geometries to be solved approximately.
Steady-state flow to a pumping well (which never truly occurs, but is sometimes a useful approximation) is commonly called the Thiem solution.
The above groundwater flow equations are valid for three dimensional flow. In unconfined aquifers, the solution to the 3D form of the equation is complicated by the presence of a free surface water table boundary condition: in addition to solving for the spatial distribution of heads, the location of this surface is also an unknown. This is a non-linear problem, even though the governing equation is linear.
An alternative formulation of the groundwater flow equation may be obtained by invoking the Dupuit–Forchheimer assumption, where it is assumed that heads do not vary in the vertical direction (i.e., ). A horizontal water balance is applied to a long vertical column with area extending from the aquifer base to the unsaturated surface. This distance is referred to as the saturated thickness, b. In a confined aquifer, the saturated thickness is determined by the height of the aquifer, H, and the pressure head is non-zero everywhere. In an unconfined aquifer, the saturated thickness is defined as the vertical distance between the water table surface and the aquifer base. If , and the aquifer base is at the zero datum, then the unconfined saturated thickness is equal to the head, i.e., b=h.
Assuming both the hydraulic conductivity and the horizontal components of flow are uniform along the entire saturated thickness of the aquifer (i.e., and ), we can express Darcy's law in terms of integrated groundwater discharges, Qx and Qy:
Inserting these into our mass balance expression, we obtain the general 2D governing equation for incompressible saturated groundwater flow:
Where n is the aquifer porosity. The source term, N (length per time), represents the addition of water in the vertical direction (e.g., recharge). By incorporating the correct definitions for saturated thickness, specific storage, and specific yield, we can transform this into two unique governing equations for confined and unconfined conditions:
(confined), where S=Ssb is the aquifer storativity and
(unconfined), where Sy is the specific yield of the aquifer.
Note that the partial differential equation in the unconfined case is non-linear, whereas it is linear in the confined case. For unconfined steady-state flow, this non-linearity may be removed by expressing the PDE in terms of the head squared:
Or, for homogeneous aquifers,
This formulation allows us to apply standard methods for solving linear PDEs in the case of unconfined flow. For heterogeneous aquifers with no recharge, Potential flow methods may be applied for mixed confined/unconfined cases.