Move Class¶
-
class
move_class.
CBMCRegrowth
(simulation, anchortype, numtrials=5, parallel=False)[source]¶ A class that encapsulates a Configurationally Biased Regrowth move as outline by Siepmann et al. that inherits from the Move class. Here the dihedral force fields of the simulation are also passed in to ais in choosing trial positions.
- Parameters
dihedral_ffs (list of type DihedralForceField) – A list of DihedralForceField objects associated with the simulation
lmp (lammps object) – The lammps instance associated with the simulation. Passed in so that the move can evaluate energies of moves and thereby calculate probabilities of acceptance.
molecules (list of type Molecule) – A list of molecules that are available to apply a MC move to.
numtrials (int) – The number of trial placements used at each step of the regrowth move. Default is 5 trials.
anchortype (int) – The type number in the LAMMPS file used for the atom type used for the anchor atom in each molecule.
-
evaluate_energies
(molecule, index, rotations)[source]¶ Evluates the pair energy of the system for each of the given dihedral rotations at the specified index. For these enegies to be consistent with CBMC all atoms past the index should be turned off with turn_off_molecule_atoms.
- Parameters
molecule (Molecule) – The molecule on which the dihedral rotations will be carried out
index (int) – The index of the atom that is in the last position of the dihedral to be rotated.
rotations (list of floats) – A list of floats which represent the desired rotation from the current dihedral angle in Radians.
- Returns
energies – An array of the pair energy for each of the specified rotations.
- Return type
Numpy array of floats
-
parallel_evaluate_energies
(molecule, index, rotations)[source]¶ Evaluates the pair potential energy of numtrials number of rotations about a the dihedral at the given molecule index and returns the result.
- Parameters
molecule (Molecule) – The molecule that is currently being regrown
index (int) – The index of the monomer in the molecular chain that is being rotated.
rotations (float) – The degree of rotation of the dihedral in radians needed to reach each sample point for evaluation
- Returns
energies – A list of the pair potential energy for each rotation.
- Return type
float list
-
select_dih_angles
(dih_type)[source]¶ Returns numtrials number of dihedral angles with probability given by the PDF given by the boltzmann distribution determined by the temperature and the dihedral forcefield.
- Parameters
dih_type (int) – An integer which corresponds to the type of Dihedral one wishes to samples.
- Returns
trial_dih_angles – An array of floats which correspond to the selected dihedral angles in radians.
- Return type
Numpy array of floats
-
select_index
(molecule)[source]¶ Selects a random index of a molecule ranging from 3 to the final index. The index selection starts at 3 as no dihedral rotation does not move any atoms with index less than 3.
- Parameters
molecule (Molecule) – The Molecule objectone wishes to select a ranomd index from.
- Returns
index – A random index from 3 to length of molecule.
- Return type
int
-
select_random_molecule
()[source]¶ Selects a random elegible molecule (one with an anchor atom set) from the molecules provided by the Simulation object that the CBMCRegrowth object was passed in at initialization.
- Returns
Random Elegible Molecule – A randomly chosen molecule from the list of elegible ones.
- Return type
-
class
move_class.
CBMCSwap
(simulation, anchortype, type_lengths, starting_index=3, numtrials=5, parallel=False)[source]¶ -
align_mol_to_positions
(mol, positions)[source]¶ swap_atom1_positions = np.copy(np.array([mol1.getAtomByMolIndex(i).position for i in range(0,index+1)])) swap_atom2_positions = np.copy(np.array([mol2.getAtomByMolIndex(i).position for i in range(0,index+1)])) anchor_distance = np.copy(mol1.getAtomByMolIndex(0).position - mol2.getAtomByMolIndex(0).position)
- for i in range(index+1):
move1 = swap_atom2_positions[i]-mol1.getAtomByMolIndex(i).position move2 = swap_atom1_positions[i]-mol2.getAtomByMolIndex(i).position mol1.move_atoms_by_index(move1,i) mol2.move_atoms_by_index(move2,i)
-
select_random_molecules
()[source]¶ Selects a random elegible molecule (one with an anchor atom set) from the molecules provided by the Simulation object that the CBMCRegrowth object was passed in at initialization.
- Returns
Random Elegible Molecule – A randomly chosen molecule from the list of elegible ones.
- Return type
-
-
class
move_class.
Move
(simulation)[source]¶ A class used to encapsulate all MC moves that can be used by a simulation.
- Parameters
lmp (lammps object) – The lammps instance associated with the simulation. Passed in so that the move can evaluate energies of moves and thereby calculate probabilities of acceptance.
molecules (list of type Molecule) – A list of molecules that are available to apply a MC move to.
temp (float) – The temperature of the simulation in Kelvin.
-
class
move_class.
TranslationMove
(simulation, max_disp, stationary_types)[source]¶ -
select_random_molecule
()[source]¶ Selects a random elegible molecule (one with no atoms of the type specified by stationary_types) from the molecules provided by the Simulation object that the CBMCRegrowth object was passed in at initialization.
- Returns
Random Elegible Molecule – A randomly chosen molecule from the list of elegible ones.
- Return type
-