A study of the phase transitions, electronic structures and optical properties of Mg2Si under high pressure