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
See also
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
|
add a new minimum to database |
|
Add transition state object |
|
add multiple properties from a dictionary |
|
add a system property to the database |
|
|
|
return the minimum with a given id |
|
return the TransitionState between two minima |
return the transition state with id |
|
return all transition states connected to a minimum |
|
return the minimum with the lowest energy |
|
|
return the minimum with a given name |
|
merge two minima in the database |
|
return an iterator over all minima in database |
|
wrapper class to add minima |
return the number of minima in the database |
|
return the number of transition states in the database |
|
|
|
|
remove a minimum from the database |
|
remove a transition states from the database |
|
return an iterator over all transition states in database |
Attributes