1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
|
|
42 |
|
/** |
54 |
|
#include "primitives/StuntDouble.hpp" |
55 |
|
#include "primitives/DirectionalAtom.hpp" |
56 |
|
#include "types/AtomStamp.hpp" |
57 |
< |
namespace oopse{ |
58 |
< |
class RigidBody : public StuntDouble { |
59 |
< |
public: |
57 |
> |
namespace OpenMD{ |
58 |
> |
class RigidBody : public StuntDouble { |
59 |
> |
public: |
60 |
|
|
61 |
< |
typedef std::vector<Atom*>::iterator AtomIterator; |
61 |
> |
typedef std::vector<Atom*>::iterator AtomIterator; |
62 |
|
|
63 |
< |
RigidBody(); |
63 |
> |
RigidBody(); |
64 |
|
|
65 |
< |
virtual std::string getType() { return name_;} |
65 |
> |
virtual std::string getType() { return name_;} |
66 |
|
|
67 |
< |
/** Sets the name of this stuntdouble*/ |
68 |
< |
virtual void setType(const std::string& name) { name_ = name;} |
67 |
> |
/** Sets the name of this stuntRealType*/ |
68 |
> |
virtual void setType(const std::string& name) { name_ = name;} |
69 |
|
|
70 |
|
|
71 |
< |
/** |
72 |
< |
* Sets the previous rotation matrix of this stuntdouble |
73 |
< |
* @param a new rotation matrix |
74 |
< |
*/ |
75 |
< |
virtual void setPrevA(const RotMat3x3d& a); |
71 |
> |
/** |
72 |
> |
* Sets the previous rotation matrix of this stuntdouble |
73 |
> |
* @param a new rotation matrix |
74 |
> |
*/ |
75 |
> |
virtual void setPrevA(const RotMat3x3d& a); |
76 |
|
|
77 |
< |
/** |
78 |
< |
* Sets the current rotation matrix of this stuntdouble |
79 |
< |
* @param a new rotation matrix |
80 |
< |
* @note setA will not change the position and rotation matrix of Directional atoms belong to |
81 |
< |
* this rigidbody. If you want to do that, use #updateAtoms |
82 |
< |
*/ |
83 |
< |
virtual void setA(const RotMat3x3d& a); |
84 |
< |
/** |
85 |
< |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
86 |
< |
* @param a rotation matrix to be set |
87 |
< |
* @param snapshotNo |
88 |
< |
* @see #getA |
89 |
< |
*/ |
90 |
< |
virtual void setA(const RotMat3x3d& a, int snapshotNo); |
77 |
> |
/** |
78 |
> |
* Sets the current rotation matrix of this stuntdouble |
79 |
> |
* @param a new rotation matrix |
80 |
> |
* @note setA will not change the position and rotation matrix of Directional atoms belong to |
81 |
> |
* this rigidbody. If you want to do that, use #updateAtoms |
82 |
> |
*/ |
83 |
> |
virtual void setA(const RotMat3x3d& a); |
84 |
> |
/** |
85 |
> |
* Sets the rotation matrix of this stuntdouble in specified snapshot |
86 |
> |
* @param a rotation matrix to be set |
87 |
> |
* @param snapshotNo |
88 |
> |
* @see #getA |
89 |
> |
*/ |
90 |
> |
virtual void setA(const RotMat3x3d& a, int snapshotNo); |
91 |
|
|
92 |
< |
/** |
93 |
< |
* Returns the inertia tensor of this stuntdouble |
94 |
< |
* @return the inertia tensor of this stuntdouble |
95 |
< |
*/ |
96 |
< |
virtual Mat3x3d getI(); |
92 |
> |
/** |
93 |
> |
* Returns the inertia tensor of this stuntdouble |
94 |
> |
* @return the inertia tensor of this stuntdouble |
95 |
> |
*/ |
96 |
> |
virtual Mat3x3d getI(); |
97 |
|
|
98 |
|
|
99 |
< |
/** Sets the internal unit frame of this stuntdouble by three euler angles */ |
100 |
< |
void setElectroFrameFromEuler(double phi, double theta, double psi); |
99 |
> |
/** Sets the internal unit frame of this stuntdouble by three euler angles */ |
100 |
> |
void setElectroFrameFromEuler(RealType phi, RealType theta, RealType psi); |
101 |
|
|
102 |
< |
/** |
103 |
< |
* Returns the gradient of this stuntdouble |
104 |
< |
* @return the inertia tensor of this stuntdouble |
105 |
< |
* @see #setI |
106 |
< |
*/ |
107 |
< |
virtual std::vector<double> getGrad(); |
102 |
> |
/** |
103 |
> |
* Returns the gradient of this stuntdouble |
104 |
> |
* @return the inertia tensor of this stuntdouble |
105 |
> |
* @see #setI |
106 |
> |
*/ |
107 |
> |
virtual std::vector<RealType> getGrad(); |
108 |
|
|
109 |
< |
virtual void accept(BaseVisitor* v); |
109 |
> |
virtual void accept(BaseVisitor* v); |
110 |
|
|
111 |
< |
void addAtom(Atom* at, AtomStamp* ats); |
111 |
> |
void addAtom(Atom* at, AtomStamp* ats); |
112 |
|
|
113 |
< |
/** calculate the reference coordinates */ |
114 |
< |
void calcRefCoords(); |
113 |
> |
/** calculates the reference coordinates */ |
114 |
> |
void calcRefCoords(); |
115 |
|
|
116 |
< |
/** Convert Atomic forces and torques to total forces and torques */ |
117 |
< |
void calcForcesAndTorques(); |
116 |
> |
/** Converts Atomic forces and torques to total forces and torques */ |
117 |
> |
void calcForcesAndTorques(); |
118 |
|
|
119 |
< |
/** update the positions of atoms belong to this rigidbody */ |
120 |
< |
void updateAtoms(); |
119 |
> |
/** Converts Atomic forces and torques to total forces and torques and computes the rigid body contribution to the virial. Returns the rigid body contribution to the virial as a 3x3 matrix. */ |
120 |
> |
Mat3x3d calcForcesAndTorquesAndVirial(); |
121 |
|
|
122 |
< |
Atom* beginAtom(std::vector<Atom*>::iterator& i); |
122 |
> |
/** update the positions of atoms belong to this rigidbody */ |
123 |
> |
void updateAtoms(); |
124 |
|
|
125 |
< |
Atom* nextAtom(std::vector<Atom*>::iterator& i); |
125 |
> |
void updateAtoms(int frame); |
126 |
|
|
127 |
< |
std::vector<Atom*>::iterator getBeginAtomIter() { |
128 |
< |
return atoms_.begin(); |
129 |
< |
} |
127 |
> |
void updateAtomVel(); |
128 |
> |
|
129 |
> |
void updateAtomVel(int frame); |
130 |
|
|
131 |
< |
std::vector<Atom*>::iterator getEndAtomIter() { |
132 |
< |
return atoms_.end(); |
133 |
< |
} |
131 |
> |
Atom* beginAtom(std::vector<Atom*>::iterator& i) { |
132 |
> |
i = atoms_.begin(); |
133 |
> |
return i != atoms_.end() ? *i : NULL; |
134 |
> |
} |
135 |
|
|
136 |
< |
/** |
137 |
< |
* Returns the atoms of this rigid body |
138 |
< |
* @return the atoms of this rigid body in a vector |
139 |
< |
* @deprecate |
138 |
< |
*/ |
139 |
< |
std::vector<Atom*> getAtoms() { |
140 |
< |
return atoms_; |
141 |
< |
} |
136 |
> |
Atom* nextAtom(std::vector<Atom*>::iterator& i) { |
137 |
> |
++i; |
138 |
> |
return i != atoms_.end() ? *i : NULL; |
139 |
> |
} |
140 |
|
|
141 |
< |
/** |
142 |
< |
* Returns the number of atoms in this rigid body |
143 |
< |
* @return the number of atoms in this rigid body |
144 |
< |
*/ |
145 |
< |
int getNumAtoms() { |
146 |
< |
return atoms_.size(); |
147 |
< |
} |
141 |
> |
std::vector<Atom*>::iterator getBeginAtomIter() { |
142 |
> |
return atoms_.begin(); |
143 |
> |
} |
144 |
> |
|
145 |
> |
std::vector<Atom*>::iterator getEndAtomIter() { |
146 |
> |
return atoms_.end(); |
147 |
> |
} |
148 |
|
|
149 |
< |
/** |
150 |
< |
* Return the position of atom which belongs to this rigid body. |
151 |
< |
* @return true if index is valid otherwise return false |
152 |
< |
* @param pos the position of atom which will be set on return if index is valid |
153 |
< |
* @param index the index of the atom in rigid body's private data member atoms_ |
154 |
< |
*/ |
155 |
< |
bool getAtomPos(Vector3d& pos, unsigned int index); |
149 |
> |
/** |
150 |
> |
* Returns the atoms of this rigid body |
151 |
> |
* @return the atoms of this rigid body in a vector |
152 |
> |
* @deprecate |
153 |
> |
*/ |
154 |
> |
std::vector<Atom*> getAtoms() { |
155 |
> |
return atoms_; |
156 |
> |
} |
157 |
|
|
158 |
< |
/** |
159 |
< |
* Return the position of atom which belongs to this rigid body. |
160 |
< |
* @return true if atom belongs to this rigid body,otherwise return false |
161 |
< |
* @param pos position of atom which will be set on return if atom belongs to this rigid body |
162 |
< |
* @param atom the pointer to an atom |
163 |
< |
*/ |
164 |
< |
bool getAtomPos(Vector3d& pos, Atom* atom); |
158 |
> |
/** |
159 |
> |
* Returns the number of atoms in this rigid body |
160 |
> |
* @return the number of atoms in this rigid body |
161 |
> |
*/ |
162 |
> |
int getNumAtoms() { |
163 |
> |
return atoms_.size(); |
164 |
> |
} |
165 |
|
|
166 |
< |
/** |
167 |
< |
* Return the velocity of atom which belongs to this rigid body. |
168 |
< |
* @return true if index is valid otherwise return false |
169 |
< |
* @param vel the velocity of atom which will be set on return if index is valid |
170 |
< |
* @param index the index of the atom in rigid body's private data member atoms_ |
171 |
< |
*/ |
172 |
< |
bool getAtomVel(Vector3d& vel, unsigned int index); |
166 |
> |
/** |
167 |
> |
* Return the position of atom which belongs to this rigid body. |
168 |
> |
* @return true if index is valid otherwise return false |
169 |
> |
* @param pos the position of atom which will be set on return if index is valid |
170 |
> |
* @param index the index of the atom in rigid body's private data member atoms_ |
171 |
> |
*/ |
172 |
> |
bool getAtomPos(Vector3d& pos, unsigned int index); |
173 |
|
|
174 |
< |
/** |
175 |
< |
* Return the velocity of atom which belongs to this rigid body. |
176 |
< |
* @return true if atom belongs to this rigid body,otherwise return false |
177 |
< |
* @param vel velocity of atom which will be set on return if atom belongs to this rigid body |
178 |
< |
* @param atom the pointer to an atom |
179 |
< |
*/ |
180 |
< |
bool getAtomVel(Vector3d& vel, Atom*); |
174 |
> |
/** |
175 |
> |
* Return the position of atom which belongs to this rigid body. |
176 |
> |
* @return true if atom belongs to this rigid body,otherwise return false |
177 |
> |
* @param pos position of atom which will be set on return if atom belongs to this rigid body |
178 |
> |
* @param atom the pointer to an atom |
179 |
> |
*/ |
180 |
> |
bool getAtomPos(Vector3d& pos, Atom* atom); |
181 |
|
|
182 |
< |
/** |
183 |
< |
* Return the reference coordinate of atom which belongs to this rigid body. |
184 |
< |
* @return true if index is valid otherwise return false |
185 |
< |
* @param coor the reference coordinate of atom which will be set on return if index is valid |
186 |
< |
* @param index the index of the atom in rigid body's private data member atoms_ |
187 |
< |
*/ |
188 |
< |
bool getAtomRefCoor(Vector3d& coor, unsigned int index); |
182 |
> |
/** |
183 |
> |
* Return the velocity of atom which belongs to this rigid body. |
184 |
> |
* @return true if index is valid otherwise return false |
185 |
> |
* @param vel the velocity of atom which will be set on return if index is valid |
186 |
> |
* @param index the index of the atom in rigid body's private data member 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 coor velocity of atom which will be set on return if atom belongs to this rigid body |
194 |
< |
* @param atom the pointer to an atom |
195 |
< |
*/ |
196 |
< |
bool getAtomRefCoor(Vector3d& coor, Atom* atom); |
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 to this rigid body |
194 |
> |
* @param atom the pointer to an atom |
195 |
> |
*/ |
196 |
> |
bool getAtomVel(Vector3d& vel, Atom*); |
197 |
|
|
198 |
< |
private: |
199 |
< |
std::string name_; |
200 |
< |
Mat3x3d inertiaTensor_; |
201 |
< |
RotMat3x3d sU_; /**< body fixed standard unit vector */ |
198 |
> |
/** |
199 |
> |
* Return the reference coordinate of atom which belongs to this rigid body. |
200 |
> |
* @return true if index is valid otherwise return false |
201 |
> |
* @param coor the reference coordinate of atom which will be set on return if index is valid |
202 |
> |
* @param index the index of the atom in rigid body's private data member atoms_ |
203 |
> |
*/ |
204 |
> |
bool getAtomRefCoor(Vector3d& coor, unsigned int index); |
205 |
> |
|
206 |
> |
/** |
207 |
> |
* Return the velocity of atom which belongs to this rigid body. |
208 |
> |
* @return true if atom belongs to this rigid body,otherwise return false |
209 |
> |
* @param coor velocity of atom which will be set on return if atom belongs to this rigid body |
210 |
> |
* @param atom the pointer to an atom |
211 |
> |
*/ |
212 |
> |
bool getAtomRefCoor(Vector3d& coor, Atom* atom); |
213 |
> |
|
214 |
> |
private: |
215 |
> |
std::string name_; |
216 |
> |
Mat3x3d inertiaTensor_; |
217 |
> |
RotMat3x3d sU_; /**< body fixed standard unit vector */ |
218 |
|
|
219 |
< |
std::vector<Atom*> atoms_; |
220 |
< |
std::vector<Vector3d> refCoords_; |
221 |
< |
std::vector<RotMat3x3d> refOrients_; |
222 |
< |
}; |
219 |
> |
std::vector<Atom*> atoms_; |
220 |
> |
std::vector<Vector3d> refCoords_; |
221 |
> |
std::vector<RotMat3x3d> refOrients_; |
222 |
> |
}; |
223 |
|
|
224 |
< |
}//namepace oopse |
224 |
> |
}//namespace OpenMD |
225 |
|
|
226 |
|
#endif //PRIMITIVES_RIGIDBODY_HPP |
227 |
|
|