|
All
Energy classes provide four methods that are to be
used for Monte Carlo calculations. These are
summarized in the following table:
|
Method
|
Functions
|
|
mcprep()
|
Usable
in three ways:
[0] prepare the object for Monte
Carlo calculations
[1] initialize the object for
Monte Carlo calculation
[2] (optional) remove all Monte
Carlo data structures
|
|
mcmove()
|
returns
the change in energy for the given move
unit
|
|
mcpass()
|
accepts
the previous move
|
|
mceval()
|
returns
the total energy
|
These
methods have to be called in the proper order. The
method mcprep()
has to be called at least twice before the other
methods can be used. After that,
mcmove()
has to be called before
mcpass(),
and mceval()
is usually called only at the end of a Monte Carlo
sweep and only to acquire the value of the total
energy (e.g. for printing). These methods perform
very little data checking and will not fail
gracefully.
The
user of these methods is responsible for the
following: [1] dividing the molecular
system into move units; each unit consists of one
or more atoms that are numbered consecutively; the
move unit may overlap; the make up of all units
must be provided at setup; [2] moving a
unit but the conformation of the unit must not be
changed; these methods will only report the effects
of the move and [3] making a decision
whether to accept a trial move; rejected moves need
not be reported but accepted moves must be
registered and recorded.
These
methods are also available for the Model class. The
methods in the Model object simply call the
corresponding methods in all the Energy classes
that had been registered with the Model. Normally,
one would apply the methods for the entire Model
instead of to individual Energy classes. In the
following, X is either a Model object or an
individual Energy object.
The
mcprep()
method
|
Method
Name
|
Number
of Arguments
|
Return
Value
|
|
mcprep
|
1
|
None
|
|
Argument
|
Value
|
Preset
Value
|
|
optional
|
tuple
of pairs of atom
numbers
|
-
|
This
method is used in three distinct ways at different
stages of a Monte Carlo calculation.
[0]
Setting up for Monte Carlo
calculations
The
Monte Carlo method must be set up by calling the
mcprep()
method with a nonzero length tuple in the argument.
This tuple must contain tuples, each of which
contains two atom numbers, the start and the end of
a range. The range defines consecutively numbered
atoms that are to be moved as a group, i.e., the
conformation of the group will not be
distorted.
Preparation
for Monte Carlo calculations consists of creating a
directory of the interactions and an energy table.
The directory lists, for each move unit, the
interactions that have to be calculated. When a
unit is moved, interactions that are entirely
within the unit do not change because the
conformation of the unit has not changed.
Interactions that are outside the unit do not
change because only the unit has been moved. It is
only interactions that cross the boundary between
the move unit and everything else that would
change; these are listed in the directory for a
given move unit. The energy table is used to store
the value of each interaction. Note that at this
stage, space is allocated for the energy table, but
the interactions have not been computed.
For
example:
X.mcprep(
( ( 13, 25 ), ( 4, 4 ), ( 0, 5 ) ) )
prepares
for a Monte Carlo calculation involving three move
units: the first is a group of atoms from 13 to 25
(inclusive), the second is a single atom and the
third is a group of atoms from numbers 0 to 5. The
third move unit overlaps with the second, which is
acceptable with some types of Monte Carlo moves but
not others. A counter example is:
X.mcprep(
( ( 45, 39 ), ) )
which
is an attempt to define a single move unit. Note
the dangling comma, which is required. However, the
unit definition will be rejected because the second
atom number is not larger than the
first.
Whenever
a nonbond list is updated, the directory and the
energy table are recreated as well.
[1]
Initialization for Monte Carlo
When
this method is called with an empty argument
list:
X.mcprep(
)
all
the interactions are calculated and their values
are saved in the energy table. This is a necessary
step at the start of each Monte Carlo
calculation.
[2]
When Monte Carlo is no longer needed
When
this method is called with an empty
tuple:
X.mcprep(
( ) )
all
the additional data structures that had been
created for Monte Carlo calculations, the
directory, energy and other tables, are freed.
Further attempts at Monte Carlo calculations will
fail. It is not necessary to apply this step. One
can interleave Monte Carlo calculations with other
types of calculation and if the data structures are
preserved, it is not necessary to set up the
calculation at each switch. However, if Monte Carlo
calculations are no longer used, and the data
structures are preserved, the Monte Carlo directory
of interactions will be recreated whenever nonbond
lists are updated; this can be time
consuming.
The
mcmove()
method
|
Method
Name
|
Number
of Arguments
|
Return
Value
|
|
mcmove
|
1
|
floating
point
|
|
Argument
|
Value
|
Preset
Value
|
|
required
|
integer
|
-
|
The
argument must contain an integer, the move unit.
Move units are numbered starting from zero. It is
assumed that the move unit has been transformed
elsewhere and that the original coordinates can be
recovered. (This method does not actually move a
unit, it only calculates the change caused by the
move of the unit.) For the given move unit, the
directory is used to look up the interactions that
has to be calculated. These are calculated and new
values are saved in another table while the old
values are available from the energy table. The two
sets of values are added up and the energy
difference (New minus Old) is returned in internal
units of energy (CEU).
In
the first example, where three move units were
defined, mcmove()
can be called in only three possible
ways:
X.mcmove(
0 )
X.mcmove(
1 )
X.mcmove( 2 )
Normally,
the move units are selected at random.
The
caller will use the return value (the energy
change) to decide whether to accept or reject the
move. For example, the Metropolis criterion is
widely used. It is the responsibility of the caller
to restore the original coordinates if the trial
move of a unit is rejected. However, if a move is
accepted, the next method must be
called.
The
mcpass()
method
|
Method
Name
|
Number
of Arguments
|
Return
Value
|
|
mcpass
|
0
|
None
|
This
method can be called in only one way:
X.mcpass(
)
i.e.,
with an empty argument list. This method updates
the energy table. The interactions that were
calculated and whose values were saved in the
temporary table are copied back to the energy
table.
The
mceval()
method
|
Method
Name
|
Number
of Arguments
|
Return
Value
|
|
mceval
|
0
|
floating
point
|
The
values in the energy table are added up and the
total is returned in internal units of energy
(CEU).
Effects
of calls to other Energy methods
When
the X.compile()
method is called, the data structures created for
Monte Carlo calculations are destroyed. This is
necessary because the force field would have
changed and the information necessary to reindex
the interactions for Monte Carlo are not available.
Monte Carlo must be set up anew after each call to
compile().
Nonbond
lists are updated periodically (using
X.update())
during any calculation. Whenever this happens, the
Monte Carlo indices are also recreated and the
energy tables are refilled. If the additional
computations are of concern, try to increase the
interval between updates. It would be necessary to
compensate by increasing the cutoff distance (for
consideration of a nonbond interaction). This will
result in more memory use and some increase in the
time spent in computing the nonbond interactions.
If Monte Carlo calculations are no longer
contemplated, the data structures can be released
(using X.mcprep(()))
and there will be no further reindexing attempts.
It is also no longer possible to use the Monte
Carlo method.
|