schrodinger.application.matsci.montecarlo module¶
Classes related to Monte Carlo simulations
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.matsci.montecarlo.
ClashChecker
(basename='cell', backend=None, logger=None, color=None, vdw_scale=1.0)¶ Bases:
schrodinger.application.matsci.amorphous.BuilderWithClashDetection
A builder used just for checking for clashes during Monte Carlo simulations
-
checkForRings
(struct)¶ Check for rings in struct and cache them
Parameters: struct ( schrodinger.structure.Structure
) – The structure to check for rings
-
findRings
(struct)¶ Return the cache of found rings - struct is not used because the structure may change coordinates but never bonding during an MC run. It is kept for API compatibility with the parent class.
Parameters: struct – unused Return type: list Returns: The list of found rings
-
-
class
schrodinger.application.matsci.montecarlo.
Metropolizer
(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, cleanup=True)¶ Bases:
object
A class that runs a Monte Carlo simulation using the Metropolis algorithm
-
ROTATE
= 0¶
-
TRANSLATE
= 1¶
-
findFirstDisorderedMolecule
()¶ Find the first molecule number that isn’t part of the scaffold
Return type: int Returns: The first non-scaffold molecule number
-
getClashPenalty
(candidate)¶ Get the energy penalty due to clashes
Parameters: candidate ( schrodinger.structure.Structure
) – The structure to check for clashesReturn type: float Returns: The penalty based on the number of clashes
-
getClosestApproach
(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()Return type: float Returns: The closest approach between coords and the scaffold, or the gravity center if no scaffold was used.
-
getEnergy
(candidate, target=None)¶ Compute the total energy of the system
Parameters: - candidate (
schrodinger.structure.Structure
) – The entire cell containing all molecules - target (
MonteCarloMolecule
) – The MCM object for the just-moved molecule (None if this is the 0th iteration
Return type: (float, float, float, float)
Returns: The total energy, forcefield energy, gravitational energy and clash energy (total energy is the sum of the last three)
- candidate (
-
getGravityEnergy
(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: target ( MonteCarloMolecule
) – A molecule that has been randomly movedReturn type: float Returns: The gravitational energy of the target’s new position
-
getNumClashes
(struct)¶ Get the number of clashes for the proposed structure
Parameters: struct ( schrodinger.structure.Structure
) – The structure to check for clashesReturn type: int Returns: The total number of clashes found
-
getTargetMolecule
(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
Return type: Returns: The MCM object for the chosen molecule
- candidate (
-
isAccepted
(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
Return type: bool
Returns: Whether the move is accepted or not
-
log
(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
-
performMovement
(target)¶ Move the molecule randomly
Parameters: target ( MonteCarloMolecule
) – The MCM object to moveReturn type: int Returns: A class constant indicating whether the move was ROTATE or TRANSLATE
-
setupGravity
()¶ Pre-compute data for the gravity term
-
simulate
()¶ Run the Monte Carlo simulated annealing
-
-
class
schrodinger.application.matsci.montecarlo.
MonteCarloMolecule
(cell, molnum, box)¶ Bases:
object
Class for treatment of a moving molecule during a Monte Carlo iteration
-
getCoordinates
()¶ Get the xyz coordinate for this molecule
Return type: numpy.array
Returns: The xyz coordinates of this molecule
-
randomlyRotate
(max_degrees)¶ Randomly rotate the molecule by no more than the given number of degrees
Parameters: max_degrees (float) – The largest rotation allowed
-
randomlyTranslate
(mu_sigma)¶ Randomly translate the molecule. The distribution of translation distances is given by a lognormal distribution.
Parameters: mu_sigma ((float, float)) – (mu, sigma). mu gives the mean value of the lognormal distribution the translation is taken from. sigma gives the standard deviation of the distribution
-
updateCoordinates
()¶ Update the coordinates of this molecule within the entire cell
-