Package schrodinger :: Package application :: Package matsci :: Module montecarlo :: Class Metropolizer
[hide private]
[frames] | no frames]

Class Metropolizer

object --+
         |
        Metropolizer

A class that runs a Monte Carlo simulation using the Metropolis algorithm

Instance Methods [hide private]
 
__init__(self, scaffold, cell=None, weight_rotate=0.5, weight_translate=0.5, translate_mu=0.25, translate_sigma=1.0, max_rotate=360.0, temperatures=[300.0], iterations=10000, clash_penalty=50.0, minimize_interval=None, forcefield=14, vdw_scale=1.0, gravity=True, gravity_weight=4.0, logger=None)
Create a Metropolizer object
 
setupGravity(self)
Pre-compute data for the gravity term
int
getNumClashes(self, struct)
Get the number of clashes for the proposed structure
float
getClosestApproach(self, coords)
Get the closest approach between the given set of coordinates and the scaffold molecule or gravity center if no scaffold.
float
getGravityEnergy(self, target)
Evaluate the gravitational energy of the given target.
float
getClashPenalty(self, candidate)
Get the energy penalty due to clashes
 
simulate(self)
Run the Monte Carlo simulated annealing
MonteCarloMolecule
getTargetMolecule(self, candidate, first, last)
Select the molecule to move this iteration
int
findFirstDisorderedMolecule(self)
Find the first molecule number that isn't part of the scaffold
(float, float, float, float)
getEnergy(self, candidate, target=None)
Compute the total energy of the system
bool
isAccepted(self, old_energy, new_energy)
Use the Metropolis equation to determine if the move is accepted
int
performMovement(self, target)
Move the molecule randomly
 
log(self, msg, level=20)
Add a message to the log file

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  ROTATE = 0
hash(x)
  TRANSLATE = 1
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, scaffold, cell=None, weight_rotate=0.5, weight_translate=0.5, translate_mu=0.25, translate_sigma=1.0, max_rotate=360.0, temperatures=[300.0], iterations=10000, clash_penalty=50.0, minimize_interval=None, forcefield=14, vdw_scale=1.0, gravity=True, gravity_weight=4.0, logger=None)
(Constructor)

 

Create a Metropolizer object

Parameters:
  • scaffold (amorphous.Scaffold) - The scaffold object that controls the cell structure
  • cell (schrodinger.structure.Structure) - The structure containing the molecules to move via Monte Carlo
  • weight_rotate (float) - The weight of rotation when randomly choosing to rotate or translate
  • weight_translate (float) - The weight of translations when randomly choosing to rotate or translate
  • translate_mu (float) - The mean of the natural logarithm function for the log-normal distribution of translation distances.
  • translate_sigma (float) - The standard deviation of the natural logarithm function for the log-normal distribution of translation distances.
  • max_rotate (float) - The maximum number of degrees for any rotation
  • temperatures (list of float) - A list of temperatures to run the annealing at
  • iterations (int) - The number of Monte Carlo iterations to run at each temperature
  • clash_penalty (float) - Penalty for clashes
  • minimize_interval (int) - Do a minimization after every Xth interval. Not implemented at this time.
  • forcefield (int or None) - The mmffld number of the forcefield to use for energy evaluations. Use None to turn off forcefield energy evaluations.
  • vdw_scale (float) - The VdW scale factor to use for clash checking
  • gravity (bool) - Whether to use the gravity term. Gravity attracts all molecules toward the scaffold if a scaffold molecule is present, or the center of the cell if no scaffold is present. If no forcefield term is included, then a simple hard shell model is used to prevent clashes caused by gravity.
  • logger (logging.Logger) - The logger for this class
Overrides: object.__init__

getNumClashes(self, struct)

 

Get the number of clashes for the proposed structure

Parameters:
Returns: int
The total number of clashes found

getClosestApproach(self, coords)

 

Get the closest approach between the given set of coordinates and the scaffold molecule or gravity center if no scaffold.

Parameters:
  • coords (numpy.array) - The XYZ coordinates to check for close approach to the scaffold - such as from the getXYZ()
Returns: float
The closest approach between coords and the scaffold, or the gravity center if no scaffold was used.

getGravityEnergy(self, target)

 

Evaluate the gravitational energy of the given target. The energy is simply the difference of the original distance between the target and the gravitational source and the new distance between them.

Parameters:
Returns: float
The gravitational energy of the target's new position

getClashPenalty(self, candidate)

 

Get the energy penalty due to clashes

Parameters:
Returns: float
The penalty based on the number of clashes

getTargetMolecule(self, candidate, first, last)

 

Select the molecule to move this iteration

Parameters:
  • candidate (schrodinger.structure.Structure) - The entire cell containing all molecules
  • first (int) - The first valid molecule number to pick
  • last (int) - The last valid molecule number to pick
Returns: MonteCarloMolecule
The MCM object for the chosen molecule

findFirstDisorderedMolecule(self)

 

Find the first molecule number that isn't part of the scaffold

Returns: int
The first non-scaffold molecule number

getEnergy(self, candidate, target=None)

 

Compute the total energy of the system

Parameters:
Returns: (float, float, float, float)
The total energy, forcefield energy, gravitational energy and clash energy (total energy is the sum of the last three)

isAccepted(self, old_energy, new_energy)

 

Use the Metropolis equation to determine if the move is accepted

Parameters:
  • old_energy (float) - The previous energy
  • new_energy (float) - The new energy
Returns: bool
Whether the move is accepted or not

performMovement(self, target)

 

Move the molecule randomly

Parameters:
Returns: int
A class constant indicating whether the move was ROTATE or TRANSLATE

log(self, msg, level=20)

 

Add a message to the log file

Parameters:
  • msg (str) - The message to add
  • level (int) - A logging priority level of the message