Structural, spectroscopic and electronic properties of hydrogen-bonded water molecules in crystals. Ab initio calculations and experimental data of MC12·n(H,D)2O, M = Sr or Ba