Structures and stabilities of MgC3 isomers: a theoretical study