Understanding phase behaviour in the geological storage of carbon dioxide