  Grain boundaries play a critical role in applications of superconducting
Nb$_3$Sn: in dc applications, grain boundaries preserve the material's
inherently high critical current density by pinning flux, while in ac
applications grain boundaries can provide weak points for flux entry and lead
to significant dissipation. We present the first $\textit{ab initio}$ study to
investigate the physics of different boundary types in Nb$_3$Sn using density
functional theory. We identify an energetically favorable selection of tilt and
twist grain boundaries of distinct orientations. We find that clean grain
boundaries free of point defects reduce the Fermi-level density of states by a
factor of two, an effect that decays back to the bulk electronic structure
$\sim1-1.5$ nm from the boundary. We further calculate the binding
free-energies of tin substitutional defects to multiple boundaries, finding a
strong electronic interaction that extends to a distance comparable to that of
the reduction of density of states. Associated with this interaction, we
discover a universal trend in defect electronic entropies near a boundary. We
probe the effects of defect segregation on grain boundary electronic structure
and calculate the impact of substitutional impurities on the Fermi-level
density of states in the vicinity of a grain boundary, finding that titanium
and tantalum have little impact regardless of placement, whereas tin, copper,
and niobium defects each have a significant impact but only on sites away from
the boundary core. Finally, we consider how all of these effects impact the
local superconducting transition temperature $T_\textrm{c}$ as a function of
distance from the boundary plane.
