An ab initio study of spectroscopic and thermodynamic characteristics of MgH2 and TiC systems