## Introduction

The Heisenberg model has been widely studied as both a classical and quantum description of crystal magnetism. In either interpretation, the Hamiltonian can be expressed as:

$$H=-\mathop{\sum}\limits_{i,j}{J}_{ij}\,{{{{\bf{S}}}}}_{i}\cdot {{{{\bf{S}}}}}_{j}$$
(1)

where i and j sum over lattices sites and Jij is an interaction energy determined by the relative positions of i and j. Classically, Si is a dimensionless spin vector proportional to local magnetic moment. While atomic magnetism has fundamentally quantum origins, the classical model largely accounts for the energies of static spin configurations, reproducing experimental magnon spectra and capturing magnetic contributions to the energies of electronic structure calculations1,2. It does not, however, accurately describe thermodynamic properties below the magnetic disordering temperature3,4 and, while alternatives have been proposed3,4,5,6,7,8,9,10, the efficient simulation of finite temperature magnetism remains an outstanding problem in computational materials science.

The limited success of the classical Heisenberg model can be understood by regarding classical moments as the quantum expectation values of spin operators, as is detailed in the following section. With this perspective, we consider Monte Carlo (MC) simulation of the Heisenberg model, a popular approach to calculating thermodynamic properties by probabilistically sampling the spin-configuration space. The deficiency of classical MC (CMC) methods is addressed and a more accurate, but similarly general, semiclassical MC (SMC) sampling technique is proposed, demonstrated, and discussed.

## Results

### Background and motivation

In the more physical quantum Heisenberg model, Si operates on spinor $$\left|{\chi }_{i}\right\rangle$$ to measure the spin of lattice site i. N spins of quantum number s form a (2s + 1)N-dimensional Hilbert space. A canonical system in thermal equilibrium is described by density operator ρ = eβH/Z, where partition function Z = tr(eβH) and β is the reciprocal product of Boltzmann’s constant and temperature. Thermodynamic quantities corresponding to ensemble averages, such as energy or magnetization, are determined from ρ as $$\overline{O}=\left\langle O\right\rangle =\,{{\mbox{tr}}}\,(\rho \,O)$$, where $$\overline{O}$$ denotes the ensemble average and $$\left\langle O\right\rangle$$ indicates a quantum expectation value.

Density operators are typically expanded as sums over energy eigenstate projectors, although the eigensystem of Eq. (1) is not generally solvable. Instead, states may be sampled through quantum MC (QMC) techniques11, although current methods appear numerically unstable for Hamiltonians containing competing interactions12, such as geometric frustration13 or even values of Jij with opposing signs14, as is often the case in real materials. Compared to CMC, QMC is also far more conceptually and computationally complex, with simulation time scaling nonlinearly with system size15.

Fortunately, magnets that are not significantly entangled may not require a full quantum treatment. Above some temperature, all equilibrium systems become unentangled, or separable16, meaning that ρ may be expressed as a sum over product states $$\left|{\psi }_{p}\right\rangle =\left|{\chi }_{1}\right\rangle \otimes \left|{\chi }_{2}\right\rangle \cdots \otimes \left|{\chi }_{N}\right\rangle$$. Entanglement phenomena have been primarily identified in one or two-dimensional systems at low temperatures17,18, so we assume that separability is at least a very a good approximation for conventional three-dimensional magnets above a few degrees Kelvin.

Product states are attractive because their expectation values distribute across components of the tensor product19, enabling effectively classical evaluation of the Heisenberg Hamiltonian. For product state $$\left|{\psi }_{p}\right\rangle$$, energy Ep can be determined as:

$${\left\langle H\right\rangle }_{p}=-\mathop{\sum}\limits_{i,j}{J}_{ij}\,{\left\langle {{{{\bf{S}}}}}_{i}\cdot {{{{\bf{S}}}}}_{j}\right\rangle }_{p}=-\mathop{\sum}\limits_{i,j}{J}_{ij}\,{\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}\cdot {\left\langle {{{{\bf{S}}}}}_{j}\right\rangle }_{p},$$
(2)

where $${\left\langle O\right\rangle }_{p}$$ denotes $$\left\langle {\psi }_{p}| O| {\psi }_{p}\right\rangle$$. Equation (2) explains the success of the classical Heisenberg model in evaluating the energies of given magnetic structures, if classical Si is understood as quantum $${\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}$$.

