Home > Visualization > Vector Analysis & Curvilinear Coordinates

Module 1.2 Divergence of Vector Fields & Gauss’s Law

Modules Index
Simulation 1

2D/3D Vector Field Divergence & Flux Density Visualizer - Point Sources, Sinks, Dipoles, and Incompressible Solenoidal Flow

Python 3.11 with Matplotlib Slider Ready

Interactive Physics Ready

Click "Run Code" to launch simulation and interactive parameter sliders.


                                

Mathematical Problem Formulation

2D/3D Vector Field Divergence & Flux Density Visualizer: Point Sources, Sinks, Dipoles, and Incompressible Solenoidal Flow

Theoretical Background & Explanation

Divergence and Net Flux Concept

Figure 2.1: Physical Meaning of Divergence: (Left) Positive divergence $\nabla \cdot \vec{F} > 0$ acting as a field source with net outward flux, (Middle) Negative divergence $\nabla \cdot \vec{F} < 0$ acting as a field sink with net inward flux, (Right) Zero divergence $\nabla \cdot \vec{F} = 0$ representing solenoidal/incompressible flow with equal inflow and outflow.

The Divergence Operator ($\nabla \cdot \vec{F}$)

The divergence of a vector field $\vec{F}(x,y,z)$ is a scalar field quantifying the net outward flux of the vector field per unit volume expanding away from an infinitesimal point: $$\nabla \cdot \vec{F} = \lim_{\Delta V \to 0} \frac{1}{\Delta V} \oiint_{\Delta S} \vec{F} \cdot d\vec{S}$$

1. Rectangular Cartesian Formulation

Taking the inner product between the spatial del operator $\nabla = \hat{i}\frac{\partial}{\partial x} + \hat{j}\frac{\partial}{\partial y} + \hat{k}\frac{\partial}{\partial z}$ and the vector field $\vec{F} = F_x \hat{i} + F_y \hat{j} + F_z \hat{k}$:

$$\nabla \cdot \vec{F} = \frac{\partial F_x}{\partial x} + \frac{\partial F_y}{\partial y} + \frac{\partial F_z}{\partial z}$$

Consider an infinitesimal rectangular box of dimensions $\Delta x \times \Delta y \times \Delta z$. The net outward flux through the two faces perpendicular to the $x$-axis is: $$\Delta \Phi_x = \left[ F_x\left(x + \frac{\Delta x}{2}, y, z\right) - F_x\left(x - \frac{\Delta x}{2}, y, z\right) \right] \Delta y \Delta z \approx \frac{\partial F_x}{\partial x} \Delta x \Delta y \Delta z$$ Summing over all three pairs of faces and dividing by $\Delta V = \Delta x \Delta y \Delta z$ rigorously produces the Cartesian formula above.

2. Physical Classification of Vector Fields

