ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Molecule.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Molecule.cpp (file contents):
Revision 428 by mmeineke, Thu Mar 27 21:07:14 2003 UTC vs.
Revision 450 by mmeineke, Thu Apr 3 21:12:51 2003 UTC

# Line 2 | Line 2
2  
3  
4   #include "Molecule.hpp"
5 + #include "simError.h"
6  
7  
8  
# Line 101 | Line 102 | double Molecule::getPotential( void ){
102  
103    return myPot;
104   }
105 +
106 + void Molecule::printMe( void ){
107 +  
108 +  int i;
109 +
110 +  for(i=0; i<nBonds; i++){
111 +    myBonds[i]->printMe();
112 +  }
113 +
114 +  for(i=0; i<nBends; i++){
115 +    myBends[i]->printMe();
116 +  }
117 +
118 +  for(i=0; i<nTorsions; i++){
119 +    myTorsions[i]->printMe();
120 +  }
121 + }
122 +
123 + void Molecule::moveCOM(double delta[3]){
124 +  double x, y, z;
125 +  int i;
126 +
127 +  for(i=0; i<nAtoms; i++) {
128 +    if(myAtoms[i] != NULL ) {
129 +
130 +      x = myAtoms[i]->getX() + delta[0];
131 +      y = myAtoms[i]->getY() + delta[1];
132 +      z = myAtoms[i]->getZ() + delta[2];
133 +
134 +      myAtoms[i]->setX(x);
135 +      myAtoms[i]->setY(y);
136 +      myAtoms[i]->setZ(z);
137 +    }
138 +  }
139 + }
140 +
141 + void Molecule::getCOM( double COM[3] ) {
142 +
143 +  double mass, mtot;
144 +  int i;
145 +
146 +  COM[0] = 0.0;
147 +  COM[1] = 0.0;
148 +  COM[2] = 0.0;
149 +  mtot   = 0.0;
150 +
151 +  for (i=0; i < nAtoms; i++) {
152 +    if (myAtoms[i] != NULL) {
153 +
154 +      mass = myAtoms[i]->getMass();
155 +      mtot   += mass;
156 +      COM[0] += myAtoms[i]->getX() * mass;
157 +      COM[1] += myAtoms[i]->getY() * mass;
158 +      COM[2] += myAtoms[i]->getZ() * mass;
159 +
160 +    }
161 +  }
162 +
163 +  COM[0] /= mtot;
164 +  COM[1] /= mtot;
165 +  COM[2] /= mtot;
166 +
167 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines