We have developed a complete model of the hydrogen molecule as part of the spectral simulation code Cloudy. Our goal is to apply this to spectra of high-redshift star-forming regions where H2 absorption is seen, but where few other details are known, to understand its implication for star formation. The microphysics of H2 is intricate, and it is important to validate these numerical simulations in better-understood environments. This paper studies a well-defined line-of-sight through the Galactic interstellar medium (ISM) as a test of the microphysics and methods we use. We present a self-consistent calculation of the observed absorption-line spectrum to derive the physical conditions in the ISM towards HD185418, a line-of-sight with many observables. We deduce density, temperature, local radiation field, cosmic ray ionization rate, chemical composition and compare these conclusions with conditions deduced from analytical calculations. We find a higher density, similar abundances, and require a cosmic ray flux enhanced over the Galactic background value, consistent with enhancements predicted by MHD simulations.