• No results found

Chapter 2 Computational methods

2.1 Monte Carlo method

The simulation of the Stockmayer fluid uses the Monte Carlo method, which makes use of a random number generator to carry out the random movement of particles within the simulation cell. How the Monte Carlo routine works is briefly described. The system begins with a set of coordinates and dipoles orientations, which are stored in memory. The energy of the system in its initial state is calculated and designated Uold. The coordinates and dipoles are both then randomly moved and rotated

respectively and the energy of the system is calculated, designated Unew. If the energy

of the new configuration is more favourable than the old configuration, the move is accepted and the procedure is repeated this time with the new accepted coordinates and dipoles. This means Uoldis equal to Unewbefore the subsequent move of particles.

However if the move is not accepted because the new configuration is less favourable in energy than the old configuration, then the Boltzmann factor, P, is calculated (Equation 4). This is then compared to a random number, distributed 0-1. If the P value is greater than the random number the move is accepted. However, if the P value is less than the random number, the move is rejected and the loop begins again with the original coordinates and dipoles168. The Monte Carlo method is summarized in Figure 30.          T b k ΔU - exp

P where; ΔUUnew Uold

Equation 4 - The Boltzmann factor calculation. The equation above shows the

Boltzmann factor is dependent on both the temperature and energy difference. When the energy difference ΔU is small or the temperature is high this produces values of P approaching 1, which increase the probability of higher energy configurations being accepted.

Figure 30 - The description of how the Monte Carlo method works. The figure shows

the basic components of the Monte Carlo method. The system starts with an initial configuration with energy Uold, a new configuration is calculated with energy Unew.

The blue arrows indicate successfully accepted new configurations, whilst the red arrows indicate the rejected configurations.

The Monte Carlo method works by using a random number generator, distributed between 0-1, to carry out the movement of particles. The particles are displaced relative to their previous positions, with the direction of the displacement being dependent on the random number generated for the x, y or z displacement of the particles. For example, if a particle has the initial coordinates X1,Y1,Z1 the random

number generator works to produce a new set of coordinates X2,Y2, Z2 based on the

initial position of the particle (Figure 31). It should be noted that because the random number generator produces numbers between 0 to 1 so that it would not be able to move a particle in the negative direction as such by subtracting 0.5 from the random generated number a uniform distribution occurs between -0.5 and +0.5 and so it is possible to move a particle in any direction.

Initial coordinates

Energy calculated for initial configuration = Uold Random movement of a particle Random reorientation of dipole

If Unew< Uoldmove is accepted

If Unew> Uold then calculate

P = exp(-ΔU/KbT)

If P < random number move is not accepted If P > random number

move is accepted Initial dipoles

Energy calculated for new configuration

= Unew

Original coordinates and dipole orientations

X2= X1+ ((random number - 0.5) x maximum displacement)

Y2= Y1+ ((random number - 0.5) x maximum displacement)

Z2= Z1+ ((random number - 0.5) x maximum displacement)

Figure 31 - The movement of particles in the Monte Carlo method simulations. The

figure shows how new configurations, X2 Y2 Z2, are generated by use of a random

number (between 0 & 1). The size of the displacement from the original coordinates, X1Y1Z1, is controlled by the variable maximum displacement.

The maximum displacement possible at any given point in the simulation differs as the maximum displacement is a variable that changes according to the set acceptance ratio, typically between 0.2 or 0.5, of the simulation. The dynamic acceptance ratio, the ratio between the number of accepted moves over the number of steps, of the simulation is calculated throughout the simulation run. This is then compared periodically to the set acceptance ratio; if the dynamic acceptance ratio is higher than the set acceptance ratio then the maximum displacement increases. The larger displacements are usually energetically unfavourable so the number of accepted moves should decrease and as such the dynamic acceptance ratio will be lowered. Conversely if the dynamic acceptance ratio is lower than the set acceptance ratio then the maximum displacement decreases to increase the number of accepted moves and hence increase the dynamic acceptance ratio. The result of this action is to cause different size of movements through out the simulation run; for example the movement in a single plane of a particle through the simulation run is shown in Figure 32. The dashed squares indicate the possible area where the particle could move, the different sizes of the squares represent the different adjustments made to the maximum displacement in order to adhere to the set acceptance ratio. It should also be noted that the three dimensional movement of particles is cubic. The volume

X1Y1Z1

that it is possible for the particle to move from its initial position is equal to the max displacement value cubed (Figure 33).

Figure 32 - The variation of the maximum displacement throughout the simulation.

The figure illustrates how the maximum displacement varies for a single particle in order for the simulation to adhere to set acceptance ratio. The larger squares indicate a higher max displacement and the different colour of the squares indicate individual moves.

Figure 33 - The three dimensional movement of a particle in the simulation box. The

figure above shows the effect of increasing the maximum displacement leads to probable larger sized moves, which in tern leads to a lower dynamic acceptance ratio in the simulation. The situation is reversed when the maximum displacement decreases.

Increasing maximum displacement value (decreasing dynamic acceptance ratio)

Related documents