StructureDB

struct StructureDB

Container for a collection of Structure(s).

Usage example:

# Default constructor creates an empty StructureDB object.
StructureDB stdb;
# Add structures from the file "db.dat"
stdb.add("db.dat");
Usage example:
# Load all structure files listed in a Config file
Config config("config");
StructureDB stdb(config);
Usage example:
# Print this object summary using streams:
std::cout << stdb;

# Print 3rd Atom data from the 1st Structure
std::cout << stdb(0,2);

See also

Structure NNFinder

Public Functions

StructureDB()

Create an empty StructureDB object.

StructureDB(const Config &config)

Create this object and load structures listed in the config file

Note

Required Config key: DBFILE

void add(const Config &config)

Add structures listed in the config file

Note

Required Config key: DBFILE

void add(const std::string fn)

Add all structures from a file

void add(const Structure &s)

Add a single Structure object to this container

void remove(size_t i)

remove i-th Structure object from this container

size_t size() const
Returns:

number of structures held by this object

size_t size(size_t n) const

n={0,…,number of DBFILEs-1}

Returns:

number of structures in the n-th DBFILE

Structure &operator()(size_t s)

Usage example:

# Get reference to the 2nd structure held be this object
# and bind it to Structure st.
Structure &st = st(1);

Returns:

reference to the s-th structure

Atom &operator()(size_t s, size_t a)

Usage example:

# Get reference to the 5th atom in the 3rd structure
# held by this object and bind it to the atom object.
Atom &atom = st(2,4);

Returns:

reference to the a-th atom in the s-th structure

size_t calc_natoms() const

Calculate total number of atoms stored by this object

size_t calc_natoms(size_t n) const

Calculate total number of atoms in the n-th DBFILE.

n={0,…,number of DBFILEs-1}

std::unordered_set<Element> get_unique_elements()

Return unique elements for all Structures

Public Members

std::vector<size_t> dbidx

Store indices for each dataset.

e.g. if 3 datasets of sizes 11,13,15 dbidx=={0,11,24,39}

Friends

inline friend std::ostream &operator<<(std::ostream &os, const StructureDB &stdb)

Print this object summary to the stream