# Sources and sinks

In the physical sciences, engineering and mathematics, sources and sinks is an analogy used to describe properties of vector fields. It generalizes the idea of fluid sources and sinks (like the faucet and drain of a bathtub) across different scientific disciplines. These terms describe points, regions, or entities where a vector field originates or terminates. This analogy is usually invoked when discussing the continuity equation, the divergence of the field and the divergence theorem. The analogy sometimes includes swirls and saddles for points that are neither of the two.
In the case of electric fields the idea of flow is replaced by field lines and the sources and sinks are electric charges.

## Description and fluid dynamics analogy

In physics, a vector field $\mathbf {b} (x,y,z)$ is a function that returns a vector and is defined for each point (with coordinates $x,y,z$) in a region of space. The idea of sources and sinks applies to $\mathbf {b}$ if it follows a continuity equation of the form
    ${\frac {\partial a}{\partial t}}+\nabla \cdot \mathbf {b} =s$,
where $t$ is time, $a$ is some quantity density associated to $\mathbf {b}$, and $s$ is the source-sink term. The points in space where $s>0$ are called a sources and when $s<0$ are called sinks. The integral version of the continuity equation is given by the divergence theorem.
These concepts originate from sources and sinks in fluid dynamics, where the flow is conserved per the continuity equation related to conservation of mass, given by
    ${\frac {\partial \rho }{\partial t}}+\nabla \cdot \mathbf {v} =Q$
where $\rho$ is the mass density of the fluid, $\mathbf {v}$ is the flow velocity vector, and $Q$ is the source-sink flow (fluid mass per unit volume per unit time). This equation implies that any emerging or disappearing amount of flow in a given volume must have a source or a sink, respectively. Sources represent locations where fluid is added to the region of space, and sinks represent points of removal of fluid. The term $Q$ is positive for a source and negative for a sink. Note that for incompressible flow or time-independent systems, $Q$ is directly related to the divergence as
    $\nabla \cdot \mathbf {v} =Q$.
For this kind of flow, solenoidal vector fields (no divergence) have no source or sinks. When at a given point $Q=0$ but the curl $\nabla \times \mathbf {v} \neq 0$, the point is sometimes called a swirl. And when both divergence and curl are zero, the point is sometimes called a saddle.

## Other examples in physics
### Electromagnetism

In electrodynamics, the current density behaves similar to hydrodynamics as it also follows a continuity equation due to the charge conservation:
    ${\frac {\partial \rho _{e}}{\partial t}}+\nabla \cdot \mathbf {j} =\sigma$,
where this time $\rho _{e}$ is the charge density, $\mathbf {j}$ is the current density vector, and $\sigma$ is the current source-sink term. The current source and current sinks are where the current density emerges $\sigma >0$ or vanishes $\sigma <0$, respectively (for example, the source and sink can represent the two poles of an electrical battery in a closed circuit).
The concept is also used for the electromagnetic fields, where fluid flow is replaced by field lines. For an electric field $\mathbf {E}$, a source is a point where electric field lines emanate, such as a positive charge ($\nabla \cdot \mathbf {E} >0$), while a sink is where field lines converge ($\nabla \cdot \mathbf {E} <0$), such as a negative charge. This happens because electric fields follow Gauss's law given by
    $\nabla \cdot \mathbf {E} =\rho _{e}/\epsilon _{0}$,
where $\epsilon _{0}$ is the vacuum permittivity. In this sense, for a magnetic field $\mathbf {B}$ there are no sources or sinks because there are no magnetic monopoles as described by Gauss's law for magnetism which states that
    $\nabla \cdot \mathbf {B} =0$.
Electric and magnetic fields also carry energy as described by Poynting's theorem, given by
    ${\frac {\partial u}{\partial t}}+\nabla \cdot \mathbf {S} =-\mathbf {J} \cdot \mathbf {E}$
where $u$ is the electromagnetic energy density, $\mathbf {S}$ is the Poynting vector and $-\mathbf {J} \cdot \mathbf {E}$ can be considered as an energy source-sink term.

### Newtonian gravity

Similar to electric and magnetic fields, one can discuss the case of a Newtonian gravitational field $\mathbf {g}$ described by Gauss's law for gravity,
    $\nabla \cdot \mathbf {g} =-4\pi G\rho$,
where $G$ is the gravitational constant. As gravity is only attractive ($\rho \geq 0$), there are only gravitational sinks but no sources. Sinks are represented by point masses.

### Thermodynamics and transport

In thermodynamics, the source and sinks correspond to two types of thermal reservoirs, where energy is supplied or extracted, such as heat flux sources or heat sinks. In thermal conduction this is described by the heat equation. The terms are also used in non-equilibrium thermodynamics by introducing the idea of sources and sinks of entropy flux.

### Chaos theory

In chaos theory and complex system, the idea of sources and sinks is used to describes repellors and attractors, respectively.

## In mathematics
### Complex functions

This terminology is also used in complex analysis, as complex number can be desrcibed as vectors in the complex plane.Sources and sinks are associated with zeros and poles of meromorphic function, representing inflows and outflows in a harmonic function. A complex function is defined to a source or a sink if it has a pole of order 1.

### Topology

In topology, the terminology of sources and sinks is used when discussing a vector field over a compact differentiable manifold. In this context the index of a vector field is +1 if it is a source or a sink, if the value is -1 it is called a saddle point. This concept is useful to introduce the Poincaré–Hopf theorem and the hairy ball theorem.

## Other uses

Other areas where this terminology is used include source–sink dynamics in ecology and current source density analysis in neuroscience.