When $${\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}$$ is not prescribed, however—as is typically the case for thermodynamic ensembles—classical methods are far less accurate as determining which values of $${\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}$$ to consider requires significant approximation. Most notably, conventional CMC simulations sample spin states continuously, which is only justified in the limit of an infinite spin quantum number20,21. Taking this limit provides the standard derivation of the classical Heisenberg model and leads to a scaling relation between the quantum (Jij) and classical ($${J}_{ij}^{\infty }$$) interaction energies for spin quantum number s:

$$s(s+1){J}_{ij}={s}^{2}{J}_{ij}^{\infty }.$$
(3)

Perhaps unsurprisingly, the assumption of infinite s causes unphysical thermodynamic behavior in not only CMC, but also classical spin dynamics simulations22.

However, if $${\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}$$ were known for all the components of a separable representation, its thermodynamic properties could be calculated with quantum accuracy and classical convenience. For a separable ensemble that can be represented in terms of product states p, the average of observable O may be expressed as a classical sum, i.e.:

$$\overline{O}=\frac{1}{Z}\mathop{\sum}\limits_{p}{{{{\rm{e}}}}}^{-\beta {E}_{p}}{\left\langle O\right\rangle }_{p},$$
(4)

as detailed in Supplementary Note 1. For the determination of $$\overline{E}$$, Eq. (2) can be substituted into Eq. (4) such that the ensemble average is expressed in terms of $${\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}$$, with a similar procedure possible for other thermodynamic properties. Of course, identifying specific $$\left|{\psi }_{p}\right\rangle$$ or $${\left\langle {{{{\bf{S}}}}}_{i}\right\rangle }_{p}$$ is no easier than determining eigenstates, but it may be feasible to approximate the density of product states more accurately than classical methods. Indeed, representatively sampling states in a high-dimensional configuration space is the fundamental purpose of MC simulations.

Previous efforts to improve the accuracy of classical simulations can be understood from this perspective. For example, spin-wave excitations can be quantized using Planck statistics, which reasonably describe magnetization behavior1, although local updating methods are generally far more efficient for atomistic simulations. Ref. 8 approximates a density of states explicitly calculated using first-principles methods by introducing and adjusting an effective simulation temperature. This approach, which can be applied in continuous time spin dynamics as well as MC simulations9, works well at low temperatures, but requires parameterization and underestimates8 (or overestimates9) magnetization at intermediate temperatures. Somewhat similarly, ref. 7 describes a method for empirically determining effective temperatures, while ref. 10 reproduces a Planck distribution through careful control of a spin dynamics thermostat. It is also worth noting that the methods of refs. 3,7,8,9 directly depend on the Curie temperature (TC), above which CMC is performed.

### Semiclassical sampling by local quantization

Alternatively, we propose a more direct approach for estimating the separable density of states based on a locally quantum approximation of state evolution. In the simplest form of CMC, a new state is trialed by mutating the (expected) spin of randomly selected site k, while the spins of all other sites i ≠ k are fixed. Trial $$\left\langle {{{{\bf{S}}}}}_{k}\right\rangle$$ is traditionally chosen with uniform probability for all directions, as is classically allowed. However, it is possible to introduce an approximate quantization by treating this ultimately fictitious permutation as a quantum problem.

In this approach, Eq. (1) can be reframed as a single-spin quantum Hamiltonian for site k:

$${H}_{k}={E}_{i\ne k}-{{{{\bf{S}}}}}_{k}\cdot 2\mathop{\sum}\limits_{j}{J}_{kj}\,\left\langle {{{{\bf{S}}}}}_{j}\right\rangle,$$
(5)

where $$\left\langle {{{{\bf{S}}}}}_{j}\right\rangle$$ is the fixed spin of neighboring site j. (The factor of two originates from the double summation in Eq. (1)). As Eik is constant, Eq. (5) has the elementary solutions of a spin in the magnetic field $${{{{\bf{B}}}}}_{k}=2{\sum }_{j}{J}_{kj}\left\langle {{{{\bf{S}}}}}_{j}\right\rangle$$. Specifically, Sk is quantized along Bk with quantum number ms = −s, −s + 1, … , s; its orthogonal components are inherently uncertain, but their expectation values precess around Bk in time.

