pele.systems.basesystem#

class pele.systems.basesystem.BaseParameters[source]

Source

class BaseParameters(dict):

define a dictionary who’s values can be accessed like attributes

if params is a BaseParameters object then this command:

base_params["key"] = value

is the same as:

base_params.key = value

This only works for keys that are strings

class pele.systems.basesystem.Parameters[source]

Source

class Parameters(BaseParameters):

Define the parameter tree for use with BaseSystem class

pele.systems.basesystem.dict_copy_update()[source]

Source

def dict_copy_update(dict1, dict2):

return a new dictionary from the union of dict1 and dict2.

If there are conflicts, take the value in dict2

class pele.systems.basesystem.BaseSystem[source]

Source

class BaseSystem:

The base class for a System object

Notes

The following functions need to be overloaded for running the given routines

Global Optimization:

  1. get_potential : required

  2. get_takestep : optional

  3. get_random_configuration : optional

  4. get_compare_exact : optional

Connecting Minima and Transition State Searches:

  1. get_potential : required

  2. get_mindist : required

  3. get_orthogonalize_to_zero_eigenvectors : required

  4. get_compare_exact : optional, recommended

thermodynamics:

  1. get_metric_tensor

GUI:

  1. all of the above functions are required, plus

  2. draw : required

  3. smooth_path : required

  4. load_coords_pymol : recommended

additionally, it’s a very good idea to specify the accuracy in the database using self.params.database.accuracy

See the method documentation for more information and relevant links

BaseSystem.__call__()[source]

Source

def __call__(self):

calling a system returns itself

this exists solely for the gui. this should be rewritten

BaseSystem.get_potential()[source]

Source

def get_potential(self):

return the potential object

See also

pele.potentials
BaseSystem.get_random_configuration()[source]

Source

def get_random_configuration(self):

return starting point for basinhopping, etc.

Returns:
coordsarray
BaseSystem.get_random_minimized_configuration()[source]

Source

def get_random_minimized_configuration(self, **kwargs):

return a random configuration that is already minimized

Returns:
resultan optimizer Results object

See also

pele.optimize
BaseSystem.get_minimizer()[source]

Source

def get_minimizer(self, **kwargs):

return a function to minimize the structure

Notes The function should be one of the optimizers in pele.optimize, or have similar structure.

See also

pele.optimize
BaseSystem.get_compare_exact()[source]

Source

def get_compare_exact(self):

object that returns True if two structures are identical.

true_false = compare_exact(coords1, coords2)

See also

pele.mindist
BaseSystem.get_compare_minima()[source]

Source

def get_compare_minima(self):

a wrapper for compare exact so in input can be in Minimum Form

BaseSystem.get_system_properties()[source]

Source

def get_system_properties(self):

return a dictionary of system specific properties.

Notes

These will be stored automatically in the database. The keys must be strings.

BaseSystem.create_database()[source]

Source

def create_database(self, *args, **kwargs):

return a new database object

See also

pele.storage
BaseSystem.get_takestep()[source]

Source

def get_takestep(self, **kwargs):

return the takestep object for use in basinhopping, etc.

See also

pele.takestep

Notes

default is random displacement with adaptive step size and adaptive temperature

BaseSystem.get_basinhopping()[source]

Source

def get_basinhopping(
    self,
    database=None,
    takestep=None,
    coords=None,
    add_minimum=None,
    max_n_minima=None,
    **kwargs
):

construct a basinhopping object with takestep and accept step already implemented

Parameters:
databaseobject

Use this object to store the minima. If None, use self.create_database()

takestepobject

Use this takestep routine. If None, use self.get_takestep()

coords1-d numpy array

The starting point for the basinhopping run. If None, use self.get_random_configuration()

add_minimiumcallable

Call this function each time a minimum is found. This is used instead of the database.

max_n_minimaint

Only keep this number of minima in the database. The minima with the lowest energy are kept. This is ignored if add_minimum is passed

kwargskey word arguments

Extra key word arguments are passed to BasinHopping.

BaseSystem.get_mindist()[source]

Source

def get_mindist(self):

return a function that structurally aligns two configurations

Returns:
mindistcallable object with the form::

dist, X1new, X2new = mindist(X1, X2)

See also

pele.mindist

Notes

The mindist object returns returns the best alignment between two configurations, taking into account all global symmetries. X2new might be different from X2, but X1new should be the same as X1.

If you have a simple system with cartesian distances and no symmetries, you can simply return:

