pele.storage.Database#

class pele.storage.Database(db=':memory:', accuracy=0.001, connect_string='sqlite:///%s', compareMinima=None, createdb=True)[source]#

Database storage class

The Database class handles the connection to the database. It has functions to create new Minima and TransitionState objects. The objects are persistent in the database and exist as soon as the Database class in connected to the database. If any value in the objects is changed, the changes are automatically persistent in the database (TODO: be careful, check commit transactions, …)

Database uses SQLAlchemy to connect to the database. Check the web page for available connectors. Unless you know better, the standard sqlite should be used. The database can be generated in memory (default) or written to a file if db is specified when creating the class.

Parameters:
dbstring, optional

filename of new or existing database to connect to. default creates new database in memory.

accuracyfloat, optional

energy tolerance to count minima as equal

connect_stringstring, optional

connection string, default is sqlite database

compareMinimacallable, bool = compareMinima(min1, min2), optional

called to determine if two minima are identical. Only called if the energies are within accuracy of each other.

createdbboolean, optional

create database if not exists, default is true

Attributes:
enginesqlalchemy database engine
sessionsqlalchemy session
accuracyfloat
on_minimum_removedsignal

called when a minimum is removed from the database

on_minimum_addedsignal

called when a new, unique, minimum is added to the database

on_ts_removedsignal

called when a transition_state is removed from the database

on_ts_addedsignal

called when a new, unique, transition state is added to the database

compareMinima

Examples

>>> from pele.storage import Database
>>> db = Database(db="test.db")
>>> for energy in np.random.random(10):
>>>     a.addMinimum(energy, np.random.random(10))
>>>
>>> for minimum in database.minima():
>>>     print minimum.energy

Methods

addMinimum(E, coords[, commit, ...])

add a new minimum to database

addTransitionState(energy, coords, min1, min2)

Add transition state object

add_properties(properties[, overwrite])

add multiple properties from a dictionary

add_property(name, value[, dtype, commit, ...])

add a system property to the database

findMinimum(E, coords)

getMinimum(mid)

return the minimum with a given id

getTransitionState(min1, min2)

return the TransitionState between two minima

getTransitionStateFromID(id_)

return the transition state with id id_

getTransitionStatesMinimum(min1)

return all transition states connected to a minimum

get_lowest_energy_minimum()

return the minimum with the lowest energy

get_property(property_name)

return the minimum with a given name

mergeMinima(min1, min2)

merge two minima in the database

minima([order_energy])

return an iterator over all minima in database

minimum_adder([Ecut, max_n_minima, ...])

wrapper class to add minima

number_of_minima()

return the number of minima in the database

number_of_transition_states()

return the number of transition states in the database

properties([as_dict])

removeMinimum(m[, commit])

remove a minimum from the database

remove_transition_state(ts[, commit])

remove a transition states from the database

transition_states([order_energy])

return an iterator over all transition states in database

Attributes