The solutions of Eq. (5) can be statistically sampled according to the following SMC procedure, which is illustrated in Fig. 1. For each MC step, site k is randomly selected and Bk is computed. A trial quantization along Bk (corresponding to some ms) is chosen at random, defining the component of $$\left\langle {{{{\bf{S}}}}}_{k}\right\rangle$$ along Bk; any remaining perpendicular component is then randomly chosen to account for continuous precession. The accessible trial states $$\left\langle {{{{\bf{S}}}}}_{k}\right\rangle$$ for a hypothetical scenario are drawn as rings around Bk in Fig. 1. The trial energy is computed and acceptance or rejection is determined according to the standard Metropolis criteria, after which a new k is chosen for the next step. In practice, SMC requires only marginally more effort than CMC, with spin quantum number s being the only additional parameter.

While the impact of multiple-spin interactions on quantization has been neglected, these solutions should still estimate the true distribution of product states better than purely classical methods, although the extent of the improvement is not immediately clear as separable solutions of large ensembles are generally intractable. In practice, the results are notably more accurate—indeed, the remainder of this paper demonstrates how locally quantized SMC reasonably describes thermodynamic properties across a wide temperature range, albeit with several caveats.

### Magnetization of Fe

The zero-field spontaneous magnetization of body-centered cubic (bcc) Fe provides a classic benchmark for finite temperature magnetic predictions. Figure 2 shows measurements from ref. 23 alongside notably differing CMC calculations (see Methods for details). The experimental ground state moment of 2.2 μB/atom implies a quantum number of s = 1.1, neglecting orbital contributions that are suppressed under the system’s cubic symmetry. As a transition metal, the itinerant magnetism of Fe is less than perfectly described by a collection of atomic spinors, but the standard Heisenberg model appears to provide a passable approximation24. Previous studies have modeled Fe by interpolating results for s = 1 and s = 3/23, but for the purpose of demonstration, Fig. 2 shows distinct SMC magnetization curves for s = 1, 3/2, and 2.

All the quantized calculations greatly improve upon CMC, although no single value of s exactly replicates experiment. Using s = 1, as is closest to the experimentally implied value, provides the best results near TC, but not at lower temperatures, where s = 3/2 appears slightly more accurate. The next highest value of s = 2 is generally further from experiment, expectedly approaching the classical limit of infinite s—the gradual convergence of CMC and SMC is further shown in Supplementary Fig. 2. Critical magnetization behavior is also examined in Supplementary Fig. 3. Some remaining inaccuracies are discussed later, but the overall dramatic improvement clearly shows the potential of semiclassical local quantization.

### Heat capacity and magnetic short-range order

While demonstrative, direct comparison of computational predictions to experiments is complicated by the many levels of approximation inherent in the theory. Fortunately, ref. 3 provides effectively exact QMC heat capacities for a small bcc ferromagnet with nearest neighbor Heisenberg interactions, which are shown in Fig. 3 for four spin quantum numbers in addition to infinite spin CMC (see Methods for details). Heat capacity is defined as:

$$C=\frac{\partial \overline{E}}{\partial T},$$
(6)

from which many other thermodynamic properties can be derived. Figure 3 shows that direct calculation of SMC heat capacity according to Eq. (6) largely reproduces QMC at lower temperatures, but results in significant errors around TC, with altogether less improvement over CMC than seen in Fig. 2.

An explanation for excessive heat capacity in the critical region follows from Eq. (6); overestimation of heat capacity implies that simulation energies increase too rapidly with respect to temperature, which is explicitly shown in Fig. 4. Below TC, semiclassical energies closely track QMC values, but magnetic disordering imparts a rapid increase in energy, resulting in an overestimation of energy that only gradually disappears at higher temperatures. Excess energies indicate that these simulations are less ordered than their QMC counterparts—since the error only becomes significant as long-range order disappears, it is apparent that locally quantized SMC systematically underestimates magnetic short-range order (MSRO).

