
Condensed Matter Physics, 2022, Vol. 25, No. 3, 33201: 1–18
DOI: 10.5488/CMP.25.33201
http://www.icmp.lviv.ua/journal
On the algorithm to perform Monte Carlo simulations
in cells with constant volume and variable shape
A. Baumketner ∗
Institute for Condensed Matter Physics of the National Academy of Sciences of Ukraine, 1 Svientsitskii Str.,
79011, Lviv, Ukraine
Received May 02, 2022, in final form May 02, 2022
In simulations of crystals, unlike liquids or gases, it may happen that the properties of the studied system depend
not only on the volume of the simulation cell but also on its shape. For such cases it is desirable to change
the shape of the box on the fly in the course of the simulation as it may not be known ahead of time which
geometry fits the studied system best. In this work we derive an algorithm for this task based on the condition
that the distribution of specific geometrical parameter observed in simulations at a constant volume matches
that observed in the constant-pressure ensemble. The proposed algorithm is tested for the system of hard-
core ellipses which makes lattices of different types depending on the asphericity parameter of the particle.
It is shown that the performance of the algorithm critically depends on the range of the sampled geometrical
parameter. If the range is narrow, the impact of the sampling method is minimal. If the range is large, inadequate
sampling can lead to significant distortions of the relevant distribution functions and, as a consequence, errors
in the estimates of free energy.
Key words: hard-ellipse fluid, Monte Carlo simulation, constant volume, varying shape, umbrella sampling
1. Introduction
Today computer simulations play a key role in fundamental research across multiple disciplines,
including physics, chemistry and materials science [1]. A large share of computational studies employ
simulation boxes with fixed volume. This choice is mainly motivated by convenience as constant-
volume/constant-temperature ensemble is easier to program than the equivalent ensemble with constant
pressure. But this is also due to the involvement of the constant-volume ensemble in other, specialized
simulation techniques such as free energy calculations [2], Gibbs ensemble [3] or replica-exchange
method [4–6]. Regardless of the particular context, it is always understood that the effect of volume
vanishes in the thermodynamic limit where the results are thought to be independent of the employed
ensemble. This claim is certainly true for liquids or gases, whose properties are independent of the
geometry of the box.
In the case of crystals, however, the situation could be quite different [7, 8]. In crystalline materials
there could be properties that depend explicitly on the volume as well as on the shape of the box. Take
for instance the example of a rectangular lattice with lattice constants 𝑎and 𝑏, as shown in figure 1. The
dimensions of the box that accommodates 𝑛columns and 𝑚rows are 𝐿𝑥=𝑎𝑛 along 𝑥axis and 𝐿𝑦=𝑏𝑚
along 𝑦axis as shown in figure 1 (a). The corresponding aspect ratio is 𝜏=𝐿𝑥/𝐿𝑦=𝑎𝑛/𝑏𝑚. Now, let
us assume that the lattice constants are not known ahead of time but are meant to be determined in the
course of the simulations. If we initially choose a box with the wrong aspect ratio, 𝜏0> 𝜏 for instance,
see figure 1 (b) for appropriate illustration, the lattice constant determined in simulations will also be
incorrect. Since the geometry of the cell drives the structure of the lattice, wrong geometry translates
into wrong structure. Importantly, lattice distortions will not go away easily even when the size of the
simulation box is increased.
∗Corresponding author: andrij@icmp.lviv.ua.
This work is licensed under a Creative Commons Attribution 4.0 International License. Further distribution
of this work must maintain attribution to the author(s) and the published article’s title, journal citation, and DOI.
33201-1
arXiv:2210.00485v1 [physics.comp-ph] 2 Oct 2022