1 |
< |
#ifndef _MOLECULE_H_ |
2 |
< |
#define _MOLECULE_H_ |
1 |
> |
/* |
2 |
> |
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
> |
* |
4 |
> |
* Contact: oopse@oopse.org |
5 |
> |
* |
6 |
> |
* This program is free software; you can redistribute it and/or |
7 |
> |
* modify it under the terms of the GNU Lesser General Public License |
8 |
> |
* as published by the Free Software Foundation; either version 2.1 |
9 |
> |
* of the License, or (at your option) any later version. |
10 |
> |
* All we ask is that proper credit is given for our work, which includes |
11 |
> |
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
> |
* of your source code files, and to any copyright notice that you may distribute |
13 |
> |
* with programs based on this work. |
14 |
> |
* |
15 |
> |
* This program is distributed in the hope that it will be useful, |
16 |
> |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
> |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
> |
* GNU Lesser General Public License for more details. |
19 |
> |
* |
20 |
> |
* You should have received a copy of the GNU Lesser General Public License |
21 |
> |
* along with this program; if not, write to the Free Software |
22 |
> |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
> |
* |
24 |
> |
*/ |
25 |
|
|
26 |
< |
#include <set> |
26 |
> |
/** |
27 |
> |
* @file Molecule.hpp |
28 |
> |
* @author tlin |
29 |
> |
* @date 10/25/2004 |
30 |
> |
* @version 1.0 |
31 |
> |
*/ |
32 |
> |
|
33 |
> |
#ifndef PRIMITIVES_MOLECULE_HPP |
34 |
> |
#define PRIMITIVES_MOLECULE_HPP |
35 |
|
#include <vector> |
36 |
+ |
#include <iostream> |
37 |
|
|
38 |
< |
#include "Atom.hpp" |
39 |
< |
#include "SRI.hpp" |
40 |
< |
#include "MoleculeStamp.hpp" |
41 |
< |
#include "RigidBody.hpp" |
42 |
< |
#include "CutoffGroup.hpp" |
38 |
> |
#include "math/Vector3.hpp" |
39 |
> |
#include "primitives/Atom.hpp" |
40 |
> |
#include "primitives/RigidBody.hpp" |
41 |
> |
#include "primitives/Bond.hpp" |
42 |
> |
#include "primitives/Bend.hpp" |
43 |
> |
#include "primitives/Torsion.hpp" |
44 |
> |
#include "primitives/CutoffGroup.hpp" |
45 |
|
|
46 |
< |
using namespace std; |
46 |
> |
namespace oopse{ |
47 |
|
|
48 |
< |
typedef struct{ |
16 |
< |
|
17 |
< |
int stampID; // the ID in the BASS component stamp array |
18 |
< |
int nAtoms; // the number of atoms in the molecule |
19 |
< |
int nBonds; // ... .. .. . .bonds .. .. . . . . |
20 |
< |
int nBends; // . . . . .. . .bends . . . . .. . |
21 |
< |
int nTorsions; // .. . . .. . . torsions . . .. . . |
22 |
< |
int nRigidBodies; // .. .. .. . rigid bodies ... .. |
23 |
< |
int nOriented; // .. . . . .. . oriented atoms . . . |
24 |
< |
|
25 |
< |
Atom** myAtoms; // the array of atoms |
26 |
< |
Bond** myBonds; // arrays of all the short range interactions |
27 |
< |
Bend** myBends; |
28 |
< |
Torsion** myTorsions; |
29 |
< |
vector<RigidBody*> myRigidBodies; |
30 |
< |
vector<StuntDouble*> myIntegrableObjects; |
31 |
< |
vector<CutoffGroup*> myCutoffGroups; |
32 |
< |
} molInit; |
48 |
> |
class Constraint; |
49 |
|
|
50 |
< |
class Molecule{ |
50 |
> |
/** |
51 |
> |
* @class Molecule Molecule.hpp "primitives/Molecule.hpp" |
52 |
> |
* @brief |
53 |
> |
*/ |
54 |
> |
class Molecule { |
55 |
> |
public: |
56 |
|
|
57 |
< |
public: |
58 |
< |
|
59 |
< |
Molecule( void ); |
60 |
< |
~Molecule( void ); |
57 |
> |
typedef std::vector<Atom*>::iterator AtomIterator; |
58 |
> |
typedef std::vector<Bond*>::iterator BondIterator; |
59 |
> |
typedef std::vector<Bend*>::iterator BendIterator; |
60 |
> |
typedef std::vector<Torsion*>::iterator TorsionIterator; |
61 |
> |
typedef std::vector<RigidBody*>::iterator RigidBodyIterator; |
62 |
> |
typedef std::vector<CutoffGroup*>::iterator CutoffGroupIterator; |
63 |
> |
typedef std::vector<StuntDouble*>::iterator IntegrableObjectIterator; |
64 |
|
|
65 |
< |
void initialize( molInit &theInit ); |
65 |
> |
Molecule(int stampId, int globalIndex, const std::string& molName); |
66 |
> |
virtual ~Molecule(); |
67 |
|
|
68 |
< |
void setMyIndex( int theIndex ){ myIndex = theIndex;} |
69 |
< |
int getMyIndex( void ) { return myIndex; } |
68 |
> |
/** |
69 |
> |
* Returns the global index of this molecule. |
70 |
> |
* @return the global index of this molecule |
71 |
> |
*/ |
72 |
> |
int getGlobalIndex() { |
73 |
> |
return globalIndex_; |
74 |
> |
} |
75 |
|
|
76 |
< |
int getGlobalIndex( void ) { return globalIndex; } |
77 |
< |
void setGlobalIndex( int theIndex ) { globalIndex = theIndex; } |
76 |
> |
/** |
77 |
> |
* Returns the stamp id of this molecule |
78 |
> |
* @note Ideally, every molecule should keep a pointer of its molecule stamp instead of its |
79 |
> |
* stamp id. However, the pointer will become invalid, if the molecule migrate to other processor. |
80 |
> |
*/ |
81 |
> |
int getStampId() { |
82 |
> |
return stampId_; |
83 |
> |
} |
84 |
|
|
85 |
< |
int getNAtoms ( void ) {return nAtoms;} |
86 |
< |
int getNBonds ( void ) {return nBonds;} |
87 |
< |
int getNBends ( void ) {return nBends;} |
88 |
< |
int getNTorsions( void ) {return nTorsions;} |
89 |
< |
int getNRigidBodies( void ) {return myRigidBodies.size();} |
90 |
< |
int getNOriented( void ) {return nOriented;} |
91 |
< |
int getNMembers ( void ) {return nMembers;} |
92 |
< |
int getStampID ( void ) {return stampID;} |
85 |
> |
/** Returns the name of the molecule */ |
86 |
> |
std::string getType() { |
87 |
> |
return moleculeName_; |
88 |
> |
} |
89 |
> |
|
90 |
> |
/** |
91 |
> |
* Sets the global index of this molecule. |
92 |
> |
* @param new global index to be set |
93 |
> |
*/ |
94 |
> |
int setGlobalIndex(int index) { |
95 |
> |
return globalIndex_; |
96 |
> |
} |
97 |
|
|
98 |
< |
Atom** getMyAtoms ( void ) {return myAtoms;} |
99 |
< |
Bond** getMyBonds ( void ) {return myBonds;} |
100 |
< |
Bend** getMyBends ( void ) {return myBends;} |
61 |
< |
Torsion** getMyTorsions( void ) {return myTorsions;} |
62 |
< |
vector<RigidBody*> getMyRigidBodies( void ) {return myRigidBodies;} |
63 |
< |
vector<StuntDouble*>& getIntegrableObjects(void) {return myIntegrableObjects;} |
98 |
> |
|
99 |
> |
/** add an atom into this molecule */ |
100 |
> |
void addAtom(Atom* atom); |
101 |
|
|
102 |
< |
//beginCutoffGroup return the first group and initialize the iterator |
103 |
< |
CutoffGroup* beginCutoffGroup(vector<CutoffGroup*>::iterator& i){ |
67 |
< |
i = myCutoffGroups.begin(); |
68 |
< |
return i != myCutoffGroups.end()? *i : NULL; |
69 |
< |
} |
102 |
> |
/** add a bond into this molecule */ |
103 |
> |
void addBond(Bond* bond); |
104 |
|
|
105 |
< |
//nextCutoffGroup return next cutoff group based on the iterator |
106 |
< |
CutoffGroup* nextCutoffGroup(vector<CutoffGroup*>::iterator& i){ |
73 |
< |
i++; |
74 |
< |
return i != myCutoffGroups.end()? *i : NULL; |
75 |
< |
} |
105 |
> |
/** add a bend into this molecule */ |
106 |
> |
void addBend(Bend* bend); |
107 |
|
|
108 |
< |
int getNCutoffGroups() {return nCutoffGroups;} |
108 |
> |
/** add a torsion into this molecule*/ |
109 |
> |
void addTorsion(Torsion* torsion); |
110 |
|
|
111 |
< |
void setStampID( int info ) {stampID = info;} |
111 |
> |
/** add a rigidbody into this molecule */ |
112 |
> |
void addRigidBody(RigidBody *rb); |
113 |
|
|
114 |
< |
void calcForces( void ); |
115 |
< |
void atoms2rigidBodies( void ); |
83 |
< |
double getPotential( void ); |
84 |
< |
|
85 |
< |
void printMe( void ); |
114 |
> |
/** add a cutoff group into this molecule */ |
115 |
> |
void addCutoffGroup(CutoffGroup* cp); |
116 |
|
|
117 |
< |
void getCOM( double COM[3] ); |
118 |
< |
void moveCOM( double delta[3] ); |
89 |
< |
double getCOMvel( double COMvel[3] ); |
90 |
< |
|
91 |
< |
double getTotalMass(); |
117 |
> |
/** */ |
118 |
> |
void complete(); |
119 |
|
|
120 |
< |
private: |
120 |
> |
/** Returns the total number of atoms in this molecule */ |
121 |
> |
unsigned int getNAtoms() { |
122 |
> |
return atoms_.size(); |
123 |
> |
} |
124 |
|
|
125 |
< |
int stampID; // the ID in the BASS component stamp array |
126 |
< |
int nAtoms; // the number of atoms in the molecule |
127 |
< |
int nBonds; // ... .. .. . .bonds .. .. . . . . |
128 |
< |
int nBends; // . . . . .. . .bends . . . . .. . |
99 |
< |
int nTorsions; // .. . . .. . . torsions . . .. . . |
100 |
< |
int nRigidBodies; // .. . . .. .rigid bodies . . .. . . |
101 |
< |
int nOriented; // .. . . . .. . oriented atoms . . . |
102 |
< |
int nMembers; // .. . . . . . .atoms (legacy code) . . . |
103 |
< |
int nCutoffGroups; |
104 |
< |
|
105 |
< |
int myIndex; // mostly just for debug (and for making pressure calcs work) |
106 |
< |
int globalIndex; |
125 |
> |
/** Returns the total number of bonds in this molecule */ |
126 |
> |
unsigned int getNBonds(){ |
127 |
> |
return bonds_.size(); |
128 |
> |
} |
129 |
|
|
130 |
< |
Atom** myAtoms; // the array of atoms |
131 |
< |
Bond** myBonds; // arrays of all the short range interactions |
132 |
< |
Bend** myBends; |
133 |
< |
Torsion** myTorsions; |
134 |
< |
vector<RigidBody*> myRigidBodies; |
135 |
< |
vector<StuntDouble*> myIntegrableObjects; |
136 |
< |
vector<CutoffGroup*> myCutoffGroups; |
130 |
> |
/** Returns the total number of bends in this molecule */ |
131 |
> |
unsigned int getNBends() { |
132 |
> |
return bends_.size(); |
133 |
> |
} |
134 |
> |
|
135 |
> |
/** Returns the total number of torsions in this molecule */ |
136 |
> |
unsigned int getNTorsions() { |
137 |
> |
return torsions_.size(); |
138 |
> |
} |
139 |
> |
|
140 |
> |
/** Returns the total number of rigid bodies in this molecule */ |
141 |
> |
unsigned int getNRigidBodies() { |
142 |
> |
return rigidBodies_.size(); |
143 |
> |
} |
144 |
> |
|
145 |
> |
/** Returns the total number of integrable objects in this molecule */ |
146 |
> |
unsigned int getNIntegrableObjects() { |
147 |
> |
return integrableObjects_.size(); |
148 |
> |
} |
149 |
> |
|
150 |
> |
/** Returns the total number of cutoff groups in this molecule */ |
151 |
> |
unsigned int getNCutoffGroups() { |
152 |
> |
return cutoffGroups_.size(); |
153 |
> |
} |
154 |
> |
|
155 |
> |
/** Returns the total number of constraints in this molecule */ |
156 |
> |
unsigned int getNConstraints() { |
157 |
> |
return constraints_.size(); |
158 |
> |
} |
159 |
> |
|
160 |
> |
Atom* getAtomAt(unsigned int i) { |
161 |
> |
assert(i < atoms_.size()); |
162 |
> |
return atoms_[i]; |
163 |
> |
} |
164 |
> |
/** |
165 |
> |
* Returns the first atom in this molecule and initialize the iterator. |
166 |
> |
* @return the first atom, return NULL if there is not cut off group in this molecule |
167 |
> |
* @param i iteraotr |
168 |
> |
*/ |
169 |
> |
Atom* beginAtom(std::vector<Atom*>::iterator& i); |
170 |
> |
|
171 |
> |
Atom* nextAtom(std::vector<Atom*>::iterator& i); |
172 |
> |
|
173 |
> |
/** |
174 |
> |
* Returns the first bond in this molecule and initialize the iterator. |
175 |
> |
* @return the first bond, return NULL if there is not cut off group in this molecule |
176 |
> |
* @param i iteraotr |
177 |
> |
*/ |
178 |
> |
Bond* beginBond(std::vector<Bond*>::iterator& i); |
179 |
> |
|
180 |
> |
Bond* nextBond(std::vector<Bond*>::iterator& i); |
181 |
> |
|
182 |
> |
/** |
183 |
> |
* Returns the first bend in this molecule and initialize the iterator. |
184 |
> |
* @return the first bend, return NULL if there is not cut off group in this molecule |
185 |
> |
* @param i iteraotr |
186 |
> |
*/ |
187 |
> |
Bend* beginBend(std::vector<Bend*>::iterator& i); |
188 |
> |
|
189 |
> |
Bend* nextBend(std::vector<Bend*>::iterator& i); |
190 |
> |
|
191 |
> |
/** |
192 |
> |
* Returns the first torsion in this molecule and initialize the iterator. |
193 |
> |
* @return the first torsion, return NULL if there is not cut off group in this molecule |
194 |
> |
* @param i iteraotr |
195 |
> |
*/ |
196 |
> |
Torsion* beginTorsion(std::vector<Torsion*>::iterator& i); |
197 |
> |
Torsion* nextTorsion(std::vector<Torsion*>::iterator& i); |
198 |
> |
|
199 |
> |
/** |
200 |
> |
* Returns the first rigid body in this molecule and initialize the iterator. |
201 |
> |
* @return the first rigid body, return NULL if there is not cut off group in this molecule |
202 |
> |
* @param i iteraotr |
203 |
> |
*/ |
204 |
> |
RigidBody* beginRigidBody(std::vector<RigidBody*>::iterator& i); |
205 |
> |
|
206 |
> |
RigidBody* nextRigidBody(std::vector<RigidBody*>::iterator& i); |
207 |
> |
|
208 |
> |
/** |
209 |
> |
* Returns the first integrable object in this molecule and initialize the iterator. |
210 |
> |
* @return the first integrable object, return NULL if there is not cut off group in this molecule |
211 |
> |
* @param i iteraotr |
212 |
> |
*/ |
213 |
> |
StuntDouble* beginIntegrableObject(std::vector<StuntDouble*>::iterator& i); |
214 |
> |
|
215 |
> |
StuntDouble* nextIntegrableObject(std::vector<StuntDouble*>::iterator& i); |
216 |
> |
|
217 |
> |
/** |
218 |
> |
* Returns the first cutoff group in this molecule and initialize the iterator. |
219 |
> |
* @return the first cutoff group, return NULL if there is not cut off group in this molecule |
220 |
> |
* @param i iteraotr |
221 |
> |
*/ |
222 |
> |
CutoffGroup* beginCutoffGroup(std::vector<CutoffGroup*>::iterator& i); |
223 |
> |
|
224 |
> |
/** |
225 |
> |
* Returns next cutoff group based on the iterator |
226 |
> |
* @return next cutoff group |
227 |
> |
* @param i |
228 |
> |
*/ |
229 |
> |
CutoffGroup* nextCutoffGroup(std::vector<CutoffGroup*>::iterator& i); |
230 |
> |
|
231 |
> |
Constraint* beginConstraint(std::vector<Constraint*>::iterator& i); |
232 |
> |
|
233 |
> |
Constraint* nextConstraint(std::vector<Constraint*>::iterator& i); |
234 |
> |
|
235 |
> |
|
236 |
> |
/** return the total potential energy of short range interaction of this molecule */ |
237 |
> |
double getPotential(); |
238 |
> |
|
239 |
> |
|
240 |
> |
/** return the center of mass of this molecule */ |
241 |
> |
Vector3d getCom(); |
242 |
> |
|
243 |
> |
/** Moves the center of this molecule */ |
244 |
> |
void moveCom(const Vector3d& delta); |
245 |
> |
|
246 |
> |
/** Returns the velocity of center of mass of this molecule */ |
247 |
> |
Vector3d getComVel(); |
248 |
> |
|
249 |
> |
/** Returns the total mass of this molecule */ |
250 |
> |
double getTotalMass(); |
251 |
> |
|
252 |
> |
friend std::ostream& operator <<(std::ostream& o, Molecule& mol); |
253 |
> |
|
254 |
> |
private: |
255 |
> |
|
256 |
> |
int globalIndex_; |
257 |
> |
|
258 |
> |
std::vector<Atom*> atoms_; |
259 |
> |
std::vector<Bond*> bonds_; |
260 |
> |
std::vector<Bend*> bends_; |
261 |
> |
std::vector<Torsion*> torsions_; |
262 |
> |
std::vector<RigidBody*> rigidBodies_; |
263 |
> |
std::vector<StuntDouble*> integrableObjects_; |
264 |
> |
std::vector<CutoffGroup*> cutoffGroups_; |
265 |
> |
std::vector<Constraint*> constraints_; |
266 |
> |
|
267 |
> |
int stampId_; |
268 |
> |
std::string moleculeName_; |
269 |
|
}; |
270 |
|
|
271 |
< |
#endif |
271 |
> |
} //namespace oopse |
272 |
> |
#endif // |