In contrast, Fig. 4 shows how CMC energies are correct in the high-temperature limit despite significant error below TC. Nonetheless, CMC and SMC predict very similar degrees of order above TC, as demonstrated in Fig. 5 for nearest neighbor spins in bcc Fe. These two observations imply that accurate CMC energies (and related properties, such as heat capacity) above TC originate from the $$\frac{s+1}{s}$$ energetic scaling that was introduced in Eq. (3). Indeed, CMC has long been believed to underestimate MSRO on the basis of both experiment25,26 and theory27,28,29,30. As a reference, Fig. 5 includes the significantly more ordered predictions30 of dynamic spin-fluctuation theory31, an advanced linear-response technique that does not explicitly consider local moments.

The observation that scaling CMC interaction parameters, as is required to preserve the Curie temperature, leads to accurate energies above TC implies that a similar correction factor could recover realistic MSRO. This simple idea is tested in Fig. 5, which includes a version of the CMC spin–spin correlations multiplied post hoc by $$\frac{s+1}{s}$$ (for s = 1.1) that favorably compares to the theory of ref. 30. The remaining discrepancy may be attributable to the neglect of longitudinal spin fluctuations, which, although relatively small in Fe, can significantly affect MSRO24, as well as the specific parameterization of the Hamiltonian.

The proposed scaling factor offers a path for correcting SMC, either post hoc or possibly through scaling interaction parameters Jij as in CMC. With an optimized interpolation scheme smoothly introducing the scaling factor across the critical region, SMC could conceivably replicate QMC across across all temperatures in a manner reminiscent of previously employed techniques3,7. However, this approach would compromise much of the convenience of SMC and a somewhat more straightforward method for recovering accurate heat capacities is explored in the following section.

### Improved accuracy from fluctuations

Heat capacity may alternatively (and more conventionally) be calculated according to the fluctuation-dissipation theorem, i.e.:

$$C=\frac{\overline{{E}^{2}}-{\overline{E}}^{2}}{{k}_{B}{T}^{2}},$$
(7)

which must equal Eq. (6) for a statistically valid ensemble. However, SMC heat capacities determined in this manner, plotted in Fig. 6, notably differ from those previously calculated in Fig. 3—in fact, the values obtained from the fluctuation-dissipation theorem are significantly closer to the QMC of ref. 3.

The disagreement between the heat capacities calculated from Eqs. (6) and (7) can be attributed to a violation of balance by the SMC sampling procedure. Local quantization clearly does not satisfy detailed balance, as the local field at any site is frequently changed as neighboring spins are reoriented. If a spin is re-quantized along an updated local field, it is likely impossible to directly return to the prior state along the former quantization axis, which is a fundamental requirement for detailed balance. It is less immediately obvious that this procedure violates the statistically necessary condition of balance32, but the difference between the two methods of calculating heat capacity, which are formally equivalent for a properly sampled ensemble, suggest an absence of balance. In contrast, if all spins are quantized along a fixed axis, then (detailed) balance is recovered and both methods of calculating heat capacity predict consistent values, which are similar to those of Fig. 3 (this is explicitly shown in Supplementary Fig. 1). For local quantization, issues of balance could be circumvented by performing non-Markovian MC such as Wang-Landau sampling33, which determines $$\overline{{E}^{2}}$$ from a sampled distribution of E such that Eq. (7) reproduces Eq. (6).

However, the degree of accuracy shown in Fig. 6 suggests that the fluctuation-based calculations are capturing more realistic physics. Despite excessive average energies due to the underestimation of MSRO, the SMC calculations appear to sample realistic energetic fluctuations. As shown in Fig. 3, the heat capacities of Eq. (6) are about as accurate as the best existing methods for (non-quantum) magnetic thermodynamics, exemplified by the “rescaled” MC of ref. 3, which applies an empirical correction factor to CMC based on lattice-specific QMC for a model Hamiltonian. The fluctuation-based approach thus seems very promising for practical calculations, although it would benefit from a more rigorous explanation for the demonstrated accuracy.

### Antiferromagnetic susceptibility of RbMnF3

While only ferromagnets have been considered up to this point, SMC sampling works similarly well for antiferromagnets, of which RbMnF3 is one of the simplest examples. In this compound, Mn ions form a simple cubic sublattice with s = 5/2 and effectively nearest neighbor exchange interactions34. Figure 2 shows the zero-field parallel susceptibility (χ) of RbMnF3, both from experiment35 and calculated with CMC and SMC via the fluctuation-dissipation theorem:

