  We extend the non-equilibrium model for the chemical and thermal evolution of
diffuse interstellar gas presented in Richings et al. (2014) to account for
shielding from the UV radiation field. We attenuate the photochemical rates by
dust and by gas, including absorption by HI, H2, HeI, HeII and CO where
appropriate. We then use this model to investigate the dominant cooling and
heating processes in interstellar gas as it becomes shielded from the UV
radiation. We consider a one-dimensional plane-parallel slab of gas irradiated
by the interstellar radiation field, either at constant density and temperature
or in thermal and pressure equilibrium. The dominant thermal processes tend to
form three distinct regions in the clouds. At low column densities cooling is
dominated by ionised metals such as SiII, FeII, FeIII and CII, which are
balanced by photoheating, primarily from HI. Once the hydrogen-ionising
radiation becomes attenuated by neutral hydrogen, photoelectric dust heating
dominates, while CII becomes dominant for cooling. Finally, dust shielding
triggers the formation of CO and suppresses photoelectric heating. The dominant
coolants in this fully shielded region are H2 and CO. The column density of the
HI-H2 transition predicted by our model is lower at higher density (or at
higher pressure for gas clouds in pressure equilibrium) and at higher
metallicity, in agreement with previous PDR models. We also compare the HI-H2
transition in our model to two prescriptions for molecular hydrogen formation
that have been implemented in hydrodynamic simulations.
