StructureDB
-
struct StructureDB
Container for a collection of Structure(s).
Usage example:
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 Context file Context context("context"); StructureDB stdb(context);
# Print this object summary using streams: std::cout << stdb; # Print 3rd Atom data from the 1st Structure std::cout << stdb(0,2);
Public Functions
-
StructureDB()
Create an empty StructureDB object.
-
StructureDB(const tadah::core::Context &context)
Create this object and load structures listed in the context file
Note
Required Context key: DBFILE
-
void add(const tadah::core::Context &context)
Add structures listed in the context file
\note Required Context key: \ref DBFILE
-
void add(const std::string fn)
Add all structures from a file
-
int add(const std::string fn, size_t first, int N = 1)
Add N structures from a file begining from first index.
Indexing starts from zero, i.e. first=0 corresponds to the first structure in the file.
In the case of N greater than the number of available structures, this method will load only the available ones.
Return the number of loaded structures.
-
void add(const StructureDB &stdb)
Add all structure from other Structure object to 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::set<tadah::core::Element> get_unique_elements() const
Return unique elements for all Structures.
-
void dump_to_file(const std::string &filepath, bool append, size_t prec = 12) const
Method to dump class content to a file
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}
Public Static Functions
-
static std::set<tadah::core::Element> find_unique_elements(const tadah::core::Context &c)
Find unique elements in provided Context file
-
static std::set<tadah::core::Element> find_unique_elements(const std::string &fn)
Find unique elements in provided file
-
static std::pair<int, int> count(const tadah::core::Context &c)
Count number of structures and atoms in all datasets from the Context file.
-
static std::pair<int, int> count(const std::string fn)
Count number of structures and atoms in a single dataset.
Friends
-
inline friend std::ostream &operator<<(std::ostream &os, const StructureDB &stdb)
Print this object summary to the stream
-
StructureDB()