- Home
- Library
- Lattice and Hamiltonian Field Theory
- A Scalar Field on a Lattice
- A First Scalar-Field Simulation
A First Scalar-Field Simulation
How much does a field at one site tell us about the field at its neighbor? In a free theory we can invert a matrix to answer this question. Adding a quartic interaction makes that inverse insufficient, but the finite Euclidean integral is still well defined. We will sample it with local field updates, first recover the free answer, and then measure how the interaction changes the correlation.
The complete example runs on an periodic lattice. It includes the update, measurements, starting-state comparison and statistical error analysis. Its output is a calculation at one finite regulator; obtaining continuum physics requires the separate spacing and volume limits.
Preparation: The dimensionless scalar lattice action and the meaning of a covariance matrix. The sampling probability and error estimate are developed below.
The finite integral to be sampled
Let label sites in two Euclidean dimensions, with indices understood modulo eight. There are real integration variables . This counts sites, whereas the physical Euclidean volume is . Use
Here is the dimensionless bare mass coefficient and in two dimensions. We compare and , keeping every other parameter fixed. Neither nor the quartic coefficient is an extracted physical mass or coupling.
The probability density and observable mean are
Both selected actions are strictly confining at large field and have finite . We need ratios of weights, so we never evaluate to update the configuration. The two Euclidean directions have equal spacing and identical periodic boundaries. A simulation sweep is an algorithmic time step, unrelated to either coordinate or to Lorentzian time evolution.
Change one field, then decide whether to keep it
Hold the neighbors of site fixed. Write its old value as , propose with uniform on , and define the neighbor sum
Every incident kinetic bond contributes to the action difference. Collecting their quadratic and linear terms gives
Thus an update needs four neighbors, not a reevaluation of the full action. The companion checks this local expression against the full action difference for independently chosen test configurations and moves; the largest discrepancy in the recorded run is .
The proposal is symmetric: the probability density of proposing from equals that of proposing from . Accept with probability
To see why this works, multiply the forward proposal and acceptance by the old weight. The accepted probability flux is proportional to
which is unchanged on exchanging the configurations. This is detailed balance for this single-site update. Rejection leaves the old configuration in the sequence. Counting it again is necessary for the intended probability measure; deleting rejections biases the average. The original construction and this rejection issue are explained in Metropolis et al., §II, pp. 1088–1089.
In code, use log(u) < -delta_action for a uniform instead of forming a potentially overflowing exponential. With , the local calculation is:
delta = proposal - old
delta_action = (
(4 + mass_squared) * (old * delta + delta**2 / 2)
- neighbor_sum * delta
+ coupling * (proposal**4 - old**4) / 24
)
if np.log(rng.random()) < -delta_action:
field[t, x] = proposal
# Otherwise the old value remains. The sweep still advances.
A sweep updates every site once. The executable groups sites by the parity of : all even sites, then all odd sites. On this even periodic lattice, sites of one parity have no nearest-neighbor bonds among themselves, so their conditional updates can be evaluated in parallel. After accepting even-site moves, recompute neighbors for the odd sites. Each half-sweep preserves the target; their ordered composition therefore preserves it, although the complete sweep need not itself obey detailed balance. This particular shortcut would fail without modification on an odd periodic extent or with interactions coupling sites within one parity.
Repeated finite steps can reach arbitrary open regions of the field space, and rejections prevent compulsory alternation. These facts do not provide a useful numerical bound on equilibration time. A large acceptance fraction is also insufficient: proposals with an extremely small almost always succeed while exploring very slowly.
What to measure
After each complete sweep, store the action per site, the mean field, and the translation- and direction-averaged two-point estimator
The exact field mean vanishes by symmetry. We use the un-subtracted two-point estimator because that mean is known, rather than subtracting a noisy sample mean squared. This averages two axes; it does not sum an entire spatial slice to project onto zero momentum. Consequently its decay generally contains more than one transfer energy even for the free theory. Fitting a single exponential at every separation would impose the wrong model, and periodic images matter near .
At , the action is with
The exact covariance is . Equivalently, discrete Fourier modes give
The directional average has the same expectation by square-lattice symmetry. Direct matrix inversion and the Fourier covariance agree within in the companion. These are finite-lattice targets, including their periodic images; comparing with an infinite-volume continuum propagator instead would incorrectly blame legitimate regulator effects on the sampler.
There is another useful exact check even with the quartic term. Integration by parts over a single real field gives
The boundary term vanishes because of the positive quadratic or quartic large-field behavior. Sum over sites and split into its homogeneous quadratic and quartic pieces. Euler's identity yields
Only the free theory therefore has . The program separately measures , called the Ward observable in its output, whose target is one in both cases. This check tests a relation among sampled moments, not the complete distribution.
Equilibrate and estimate correlated errors
The retained experiment uses seed 20261025 with NumPy's PCG64 generator and two SeedSequence children, one per action. Disjoint random draws drive 32 replicas of each action. Sixteen begin with every field zero; sixteen begin with every field . Each discards 2,048 sweeps, then retains all 16,384 subsequent measurements. The proposal half-width stays at throughout; no adaptation or seed selection is performed.
Dispersed starts test whether a plausible-looking short history still remembers its initialization. For the free action, the first 64-sweep average of is about from the zero starts and from the starts. Over the last 512 discarded sweeps the corresponding averages are and . In the retained data, the largest difference between starting groups among the measured observables is combined replica standard errors for the free theory and for the interacting theory. The comparison supports the burn-in choice for these runs. Wolff, §1 explains how to check equilibration before applying stationary error formulas.
Successive measurements share fields and are correlated. For one stationary observable history , expanding the variance of its average gives
Dropping all terms with is the independent-sample approximation; it is unjustified merely because the program uses fresh random numbers for proposals. We instead group consecutive measurements into blocks. Let be block 's mean in replica , let be the number of blocks per replica, and let be that replica's overall mean. For independent replicas of equal length, the blocked standard-error estimate is
This treats different blocks within a replica as approximately independent. Increase their length until the estimate stabilizes while keeping enough blocks. Blocks never cross replica boundaries. The binning derivation and its residual finite-block bias are discussed in Wolff, Appendix B, pp. 15–16; the more detailed autocorrelation article explains alternatives and slow-mode failures.
For the free , block lengths 1, 4, 16, 64 and 256 sweeps give standard errors , , , and . Treating every configuration as independent would underestimate the error by almost a factor of three. The interacting sequence gives , , , and . We quote the 256-sweep estimate, with 64 blocks per replica.
The spread of the 32 complete replica means is a separate error estimate. For it gives and for the free and interacting cases. That finite-replica estimate is itself noisy; its difference from the blocked estimate is a reason to retain both diagnostics, not to report more digits of precision. The code also compares 1,024-, 4,096- and 8,192-sweep prefixes with the full run. For example, the free changes from at 4,096 sweeps to at 16,384, using replica errors for that comparison. The roughly halved error is consistent with inverse-square-root statistical scaling over those lengths. Prefixes are nested, so these two estimates are correlated.
Results at one fixed lattice spacing and volume
The results below use the full histories and 256-sweep blocked errors. All quantities are dimensionless, and uncertainties are estimated standard errors rather than rigorous bounds.
| Observable | Exact free target | Sampled free | Sampled |
|---|---|---|---|
| Ward observable |
The largest free discrepancy relative to a quoted blocked error is about ; a correct noisy run need not place every exact answer inside a one-standard-error interval. The fixed four-standard-error diagnostics in the code use replica errors and all pass, but they remain probabilistic checks and the observables are correlated. The acceptance fractions are and . Their closeness says little about the size of the physical interaction effect.
The positive quartic term suppresses large field fluctuations, and the measured correlations decrease at every plotted separation. The plot shows the finite-lattice Gaussian prediction and the measured change; the gentle flattening near half the periodic extent is part of this geometry.
Axis-averaged on the periodic lattice at . Circles and squares are Monte Carlo means for and ; bars are 256-sweep blocked standard errors, sometimes smaller than the symbols. The black line joins the exact free values as a guide. The vertical axis is logarithmic; symbols are displaced slightly horizontally for visibility. No continuum or infinite-volume extrapolation is included.
From the repository root, reproduce the calculation with Python 3 and NumPy:
python3 examples/lattice-hamiltonian/lattice-fields/simulate.py
The program writes simulation-results.json beside its source, including parameters, exact targets, block errors, starting-group checks and prefixes. plot_simulation.py additionally requires Matplotlib and regenerates the figure from that result. The retained run used Python 3.9.6 and NumPy 2.0.2. The scientific implementation is new; the source and selected output stay with the example so that changing the model requires an explicit new calculation.
To turn propagation into an energy, first choose the spatial projection and the finite-time model. The finite-time spectral trace explains the backward term. The continuum mass calculation uses the same free action with spatial momentum zero at several spacings. The single interacting ensemble here measures a different correlator at one spacing.
Summary
A finite scalar simulation starts with a specified integration measure and action. A local Metropolis step samples that measure without knowing its normalization; a complete sweep and its rejected moves must be recorded consistently. Matrix inversion checks the free observable, integration by parts tests an interacting moment relation, and dispersed starts plus blocking expose different sources of error. These checks make a small finite-lattice result interpretable before addressing physical extrapolation or faster algorithms.
Exercises
An action difference at one site
With , , old field zero and four zero neighbors, propose . Find the action change and acceptance probability. Identify separately the kinetic, mass and quartic contributions.
Solution
The four incident bonds each acquire , so the kinetic contribution is . The mass term contributes and the quartic term contributes . Therefore , and the acceptance probability is . Counting only the two outgoing bonds would miss half the kinetic change: the two incoming bonds also contain the changed site.
Why simultaneous updates need a condition
Two neighboring sites have old values and proposed increments . Compare the exact change of their bond action with the sum of two local changes computed using the old neighbors. Explain the implication for a parallel update of all sites.
Solution
The exact change is
The sum of local changes with frozen old neighbors omits . Independent acceptance decisions based on those stale neighbors therefore do not generally preserve the intended coupled distribution. A single collective Metropolis proposal could use the full action change, or a sequential sweep could use already updated values. Our checkerboard implementation avoids the cross term because no bond joins two sites updated in the same half-sweep. Recompute the neighbors before the next parity.
References
- Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953), “Equation of state calculations by fast computing machines,” The Journal of Chemical Physics 21, 1087–1092, doi:10.1063/1.1699114. The proposal, acceptance and retained-rejection discussion is in §II, pp. 1088–1089; institutional PDF copy.
- Wolff, U., ALPHA Collaboration (2004), “Monte Carlo errors with less errors,” Computer Physics Communications 156, 143–153; erratum 176 (2007), 383, doi:10.1016/S0010-4655(03)00467-3, arXiv:hep-lat/0306017v4, PDF. We use §1's equilibration distinction and Appendix B's blocking analysis, not the paper's automatic autocorrelation-window implementation.
Scrollable formula. Use Left and Right arrow keys to reveal hidden content.
Scrollable table. Use Left and Right arrow keys to reveal hidden columns.
Scrollable figure. Use Left and Right arrow keys to reveal hidden content.