  This paper presents a detailed hydrostatic model of the upper atmosphere of
HD 189733b, with the goal of constraining its temperature, particle densities,
and radiation field over the pressure range $10^{-4}-10\, \mu \rm bar$, where
the observed H$\alpha$ transmission spectrum is produced. The atomic hydrogen
level population is computed including both collisional and radiative
transition rates. The Ly$\alpha$ resonant scattering is computed using a
Monte-Carlo simulation. The model transmission spectra are in broad agreement
with the data. Excitation of the H(2$\ell$) population is mainly by Ly$\alpha$
radiative excitation due to the large Ly$\alpha$ intensity. The density of
H(2$\ell$) is nearly flat over two decades in pressure, and is optically thick
to H$\alpha$. Additional models computed for a range of the stellar Lyman
continuum (LyC) flux suggest that the variability in H$\alpha$ transit depth
may be due to the variability in the stellar LyC. Since metal lines provide the
dominant cooling of this part of the atmosphere, the atmosphere structure is
sensitive to the density of species such as Mg and Na which may themselves be
constrained by observations. Since the H$\alpha$ and Na D lines have comparable
absorption depths, we argue that the center of the Na D lines are also formed
in the atomic layer where the H$\alpha$ line is formed.
