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 829 by gezelter, Tue Oct 28 16:03:37 2003 UTC vs.
Revision 1113 by tim, Thu Apr 15 16:18:26 2004 UTC

# Line 15 | Line 15 | Molecule::Molecule( void ){
15  
16   }
17  
18
19
18   Molecule::~Molecule( void ){
19    int i;
20    
# Line 40 | Line 38 | Molecule::~Molecule( void ){
38      delete[] myTorsions;
39    }
40  
43  if( myExcludes != NULL ){
44    for(i=0; i<nExcludes; i++) if(myExcludes[i] != NULL ) delete myExcludes[i];
45    delete[] myExcludes;
46  }
41   }
42  
43  
# Line 54 | Line 48 | void Molecule::initialize( molInit &theInit ){
48    nBonds = theInit.nBonds;
49    nBends = theInit.nBends;
50    nTorsions = theInit.nTorsions;
51 <  nExcludes = theInit.nExcludes;
51 >  nRigidBodies = theInit.nRigidBodies;
52    nOriented = theInit.nOriented;
53  
54    myAtoms = theInit.myAtoms;
55    myBonds = theInit.myBonds;
56    myBends = theInit.myBends;
57    myTorsions = theInit.myTorsions;
58 <  myExcludes = theInit.myExcludes;
58 >  myRigidBodies = theInit.myRigidBodies;
59 >
60 >  myIntegrableObjects = theInit.myIntegrableObjects;
61 >
62 >  for (int i = 0; i < myRigidBodies.size(); i++)
63 >      myRigidBodies[i]->calcRefCoords();
64      
65   }
66  
# Line 69 | Line 68 | void Molecule::calcForces( void ){
68    
69    int i;
70  
71 +  for(i=0; i<myRigidBodies.size(); i++) {
72 +    myRigidBodies[i]->updateAtoms();
73 +  }
74 +
75    for(i=0; i<nBonds; i++){
76      myBonds[i]->calc_forces();
77    }
# Line 80 | Line 83 | void Molecule::calcForces( void ){
83    for(i=0; i<nTorsions; i++){
84      myTorsions[i]->calc_forces();
85    }
86 +
87 +  // Rigid Body forces and torques are done after the fortran force loop
88 +
89   }
90  
91  
# Line 87 | Line 93 | double Molecule::getPotential( void ){
93    
94    int i;
95    double myPot = 0.0;
96 +
97 +  for(i=0; i<myRigidBodies.size(); i++) {
98 +    myRigidBodies[i]->updateAtoms();
99 +  }
100    
101    for(i=0; i<nBonds; i++){
102      myPot += myBonds[i]->get_potential();
# Line 118 | Line 128 | void Molecule::printMe( void ){
128    for(i=0; i<nTorsions; i++){
129      myTorsions[i]->printMe();
130    }
131 +
132   }
133  
134   void Molecule::moveCOM(double delta[3]){
135    double aPos[3];
136    int i, j;
137  
138 <  for(i=0; i<nAtoms; i++) {
139 <    if(myAtoms[i] != NULL ) {
138 >  for(i=0; i<myIntegrableObjects.size(); i++) {
139 >    if(myIntegrableObjects[i] != NULL ) {
140        
141 <      myAtoms[i]->getPos( aPos );
141 >      myIntegrableObjects[i]->getPos( aPos );
142        
143        for (j=0; j< 3; j++)
144          aPos[j] += delta[j];
145  
146 <      myAtoms[i]->setPos( aPos );
146 >      myIntegrableObjects[i]->setPos( aPos );
147      }
148    }
149 +
150 +  for(i=0; i<myRigidBodies.size(); i++) {
151 +
152 +      myRigidBodies[i]->getPos( aPos );
153 +
154 +      for (j=0; j< 3; j++)
155 +        aPos[j] += delta[j];
156 +      
157 +      myRigidBodies[i]->setPos( aPos );
158 +    }
159   }
160  
161 + void Molecule::atoms2rigidBodies( void ) {
162 +  int i;
163 +  for (i = 0; i < myRigidBodies.size(); i++) {
164 +    myRigidBodies[i]->calcForcesAndTorques();  
165 +  }
166 + }
167 +
168   void Molecule::getCOM( double COM[3] ) {
169  
170    double mass, mtot;
# Line 148 | Line 176 | void Molecule::getCOM( double COM[3] ) {
176  
177    mtot   = 0.0;
178  
179 <  for (i=0; i < nAtoms; i++) {
180 <    if (myAtoms[i] != NULL) {
179 >  for (i=0; i < myIntegrableObjects.size(); i++) {
180 >    if (myIntegrableObjects[i] != NULL) {
181  
182 <      mass = myAtoms[i]->getMass();
182 >      mass = myIntegrableObjects[i]->getMass();
183        mtot   += mass;
184        
185 <      myAtoms[i]->getPos( aPos );
185 >      myIntegrableObjects[i]->getPos( aPos );
186  
187        for( j = 0; j < 3; j++)
188          COM[j] += aPos[j] * mass;
# Line 178 | Line 206 | double Molecule::getCOMvel( double COMvel[3] ) {
206  
207    mtot   = 0.0;
208  
209 <  for (i=0; i < nAtoms; i++) {
210 <    if (myAtoms[i] != NULL) {
209 >  for (i=0; i < myIntegrableObjects.size(); i++) {
210 >    if (myIntegrableObjects[i] != NULL) {
211  
212 <      mass = myAtoms[i]->getMass();
212 >      mass = myIntegrableObjects[i]->getMass();
213        mtot   += mass;
214  
215 <      myAtoms[i]->getVel(aVel);
215 >      myIntegrableObjects[i]->getVel(aVel);
216  
217        for (j=0; j<3; j++)
218          COMvel[j] += aVel[j]*mass;
# Line 201 | Line 229 | double Molecule::getTotalMass()
229  
230   double Molecule::getTotalMass()
231   {
232 <  int natoms;
205 <  Atom** atoms;
232 >
233    double totalMass;
234    
208  natoms = getNAtoms();
209  atoms = getMyAtoms();
235    totalMass = 0;
236 <  for(int i =0; i < natoms; i++){
237 <    totalMass += atoms[i]->getMass();
236 >  for(int i =0; i < myIntegrableObjects.size(); i++){
237 >    totalMass += myIntegrableObjects[i]->getMass();
238    }
239  
240    return totalMass;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines