|
The
Molecular Mechanics class
(MolMech)
is the parent class of the Molecular
Dynamics
(Motors),
Energy
Minimization
(Minimizers)
and Monte
Carlo
(MonteCarlo)
classes.
The
MolMech
class is defined in the
MolMech
module in Yup.Models. Since the subclass modules
are in the same sub-directory of the Yup package,
only a local import is necessary:
from
MolMech import
MolMech.
If a subclass is outside the package hierarchy then
a full import path is required:
from
Yup.Methods.MolMech import
MolMech.
Data
Attributes
Data
attribute names are case-sensitive. Most of the
data attributes can be assigned new values.
However, read-only attributes must not be assigned
new values. If you do, the classes will not work.
However, it is easy to recover from this stupidity:
simply delete the added attribute.
Note
that each molecular mechanics class inherits the data attributes from
this class. Therefore, you have to set these attributes independently
for each descendant class. For example, you can set NumberOfPrintDivisions to 25 in the Motors class for molecular dynamics, and 10 in the Minimizers
class for energy minimization. If you want to set the same value (that
is not the default) in both classes, you will have to set the attribute
separately in each class.
|
Attribute
|
Description
|
|
MODEL
|
This
attribute is read-only. Returns the Model
object registered when the class was
instanced.
|
|
ArchiveInterval
|
Interval
between periodic archives. The default
value is 0 which means no periodic
archive. Even if set greater than zero,
archiving is done only if the appropriate
file names (the
CoordinateArchive
and Motors.VelocityArchive
attributes) are not at their default
values of blank strings.
|
|
CoordinateArchive
|
Name
of archive into which the Coordinates will
be written at intervals defined in the
ArchiveInterval
attribute. The default value is a blank
string which means that this archive is
not created.
|
|
ColumnWidth
|
The
width of each column in the printout
generated by the molecular mechanic
methods. The preset value is 11, where 10
columns are used to print the number and
the last column is reserved for a space.
This is wide enough to print numbers to
only four places of significance in
scientific format (allowing room for the
signs). If set below 8, number fields are
was wide as necessary and are separated by
tabs. The columns of numbers will no
longer line up for most tab settings but
the output is suitable for input to
databases or spreadsheets.
|
|
NumberOfPrintDivisions
|
This
is one less than the number of energy
output lines from the molecular mechanic
methods. The preset value is 5, i.e.,
there will be 6 lines of output. The
starting values (the zeroth step) and the
final values (which may be short of the
total number of steps requested by the
user, e.g., if an energy minimization is
terminated prematurely) are always
printed.
If set to zero, the calculation will be
carried out without any print out except
for exceptions and error messages.
If set to a negative integer, the absolute
number will be taken as the print
interval. Thus, to print every step of a
calculation set this attribute to
-1.
|
|
UpdateInterval
|
The
number of steps between updates of the
non-bond lists. The preset value is 100.
The non-bond list update creates a list of
atom pairs whose atoms are within a
certain distance of one another. This
distance is somewhat larger than a cutoff
distance which is the distance at which
the magnitude of the non-bond interaction
is considered to be insignificant. In
between updates, some atom pairs in the
list may move further apart from one
another and should really be taken off the
list. At the same time, atom pairs that
are not in the list may move close enough
that they should really be considered for
calculation. This attribute must be set so
that the non-bond lists are accurate and
this also depends on the distance settings
in the non-bond energy modules.
|
| UserAfterInterval |
If set above 0, this is the interval between calls to the userafter() method (see below). Preset value is 0. |
| UserBeforeInterval |
If set above 0, this is the interval between calls to the userbefore() method (see below). Preset value is 0. |
Methods
The
MolMech
class defines only the constructor function and four
methods.
The constructor function requires one argument, the
model on which the molecular mechanics method is to
be applied. This is a Model
object that is constructed by a force
field assembler.
|
Constructor
|
Number
of Arguments
|
Return
Value
|
|
MolMech
|
1
|
The
new MolMech object
|
|
Argument
|
Purpose
|
Preset
Value
|
|
a
Model object
|
the
model that is to be subjected to the
molecular mechanics
calculation
|
-
|
The
model object must be complete, i.e., the
Map,
Energy
and Coordinates
attributes must all be defined.
The Prologue
method is called to prepare for a
calculation.
|
Method
|
Argument
Keywords
|
Return
Values
|
|
Prologue
|
"numsteps",
"limit"
|
Tuple
of 4 items
|
|
Argument
|
Type
|
Preset
Value
|
|
numsteps
|
Integer
|
-
|
|
limit
|
None, a group AtomMap or a list of two integers
|
-
|
Molecular
mechanic calculations can be restricted to a
portion of a model. Please see the Targeted Simulation section of the Introduction to see how to set this argument. However, the
energy is always evaluated for the entire model
regardless of this setting.
This
method will set the column width attribute in the
Potential
module to the same value as set in the
ColumnWidth
attribute of this class.
The
returned tuple contains four items. (1) the
coordinate AtomVector of the group specified in
limit
or of the entire model if
limit
is None, (2) the corresponding gradient AtomVector,
(3) the evaluate()
method of the Model object that is registered with
this class and (4) the numbers of steps between
printing, calculated from the values specified in
numsteps
and the NumberOfPrintDivisions
attribute.
The Preface
method is called to prepare for a Monte Carlo
calculation.
|
Method
|
Argument
Keywords
|
Return
Values
|
|
Preface
|
"numsteps"
|
Tuple
of 5 items
|
|
Argument
|
Type
|
Preset
Value
|
|
numsteps
|
Integer
|
-
|
This
method will set the column width attribute in the
Potential
module to the same value as set in the
ColumnWidth
attribute of this class.
The
returned tuple contains five items. (1) the
mcprep()
method, (2) the mcmove()
method, (3) the mcpass()
method, (4) the mceval()
method, all four methods are of the Model object
that is registered with this class and (5) the
numbers of steps between printing, calculated from
the values specified in
numsteps
and the NumberOfPrintDivisions
attribute.
The following two methods provide a limited opportunity to customize the molecular mechanics calculations.
The userafter method is called every so many steps as defined in the UserAfterInterval attribute immediately after the steps that update the coordinates. The userbefore method is called every so many steps as defined in the UserBeforeInterval attribute immediately before the steps that update the coordinates.
These
methods are parameter-less (except for self). Note that these methods must be replaced with your own
definitions. The methods that are provided in the MolMech
class will only raise a Runtime exception.
To use this facility: define a class based on the appropriate molecular mechanics class: Motors, Minimizers or Casino. Override the userafter and/or userbefore methods,
i.e. by defining these methods in your derived class. For your class,
use your initialization function to cache whatever objects that your
update methods need. You will have to examine the code for the parent module to see what other (undocumented) attributes and methods that are accessible to
you. Once you have a definition, you can create an instance of your
class. Then, set values for the UserAfterInterval and/or UserBeforeInterval attributes. You still have the attributes of the parent class that you have to set and methods that you can call. An example can be found in the Calculate
module of the rrDNAv1
model.
Functions
The
AVLimits function takes a list of AtomVectors, impose the specified limits and returns a list of restricted AtomVectors.
|
Method
|
Number of Arguments
|
Return
Values
|
|
AVLimits
|
2
|
Tuple of restricted AtomVector
|
|
Argument
|
Type
|
Preset
Value
|
|
AV
|
list of AtomVector
|
-
|
| limit |
None, AtomMap or list of two Integers |
- |
Please see the Targeted Simulation section of the Introduction to see how to set limit.
|