OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
FragmentStamp.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#ifndef TYPES_FRAGMENTSTAMP_HPP
46#define TYPES_FRAGMENTSTAMP_HPP
47
48#include <utility>
49#include <vector>
50
51#include "types/AtomStamp.hpp"
52#include "types/BendStamp.hpp"
53#include "types/BondStamp.hpp"
54#include "types/ConstraintStamp.hpp"
55#include "types/CutoffGroupStamp.hpp"
56#include "types/FragmentStamp.hpp"
57#include "types/InversionStamp.hpp"
58#include "types/NodesStamp.hpp"
59#include "types/RigidBodyStamp.hpp"
60#include "types/TorsionStamp.hpp"
61
62namespace OpenMD {
63
64 class FragmentStamp : public DataHolder {
65 DeclareParameter(Name, std::string);
66
67 public:
69 virtual ~FragmentStamp();
70
71 bool addAtomStamp(AtomStamp* atom);
72 bool addBondStamp(BondStamp* bond);
73 bool addBendStamp(BendStamp* bend);
74 bool addTorsionStamp(TorsionStamp* torsion);
75 bool addInversionStamp(InversionStamp* inversion);
76 bool addRigidBodyStamp(RigidBodyStamp* rigidbody);
77 bool addCutoffGroupStamp(CutoffGroupStamp* cutoffgroup);
78 bool addConstraintStamp(ConstraintStamp* constraint);
79 bool addNodesStamp(NodesStamp* nodes);
80
81 std::size_t getNAtoms() { return atomStamps_.size(); }
82 std::size_t getNBonds() { return bondStamps_.size(); }
83 std::size_t getNBends() { return bendStamps_.size(); }
84 std::size_t getNTorsions() { return torsionStamps_.size(); }
85 std::size_t getNInversions() { return inversionStamps_.size(); }
86 std::size_t getNRigidBodies() { return rigidBodyStamps_.size(); }
87 std::size_t getNCutoffGroups() { return cutoffGroupStamps_.size(); }
88 std::size_t getNConstraints() { return constraintStamps_.size(); }
89
90 std::size_t getNNodes() { return nodesStamps_.size(); }
91
92 AtomStamp* getAtomStamp(int index) { return atomStamps_[index]; }
93 BondStamp* getBondStamp(int index) { return bondStamps_[index]; }
94 BendStamp* getBendStamp(int index) { return bendStamps_[index]; }
95 TorsionStamp* getTorsionStamp(int index) { return torsionStamps_[index]; }
96 InversionStamp* getInversionStamp(int index) {
97 return inversionStamps_[index];
98 }
99 RigidBodyStamp* getRigidBodyStamp(int index) {
100 return rigidBodyStamps_[index];
101 }
102 CutoffGroupStamp* getCutoffGroupStamp(int index) {
103 return cutoffGroupStamps_[index];
104 }
105 ConstraintStamp* getConstraintStamp(int index) {
106 return constraintStamps_[index];
107 }
108 NodesStamp* getNodesStamp(int index) { return nodesStamps_[index]; }
109
110 bool isBondInSameRigidBody(BondStamp* bond);
111 bool isAtomInRigidBody(int atomIndex);
112 bool isAtomInRigidBody(int atomIndex, int& whichRigidBody,
113 int& consAtomIndex);
114 std::vector<std::pair<int, int>> getJointAtoms(int rb1, int rb2);
115
116 std::size_t getNFreeAtoms() { return freeAtoms_.size(); }
117 virtual void validate();
118 int getIndex() { return index_; }
119
120 private:
121 void fillBondInfo();
122 void checkAtoms();
123 void checkBonds();
124 void checkBends();
125 void checkTorsions();
126 void checkInversions();
127 void checkRigidBodies();
128 void checkCutoffGroups();
129 void checkNodes();
130 void checkConstraints();
131
132 template<class Cont, class T>
133 bool addIndexSensitiveStamp(Cont& cont, T* stamp) {
134 // typename Cont::iterator i;
135 unsigned int index = stamp->getIndex();
136 bool ret = false;
137 size_t size = cont.size();
138
139 if (size >= index + 1) {
140 if (cont[index] != NULL) {
141 ret = false;
142 } else {
143 cont[index] = stamp;
144 ret = true;
145 }
146 } else {
147 cont.insert(cont.end(), index - cont.size() + 1, NULL);
148 cont[index] = stamp;
149 ret = true;
150 }
151
152 return ret;
153 }
154
155 int index_;
156 std::vector<AtomStamp*> atomStamps_;
157 std::vector<int> freeAtoms_;
158 std::vector<BondStamp*> bondStamps_;
159 std::vector<BendStamp*> bendStamps_;
160 std::vector<TorsionStamp*> torsionStamps_;
161 std::vector<InversionStamp*> inversionStamps_;
162 std::vector<RigidBodyStamp*> rigidBodyStamps_;
163 std::vector<CutoffGroupStamp*> cutoffGroupStamps_;
164 std::vector<ConstraintStamp*> constraintStamps_;
165 std::vector<NodesStamp*> nodesStamps_;
166 std::vector<int> nodeAtoms_;
167 std::vector<int> atom2Rigidbody;
168 };
169} // namespace OpenMD
170
171#endif
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.