OpenMD 3.2
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 following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48#ifndef TYPES_FRAGMENTSTAMP_HPP
49#define TYPES_FRAGMENTSTAMP_HPP
50
51#include <utility>
52#include <vector>
53
54#include "types/AtomStamp.hpp"
55#include "types/BendStamp.hpp"
56#include "types/BondStamp.hpp"
57#include "types/ConstraintStamp.hpp"
58#include "types/CutoffGroupStamp.hpp"
59#include "types/FragmentStamp.hpp"
60#include "types/InversionStamp.hpp"
61#include "types/NodesStamp.hpp"
62#include "types/RigidBodyStamp.hpp"
63#include "types/TorsionStamp.hpp"
64
65namespace OpenMD {
66
67 class FragmentStamp : public DataHolder {
68 DeclareParameter(Name, std::string);
69
70 public:
71 FragmentStamp();
72 virtual ~FragmentStamp();
73
74 bool addAtomStamp(AtomStamp* atom);
75 bool addBondStamp(BondStamp* bond);
76 bool addBendStamp(BendStamp* bend);
77 bool addTorsionStamp(TorsionStamp* torsion);
78 bool addInversionStamp(InversionStamp* inversion);
79 bool addRigidBodyStamp(RigidBodyStamp* rigidbody);
80 bool addCutoffGroupStamp(CutoffGroupStamp* cutoffgroup);
81 bool addConstraintStamp(ConstraintStamp* constraint);
82 bool addNodesStamp(NodesStamp* nodes);
83
84 std::size_t getNAtoms() { return atomStamps_.size(); }
85 std::size_t getNBonds() { return bondStamps_.size(); }
86 std::size_t getNBends() { return bendStamps_.size(); }
87 std::size_t getNTorsions() { return torsionStamps_.size(); }
88 std::size_t getNInversions() { return inversionStamps_.size(); }
89 std::size_t getNRigidBodies() { return rigidBodyStamps_.size(); }
90 std::size_t getNCutoffGroups() { return cutoffGroupStamps_.size(); }
91 std::size_t getNConstraints() { return constraintStamps_.size(); }
92
93 std::size_t getNNodes() { return nodesStamps_.size(); }
94
95 AtomStamp* getAtomStamp(int index) { return atomStamps_[index]; }
96 BondStamp* getBondStamp(int index) { return bondStamps_[index]; }
97 BendStamp* getBendStamp(int index) { return bendStamps_[index]; }
98 TorsionStamp* getTorsionStamp(int index) { return torsionStamps_[index]; }
99 InversionStamp* getInversionStamp(int index) {
100 return inversionStamps_[index];
101 }
102 RigidBodyStamp* getRigidBodyStamp(int index) {
103 return rigidBodyStamps_[index];
104 }
105 CutoffGroupStamp* getCutoffGroupStamp(int index) {
106 return cutoffGroupStamps_[index];
107 }
108 ConstraintStamp* getConstraintStamp(int index) {
109 return constraintStamps_[index];
110 }
111 NodesStamp* getNodesStamp(int index) { return nodesStamps_[index]; }
112
113 bool isBondInSameRigidBody(BondStamp* bond);
114 bool isAtomInRigidBody(int atomIndex);
115 bool isAtomInRigidBody(int atomIndex, int& whichRigidBody,
116 int& consAtomIndex);
117 std::vector<std::pair<int, int>> getJointAtoms(int rb1, int rb2);
118
119 std::size_t getNFreeAtoms() { return freeAtoms_.size(); }
120 virtual void validate();
121 int getIndex() { return index_; }
122
123 private:
124 void fillBondInfo();
125 void checkAtoms();
126 void checkBonds();
127 void checkBends();
128 void checkTorsions();
129 void checkInversions();
130 void checkRigidBodies();
131 void checkCutoffGroups();
132 void checkNodes();
133 void checkConstraints();
134
135 template<class Cont, class T>
136 bool addIndexSensitiveStamp(Cont& cont, T* stamp) {
137 // typename Cont::iterator i;
138 unsigned int index = stamp->getIndex();
139 bool ret = false;
140 size_t size = cont.size();
141
142 if (size >= index + 1) {
143 if (cont[index] != NULL) {
144 ret = false;
145 } else {
146 cont[index] = stamp;
147 ret = true;
148 }
149 } else {
150 cont.insert(cont.end(), index - cont.size() + 1, NULL);
151 cont[index] = stamp;
152 ret = true;
153 }
154
155 return ret;
156 }
157
158 int index_;
159 std::vector<AtomStamp*> atomStamps_;
160 std::vector<int> freeAtoms_;
161 std::vector<BondStamp*> bondStamps_;
162 std::vector<BendStamp*> bendStamps_;
163 std::vector<TorsionStamp*> torsionStamps_;
164 std::vector<InversionStamp*> inversionStamps_;
165 std::vector<RigidBodyStamp*> rigidBodyStamps_;
166 std::vector<CutoffGroupStamp*> cutoffGroupStamps_;
167 std::vector<ConstraintStamp*> constraintStamps_;
168 std::vector<NodesStamp*> nodesStamps_;
169 std::vector<int> nodeAtoms_;
170 std::vector<int> atom2Rigidbody;
171 };
172} // namespace OpenMD
173
174#endif
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.