2024/12/26
Molecular Monte Carlo Simulation
    What is Molecular Monte Carlo
    Simulation?
   We already learned how random numbers could be used to
    solve problems such as difficult multiple integrals. This
    relatively straight-forward problem solving strategy is only
    one aspect of Monte Carlo. More generally, Monte Carlo can
    be used to simulate natural processes that are intractable by
    conventional means.
   All natural phenomena, such as the boiling point of a fluid,
    the viscosity or hardness of a material etc, are caused by
    interatomic interactions. Monte Carlo can be used to simulate
    these interactions.
   In some disciplines, the word ‘simulate’ is synonymous with
    ‘crude approximation.’ A ‘simulated’ solution is obtained
    because the exact solution is intractable.
                                                                            1
                                                                  2024/12/26
     Generalized MMC Algorithm
    At the outset it is useful to have a generalized framework
     for the MMC algorithm. MMC simulation works by
     generating transitions between different states. This
     involves :
      – (a) generating a random trial configuration;
      – (b) evaluating an ‘acceptance criterion’ by calculating
         the change in energy and other properties in the trial
         configuration; and
      – (c) comparing the acceptance criterion to a random
         number and either accepting or rejecting the trial
         configuration
     Generalized MMC Algorithm
     (contd)
A general MMC Algorithm is illustrated below:
Part 1 Create an initial configuration (config).
Part 2 Generate a Markov Chain for Ncycles:
loop i  1 ... NCycles
   Create a new configuration (configTrial).
   Find the transition probability w(config, configTrial).
   Generate a uniform random number (R) between 0 and 1.
   if (w > R) then
        Accept move (config = configTrial).
   else
        Reject move (config is unaltered).
   end if
end loop
                                                                          2
                                                                      2024/12/26
    Generalized MMC Algorithm
    (contd)
   After an initial configuration is generated (Part 1), the
    algorithm works (Part 2) by repeatedly either accepting or
    rejecting new configurations. The algorithm introduces the
    concept of a ‘Markov chain.’
   It is important to realize that not all states will make a
    significant contribution to the configurational properties of
    the system. We must confine our attention to those states
    that make the most significant contributions in order to
    accurately determine the properties of the system in a
    finite time. This is achieved via a Markov chain which is a
    sequence of trails for which the outcome of successive
    trails depend only on the immediate predecessor.
   In a Markov chain, a new state will only be accepted if it is
    more ‘favorable than the existing state.
    Generalized MMC Algorithm
    (contd)
    In the NVT-ensemble, the only MC move is atom
    displacement, only consider the configurational or potential
    energy of state.
   It is important to realize that, in contrast to molecular
    dynamics, the kinetic energy has no role to play in an MMC
    simulation. The acceptance criterion only involves
    ‘configurational’ properties. Therefore, we are only interested
    in calculating the potential energy of the system.
                                                                              3
                                                                        2024/12/26
    Metropolis Sampling
   The limitations of random sampling can be avoided by
    generating configurations that make a large contribution to
    the thermodynamic average. This is the philosophy behind
    Metropolis sampling.
   Metropolis sampling biases the generation of configurations
    towards those that make the most significant contribution to
    the integral.
   It generates states with a probability of exp[−b (     )] and
    counts each of them equally.
   In contrast, simple Monte Carlo integration generates states
    with equal probability assigning them a weight of
    exp[− b ( )].
    Metropolis Sampling (contd)
       Metropolis sampling generates a Markov chain which
        satisfies the conditions that:
         (a) the outcome of each trial depends only on the
            proceeding trail; and
         (b) each trail belongs to a finite set of possible outcomes.
    The former condition highlights the distinction between
      Monte Carlo and molecular dynamics simulation methods.
      In a molecular dynamics simulation, all the states are
      connected in time.
                                                                                4
                                                                       2024/12/26
    Metropolis Sampling (contd)
                   ( ) = exp(−D ( ) /     ) … … (∗)
   The Metropolis scheme is implemented by attempting a
    trial displacement and calculating the change in energy .
    If D < 0, then (∗) > 1 and the move is accepted.
    Otherwise, if D > 0, (∗) < 1 and the move is accepted
    with a probability of (∗) = exp(−bD ). A random number
    R is generated and the move is accepted if exp −bD ³ .
    Metropolis Sampling (contd)
       Typically, this procedure is summarized by defining the
        probability of acceptance as:
                         = min[1 , exp(−b D ) ]
       It should be noted that the above equation only
        represents the acceptance criteria resulting from
        molecular displacement. A different criterion is required as
        a result of either volume change or a change in a number
        of particles.
       Lets now revisit the NVT-ensemble algorithm in greater
        detail because ALL other ensemble algorithms follow its
        basic approach.
                                                                               5
                                                                   2024/12/26
