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 1109 by gezelter, Wed Apr 14 16:32:15 2004 UTC vs.
Revision 1158 by tim, Tue May 11 21:14:26 2004 UTC

# Line 12 | Line 12 | Molecule::Molecule( void ){
12    myBonds = NULL;
13    myBends = NULL;
14    myTorsions = NULL;
15
15   }
16  
17   Molecule::~Molecule( void ){
# Line 43 | Line 42 | void Molecule::initialize( molInit &theInit ){
42  
43   void Molecule::initialize( molInit &theInit ){
44  
45 +  CutoffGroup* curCutoffGroup;
46 +  vector<CutoffGroup*>::iterator iterCutoff;
47 +  Atom* cutoffAtom;
48 +  vector<Atom*>::iterator iterAtom;
49 +  int atomIndex;
50 +  
51    nAtoms = theInit.nAtoms;
52    nMembers = nAtoms;
53    nBonds = theInit.nBonds;
# Line 50 | Line 55 | void Molecule::initialize( molInit &theInit ){
55    nTorsions = theInit.nTorsions;
56    nRigidBodies = theInit.nRigidBodies;
57    nOriented = theInit.nOriented;
58 +  nCutoffGroups = theInit.nCutoffGroups;
59  
60    myAtoms = theInit.myAtoms;
61    myBonds = theInit.myBonds;
# Line 58 | Line 64 | void Molecule::initialize( molInit &theInit ){
64    myRigidBodies = theInit.myRigidBodies;
65  
66    myIntegrableObjects = theInit.myIntegrableObjects;
67 <    
67 >
68 >  for (int i = 0; i < myRigidBodies.size(); i++)
69 >      myRigidBodies[i]->calcRefCoords();
70 >
71 >  myCutoffGroups = theInit.myCutoffGroups;
72 >
73 >  //creat a global index set of atoms which belong to cutoff group.
74 >  //it will be use to speed up the query whether an atom belongs to cutoff group or not
75 >  cutoffAtomSet.clear();
76 >
77 >  for(curCutoffGroup = beginCutoffGroup(iterCutoff); curCutoffGroup != NULL;
78 >                                                  curCutoffGroup = nextCutoffGroup(iterCutoff)){
79 >
80 >      for(cutoffAtom = curCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL;
81 >                                           cutoffAtom = curCutoffGroup->nextAtom(iterAtom)){
82 > #ifdef IS_MPI
83 >        atomIndex = cutoffAtom->getGlobalIndex();
84 > #else
85 >        atomIndex = cutoffAtom->getIndex();
86 > #endif
87 >        cutoffAtomSet.insert(atomIndex);
88 >     }// end for(cutoffAtom)    
89 >  }//end for(curCutoffGroup)
90 >  
91   }
92  
93   void Molecule::calcForces( void ){
94    
95    int i;
96 +  double com[3];
97  
98    for(i=0; i<myRigidBodies.size(); i++) {
99      myRigidBodies[i]->updateAtoms();
100    }
101  
102 +  //calculate the center of mass of the molecule
103 +  //getCOM(com);  
104 +  //for(int i = 0; i < nAtoms; i ++)
105 +  //  myAtoms[i]->setRc(com);  
106 +  
107 +
108    for(i=0; i<nBonds; i++){
109      myBonds[i]->calc_forces();
110    }
# Line 132 | Line 168 | void Molecule::moveCOM(double delta[3]){
168    double aPos[3];
169    int i, j;
170  
171 <  for(i=0; i<nAtoms; i++) {
172 <    if(myAtoms[i] != NULL ) {
171 >  for(i=0; i<myIntegrableObjects.size(); i++) {
172 >    if(myIntegrableObjects[i] != NULL ) {
173        
174 <      myAtoms[i]->getPos( aPos );
174 >      myIntegrableObjects[i]->getPos( aPos );
175        
176        for (j=0; j< 3; j++)
177          aPos[j] += delta[j];
178  
179 <      myAtoms[i]->setPos( aPos );
179 >      myIntegrableObjects[i]->setPos( aPos );
180      }
181    }
182  
# Line 173 | Line 209 | void Molecule::getCOM( double COM[3] ) {
209  
210    mtot   = 0.0;
211  
212 <  for (i=0; i < nAtoms; i++) {
213 <    if (myAtoms[i] != NULL) {
212 >  for (i=0; i < myIntegrableObjects.size(); i++) {
213 >    if (myIntegrableObjects[i] != NULL) {
214  
215 <      mass = myAtoms[i]->getMass();
215 >      mass = myIntegrableObjects[i]->getMass();
216        mtot   += mass;
217        
218 <      myAtoms[i]->getPos( aPos );
218 >      myIntegrableObjects[i]->getPos( aPos );
219  
220        for( j = 0; j < 3; j++)
221          COM[j] += aPos[j] * mass;
# Line 203 | Line 239 | double Molecule::getCOMvel( double COMvel[3] ) {
239  
240    mtot   = 0.0;
241  
242 <  for (i=0; i < nAtoms; i++) {
243 <    if (myAtoms[i] != NULL) {
242 >  for (i=0; i < myIntegrableObjects.size(); i++) {
243 >    if (myIntegrableObjects[i] != NULL) {
244  
245 <      mass = myAtoms[i]->getMass();
245 >      mass = myIntegrableObjects[i]->getMass();
246        mtot   += mass;
247  
248 <      myAtoms[i]->getVel(aVel);
248 >      myIntegrableObjects[i]->getVel(aVel);
249  
250        for (j=0; j<3; j++)
251          COMvel[j] += aVel[j]*mass;
# Line 226 | Line 262 | double Molecule::getTotalMass()
262  
263   double Molecule::getTotalMass()
264   {
265 <  int natoms;
230 <  Atom** atoms;
265 >
266    double totalMass;
267    
233  natoms = getNAtoms();
234  atoms = getMyAtoms();
268    totalMass = 0;
269 <  for(int i =0; i < natoms; i++){
270 <    totalMass += atoms[i]->getMass();
269 >  for(int i =0; i < myIntegrableObjects.size(); i++){
270 >    totalMass += myIntegrableObjects[i]->getMass();
271    }
272  
273    return totalMass;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines