OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
MoleculeStamp.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_MOLECULESTAMP_HPP
46#define TYPES_MOLECULESTAMP_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/RigidBodyStamp.hpp"
59#include "types/TorsionStamp.hpp"
60
61namespace OpenMD {
62 class MoleculeStamp : public DataHolder {
63 DeclareParameter(Name, std::string);
64 DeclareParameter(ConstrainTotalCharge, bool);
65
66 public:
68 virtual ~MoleculeStamp();
69
70 bool addAtomStamp(AtomStamp* atom);
71 bool addBondStamp(BondStamp* bond);
72 bool addBendStamp(BendStamp* bend);
73 bool addTorsionStamp(TorsionStamp* torsion);
74 bool addInversionStamp(InversionStamp* inversion);
75 bool addRigidBodyStamp(RigidBodyStamp* rigidbody);
76 bool addCutoffGroupStamp(CutoffGroupStamp* cutoffgroup);
77 bool addFragmentStamp(FragmentStamp* fragment);
78 bool addConstraintStamp(ConstraintStamp* constraint);
79
80 void setRegion(int r) { region_ = r; }
81 int getRegion() { return region_; }
82 std::size_t getNAtoms() { return atomStamps_.size(); }
83 std::size_t getNBonds() { return bondStamps_.size(); }
84 std::size_t getNBends() { return bendStamps_.size(); }
85 std::size_t getNTorsions() { return torsionStamps_.size(); }
86 std::size_t getNInversions() { return inversionStamps_.size(); }
87 std::size_t getNRigidBodies() { return rigidBodyStamps_.size(); }
88 std::size_t getNCutoffGroups() { return cutoffGroupStamps_.size(); }
89 std::size_t getNConstraints() { return constraintStamps_.size(); }
90 int getNIntegrable() { return nintegrable_; }
91 std::size_t getNFreeAtoms() { return freeAtoms_.size(); }
92 virtual void validate();
93
94 AtomStamp* getAtomStamp(int index) { return atomStamps_[index]; }
95 BondStamp* getBondStamp(int index) { return bondStamps_[index]; }
96 BendStamp* getBendStamp(int index) { return bendStamps_[index]; }
97 TorsionStamp* getTorsionStamp(int index) { return torsionStamps_[index]; }
98 InversionStamp* getInversionStamp(int index) {
99 return inversionStamps_[index];
100 }
101 RigidBodyStamp* getRigidBodyStamp(int index) {
102 return rigidBodyStamps_[index];
103 }
104 CutoffGroupStamp* getCutoffGroupStamp(int index) {
105 return cutoffGroupStamps_[index];
106 }
107 FragmentStamp* getFragmentStamp(int index) {
108 return fragmentStamps_[index];
109 }
110 ConstraintStamp* getConstraintStamp(int index) {
111 return constraintStamps_[index];
112 }
113
114 bool isBondInSameRigidBody(BondStamp* bond);
115 bool isAtomInRigidBody(int atomIndex);
116 bool isAtomInRigidBody(int atomIndex, int& whichRigidBody,
117 int& consAtomIndex);
118 std::vector<std::pair<int, int>> getJointAtoms(int rb1, int rb2);
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 checkFragments();
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 std::vector<AtomStamp*> atomStamps_;
156 std::vector<int> freeAtoms_;
157 std::vector<BondStamp*> bondStamps_;
158 std::vector<BendStamp*> bendStamps_;
159 std::vector<TorsionStamp*> torsionStamps_;
160 std::vector<InversionStamp*> inversionStamps_;
161 std::vector<RigidBodyStamp*> rigidBodyStamps_;
162 std::vector<CutoffGroupStamp*> cutoffGroupStamps_;
163 std::vector<FragmentStamp*> fragmentStamps_;
164 std::vector<ConstraintStamp*> constraintStamps_;
165 std::vector<int> atom2Rigidbody;
166 int nintegrable_;
167 int region_;
168 };
169} // namespace OpenMD
170
171#endif
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.