The sign of $\nabla \cdot \vec{F}$ classifies physical behavior across all transport phenomena:
• $\nabla \cdot \vec{F} > 0$ (Source): Field lines originate here. Positive electric charge in electrostatics ($\nabla \cdot \vec{E} = \rho / \epsilon_0$), or fluid thermal expansion.
• $\nabla \cdot \vec{F} < 0$ (Sink): Field lines terminate here. Negative electric charge, fluid suction drain, or mass condensation.
• $\nabla \cdot \vec{F} = 0$ (Solenoidal / Incompressible): Field lines never begin or end; they form continuous closed loops or extend from $-\infty$ to $+\infty$.
• Examples of Solenoidal Fields: Magnetic induction $\nabla \cdot \vec{B} = 0$ (Gauss's law for magnetism; no magnetic monopoles exist), and incompressible fluid velocity $\nabla \cdot \vec{v} = 0$ (equation of continuity with constant fluid density).

Simulation 2

Problem - Verification of Gauss's Law for a Non-Uniform Spherically Symmetric Charge Distribution

Python 3.11 with Matplotlib Slider Ready

Interactive Physics Ready

Click "Run Code" to launch simulation and interactive parameter sliders.


                                

Mathematical Problem Formulation

Problem: Verification of Gauss's Law for a Non-Uniform Spherically Symmetric Charge Distribution

Theoretical Background & Explanation

Gauss Law Problem

Figure 2.2: Gauss's Law & Divergence in Non-Uniform Spherical Charge: (Left) Cross-sectional volume density and outward electric field quivers with concentric Gaussian sphere $r < R$, (Right) Radial profiles of charge density $\rho(r)$ and continuous electric field $E(r)$ smoothly transitioning across the boundary $r = R$.

Physics Problem Statement

A spherically symmetric cosmic dust cloud of radius $R$ contains a non-uniform volume charge density given by: $$\rho(r) = \begin{cases} \rho_0 \left( 1 - \frac{r^2}{R^2} \right), & r \le R \ 0, & r > R \end{cases}$$ where $\rho_0$ is the peak charge density at the center $r=0$.
Tasks:
1. Calculate the total charge $Q_{\text{tot}}$ enclosed by the entire cloud.
2. Use the integral form of Gauss's Law $\oiint \vec{E} \cdot d\vec{S} = Q_{\text{enc}} / \epsilon_0$ to determine the electric field $\vec{E}(r)$ everywhere ($r \le R$ and $r > R$).
3. Verify that the differential divergence $\nabla \cdot \vec{E} = \frac{1}{r^2}\frac{d}{dr}(r^2 E_r)$ yields identically $\rho(r) / \epsilon_0$.

1. Total Enclosed Charge Calculation

Integrating the volume density in spherical coordinates with radial shells of volume $dV = 4\pi r^2 dr$:

$$Q_{\text{tot}} = \int_0^R \rho(r) \cdot 4\pi r^2 dr = 4\pi \rho_0 \int_0^R \left( r^2 - \frac{r^4}{R^2} \right) dr = 4\pi \rho_0 \left[ \frac{R^3}{3} - \frac{R^3}{5} \right] = \frac{8}{15}\pi \rho_0 R^3$$

2. Electric Field via Gauss's Law

By spherical symmetry, the electric field is purely radial: $\vec{E} = E(r)\hat{r}$. Over a concentric Gaussian sphere of radius $r$: $$\oiint_S \vec{E} \cdot d\vec{S} = E(r) \cdot 4\pi r^2 = \frac{Q_{\text{enc}}(r)}{\epsilon_0}$$
• Inside the Cloud ($r \le R$):

$$Q_{\text{enc}}(r) = 4\pi \rho_0 \int_0^r \left( r'^2 - \frac{r'^4}{R^2} \right) dr' = 4\pi \rho_0 \left( \frac{r^3}{3} - \frac{r^5}{5R^2} \right)$$ $$E_{\text{in}}(r) = \frac{\rho_0 r}{\epsilon_0} \left( \frac{1}{3} - \frac{r^2}{5R^2} \right)$$


• Outside the Cloud ($r > R$): $$E_{\text{out}}(r) = \frac{Q_{\text{tot}}}{4\pi\epsilon_0 r^2} = \frac{2\rho_0 R^3}{15\epsilon_0 r^2}$$

3. Differential Verification of Divergence

Applying the spherical divergence formula to $E_{\text{in}}(r)$:

$$\nabla \cdot \vec{E} = \frac{1}{r^2} \frac{d}{dr} \left( r^2 E_r \right) = \frac{1}{r^2} \frac{d}{dr} \left[ \frac{\rho_0}{\epsilon_0} \left( \frac{r^3}{3} - \frac{r^5}{5R^2} \right) \right] = \frac{\rho_0}{\epsilon_0 r^2} \left[ r^2 - \frac{r^4}{R^2} \right] = \frac{\rho_0}{\epsilon_0} \left( 1 - \frac{r^2}{R^2} \right) = \frac{\rho(r)}{\epsilon_0}$$

This completes the exact analytical and numerical proof connecting integral Gauss's law with Maxwell's 1st differential equation $\nabla \cdot \vec{E} = \rho / \epsilon_0$!