Chapter 4 Hard sphere phase switch Monte Carlo
4.4 Implementation for hard spheres
4.4.3 Synchronisation
Our implementation of phase switch Monte Carlo does not include the system de- pendent mapping that Bruce et al. [17] utilise, since our implementation is to con- currently run the two phases with the same Monte Carlo moves applied. Due to the finite nature of computational storage, there will always be rounding errors accumu- lating, and these errors will cause our two systems to diverge. In order to counteract this divergence we periodically recalculate the change that has occurred due to the Monte Carlo moves in the active system and synchronise the other system to this value. These rounding errors will be discussed later in this section.
In order to do this we must have a way of calculating the sum of all Monte Carlo moves that have been applied to a system. Our implementation for this is to use the initial, also referred to as reference, configuration and the current configu- ration and calculate the changes between them. When calculating the changes we need to be aware of what degrees of freedom we have in the system and what the Monte Carlo moves change.
In a constant volume simulation, our only Monte Carlo moves are transla- tions. This gives us a very simple calculation in order to ensure the two simulations are synchronised. We need only compare the cartesian displacement vector between the initial and final states. We calculate this displacement vectorRfor each particle i
Rα,i=rα,i−rrefα,i (4.27) whererα are the coordinates for particle iin phase α andrref
α,i denote the reference coordinates for the same particle. This can be seen to be equivalent to the alternate definition of the particle positions as
r=R+u, (4.28)
where r are the current coordinates of the particles, and u are the lattice vectors for the phase, when in our case we use an arbitrary rrefα,i configuration from the
equilibrium distribution as a reference.
The procedure for the synchronisation of the two systems is to calculate the displacement vector for each particle for the phase that is currently active and then apply those displacement vectors to the reference configuration of the passive phase. This newly calculated configuration is then set as the new configuration of the passive system. The order parameter must then be recalculated and the weighting function updated.
When simulating at constant pressure we have to include volume moves as well. Therefore we need to calculate the difference in volume between the active and passive systems and set the passive accordingly.
Since we are only accounting for a small build up of errors with synchroni- sation process, we need only apply it to the system infrequently. In all simulations the synchronisation of the two systems only occurs every 1000-10,000 Monte Carlo cycles.
Floating point numbers
Floating point is a method to represent an approximation of real numbers on a computer using a fixed, discrete amount of memory that covers a wide range of values; 64 bits is the amount for double precision. In general numbers are represented approximately to a fixed number of significant digits (the mantissa), and this can then be scaled using an exponent. The base used for scaling is usually base 2, so a typical number is represented as
signif icant digits×baseexponent. (4.29)
This allows the resolution to be adapted to the numbers, and no space is wasted on unnecessary zeros. A wide range of numbers can be stored, however, there is a trade off between range and scale implicit in this definition. This is where thermodynamic integration can have problems if the two absolute free energies are much larger than the difference, as this means the difference will only be accurate to a few digits.
The most common representation is the IEEE Standard for Floating-Point Arithmetic (IEEE 754) which is a technical standard for floating-point computation established in 1985 by the Institute of Electrical and Electronics Engineers.
Since we are trying to fit infinite numbers into a finite space, the values must be rounded to fit the finite representation. There is obviously an error associated with this necessary rounding, and it also implies that what may be an exact calcu- lation for the full numbers will be a rounded calculation for the approximate values.
This can be seen most easily for a decimal number, 0.1, that has a finite represen- tation in decimal and yet an infinite representation in binary. Therefore, when one adds two of these numbers together rounding errors will occur in the calculation.
Due to the finite nature of computers and the infinite nature of real numbers we must be aware of the possibility of rounding errors and approximations when doing arithmetic on data many times. These errors are only of the order of the significant digits of the computer, however when doing billions of operations they add up.