We propose an extension of the axial next nearest neighbour Ising (ANNNI) model to a general number of interactions between spins. We apply this to the calculation of stacking fault energies in magnesium—particularly challenging due to the long-ranged screening of the pseudopotential by the free electron gas. We employ both density functional theory (DFT) using highest possible precision, and generalized pseudopotential theory (GPT) in the form of an analytic, long ranged, oscillating pair potential. At the level of first neighbours, the Ising model is reasonably accurate, but higher order terms are required. In fact, our ‘ AN
N
NI model’ is slow to converge—an inevitable feature of the free electron-like electronic structure. In consequence, the convergence and internal consistency of the AN
N
NI model is problematic within the most precise implementation of DFT. The GPT shows the convergence and internal consistency of the DFT bandstructure approach with electron temperature, but does not lead to loss of precision. The GPT is as accurate as a full implementation of DFT but carries the additional benefit that damping of the oscillations in the AN
N
NI model parameters are achieved without entailing error in stacking fault energies. We trace this to the logarithmic singularity of the Lindhard function.