Drawing on the theory of quantum-mechanical stress, we introduce the stress
density in density-functional theory, and give specific prescriptions for
its practical and efficient implementation in the plane-wave ultrasoft pseu
dopotential method within the local-density approximation. In analogy with
the Chetty-Martin energy density, the stress density provides a spatial res
olution of the contributions to the integrated macroscopic stress tensor. W
hile this resolution is inherently nonunique (gauge dependent), there exist
gauge-independent ways of using it in practice. Here we adopt the followin
g ones: (a) calculating integrated macroscopic stresses over appropriately
defined parts of a system; (b) analyzing macroscopic averages of the stress
density; (c) analyzing changes in the stress density in response to extern
al perturbation. The abilities of the stress density are demonstrated for a
set of representative test cases from surface and interface physics: in pe
rspective, the stress density emerges as vastly more powerful and predictiv
e than the integrated macroscopic stress.