An ab initio MP2 vibrational Hamiltonian of HOD in an external electrostatic potential parametrized by the electric field and its gradient-tensor is constructed. By combining it with the fluctuating electric field induced by the D2O solvent obtained from molecular dynamics simulations, we calculate the infrared absorption of the O-H stretch. The resulting solvent shift and infrared line shape for three force fields (TIP4P, SPC/E, and SW) are in good agreement with the experiment. A collective coordinate response for the solvent effect is constructed by identifying the main electrostatic field and gradient components contributing to the line shape. This allows a realistic stochastic Liouville equation simulation of the line shapes which is not restricted to Gaussian frequency fluctuations.