STORMM Source Documentation
Loading...
Searching...
No Matches
atom_equivalence.h
1// -*-c++-*-
2#ifndef STORMM_ATOM_EQUIVALENCE_H
3#define STORMM_ATOM_EQUIVALENCE_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "Topology/atomgraph.h"
9#include "Trajectory/coordinateframe.h"
10#include "UnitTesting/stopwatch.h"
11#include "chemical_features.h"
12#include "chemistry_enumerators.h"
13
14namespace stormm {
15namespace chemistry {
16
17using topology::AtomGraph;
18using testing::StopWatch;
19
25class AtomRank {
26public:
27
33 AtomRank(const AtomGraph *ag_in = nullptr);
34
35 AtomRank(const AtomGraph *ag_in, const std::vector<double> &formal_charges,
36 const std::vector<double> &free_electrons, const std::vector<ullint> &ring_inclusion,
37 const std::vector<ChiralOrientation> &chiralities, std::vector<int> *a_idx_tree,
38 std::vector<int> *b_idx_tree, std::vector<int> *a_zn_tree, std::vector<int> *b_zn_tree,
39 std::vector<double> *a_fc_tree, std::vector<double> *b_fc_tree,
40 std::vector<double> *a_fe_tree, std::vector<double> *b_fe_tree,
41 std::vector<ullint> *a_ri_tree, std::vector<ullint> *b_ri_tree,
42 std::vector<ChiralOrientation> *a_ch_tree, std::vector<ChiralOrientation> *b_ch_tree,
43 std::vector<int> *a_coverage, std::vector<int> *b_coverage, int low_molecule_index = 0,
44 int high_molecule_index = -1);
45
46 AtomRank(const AtomGraph &ag_in, const std::vector<double> &formal_charges,
47 const std::vector<double> &free_electrons, const std::vector<ullint> &ring_inclusion,
48 const std::vector<ChiralOrientation> &chiralities, int low_molecule_index = 0,
49 int high_molecule_index = -1);
50
51 AtomRank(const AtomGraph *ag_in, const ChemicalFeatures &chemfe, int low_molecule_index = 0,
52 int high_molecule_index = -1);
53
54 AtomRank(const AtomGraph &ag_in, const ChemicalFeatures &chemfe, int low_molecule_index = 0,
55 int high_molecule_index = -1);
57
69 const std::vector<int>& getRanks() const;
70 std::vector<int> getRanks(int low_index, int high_index) const;
71 int getRank(int atom_index) const;
73
77 std::vector<int> getAtomsWithRank(const int rank_value) const;
78
82 std::vector<int> getRankPartners(const int atom_index) const;
83
84private:
85 int maximum_rank;
86 std::vector<int> ranks;
87 std::vector<int> rank_degeneracy_bounds;
88 std::vector<int> rank_instances;
89 AtomGraph *ag_pointer;
90};
91
95public:
96
118
119 AtomEquivalence(const AtomGraph *ag_in, const std::vector<double> &formal_charges,
120 const std::vector<double> &free_electrons,
121 const std::vector<ullint> &ring_inclusion,
122 const std::vector<ChiralOrientation> &chiralities, StopWatch *timer = nullptr,
123 int low_molecule_index = 0, int high_molecule_index = -1);
124
125 AtomEquivalence(const AtomGraph &ag_in, const std::vector<double> &formal_charges,
126 const std::vector<double> &free_electrons,
127 const std::vector<ullint> &ring_inclusion,
128 const std::vector<ChiralOrientation> &chiralities, StopWatch *timer = nullptr,
129 int low_molecule_index = 0, int high_molecule_index = -1);
130
131 AtomEquivalence(const ChemicalFeatures &chemfe_in, StopWatch *timer = nullptr,
132 int low_molecule_index = 0, int high_molecule_index = -1);
133
134 AtomEquivalence(const AtomGraph &ag_in, const CoordinateFrame &cf, StopWatch *timer = nullptr,
135 int low_molecule_index = 0, int high_molecule_index = -1);
137
145 AtomEquivalence(const AtomEquivalence &original) = default;
146 AtomEquivalence(AtomEquivalence &&original) = default;
147 AtomEquivalence& operator=(const AtomEquivalence &original) = default;
148 AtomEquivalence& operator=(AtomEquivalence &&original) = default;
150
152 int getGroupCount() const;
153
156 int getSymmetryDepth() const;
157
161 std::vector<int> getGroup(int group_index) const;
162
169 int getSymmetryRelatedAtom(int group_index, int domain_index, int atom_index) const;
170
174 const int* getGroupPointer(int group_index) const;
175
179 int getGroupSize(int group_index) const;
180
184 int getGroupOrder(int group_index) const;
185
190 int getGroupLevel(int group_index) const;
191
196 EquivalenceSwap getGroupRule(int group_index) const;
197
203 std::vector<int> getGroupDependencies(int group_index) const;
204
206 int getAsymmetricAtomCount() const;
207
209 const std::vector<int>& getAsymmetricAtoms() const;
210
212 const AtomGraph* getTopologyPointer() const;
213
214private:
215 int group_count;
216 int symmetry_depth;
218 std::vector<int> group_atoms;
224 std::vector<int> group_sizes;
225 std::vector<int> group_orders;
226 std::vector<int> group_bounds;
227 std::vector<int> group_levels;
233 std::vector<int> dependencies;
237 std::vector<int> dependency_bounds;
239 std::vector<int> asymmetric_atoms;
240
242 std::vector<EquivalenceSwap> group_rules;
243
245 AtomGraph *ag_pointer;
246
280 void findEquivalentAtoms(const std::vector<int> &subset_atoms, std::vector<int> *map_to_subset,
281 const std::vector<double> &formal_charges,
282 const std::vector<double> &free_electrons,
283 const std::vector<ullint> &ring_inclusion,
284 const std::vector<ChiralOrientation> &chiralities,
285 const AtomRank &arnks, std::vector<int> *domain_coverage,
286 std::vector<int> *allowed_atoms, std::vector<int> *candidate_hopper,
287 std::vector<int> *domain_assignment, std::vector<int> *jumbled_groups,
288 std::vector<int> *aligned_groups, std::vector<int> *layer_bounds);
289
316 void drawEquivalentGroups(const std::vector<int> &partners, const std::vector<int> &subset_atoms,
317 const std::vector<double> &formal_charges,
318 const std::vector<double> &free_electrons,
319 const std::vector<ullint> &ring_inclusion,
320 const std::vector<ChiralOrientation> &chiralities,
321 const AtomRank &arnks, std::vector<int> *domain_coverage,
322 std::vector<int> *allowed_atoms, std::vector<int> *candidate_hopper,
323 std::vector<int> *domain_assignment, std::vector<int> *jumbled_groups,
324 std::vector<int> *aligned_groups, std::vector<int> *layer_bounds);
325
339 void addSymmetryGroup(const std::vector<int> &all_domains, int domain_size,
340 const std::vector<int> &selected_domains, EquivalenceSwap plan);
341
344 void freeForAllSymmetryGroup(const std::vector<int> &all_domains, int domain_size,
345 const std::vector<int> &selected_domains);
346
355 void rotarySymmetryGroup(const std::vector<int> &all_domains, int domain_size,
356 const std::vector<int> &selected_domains,
357 const std::vector<bool> &touch_table);
358
361 void cullDuplicateGroups();
362
365 void findDependencies();
366
370 void orderAllGroups();
371};
372
397std::vector<int> rankAtoms(const AtomGraph *ag, const std::vector<double> &formal_charges,
398 const std::vector<double> &free_electrons,
399 const std::vector<ullint> &ring_inclusion,
400 const std::vector<ChiralOrientation> &chiralities,
401 std::vector<int> *a_idx_tree, std::vector<int> *b_idx_tree,
402 std::vector<int> *a_zn_tree, std::vector<int> *b_zn_tree,
403 std::vector<double> *a_fc_tree, std::vector<double> *b_fc_tree,
404 std::vector<double> *a_fe_tree, std::vector<double> *b_fe_tree,
405 std::vector<ullint> *a_ri_tree, std::vector<ullint> *b_ri_tree,
406 std::vector<ChiralOrientation> *a_ch_tree,
407 std::vector<ChiralOrientation> *b_ch_tree,
408 std::vector<int> *a_coverage, std::vector<int> *b_coverage,
409 int low_molecule_index = 0, int high_molecule_index = -1);
410
411std::vector<int> rankAtoms(const AtomGraph &ag, const std::vector<double> &formal_charges,
412 const std::vector<double> &free_electrons,
413 const std::vector<ullint> &ring_inclusion,
414 const std::vector<ChiralOrientation> &chiralities,
415 int low_molecule_index = 0, int high_molecule_index = -1);
416
417std::vector<int> rankAtoms(const AtomGraph *ag, const ChemicalFeatures &chemfe,
418 int low_molecule_index = 0, int high_molecule_index = -1);
419
420std::vector<int> rankAtoms(const AtomGraph &ag, const ChemicalFeatures &chemfe,
421 int low_molecule_index = 0, int high_molecule_index = -1);
423
424} // namespace chemistry
425} // namespace stormm
426
427#endif
std::vector< int > getGroup(int group_index) const
Get the atoms of one group as an independent Standard Template Library vector.
Definition atom_equivalence.cpp:570
std::vector< int > getGroupDependencies(int group_index) const
Get a list of a group's dependencies (other groups that the group in question contains completely)....
Definition atom_equivalence.cpp:614
const AtomGraph * getTopologyPointer() const
Get a const pointer to the topology for which these equivalencies apply.
Definition atom_equivalence.cpp:635
int getGroupSize(int group_index) const
Get the size of a particular group.
Definition atom_equivalence.cpp:594
AtomEquivalence(const AtomEquivalence &original)=default
int getGroupLevel(int group_index) const
Get the depth of the group of interest in terms of its dependence on (containment within) other group...
Definition atom_equivalence.cpp:604
EquivalenceSwap getGroupRule(int group_index) const
Get the manner by which combinations of the group's interchangeable subunits should be laid out in or...
Definition atom_equivalence.cpp:609
AtomEquivalence()
The constructor relies on a topology pointer plus arrays of formal charges, bond orders,...
Definition atom_equivalence.cpp:401
int getSymmetryDepth() const
Get the number of levels of symmetry-related groups. This is essential for mapping identity swaps tha...
Definition atom_equivalence.cpp:565
int getGroupCount() const
Get the number of atom equivalence groups.
Definition atom_equivalence.cpp:560
int getGroupOrder(int group_index) const
Get the order of a particular group.
Definition atom_equivalence.cpp:599
const int * getGroupPointer(int group_index) const
Get a pointer to the atom indices of a particular group.
Definition atom_equivalence.cpp:589
const std::vector< int > & getAsymmetricAtoms() const
Get a const reference to the list of atoms outside any symmetry group.
Definition atom_equivalence.cpp:630
int getSymmetryRelatedAtom(int group_index, int domain_index, int atom_index) const
Get one atom index from within a symmetry-equivalent atom group.
Definition atom_equivalence.cpp:581
int getAsymmetricAtomCount() const
Get the number of asymmetric core atoms.
Definition atom_equivalence.cpp:625
Compute ranks for each atom from one or more molecules, assigning a unique (but, essentially arbitrar...
Definition atom_equivalence.h:25
const std::vector< int > & getRanks() const
Get the rank of one or more atoms.
Definition atom_equivalence.cpp:349
AtomRank(const AtomGraph *ag_in=nullptr)
The atom ranks can be constructed with or without temporary arrays to use as a workspace....
Definition atom_equivalence.cpp:20
std::vector< int > getRankPartners(const int atom_index) const
Get a list of all atoms which have a similar rank to a specific atom.
Definition atom_equivalence.cpp:388
std::vector< int > getAtomsWithRank(const int rank_value) const
Get a list of all atoms in the system with a particular rank.
Definition atom_equivalence.cpp:373
An object to store information about chemical motifs: participation in rings, planarity,...
Definition chemical_features.h:400
Object for managing calls to the C-standard function gettimeofday(), calculating deltas and categoriz...
Definition stopwatch.h:23
A struct to hold information relating to an Amber topology. This struct's member functions are limite...
Definition atomgraph.h:50
Store the coordinates and box information for a frame, only. This abridged struct can serve when the ...
Definition coordinateframe.h:111