$${\chi }^{\parallel }=\frac{\overline{{{{{\bf{M}}}}}^{2}}-{\overline{{{{\bf{M}}}}}}^{2}}{{k}_{B}T}.$$
(8)

Both axes have been scaled relative to TN values to ease comparison with experiment. SMC is expectedly far more accurate than CMC below the disordering point, although χ is somewhat underestimated at very low temperatures. Classical χ appears slightly closer to experiment above TN, likely reflecting the underestimation of MSRO by local quantization, although the choice of scaling could also affect the alignment of these values.

## Discussion

The use of fluctuations for thermodynamic calculations largely resolves the primary source of error in SMC, but a few issues remain. In particular, local quantization systematically undersamples low-temperature excitations, which can be seen across a range of properties in Figs. 2, 6 and 7. Magnetization, for instance, should scale as an exponential of temperature in the 0 K limit, but it appears asymptotic in Fig. 2—as shown more clearly in Supplementary Fig. 4, SMC magnetization does not significantly deviate from the ferromagnetic state below ~TC/5. In reality, excitations in this region are dominated by long-wavelength spin-waves, which, while theoretically compatible with SMC, do not appear adequately sampled by local quantization. The omission of these excitations similarly explains a slight underestimation of heat capacity and susceptibility at low temperatures, as these properties reflect, respectively, energetic and magnetic fluctuations.

The absence of non-local quantizations may also be seen at higher temperatures. As shown in Fig. 6, QMC predicts slightly lower critical temperatures for s = 1/2 and s = 1 than for higher spin simulations, an effect which is not captured by SMC. For these lower quantum numbers, the locally allowed quantizations are limited and higher in energy, leaving room for lower energy, longer range excitations to play a role in the disordering transition, slightly reducing TC from the classical values. Single-site quantization also appears to inadequately predict MSRO, as seen in Fig. 4, with the implication that quantum MSRO originates from quantization states involving multiple spins.

We hope that this work will motivate further study and development of semiclassical sampling methods, including resolutions of these issues. One apparent next step would be the simultaneous quantization of multiple neighboring spins, analogous to cluster flipping algorithms employed in CMC simulations36. When permuting multiple spins, new states could be drawn from the separable component of the local exact solution, which could be easily precomputed for small clusters. While extracting product states from these solutions may be nontrivial, their inclusion could allow lower energy excitations that improve simulation accuracy at low temperatures and promote high-temperature MSRO.

Opportunities for improvement notwithstanding, the simplest form of locally quantized SMC appears to provide a physics-based, parameter-free method for calculating magnetic contributions to thermodynamic properties that is at least as accurate as current methods with increased convenience and generality.

## Methods

Simulations of Fe (Figs. 2 and 5) used ten values of Jij from ref. 2 for atomic separations up to and including $${{{{\bf{r}}}}}_{ij}=\left[\frac{3}{2}\frac{3}{2}\frac{3}{2}\right]$$, which is associated with an energy several times larger than that of any longer range interaction. The selected Jij predict a TC close to the experimental value, although, given the limitations of the Heisenberg model24, inaccuracy of the local density approximation used in parameterization37, and neglect of temperature scaling and phonon coupling38,39—among other factors—the degree of accuracy presumably involves some cancellation of errors. After an equivalent period of equilibration, 105 MC passes were performed for 2.5  105 atoms over 1250 temperatures. For Fig. 5, similar simulations were performed at intervals of 5 K.

Simulations for Figs. 3, 4 and 6 considered 512 spins to match the QMC of ref. 3; 5  106 MC passes were performed at 256 temperatures. Calculations of susceptibility in RbMnF3 for Fig. 7 involved 106 passes for 1.25  105 magnetic sites.

In the case of Bk = 0, the local Hamiltonian of Eq. (5) imposes no specific quantization, so trial Sk should be oriented randomly. While irrelevant for most simulations, this procedure ensures that $$s=\frac{1}{2}$$ SMC trajectories with initially collinear spins are not restricted to the original quantization axis (i.e., an Ising model), as would otherwise occur. In practice, these calculations were initialized with randomly oriented spins to avoid any such issues.

Simulations were implemented in Julia40 and plot data from refs. 3,30,35 were reproduced using WebPlotDigitizer41.