| 12 |
|
myBonds = NULL; |
| 13 |
|
myBends = NULL; |
| 14 |
|
myTorsions = NULL; |
| 15 |
– |
hasMassRatio = false; |
| 15 |
|
} |
| 16 |
|
|
| 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]; |
| 39 |
|
delete[] myTorsions; |
| 40 |
|
} |
| 41 |
|
|
| 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 |
+ |
GenericData* gdata; |
| 57 |
+ |
ConsRbData* rbData; |
| 58 |
+ |
RigidBody* oldRb; |
| 59 |
+ |
|
| 60 |
|
nAtoms = theInit.nAtoms; |
| 61 |
|
nMembers = nAtoms; |
| 62 |
|
nBonds = theInit.nBonds; |
| 73 |
|
|
| 74 |
|
myIntegrableObjects = theInit.myIntegrableObjects; |
| 75 |
|
|
| 76 |
< |
for (int i = 0; i < myRigidBodies.size(); i++) |
| 76 |
> |
for (int i = 0; i < myRigidBodies.size(); i++){ |
| 77 |
|
myRigidBodies[i]->calcRefCoords(); |
| 78 |
+ |
//just a quick hack |
| 79 |
+ |
|
| 80 |
+ |
gdata = myRigidBodies[i]->getProperty("OldState"); |
| 81 |
+ |
if(gdata != NULL){ |
| 82 |
+ |
rbData = dynamic_cast<ConsRbData*>(gdata); |
| 83 |
+ |
if(rbData ==NULL) |
| 84 |
+ |
cerr << "dynamic_cast to ConsRbData Error in Molecule::initialize()" << endl; |
| 85 |
+ |
else{ |
| 86 |
+ |
oldRb = rbData->getData(); |
| 87 |
+ |
oldRb->calcRefCoords(); |
| 88 |
+ |
} |
| 89 |
+ |
}//end if(gata != NULL) |
| 90 |
+ |
|
| 91 |
+ |
}//end for(int i = 0; i < myRigidBodies.size(); i++) |
| 92 |
|
|
| 93 |
+ |
myCutoffGroups = theInit.myCutoffGroups; |
| 94 |
+ |
nCutoffGroups = myCutoffGroups.size(); |
| 95 |
+ |
|
| 96 |
+ |
myConstraintPairs = theInit.myConstraintPairs; |
| 97 |
+ |
|
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
void Molecule::calcForces( void ){ |
| 106 |
|
myRigidBodies[i]->updateAtoms(); |
| 107 |
|
} |
| 108 |
|
|
| 76 |
– |
//the mass ratio will never change during the simulation. Thus, we could |
| 77 |
– |
//just calculate it at the begining of the simulation |
| 78 |
– |
if (!hasMassRatio){ |
| 79 |
– |
double totMass = getTotalMass(); |
| 80 |
– |
for(int i = 0; i < nAtoms; i ++) |
| 81 |
– |
myAtoms[i]->setMassRatio(myAtoms[i]->getMass()/totMass); |
| 82 |
– |
hasMassRatio = true; |
| 83 |
– |
} |
| 84 |
– |
|
| 109 |
|
//calculate the center of mass of the molecule |
| 110 |
< |
getCOM(com); |
| 111 |
< |
for(int i = 0; i < nAtoms; i ++) |
| 112 |
< |
myAtoms[i]->setRc(com); |
| 110 |
> |
//getCOM(com); |
| 111 |
> |
//for(int i = 0; i < nAtoms; i ++) |
| 112 |
> |
// myAtoms[i]->setRc(com); |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
for(i=0; i<nBonds; i++){ |