164 |
|
COM[1] /= mtot; |
165 |
|
COM[2] /= mtot; |
166 |
|
|
167 |
– |
return COM; |
167 |
|
} |
168 |
+ |
|
169 |
+ |
double Molecule::getCOMvel( double COMvel[3] ) { |
170 |
+ |
|
171 |
+ |
double mass, mtot; |
172 |
+ |
double aVel[3]; |
173 |
+ |
int i, j; |
174 |
+ |
|
175 |
+ |
|
176 |
+ |
for (j=0; j<3; j++) |
177 |
+ |
COMvel[j] = 0.0; |
178 |
+ |
|
179 |
+ |
mtot = 0.0; |
180 |
+ |
|
181 |
+ |
for (i=0; i < nAtoms; i++) { |
182 |
+ |
if (myAtoms[i] != NULL) { |
183 |
+ |
|
184 |
+ |
mass = myAtoms[i]->getMass(); |
185 |
+ |
mtot += mass; |
186 |
+ |
|
187 |
+ |
myAtoms[i]->getVel(aVel); |
188 |
+ |
|
189 |
+ |
for (j=0; j<3; j++) |
190 |
+ |
COMvel[j] += aVel[j]*mass; |
191 |
+ |
|
192 |
+ |
} |
193 |
+ |
} |
194 |
+ |
|
195 |
+ |
for (j=0; j<3; j++) |
196 |
+ |
COMvel[j] /= mtot; |
197 |
+ |
|
198 |
+ |
return mtot; |
199 |
+ |
|
200 |
+ |
} |