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 :

db : string, optional

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

accuracy : float, optional

energy tolerance to count minima as equal

connect_string : string, optional

connection string, default is sqlite database

compareMinima : callable, bool = compareMinima(min1, min2), optional

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

createdb : boolean, optional

create database if not exists, default is true

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

Attributes

engine (sqlalchemy database engine)
session (sqlalchemy session)
accuracy (float)
on_minimum_removed (signal) called when a minimum is removed from the database
on_minimum_added (signal) called when a new, unique, minimum is added to the database
on_ts_removed (signal) called when a transition_state is removed from the database
on_ts_added (signal) called when a new, unique, transition state is added to the database
compareMinima  

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

Previous topic

pele.storage.TransitionState.id

Next topic

pele.storage.Database.addMinimum