Detailed NVT-Ensemble
Algorithm
Part 1 loop cycle  1 ... maxCycle
Part 2 Attempt trial displacements:
loop atom  1 ... maxAtom
Part 2.1 Generate a trial displacement:
    rxTrial  pbc(rxatom + (2 * rand() - 1) * dMax)
    ryTrial  pbc(ryatom + (2 * rand() - 1) * dMax)
    rzTrial  pbc(rzatom + (2 * rand() - 1) * dMax)
Part 2.2 Calculate change in energy:
    Calculate energy of the atom (ETrial) at trial position.
    DE  ETrial - Eatom
Detailed NVT-Ensemble
Algorithm
Part 2.3 Apply Metropolis acceptance criterion:
if (D < 0 or exp(−b D )³       ())
        rxatom  rxTrial                           //accept move
        ryatom  ryTrial
        rzatom rzTrial
        Eatom ETrial
        E E + DE
        numAccept  numAccept + 1
end if
end atom loop
                                                                           6
                                                                       2024/12/26
     Detailed NVT-Ensemble
     Algorithm
     Part 2.4 Update periodically the maximum displacement:
     if (mod(cycle, updateCycle) = 0)
         acceptRatio  numAccept/(cycle * atomMax)
     if (acceptRatio > 0.5)
          dMax  1.05 * dMax
     else
          dMax  0.95 * dMax
     end if
     end if
     end cycle loop
     Detailed NVT-Ensemble
     Algorithm (contd)
   Typically, a Monte Carlo simulation is performed in cycles
    (Part 1). During each cycle, a displacement is attempted for
    every atom (Part 2). The atom to be displaced can be chosen
    randomly or alternatively, each atom can be considered in
    turn as illustrated above. It is also possible to displace every
    atom and apply the acceptance criterion to the combined
    move.
   New trial coordinates (Part 2.1) are obtained randomly up to
    a maximum value of dMax. This involves generating random
    numbers on the interval from 0 to 1 and applying periodic
    boundary conditions (pbc).
   The change in energy resulting from the trial displacement
    (Part 2.2) is simply the energy experienced by the atom at
    the trial position (Etrial) minus the energy of the atom at its
    existing position (Eatom).
                                                                               7
                                                                          2024/12/26
         Detailed NVT-Ensemble
         Algorithm (contd)
       This change in energy is evaluated and the Metropolis
        acceptance (Algorithm Part 2.3) rule is applied. If the move is
        accepted, the atom’s coordinates, the atom’s energy and the
        total energy (E) are updated.
       The maximum allowed displacement (dMax) affects the
        acceptance rate. Experience indicates that an acceptance rate
        of approximately 50% is often desirable for a Monte Carlo
        simulation.
       A small value of dMax will generally improve the acceptance
        rate but the phase space may be sampled too slowly.
        Conversely, increasing the value of dMax will reduce the
        acceptance rate. It is common to adjust the value of dMax
        during the course of the simulation to maintain a 50%
        acceptance rate.
         Detailed NVT-Ensemble
         Algorithm (contd)
        In part 2.4, the value of dMax is adjusted at intervals
         specified by updateCycle. If acceptRatio > 0.5, the value
         of dMax is increased, whereas it is decreased if
         acceptRatio < 0.5.
        It should be noted that there is no theoretical basis for
         using an acceptance rate of 50% and in some cases it
         may be actually detrimental to efficient sampling.
                                                                                  8
                                                                   2024/12/26
    Averages & Error Estimates
   The averages of a Monte Carlo simulation are only
    accumulated after an equilibration period. The number of
    cycles required for equilibrium is not known exactly
    beforehand and it should ideally be probed by test runs.
   Alternatively, it is common to discard a large number of
    early runs to be on the safe side. For example, if the
    simulation runs for 20000 cycles, the first 10000 are
    discarded and averages are only accumulated for cycles
    10001 to 20000.
   The average quoted is always the average of the entire
    postequilibration period.
    Averages and Errors (contd)
   It is always important to provide an error estimate of a
    simulation quantity. The error represents the deviation
    from the average value over the post-equilibrium cycles. If
    the error estimate is large it may indicate that equilibrium
    has not been reached or that the simulation is unreliable
    for some reason. The reasons for large errors include both
    errors in the code or an actual physical limitation.
   There are alternative ways of estimating errors. Some
    simulators average over independent runs commencing
    from different initial configurations. However, more
    commonly errors are estimated from a single run by
    dividing the post-equilibrium run into several blocks
                                                                           9
                                                                2024/12/26
 Averages and Errors (contd)
    The average of a property            is determined from:
                                 1
                     =
                             −           −1
    The post-equilibrium run is divided into blocks of
     length such that       = . The mean value of is
     calculated for each block
                                     1
                                 =
    The standard deviation is then determined by
     averaging over all of the blocks:
 Averages and Errors (contd)
                         1
                 =                   −
This standard deviation that is commonly quoted as the
  error associated with a simulation quantity.
 It should be noted, that some authors quote the
  uncertainty as:
which will always be much less than the standard
  deviation.
 Therefore, some caution is required when comparing
  error estimates from different workers.
                                                                       10