OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
RigidBody.hpp
Go to the documentation of this file.
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/**
46 * @file RigidBody.hpp
47 * @author tlin
48 * @date 10/23/2004
49 * @version 1.0
50 */
51
52#ifndef PRIMITIVES_RIGIDBODY_HPP
53#define PRIMITIVES_RIGIDBODY_HPP
54
55#include <vector>
56
59#include "types/AtomStamp.hpp"
60
61namespace OpenMD {
62 class RigidBody : public StuntDouble {
63 public:
64 using AtomIterator = std::vector<Atom*>::iterator;
65
66 RigidBody();
67
68 virtual std::string getType() { return name_; }
69
70 /** Sets the name of this stuntRealType*/
71 virtual void setType(const std::string& name) { name_ = name; }
72
73 /**
74 * Sets the previous rotation matrix of this stuntdouble
75 * @param a new rotation matrix
76 */
77 virtual void setPrevA(const RotMat3x3d& a);
78
79 /**
80 * Sets the current rotation matrix of this stuntdouble
81 * @param a new rotation matrix
82 * @note setA will not change the position and rotation matrix of
83 * Directional atoms belong to this rigidbody. If you want to do that, use
84 * #updateAtoms
85 */
86 virtual void setA(const RotMat3x3d& a);
87 /**
88 * Sets the rotation matrix of this stuntdouble in specified snapshot
89 * @param a rotation matrix to be set
90 * @param snapshotNo
91 * @see #getA
92 */
93 virtual void setA(const RotMat3x3d& a, int snapshotNo);
94
95 /**
96 * Returns the inertia tensor of this stuntdouble
97 * @return the inertia tensor of this stuntdouble
98 */
99 virtual Mat3x3d getI();
100
101 /**
102 * Returns the gradient of this stuntdouble
103 * @return the gradient of this stuntdouble
104 */
105 virtual std::vector<RealType> getGrad();
106
107 virtual void accept(BaseVisitor* v);
108
109 void addAtom(Atom* at, AtomStamp* ats);
110
111 /** calculates the reference coordinates */
112 void calcRefCoords();
113
114 /** Converts Atomic forces and torques to total forces and torques */
116
117 /**
118 Converts Atomic forces and torques to total forces and torques
119 and computes the rigid body contribution to the virial.
120 Returns the rigid body contribution to the virial as a 3x3
121 matrix.
122 */
124
125 /** update the positions of atoms belong to this rigidbody */
126 void updateAtoms();
127
128 void updateAtoms(int frame);
129
130 void updateAtomVel();
131
132 void updateAtomVel(int frame);
133
134 Atom* beginAtom(std::vector<Atom*>::iterator& i) {
135 i = atoms_.begin();
136 return i != atoms_.end() ? *i : NULL;
137 }
138
139 Atom* nextAtom(std::vector<Atom*>::iterator& i) {
140 ++i;
141 return i != atoms_.end() ? *i : NULL;
142 }
143
144 std::vector<Atom*>::iterator getBeginAtomIter() { return atoms_.begin(); }
145
146 std::vector<Atom*>::iterator getEndAtomIter() { return atoms_.end(); }
147
148 /**
149 * Returns the atoms of this rigid body
150 * @return the atoms of this rigid body in a vector
151 * @deprecated
152 */
153 std::vector<Atom*> getAtoms() { return atoms_; }
154
155 /**
156 * Returns the number of atoms in this rigid body
157 * @return the number of atoms in this rigid body
158 */
159 size_t getNumAtoms() { return atoms_.size(); }
160
161 /**
162 * Return the position of atom which belongs to this rigid body.
163 * @return true if index is valid otherwise return false
164 * @param pos the position of atom which will be set on return if index is
165 * valid
166 * @param index the index of the atom in rigid body's private data member
167 * atoms_
168 */
169 bool getAtomPos(Vector3d& pos, unsigned int index);
170
171 /**
172 * Return the position of atom which belongs to this rigid body.
173 * @return true if atom belongs to this rigid body,otherwise return false
174 * @param pos position of atom which will be set on return if atom belongs
175 * to this rigid body
176 * @param atom the pointer to an atom
177 */
178 bool getAtomPos(Vector3d& pos, Atom* atom);
179
180 /**
181 * Return the velocity of atom which belongs to this rigid body.
182 * @return true if index is valid otherwise return false
183 * @param vel the velocity of atom which will be set on return if index is
184 * valid
185 * @param index the index of the atom in rigid body's private data member
186 * atoms_
187 */
188 bool getAtomVel(Vector3d& vel, unsigned int index);
189
190 /**
191 * Return the velocity of atom which belongs to this rigid body.
192 * @return true if atom belongs to this rigid body,otherwise return false
193 * @param vel velocity of atom which will be set on return if atom belongs
194 * to this rigid body
195 * @param atom the pointer to an atom
196 */
197 bool getAtomVel(Vector3d& vel, Atom*);
198
199 /**
200 * Return the reference coordinate of atom which belongs to this rigid body.
201 * @return true if index is valid otherwise return false
202 * @param coor the reference coordinate of atom which will be set on return
203 * if index is valid
204 * @param index the index of the atom in rigid body's private data member
205 * atoms_
206 */
207 bool getAtomRefCoor(Vector3d& coor, unsigned int index);
208
209 /**
210 * Return the velocity of atom which belongs to this rigid body.
211 * @return true if atom belongs to this rigid body,otherwise return false
212 * @param coor velocity of atom which will be set on return if atom belongs
213 * to this rigid body
214 * @param atom the pointer to an atom
215 */
216 bool getAtomRefCoor(Vector3d& coor, Atom* atom);
217
218 Vector3d getRefCOM() { return refCOM_; }
219
220 private:
221 std::string name_;
222 Mat3x3d inertiaTensor_;
223 RotMat3x3d sU_; /**< body fixed standard unit vector */
224
225 std::vector<Atom*> atoms_;
226 Vector3d refCOM_; /**< center of mass relative to original coordinates */
227 std::vector<Vector3d> refCoords_;
228 std::vector<RotMat3x3d> refOrients_;
229 };
230} // namespace OpenMD
231
232#endif // PRIMITIVES_RIGIDBODY_HPP
virtual void setType(const std::string &name)
Sets the name of this stuntRealType.
Definition RigidBody.hpp:71
void calcRefCoords()
calculates the reference coordinates
virtual void setPrevA(const RotMat3x3d &a)
Sets the previous rotation matrix of this stuntdouble.
Definition RigidBody.cpp:57
bool getAtomRefCoor(Vector3d &coor, unsigned int index)
Return the reference coordinate of atom which belongs to this rigid body.
virtual void setA(const RotMat3x3d &a)
Sets the current rotation matrix of this stuntdouble.
Definition RigidBody.cpp:67
size_t getNumAtoms()
Returns the number of atoms in this rigid body.
void updateAtoms()
update the positions of atoms belong to this rigidbody
std::vector< Atom * > getAtoms()
Returns the atoms of this rigid body.
virtual std::vector< RealType > getGrad()
Returns the gradient of this stuntdouble.
Definition RigidBody.cpp:89
Mat3x3d calcForcesAndTorquesAndVirial()
Converts Atomic forces and torques to total forces and torques and computes the rigid body contributi...
virtual Mat3x3d getI()
Returns the inertia tensor of this stuntdouble.
Definition RigidBody.cpp:87
void calcForcesAndTorques()
Converts Atomic forces and torques to total forces and torques.
virtual void accept(BaseVisitor *v)
bool getAtomPos(Vector3d &pos, unsigned int index)
Return the position of atom which belongs to this rigid body.
bool getAtomVel(Vector3d &vel, unsigned int index)
Return the velocity of atom which belongs to this rigid body.
virtual std::string getType()
Returns the name of this stuntDouble.
Definition RigidBody.hpp:68
"Don't move, or you're dead! Stand up! Captain, we've got them!"
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.