  In the near-UV and optical transmission spectrum of the hot Jupiter
WASP-121b, recent observations have detected strong absorption features of Mg,
Fe, Ca, and H$\alpha$, extending outside of the planet's Roche lobe. Studying
these atomic signatures can directly trace the escaping atmosphere and
constrain the energy balance of the upper atmosphere. To understand these
features, we introduce a detailed forward model by expanding the capability of
a one-dimensional model of the upper atmosphere and hydrodynamic escape to
include important processes of atomic metal species. The hydrodynamic model is
coupled to a Ly$\alpha$ Monte Carlo radiative transfer calculation to simulate
the excited hydrogen population and associated heating/ionization effects.
Using this model, we interpret the detected atomic features in the transmission
spectrum of WASP-121b and explore the impact of metals and excited hydrogen on
its upper atmosphere. We demonstrate the use of multiple absorption lines to
impose stronger constraints on the properties of the upper atmosphere than the
analysis of a single transmission feature can provide. In addition, the model
shows that line broadening due to atmospheric outflow driven by the Roche lobe
overflow is necessary to explain the observed line widths and highlights the
importance of the high mass-loss rate caused by the Roche lobe overflow that
requires careful consideration of the structure of the lower and middle
atmosphere. We also show that metal species and excited state hydrogen can play
an important role in the thermal and ionization balance of ultra-hot Jupiter
thermospheres.
