Term structure of Mg I calculated in a frozen-cores approximation