1 |
< |
#include <stdlib.h> |
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, 234107 (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.cpp |
45 |
> |
* @author tlin |
46 |
> |
* @date 10/28/2004 |
47 |
> |
* @version 1.0 |
48 |
> |
*/ |
49 |
|
|
50 |
+ |
#include <algorithm> |
51 |
+ |
#include <set> |
52 |
|
|
53 |
|
#include "primitives/Molecule.hpp" |
54 |
+ |
#include "utils/MemoryUtils.hpp" |
55 |
|
#include "utils/simError.h" |
56 |
+ |
#include "utils/ElementsTable.hpp" |
57 |
|
|
58 |
+ |
namespace OpenMD { |
59 |
+ |
Molecule::Molecule(int stampId, int globalIndex, const std::string& molName, |
60 |
+ |
int region) : stampId_(stampId), |
61 |
+ |
globalIndex_(globalIndex), |
62 |
+ |
moleculeName_(molName), |
63 |
+ |
region_(region), |
64 |
+ |
constrainTotalCharge_(false) { |
65 |
+ |
} |
66 |
+ |
|
67 |
+ |
Molecule::~Molecule() { |
68 |
+ |
|
69 |
+ |
MemoryUtils::deletePointers(atoms_); |
70 |
+ |
MemoryUtils::deletePointers(bonds_); |
71 |
+ |
MemoryUtils::deletePointers(bends_); |
72 |
+ |
MemoryUtils::deletePointers(torsions_); |
73 |
+ |
MemoryUtils::deletePointers(inversions_); |
74 |
+ |
MemoryUtils::deletePointers(rigidBodies_); |
75 |
+ |
MemoryUtils::deletePointers(cutoffGroups_); |
76 |
+ |
MemoryUtils::deletePointers(constraintPairs_); |
77 |
+ |
MemoryUtils::deletePointers(constraintElems_); |
78 |
|
|
79 |
< |
|
80 |
< |
Molecule::Molecule( void ){ |
81 |
< |
|
82 |
< |
myAtoms = NULL; |
83 |
< |
myBonds = NULL; |
13 |
< |
myBends = NULL; |
14 |
< |
myTorsions = NULL; |
15 |
< |
} |
16 |
< |
|
17 |
< |
Molecule::~Molecule( void ){ |
18 |
< |
int i; |
19 |
< |
CutoffGroup* cg; |
20 |
< |
vector<CutoffGroup*>::iterator iter; |
79 |
> |
// integrableObjects_ don't own the objects |
80 |
> |
integrableObjects_.clear(); |
81 |
> |
fluctuatingCharges_.clear(); |
82 |
> |
|
83 |
> |
} |
84 |
|
|
85 |
< |
if( myAtoms != NULL ){ |
86 |
< |
for(i=0; i<nAtoms; i++) if(myAtoms[i] != NULL ) delete myAtoms[i]; |
87 |
< |
delete[] myAtoms; |
85 |
> |
void Molecule::addAtom(Atom* atom) { |
86 |
> |
if (std::find(atoms_.begin(), atoms_.end(), atom) == atoms_.end()) { |
87 |
> |
atoms_.push_back(atom); |
88 |
> |
} |
89 |
|
} |
90 |
< |
|
91 |
< |
if( myBonds != NULL ){ |
92 |
< |
for(i=0; i<nBonds; i++) if(myBonds[i] != NULL ) delete myBonds[i]; |
93 |
< |
delete[] myBonds; |
90 |
> |
|
91 |
> |
void Molecule::addBond(Bond* bond) { |
92 |
> |
if (std::find(bonds_.begin(), bonds_.end(), bond) == bonds_.end()) { |
93 |
> |
bonds_.push_back(bond); |
94 |
> |
} |
95 |
|
} |
96 |
< |
|
97 |
< |
if( myBends != NULL ){ |
98 |
< |
for(i=0; i<nBends; i++) if(myBends[i] != NULL ) delete myBends[i]; |
99 |
< |
delete[] myBends; |
96 |
> |
|
97 |
> |
void Molecule::addBend(Bend* bend) { |
98 |
> |
if (std::find(bends_.begin(), bends_.end(), bend) == bends_.end()) { |
99 |
> |
bends_.push_back(bend); |
100 |
> |
} |
101 |
|
} |
102 |
< |
|
103 |
< |
if( myTorsions != NULL ){ |
104 |
< |
for(i=0; i<nTorsions; i++) if(myTorsions[i] != NULL ) delete myTorsions[i]; |
105 |
< |
delete[] myTorsions; |
102 |
> |
|
103 |
> |
void Molecule::addTorsion(Torsion* torsion) { |
104 |
> |
if (std::find(torsions_.begin(), torsions_.end(), torsion) == |
105 |
> |
torsions_.end()) { |
106 |
> |
torsions_.push_back(torsion); |
107 |
> |
} |
108 |
|
} |
109 |
|
|
110 |
< |
for(cg = beginCutoffGroup(iter); cg != NULL; cg = nextCutoffGroup(iter)) |
111 |
< |
delete cg; |
112 |
< |
myCutoffGroups.clear(); |
110 |
> |
void Molecule::addInversion(Inversion* inversion) { |
111 |
> |
if (std::find(inversions_.begin(), inversions_.end(), inversion) == |
112 |
> |
inversions_.end()) { |
113 |
> |
inversions_.push_back(inversion); |
114 |
> |
} |
115 |
> |
} |
116 |
|
|
117 |
< |
} |
118 |
< |
|
119 |
< |
|
120 |
< |
void Molecule::initialize( molInit &theInit ){ |
121 |
< |
|
122 |
< |
CutoffGroup* curCutoffGroup; |
52 |
< |
vector<CutoffGroup*>::iterator iterCutoff; |
53 |
< |
Atom* cutoffAtom; |
54 |
< |
vector<Atom*>::iterator iterAtom; |
55 |
< |
int atomIndex; |
117 |
> |
void Molecule::addRigidBody(RigidBody *rb) { |
118 |
> |
if (std::find(rigidBodies_.begin(), rigidBodies_.end(), rb) == |
119 |
> |
rigidBodies_.end()) { |
120 |
> |
rigidBodies_.push_back(rb); |
121 |
> |
} |
122 |
> |
} |
123 |
|
|
124 |
< |
nAtoms = theInit.nAtoms; |
125 |
< |
nMembers = nAtoms; |
126 |
< |
nBonds = theInit.nBonds; |
127 |
< |
nBends = theInit.nBends; |
128 |
< |
nTorsions = theInit.nTorsions; |
129 |
< |
nRigidBodies = theInit.nRigidBodies; |
130 |
< |
nOriented = theInit.nOriented; |
124 |
> |
void Molecule::addCutoffGroup(CutoffGroup* cp) { |
125 |
> |
if (std::find(cutoffGroups_.begin(), cutoffGroups_.end(), cp) == |
126 |
> |
cutoffGroups_.end()) { |
127 |
> |
cutoffGroups_.push_back(cp); |
128 |
> |
} |
129 |
> |
} |
130 |
> |
|
131 |
> |
void Molecule::addConstraintPair(ConstraintPair* cp) { |
132 |
> |
if (std::find(constraintPairs_.begin(), constraintPairs_.end(), cp) == |
133 |
> |
constraintPairs_.end()) { |
134 |
> |
constraintPairs_.push_back(cp); |
135 |
> |
} |
136 |
> |
} |
137 |
> |
|
138 |
> |
void Molecule::addConstraintElem(ConstraintElem* cp) { |
139 |
> |
if (std::find(constraintElems_.begin(), constraintElems_.end(), cp) == |
140 |
> |
constraintElems_.end()) { |
141 |
> |
constraintElems_.push_back(cp); |
142 |
> |
} |
143 |
> |
} |
144 |
> |
|
145 |
> |
void Molecule::complete() { |
146 |
> |
|
147 |
> |
std::set<Atom*> rigidAtoms; |
148 |
> |
Atom* atom; |
149 |
> |
Atom* atom1; |
150 |
> |
Atom* atom2; |
151 |
> |
AtomIterator ai, aj; |
152 |
> |
RigidBody* rb; |
153 |
> |
RigidBodyIterator rbIter; |
154 |
> |
Bond* bond; |
155 |
> |
BondIterator bi; |
156 |
|
|
157 |
< |
myAtoms = theInit.myAtoms; |
66 |
< |
myBonds = theInit.myBonds; |
67 |
< |
myBends = theInit.myBends; |
68 |
< |
myTorsions = theInit.myTorsions; |
69 |
< |
myRigidBodies = theInit.myRigidBodies; |
157 |
> |
// Get list of all the atoms that are part of rigid bodies |
158 |
|
|
159 |
< |
myIntegrableObjects = theInit.myIntegrableObjects; |
159 |
> |
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { |
160 |
> |
rigidAtoms.insert(rb->getBeginAtomIter(), rb->getEndAtomIter()); |
161 |
> |
} |
162 |
> |
|
163 |
> |
// add any atom that wasn't part of a rigid body to the list of integrableObjects |
164 |
|
|
165 |
< |
for (int i = 0; i < myRigidBodies.size(); i++) |
166 |
< |
myRigidBodies[i]->calcRefCoords(); |
165 |
> |
for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { |
166 |
> |
|
167 |
> |
if (rigidAtoms.find(atom) == rigidAtoms.end()) { |
168 |
|
|
169 |
< |
myCutoffGroups = theInit.myCutoffGroups; |
170 |
< |
nCutoffGroups = myCutoffGroups.size(); |
169 |
> |
// If an atom does not belong to a rigid body, it is an |
170 |
> |
// integrable object |
171 |
|
|
172 |
< |
} |
172 |
> |
integrableObjects_.push_back(atom); |
173 |
> |
} |
174 |
> |
} |
175 |
> |
|
176 |
> |
// then add the rigid bodies themselves to the integrableObjects |
177 |
|
|
178 |
< |
void Molecule::calcForces( void ){ |
179 |
< |
|
180 |
< |
int i; |
84 |
< |
double com[3]; |
178 |
> |
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { |
179 |
> |
integrableObjects_.push_back(rb); |
180 |
> |
} |
181 |
|
|
182 |
< |
for(i=0; i<myRigidBodies.size(); i++) { |
183 |
< |
myRigidBodies[i]->updateAtoms(); |
88 |
< |
} |
182 |
> |
// find the atoms that are fluctuating charges and add them to the |
183 |
> |
// fluctuatingCharges_ vector |
184 |
|
|
185 |
< |
for(i=0; i<nBonds; i++){ |
186 |
< |
myBonds[i]->calc_forces(); |
187 |
< |
} |
185 |
> |
for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { |
186 |
> |
if ( atom->isFluctuatingCharge() ) |
187 |
> |
fluctuatingCharges_.push_back( atom ); |
188 |
> |
} |
189 |
|
|
94 |
– |
for(i=0; i<nBends; i++){ |
95 |
– |
myBends[i]->calc_forces(); |
96 |
– |
} |
190 |
|
|
191 |
< |
for(i=0; i<nTorsions; i++){ |
192 |
< |
myTorsions[i]->calc_forces(); |
193 |
< |
} |
191 |
> |
// find the electronegative atoms and add them to the |
192 |
> |
// hBondAcceptors_ vector: |
193 |
> |
|
194 |
> |
for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { |
195 |
> |
AtomType* at = atom->getAtomType(); |
196 |
> |
// get the chain of base types for this atom type: |
197 |
> |
std::vector<AtomType*> ayb = at->allYourBase(); |
198 |
> |
// use the last type in the chain of base types for the name: |
199 |
> |
std::string bn = ayb[ayb.size()-1]->getName(); |
200 |
|
|
201 |
< |
// Rigid Body forces and torques are done after the fortran force loop |
201 |
> |
int obanum = etab.GetAtomicNum(bn.c_str()); |
202 |
> |
if (obanum != 0) { |
203 |
> |
RealType eneg = etab.GetElectroNeg(obanum); |
204 |
> |
if (eneg > 3.01) { |
205 |
> |
hBondAcceptors_.push_back( atom ); |
206 |
> |
} |
207 |
> |
} |
208 |
> |
} |
209 |
|
|
210 |
< |
} |
210 |
> |
// find electronegative atoms that are either bonded to hydrogens or are |
211 |
> |
// present in the same rigid bodies: |
212 |
> |
|
213 |
> |
for (bond = beginBond(bi); bond != NULL; bond = nextBond(bi)) { |
214 |
> |
Atom* atom1 = bond->getAtomA(); |
215 |
> |
Atom* atom2 = bond->getAtomB(); |
216 |
> |
AtomType* at1 = atom1->getAtomType(); |
217 |
> |
AtomType* at2 = atom1->getAtomType(); |
218 |
> |
// get the chain of base types for this atom type: |
219 |
> |
std::vector<AtomType*> ayb1 = at1->allYourBase(); |
220 |
> |
std::vector<AtomType*> ayb2 = at2->allYourBase(); |
221 |
> |
// use the last type in the chain of base types for the name: |
222 |
> |
std::string bn1 = ayb1[ayb1.size()-1]->getName(); |
223 |
> |
std::string bn2 = ayb2[ayb2.size()-1]->getName(); |
224 |
> |
int obanum1 = etab.GetAtomicNum(bn1.c_str()); |
225 |
> |
int obanum2 = etab.GetAtomicNum(bn2.c_str()); |
226 |
|
|
227 |
< |
|
228 |
< |
double Molecule::getPotential( void ){ |
229 |
< |
|
230 |
< |
int i; |
231 |
< |
double myPot = 0.0; |
227 |
> |
if (obanum1 == 1) { |
228 |
> |
if (obanum2 != 0) { |
229 |
> |
RealType eneg = etab.GetElectroNeg(obanum2); |
230 |
> |
if (eneg > 3.01) { |
231 |
> |
HBondDonor* donor = new HBondDonor(); |
232 |
> |
donor->donorAtom = atom2; |
233 |
> |
donor->donatedHydrogen = atom1; |
234 |
> |
hBondDonors_.push_back( donor ); |
235 |
> |
} |
236 |
> |
} |
237 |
> |
} |
238 |
> |
if (obanum2 == 1) { |
239 |
> |
if (obanum1 != 0) { |
240 |
> |
RealType eneg = etab.GetElectroNeg(obanum1); |
241 |
> |
if (eneg > 3.01) { |
242 |
> |
HBondDonor* donor = new HBondDonor(); |
243 |
> |
donor->donorAtom = atom1; |
244 |
> |
donor->donatedHydrogen = atom2; |
245 |
> |
hBondDonors_.push_back( donor ); |
246 |
> |
} |
247 |
> |
} |
248 |
> |
} |
249 |
> |
} |
250 |
|
|
251 |
< |
for(i=0; i<myRigidBodies.size(); i++) { |
252 |
< |
myRigidBodies[i]->updateAtoms(); |
251 |
> |
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { |
252 |
> |
for(atom1 = rb->beginAtom(ai); atom1 != NULL; atom1 = rb->nextAtom(ai)) { |
253 |
> |
AtomType* at1 = atom1->getAtomType(); |
254 |
> |
// get the chain of base types for this atom type: |
255 |
> |
std::vector<AtomType*> ayb1 = at1->allYourBase(); |
256 |
> |
// use the last type in the chain of base types for the name: |
257 |
> |
std::string bn1 = ayb1[ayb1.size()-1]->getName(); |
258 |
> |
int obanum1 = etab.GetAtomicNum(bn1.c_str()); |
259 |
> |
if (obanum1 != 0) { |
260 |
> |
RealType eneg = etab.GetElectroNeg(obanum1); |
261 |
> |
if (eneg > 3.01) { |
262 |
> |
for(atom2 = rb->beginAtom(aj); atom2 != NULL; |
263 |
> |
atom2 = rb->nextAtom(aj)) { |
264 |
> |
AtomType* at2 = atom2->getAtomType(); |
265 |
> |
// get the chain of base types for this atom type: |
266 |
> |
std::vector<AtomType*> ayb2 = at2->allYourBase(); |
267 |
> |
// use the last type in the chain of base types for the name: |
268 |
> |
std::string bn2 = ayb2[ayb2.size()-1]->getName(); |
269 |
> |
int obanum2 = etab.GetAtomicNum(bn2.c_str()); |
270 |
> |
if (obanum2 == 1) { |
271 |
> |
HBondDonor* donor = new HBondDonor(); |
272 |
> |
donor->donorAtom = atom1; |
273 |
> |
donor->donatedHydrogen = atom2; |
274 |
> |
hBondDonors_.push_back( donor ); |
275 |
> |
} |
276 |
> |
} |
277 |
> |
} |
278 |
> |
} |
279 |
> |
} |
280 |
> |
} |
281 |
|
} |
115 |
– |
|
116 |
– |
for(i=0; i<nBonds; i++){ |
117 |
– |
myPot += myBonds[i]->get_potential(); |
118 |
– |
} |
282 |
|
|
283 |
< |
for(i=0; i<nBends; i++){ |
284 |
< |
myPot += myBends[i]->get_potential(); |
283 |
> |
RealType Molecule::getMass() { |
284 |
> |
StuntDouble* sd; |
285 |
> |
std::vector<StuntDouble*>::iterator i; |
286 |
> |
RealType mass = 0.0; |
287 |
> |
|
288 |
> |
for (sd = beginIntegrableObject(i); sd != NULL; sd = |
289 |
> |
nextIntegrableObject(i)){ |
290 |
> |
mass += sd->getMass(); |
291 |
> |
} |
292 |
> |
|
293 |
> |
return mass; |
294 |
|
} |
295 |
|
|
296 |
< |
for(i=0; i<nTorsions; i++){ |
297 |
< |
myPot += myTorsions[i]->get_potential(); |
298 |
< |
} |
296 |
> |
Vector3d Molecule::getCom() { |
297 |
> |
StuntDouble* sd; |
298 |
> |
std::vector<StuntDouble*>::iterator i; |
299 |
> |
Vector3d com; |
300 |
> |
RealType totalMass = 0; |
301 |
> |
RealType mass; |
302 |
> |
|
303 |
> |
for (sd = beginIntegrableObject(i); sd != NULL; sd = |
304 |
> |
nextIntegrableObject(i)){ |
305 |
> |
mass = sd->getMass(); |
306 |
> |
totalMass += mass; |
307 |
> |
com += sd->getPos() * mass; |
308 |
> |
} |
309 |
> |
|
310 |
> |
com /= totalMass; |
311 |
|
|
312 |
< |
return myPot; |
313 |
< |
} |
130 |
< |
|
131 |
< |
void Molecule::printMe( void ){ |
312 |
> |
return com; |
313 |
> |
} |
314 |
|
|
315 |
< |
int i; |
315 |
> |
Vector3d Molecule::getCom(int snapshotNo) { |
316 |
> |
StuntDouble* sd; |
317 |
> |
std::vector<StuntDouble*>::iterator i; |
318 |
> |
Vector3d com; |
319 |
> |
RealType totalMass = 0; |
320 |
> |
RealType mass; |
321 |
> |
|
322 |
> |
for (sd = beginIntegrableObject(i); sd != NULL; sd = |
323 |
> |
nextIntegrableObject(i)){ |
324 |
> |
mass = sd->getMass(); |
325 |
> |
totalMass += mass; |
326 |
> |
com += sd->getPos(snapshotNo) * mass; |
327 |
> |
} |
328 |
> |
|
329 |
> |
com /= totalMass; |
330 |
|
|
331 |
< |
for(i=0; i<nBonds; i++){ |
136 |
< |
myBonds[i]->printMe(); |
331 |
> |
return com; |
332 |
|
} |
333 |
|
|
334 |
< |
for(i=0; i<nBends; i++){ |
335 |
< |
myBends[i]->printMe(); |
334 |
> |
void Molecule::moveCom(const Vector3d& delta) { |
335 |
> |
StuntDouble* sd; |
336 |
> |
std::vector<StuntDouble*>::iterator i; |
337 |
> |
|
338 |
> |
for (sd = beginIntegrableObject(i); sd != NULL; sd = |
339 |
> |
nextIntegrableObject(i)){ |
340 |
> |
sd->setPos(sd->getPos() + delta); |
341 |
> |
} |
342 |
|
} |
343 |
|
|
344 |
< |
for(i=0; i<nTorsions; i++){ |
345 |
< |
myTorsions[i]->printMe(); |
344 |
> |
Vector3d Molecule::getComVel() { |
345 |
> |
StuntDouble* sd; |
346 |
> |
std::vector<StuntDouble*>::iterator i; |
347 |
> |
Vector3d velCom; |
348 |
> |
RealType totalMass = 0; |
349 |
> |
RealType mass; |
350 |
> |
|
351 |
> |
for (sd = beginIntegrableObject(i); sd != NULL; sd = |
352 |
> |
nextIntegrableObject(i)){ |
353 |
> |
mass = sd->getMass(); |
354 |
> |
totalMass += mass; |
355 |
> |
velCom += sd->getVel() * mass; |
356 |
> |
} |
357 |
> |
|
358 |
> |
velCom /= totalMass; |
359 |
> |
|
360 |
> |
return velCom; |
361 |
|
} |
362 |
|
|
363 |
< |
} |
363 |
> |
RealType Molecule::getPotential() { |
364 |
|
|
365 |
< |
void Molecule::moveCOM(double delta[3]){ |
366 |
< |
double aPos[3]; |
367 |
< |
int i, j; |
365 |
> |
Bond* bond; |
366 |
> |
Bend* bend; |
367 |
> |
Torsion* torsion; |
368 |
> |
Inversion* inversion; |
369 |
> |
Molecule::BondIterator bondIter;; |
370 |
> |
Molecule::BendIterator bendIter; |
371 |
> |
Molecule::TorsionIterator torsionIter; |
372 |
> |
Molecule::InversionIterator inversionIter; |
373 |
|
|
374 |
< |
for(i=0; i<myIntegrableObjects.size(); i++) { |
154 |
< |
if(myIntegrableObjects[i] != NULL ) { |
155 |
< |
|
156 |
< |
myIntegrableObjects[i]->getPos( aPos ); |
157 |
< |
|
158 |
< |
for (j=0; j< 3; j++) |
159 |
< |
aPos[j] += delta[j]; |
374 |
> |
RealType potential = 0.0; |
375 |
|
|
376 |
< |
myIntegrableObjects[i]->setPos( aPos ); |
376 |
> |
for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) { |
377 |
> |
potential += bond->getPotential(); |
378 |
|
} |
163 |
– |
} |
379 |
|
|
380 |
< |
for(i=0; i<myRigidBodies.size(); i++) { |
380 |
> |
for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) { |
381 |
> |
potential += bend->getPotential(); |
382 |
> |
} |
383 |
|
|
384 |
< |
myRigidBodies[i]->getPos( aPos ); |
385 |
< |
|
386 |
< |
for (j=0; j< 3; j++) |
170 |
< |
aPos[j] += delta[j]; |
171 |
< |
|
172 |
< |
myRigidBodies[i]->setPos( aPos ); |
384 |
> |
for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = |
385 |
> |
nextTorsion(torsionIter)) { |
386 |
> |
potential += torsion->getPotential(); |
387 |
|
} |
388 |
< |
} |
388 |
> |
|
389 |
> |
for (inversion = beginInversion(inversionIter); torsion != NULL; |
390 |
> |
inversion = nextInversion(inversionIter)) { |
391 |
> |
potential += inversion->getPotential(); |
392 |
> |
} |
393 |
> |
|
394 |
> |
return potential; |
395 |
> |
|
396 |
> |
} |
397 |
> |
|
398 |
> |
void Molecule::addProperty(GenericData* genData) { |
399 |
> |
properties_.addProperty(genData); |
400 |
> |
} |
401 |
|
|
402 |
< |
void Molecule::atoms2rigidBodies( void ) { |
403 |
< |
int i; |
178 |
< |
for (i = 0; i < myRigidBodies.size(); i++) { |
179 |
< |
myRigidBodies[i]->calcForcesAndTorques(); |
402 |
> |
void Molecule::removeProperty(const std::string& propName) { |
403 |
> |
properties_.removeProperty(propName); |
404 |
|
} |
181 |
– |
} |
405 |
|
|
406 |
< |
void Molecule::getCOM( double COM[3] ) { |
406 |
> |
void Molecule::clearProperties() { |
407 |
> |
properties_.clearProperties(); |
408 |
> |
} |
409 |
|
|
410 |
< |
double mass, mtot; |
411 |
< |
double aPos[3]; |
412 |
< |
int i, j; |
188 |
< |
|
189 |
< |
for (j=0; j<3; j++) |
190 |
< |
COM[j] = 0.0; |
191 |
< |
|
192 |
< |
mtot = 0.0; |
193 |
< |
|
194 |
< |
for (i=0; i < myIntegrableObjects.size(); i++) { |
195 |
< |
if (myIntegrableObjects[i] != NULL) { |
196 |
< |
|
197 |
< |
mass = myIntegrableObjects[i]->getMass(); |
198 |
< |
mtot += mass; |
410 |
> |
std::vector<std::string> Molecule::getPropertyNames() { |
411 |
> |
return properties_.getPropertyNames(); |
412 |
> |
} |
413 |
|
|
414 |
< |
myIntegrableObjects[i]->getPos( aPos ); |
415 |
< |
|
202 |
< |
for( j = 0; j < 3; j++) |
203 |
< |
COM[j] += aPos[j] * mass; |
204 |
< |
|
205 |
< |
} |
414 |
> |
std::vector<GenericData*> Molecule::getProperties() { |
415 |
> |
return properties_.getProperties(); |
416 |
|
} |
417 |
|
|
418 |
< |
for (j = 0; j < 3; j++) |
419 |
< |
COM[j] /= mtot; |
210 |
< |
} |
211 |
< |
|
212 |
< |
double Molecule::getCOMvel( double COMvel[3] ) { |
213 |
< |
|
214 |
< |
double mass, mtot; |
215 |
< |
double aVel[3]; |
216 |
< |
int i, j; |
217 |
< |
|
218 |
< |
|
219 |
< |
for (j=0; j<3; j++) |
220 |
< |
COMvel[j] = 0.0; |
221 |
< |
|
222 |
< |
mtot = 0.0; |
223 |
< |
|
224 |
< |
for (i=0; i < myIntegrableObjects.size(); i++) { |
225 |
< |
if (myIntegrableObjects[i] != NULL) { |
226 |
< |
|
227 |
< |
mass = myIntegrableObjects[i]->getMass(); |
228 |
< |
mtot += mass; |
229 |
< |
|
230 |
< |
myIntegrableObjects[i]->getVel(aVel); |
231 |
< |
|
232 |
< |
for (j=0; j<3; j++) |
233 |
< |
COMvel[j] += aVel[j]*mass; |
234 |
< |
|
235 |
< |
} |
418 |
> |
GenericData* Molecule::getPropertyByName(const std::string& propName) { |
419 |
> |
return properties_.getPropertyByName(propName); |
420 |
|
} |
421 |
|
|
422 |
< |
for (j=0; j<3; j++) |
423 |
< |
COMvel[j] /= mtot; |
424 |
< |
|
425 |
< |
return mtot; |
426 |
< |
|
427 |
< |
} |
428 |
< |
|
429 |
< |
double Molecule::getTotalMass() |
430 |
< |
{ |
431 |
< |
|
432 |
< |
double totalMass; |
433 |
< |
|
434 |
< |
totalMass = 0; |
435 |
< |
for(int i =0; i < myIntegrableObjects.size(); i++){ |
252 |
< |
totalMass += myIntegrableObjects[i]->getMass(); |
422 |
> |
std::ostream& operator <<(std::ostream& o, Molecule& mol) { |
423 |
> |
o << std::endl; |
424 |
> |
o << "Molecule " << mol.getGlobalIndex() << "has: " << std::endl; |
425 |
> |
o << mol.getNAtoms() << " atoms" << std::endl; |
426 |
> |
o << mol.getNBonds() << " bonds" << std::endl; |
427 |
> |
o << mol.getNBends() << " bends" << std::endl; |
428 |
> |
o << mol.getNTorsions() << " torsions" << std::endl; |
429 |
> |
o << mol.getNInversions() << " inversions" << std::endl; |
430 |
> |
o << mol.getNRigidBodies() << " rigid bodies" << std::endl; |
431 |
> |
o << mol.getNIntegrableObjects() << " integrable objects" << std::endl; |
432 |
> |
o << mol.getNCutoffGroups() << " cutoff groups" << std::endl; |
433 |
> |
o << mol.getNConstraintPairs() << " constraint pairs" << std::endl; |
434 |
> |
o << mol.getNFluctuatingCharges() << " fluctuating charges" << std::endl; |
435 |
> |
return o; |
436 |
|
} |
437 |
< |
|
438 |
< |
return totalMass; |
256 |
< |
} |
437 |
> |
|
438 |
> |
}//end namespace OpenMD |