return lambda x1, x2: np.linalg.norm(x1-x2), x1, x2
BaseSystem.get_orthogonalize_to_zero_eigenvectors()[source]

Source

def get_orthogonalize_to_zero_eigenvectors(self):

return None or a function which makes a vector orthogonal to the known zero eigenvectors

Returns:
orthogoptNone, or a function with the form::

vec_new = orthogVec(vec, coords)

Notes

zero eigenvectors are those which have zero eigenvalues

BaseSystem.get_double_ended_connect()[source]

Source

def get_double_ended_connect(self, min1, min2, database, **kwargs):

return a DoubleEndedConnect object

See also

pele.landscape
BaseSystem.get_pgorder()[source]

Source

def get_pgorder(self, coords):

return the point group order of the configuration

Returns:
pgorderint

See also

pele.mindist

Notes

This is a measure of the symmetry of a configuration. It is used in calculating the thermodynamic weight of a minimum. Most configurations will have pgorder 1, but some highly symmetric minima will have higher orders. Routines to compute the point group order are in module mindist. If your system has not symmetries you can just return 1.

BaseSystem.get_metric_tensor()[source]

Source

def get_metric_tensor(self, coords):

return (mass-weighted) metric tensor for given coordinates

Returns:
metric_tensorNone or 2d array

Notes

The metric tensor is needed for normal mode analysis. In the simplest case it is just the identity. For atomic systems (cartesian coordinates) with masses different to 1.0, the metric tensor is a diagonal matrix with 1/m_i on the diagonal. For curvilinear coordinates like angle axis coordinates it is more complicated. Returning None implies that the metric tensor is the identity.

BaseSystem.get_nzero_modes()[source]

Source

def get_nzero_modes(self):

return the number of vibration modes with zero frequency

Returns:
nzero_modesint

Notes

Zero modes can come from a number of different sources. You will have one zero mode for every symmetry in the Hamiltonian. e.g. 3 zero modes for translational invariance and 3 zero modes for rotational invariance. If you have extra degrees of freedom, from say frozen particles they will contribute zero modes.

Harmonic modes are necessary to calculate the free energy of a minimum in the harmonic approximation. The density of states is inversly proportional to the product of the frequencies. If the zero modes are not accounted for correctly then the product will be trivially zero and the free energy will be completely wrong.

BaseSystem.get_ndof()[source]

Source

def get_ndof(self):

return the number of degrees of freedom

Returns:
ndofint

See also

get_nzero_modes

Notes

This is the true number of degrees of freedom. It is probably the length of the coordinates array minus the number of zero modes

BaseSystem.get_normalmodes()[source]

Source

def get_normalmodes(self, coords):

return the squared normal mode frequencies and eigenvectors

Returns:
freqsarray

array of normal mode frequencies

vecs2d array

array of normal mode vectors. vecs[:,i] is the vector for the the i’th frequency

Notes

This is usually used to compute the log product of the normal mode frequencies which is used to determine the free energy of a minimum in the harmonic superposition approximation.

BaseSystem.get_log_product_normalmode_freq()[source]

Source

def get_log_product_normalmode_freq(self, coords, nnegative=0):

return the log product of the squared normal mode frequencies

Parameters:
coordsarray
nnegativeint, optional

number of expected negative eigenvalues

Returns:
lprodfloat

Notes

This is necessary to calculate the free energy contribution of a minimum

BaseSystem.draw()[source]

Source

def draw(self, coords, index):

tell the gui how to represent your system using openGL objects

Parameters:
coordsarray
indexint

we can have more than one molecule on the screen at one time. index tells which one to draw. They are viewed at the same time, so they should be visually distinct, e.g. different colors. accepted values are 1 or 2

BaseSystem.smooth_path()[source]

Source

def smooth_path(self, images, **kwargs):

return a smoothed path between two configurations.

used for movies

BaseSystem.createNEB()[source]

Source

def createNEB(self, coords1, coords2, **kwargs):

return an NEB object to find a minimum energy path from coords1 to coords2

BaseSystem.load_coords_pymol()[source]

Source

def load_coords_pymol(self, coordslist, oname, index=1):

load the coords into pymol

the new object must be named oname so we can manipulate it later

Parameters:
coordslistlist of arrays
onamestr

the new pymol object must be named oname so it can be manipulated later

indexint

we can have more than one molecule on the screen at one time. index tells which one to draw. They are viewed at the same time, so they should be visually distinct, e.g. different colors. accepted values are 1 or 2

Notes

the implementation here is a bit hacky. we create a temporary xyz file from coords and load the molecule in pymol from this file.