On the equilibrium structure of MgC2 and AlC2