ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/primitives/Molecule.hpp
Revision: 1665
Committed: Tue Nov 22 20:38:56 2011 UTC (13 years, 5 months ago) by gezelter
File size: 12195 byte(s)
Log Message:
updated copyright notices

File Contents

# Content
1 /*
2 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 *
4 * The University of Notre Dame grants you ("Licensee") a
5 * non-exclusive, royalty free, license to use, modify and
6 * redistribute this software in source and binary code form, provided
7 * that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
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.
16 *
17 * This software is provided "AS IS," without a warranty of any
18 * kind. All express or implied conditions, representations and
19 * warranties, including any implied warranty of merchantability,
20 * fitness for a particular purpose or non-infringement, are hereby
21 * excluded. The University of Notre Dame and its licensors shall not
22 * be liable for any damages suffered by licensee as a result of
23 * using, modifying or distributing the software or its
24 * derivatives. In no event will the University of Notre Dame or its
25 * licensors be liable for any lost revenue, profit or data, or for
26 * direct, indirect, special, consequential, incidental or punitive
27 * damages, however caused and regardless of the theory of liability,
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] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 */
42
43 /**
44 * @file Molecule.hpp
45 * @author tlin
46 * @date 10/25/2004
47 * @version 1.0
48 */
49
50 #ifndef PRIMITIVES_MOLECULE_HPP
51 #define PRIMITIVES_MOLECULE_HPP
52 #include <vector>
53 #include <iostream>
54
55 #include "constraints/ConstraintPair.hpp"
56 #include "math/Vector3.hpp"
57 #include "primitives/Atom.hpp"
58 #include "primitives/RigidBody.hpp"
59 #include "primitives/Bond.hpp"
60 #include "primitives/Bend.hpp"
61 #include "primitives/Torsion.hpp"
62 #include "primitives/Inversion.hpp"
63 #include "primitives/CutoffGroup.hpp"
64 #include "utils/PropertyMap.hpp"
65
66 namespace OpenMD{
67
68 class Constraint;
69
70 /**
71 * @class Molecule Molecule.hpp "primitives/Molecule.hpp"
72 * @brief
73 */
74 class Molecule {
75 public:
76
77 typedef std::vector<Atom*>::iterator AtomIterator;
78 typedef std::vector<Bond*>::iterator BondIterator;
79 typedef std::vector<Bend*>::iterator BendIterator;
80 typedef std::vector<Torsion*>::iterator TorsionIterator;
81 typedef std::vector<Inversion*>::iterator InversionIterator;
82 typedef std::vector<RigidBody*>::iterator RigidBodyIterator;
83 typedef std::vector<CutoffGroup*>::iterator CutoffGroupIterator;
84 typedef std::vector<StuntDouble*>::iterator IntegrableObjectIterator;
85 typedef std::vector<ConstraintPair*>::iterator ConstraintPairIterator;
86 typedef std::vector<ConstraintElem*>::iterator ConstraintElemIterator;
87
88
89 Molecule(int stampId, int globalIndex, const std::string& molName);
90 virtual ~Molecule();
91
92 /**
93 * Returns the global index of this molecule.
94 * @return the global index of this molecule
95 */
96 int getGlobalIndex() {
97 return globalIndex_;
98 }
99
100 /**
101 * Returns the stamp id of this molecule
102 * @note Ideally, every molecule should keep a pointer of its
103 * molecule stamp instead of its stamp id. However, the pointer
104 * will become invalid, if the molecule migrate to other
105 * processor.
106 */
107 int getStampId() {
108 return stampId_;
109 }
110
111 /** Returns the name of the molecule */
112 std::string getType() {
113 return moleculeName_;
114 }
115
116 /**
117 * Sets the global index of this molecule.
118 * @param new global index to be set
119 */
120 void setGlobalIndex(int index) {
121 globalIndex_ = index;
122 }
123
124
125 /** add an atom into this molecule */
126 void addAtom(Atom* atom);
127
128 /** add a bond into this molecule */
129 void addBond(Bond* bond);
130
131 /** add a bend into this molecule */
132 void addBend(Bend* bend);
133
134 /** add a torsion into this molecule*/
135 void addTorsion(Torsion* torsion);
136
137 /** add an improper torsion into this molecule*/
138 void addInversion(Inversion* inversion);
139
140 /** add a rigidbody into this molecule */
141 void addRigidBody(RigidBody *rb);
142
143 /** add a cutoff group into this molecule */
144 void addCutoffGroup(CutoffGroup* cp);
145
146 void addConstraintPair(ConstraintPair* consPair);
147
148 void addConstraintElem(ConstraintElem* consElem);
149
150 /** */
151 void complete();
152
153 /** Returns the total number of atoms in this molecule */
154 unsigned int getNAtoms() {
155 return atoms_.size();
156 }
157
158 /** Returns the total number of bonds in this molecule */
159 unsigned int getNBonds(){
160 return bonds_.size();
161 }
162
163 /** Returns the total number of bends in this molecule */
164 unsigned int getNBends() {
165 return bends_.size();
166 }
167
168 /** Returns the total number of torsions in this molecule */
169 unsigned int getNTorsions() {
170 return torsions_.size();
171 }
172
173 /** Returns the total number of improper torsions in this molecule */
174 unsigned int getNInversions() {
175 return inversions_.size();
176 }
177
178 /** Returns the total number of rigid bodies in this molecule */
179 unsigned int getNRigidBodies() {
180 return rigidBodies_.size();
181 }
182
183 /** Returns the total number of integrable objects in this molecule */
184 unsigned int getNIntegrableObjects() {
185 return integrableObjects_.size();
186 }
187
188 /** Returns the total number of cutoff groups in this molecule */
189 unsigned int getNCutoffGroups() {
190 return cutoffGroups_.size();
191 }
192
193 /** Returns the total number of constraints in this molecule */
194 unsigned int getNConstraintPairs() {
195 return constraintPairs_.size();
196 }
197
198 Atom* getAtomAt(unsigned int i) {
199 assert(i < atoms_.size());
200 return atoms_[i];
201 }
202
203 RigidBody* getRigidBodyAt(unsigned int i) {
204 assert(i < rigidBodies_.size());
205 return rigidBodies_[i];
206 }
207
208 Atom* beginAtom(std::vector<Atom*>::iterator& i) {
209 i = atoms_.begin();
210 return (i == atoms_.end()) ? NULL : *i;
211 }
212
213 Atom* nextAtom(std::vector<Atom*>::iterator& i) {
214 ++i;
215 return (i == atoms_.end()) ? NULL : *i;
216 }
217
218 Bond* beginBond(std::vector<Bond*>::iterator& i) {
219 i = bonds_.begin();
220 return (i == bonds_.end()) ? NULL : *i;
221 }
222
223 Bond* nextBond(std::vector<Bond*>::iterator& i) {
224 ++i;
225 return (i == bonds_.end()) ? NULL : *i;
226
227 }
228
229 Bend* beginBend(std::vector<Bend*>::iterator& i) {
230 i = bends_.begin();
231 return (i == bends_.end()) ? NULL : *i;
232 }
233
234 Bend* nextBend(std::vector<Bend*>::iterator& i) {
235 ++i;
236 return (i == bends_.end()) ? NULL : *i;
237 }
238
239 Torsion* beginTorsion(std::vector<Torsion*>::iterator& i) {
240 i = torsions_.begin();
241 return (i == torsions_.end()) ? NULL : *i;
242 }
243
244 Torsion* nextTorsion(std::vector<Torsion*>::iterator& i) {
245 ++i;
246 return (i == torsions_.end()) ? NULL : *i;
247 }
248
249 Inversion* beginInversion(std::vector<Inversion*>::iterator& i) {
250 i = inversions_.begin();
251 return (i == inversions_.end()) ? NULL : *i;
252 }
253
254 Inversion* nextInversion(std::vector<Inversion*>::iterator& i) {
255 ++i;
256 return (i == inversions_.end()) ? NULL : *i;
257 }
258
259 RigidBody* beginRigidBody(std::vector<RigidBody*>::iterator& i) {
260 i = rigidBodies_.begin();
261 return (i == rigidBodies_.end()) ? NULL : *i;
262 }
263
264 RigidBody* nextRigidBody(std::vector<RigidBody*>::iterator& i) {
265 ++i;
266 return (i == rigidBodies_.end()) ? NULL : *i;
267 }
268
269 StuntDouble* beginIntegrableObject(std::vector<StuntDouble*>::iterator& i) {
270 i = integrableObjects_.begin();
271 return (i == integrableObjects_.end()) ? NULL : *i;
272 }
273
274 StuntDouble* nextIntegrableObject(std::vector<StuntDouble*>::iterator& i) {
275 ++i;
276 return (i == integrableObjects_.end()) ? NULL : *i;
277 }
278
279 CutoffGroup* beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i) {
280 i = cutoffGroups_.begin();
281 return (i == cutoffGroups_.end()) ? NULL : *i;
282 }
283
284 CutoffGroup* nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i) {
285 ++i;
286 return (i == cutoffGroups_.end()) ? NULL : *i;
287 }
288
289 ConstraintPair* beginConstraintPair(std::vector<ConstraintPair*>::iterator& i) {
290 i = constraintPairs_.begin();
291 return (i == constraintPairs_.end()) ? NULL : *i;
292 }
293
294 ConstraintPair* nextConstraintPair(std::vector<ConstraintPair*>::iterator& i) {
295 ++i;
296 return (i == constraintPairs_.end()) ? NULL : *i;
297 }
298
299 ConstraintElem* beginConstraintElem(std::vector<ConstraintElem*>::iterator& i) {
300 i = constraintElems_.begin();
301 return (i == constraintElems_.end()) ? NULL : *i;
302 }
303
304 ConstraintElem* nextConstraintElem(std::vector<ConstraintElem*>::iterator& i) {
305 ++i;
306 return (i == constraintElems_.end()) ? NULL : *i;
307 }
308
309 /**
310 * Returns the total potential energy of short range interaction
311 * of this molecule
312 */
313 RealType getPotential();
314
315 /** get total mass of this molecule */
316 RealType getMass();
317
318 /** return the center of mass of this molecule */
319 Vector3d getCom();
320
321 /** Moves the center of this molecule */
322 void moveCom(const Vector3d& delta);
323
324 /** Returns the velocity of center of mass of this molecule */
325 Vector3d getComVel();
326
327 std::string getMoleculeName() {
328 return moleculeName_;
329 }
330
331 friend std::ostream& operator <<(std::ostream& o, Molecule& mol);
332
333 //below functions are just forward functions
334 /**
335 * Adds property into property map
336 * @param genData GenericData to be added into PropertyMap
337 */
338 void addProperty(GenericData* genData);
339
340 /**
341 * Removes property from PropertyMap by name
342 * @param propName the name of property to be removed
343 */
344 void removeProperty(const std::string& propName);
345
346 /**
347 * clear all of the properties
348 */
349 void clearProperties();
350
351 /**
352 * Returns all names of properties
353 * @return all names of properties
354 */
355 std::vector<std::string> getPropertyNames();
356
357 /**
358 * Returns all of the properties in PropertyMap
359 * @return all of the properties in PropertyMap
360 */
361 std::vector<GenericData*> getProperties();
362
363 /**
364 * Returns property
365 * @param propName name of property
366 * @return a pointer point to property with propName. If no property named propName
367 * exists, return NULL
368 */
369 GenericData* getPropertyByName(const std::string& propName);
370
371 private:
372
373 int globalIndex_;
374
375 std::vector<Atom*> atoms_;
376 std::vector<Bond*> bonds_;
377 std::vector<Bend*> bends_;
378 std::vector<Torsion*> torsions_;
379 std::vector<Inversion*> inversions_;
380 std::vector<RigidBody*> rigidBodies_;
381 std::vector<StuntDouble*> integrableObjects_;
382 std::vector<CutoffGroup*> cutoffGroups_;
383 std::vector<ConstraintPair*> constraintPairs_;
384 std::vector<ConstraintElem*> constraintElems_;
385 int stampId_;
386 std::string moleculeName_;
387 PropertyMap properties_;
388
389 };
390
391 } //namespace OpenMD
392 #endif //

Properties

Name Value
svn:keywords Author Id Revision Date