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 1097 by gezelter, Mon Apr 12 20:32:20 2004 UTC vs.
Revision 1167 by tim, Wed May 12 16:38:45 2004 UTC

# Line 12 | Line 12 | Molecule::Molecule( void ){
12    myBonds = NULL;
13    myBends = NULL;
14    myTorsions = NULL;
15  myRigidBodies = NULL;
16
15   }
16  
19
20
17   Molecule::~Molecule( void ){
18    int i;
19 +  CutoffGroup* cg;
20 +  vector<CutoffGroup*>::iterator iter;
21    
22    if( myAtoms != NULL ){
23      for(i=0; i<nAtoms; i++) if(myAtoms[i] != NULL ) delete myAtoms[i];
# Line 41 | Line 39 | Molecule::~Molecule( void ){
39      delete[] myTorsions;
40    }
41  
42 <  if( myRigidBodies != NULL ){
43 <    for(i=0; i<nRigidBodies; i++) if(myRigidBodies[i] != NULL )
44 <      delete myRigidBodies[i];
47 <    delete[] myRigidBodies;
48 <  }
42 >  for(cg = beginCutoffGroup(iter);  cg != NULL; cg = nextCutoffGroup(iter))
43 >    delete cg;
44 >  myCutoffGroups.clear();
45    
46   }
47  
48  
49   void Molecule::initialize( molInit &theInit ){
50  
51 +  CutoffGroup* curCutoffGroup;
52 +  vector<CutoffGroup*>::iterator iterCutoff;
53 +  Atom* cutoffAtom;
54 +  vector<Atom*>::iterator iterAtom;
55 +  int atomIndex;
56 +  
57    nAtoms = theInit.nAtoms;
58    nMembers = nAtoms;
59    nBonds = theInit.nBonds;
# Line 65 | Line 67 | void Molecule::initialize( molInit &theInit ){
67    myBends = theInit.myBends;
68    myTorsions = theInit.myTorsions;
69    myRigidBodies = theInit.myRigidBodies;
70 <    
70 >
71 >  myIntegrableObjects = theInit.myIntegrableObjects;
72 >
73 >  for (int i = 0; i < myRigidBodies.size(); i++)
74 >      myRigidBodies[i]->calcRefCoords();
75 >
76 >  myCutoffGroups = theInit.myCutoffGroups;
77 >  nCutoffGroups = myCutoffGroups.size();
78 >  
79   }
80  
81   void Molecule::calcForces( void ){
82    
83    int i;
84 +  double com[3];
85  
86 <  for(i=0; i<nRigidBodies; i++) {
86 >  for(i=0; i<myRigidBodies.size(); i++) {
87      myRigidBodies[i]->updateAtoms();
88    }
89  
90 +  //calculate the center of mass of the molecule
91 +  //getCOM(com);  
92 +  //for(int i = 0; i < nAtoms; i ++)
93 +  //  myAtoms[i]->setRc(com);  
94 +  
95 +
96    for(i=0; i<nBonds; i++){
97      myBonds[i]->calc_forces();
98    }
# Line 97 | Line 114 | double Molecule::getPotential( void ){
114    
115    int i;
116    double myPot = 0.0;
117 +
118 +  for(i=0; i<myRigidBodies.size(); i++) {
119 +    myRigidBodies[i]->updateAtoms();
120 +  }
121    
122    for(i=0; i<nBonds; i++){
123      myPot += myBonds[i]->get_potential();
# Line 135 | Line 156 | void Molecule::moveCOM(double delta[3]){
156    double aPos[3];
157    int i, j;
158  
159 <  for(i=0; i<nAtoms; i++) {
160 <    if(myAtoms[i] != NULL ) {
159 >  for(i=0; i<myIntegrableObjects.size(); i++) {
160 >    if(myIntegrableObjects[i] != NULL ) {
161        
162 <      myAtoms[i]->getPos( aPos );
162 >      myIntegrableObjects[i]->getPos( aPos );
163        
164        for (j=0; j< 3; j++)
165          aPos[j] += delta[j];
166  
167 <      myAtoms[i]->setPos( aPos );
167 >      myIntegrableObjects[i]->setPos( aPos );
168      }
169    }
170  
171 <  for(i=0; i<nRigidBodies; i++) {
171 >  for(i=0; i<myRigidBodies.size(); i++) {
172  
152    if (myRigidBodies[i] != NULL) {
153      
173        myRigidBodies[i]->getPos( aPos );
174  
175        for (j=0; j< 3; j++)
# Line 158 | Line 177 | void Molecule::moveCOM(double delta[3]){
177        
178        myRigidBodies[i]->setPos( aPos );
179      }
161  }  
180   }
181  
182   void Molecule::atoms2rigidBodies( void ) {
183    int i;
184 <  for (i = 0; i < nRigidBodies; i++) {
185 <    if (myRigidBodies[i] != NULL) {
168 <      myRigidBodies[i]->calcForcesAndTorques();  
169 <    }
184 >  for (i = 0; i < myRigidBodies.size(); i++) {
185 >    myRigidBodies[i]->calcForcesAndTorques();  
186    }
187   }
188  
# Line 181 | Line 197 | void Molecule::getCOM( double COM[3] ) {
197  
198    mtot   = 0.0;
199  
200 <  for (i=0; i < nAtoms; i++) {
201 <    if (myAtoms[i] != NULL) {
200 >  for (i=0; i < myIntegrableObjects.size(); i++) {
201 >    if (myIntegrableObjects[i] != NULL) {
202  
203 <      mass = myAtoms[i]->getMass();
203 >      mass = myIntegrableObjects[i]->getMass();
204        mtot   += mass;
205        
206 <      myAtoms[i]->getPos( aPos );
206 >      myIntegrableObjects[i]->getPos( aPos );
207  
208        for( j = 0; j < 3; j++)
209          COM[j] += aPos[j] * mass;
# Line 211 | Line 227 | double Molecule::getCOMvel( double COMvel[3] ) {
227  
228    mtot   = 0.0;
229  
230 <  for (i=0; i < nAtoms; i++) {
231 <    if (myAtoms[i] != NULL) {
230 >  for (i=0; i < myIntegrableObjects.size(); i++) {
231 >    if (myIntegrableObjects[i] != NULL) {
232  
233 <      mass = myAtoms[i]->getMass();
233 >      mass = myIntegrableObjects[i]->getMass();
234        mtot   += mass;
235  
236 <      myAtoms[i]->getVel(aVel);
236 >      myIntegrableObjects[i]->getVel(aVel);
237  
238        for (j=0; j<3; j++)
239          COMvel[j] += aVel[j]*mass;
# Line 234 | Line 250 | double Molecule::getTotalMass()
250  
251   double Molecule::getTotalMass()
252   {
253 <  int natoms;
238 <  Atom** atoms;
253 >
254    double totalMass;
255    
241  natoms = getNAtoms();
242  atoms = getMyAtoms();
256    totalMass = 0;
257 <  for(int i =0; i < natoms; i++){
258 <    totalMass += atoms[i]->getMass();
257 >  for(int i =0; i < myIntegrableObjects.size(); i++){
258 >    totalMass += myIntegrableObjects[i]->getMass();
259    }
260  
261    return totalMass;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines