ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/applications/simpleBuilder/MoLocator.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/applications/simpleBuilder/MoLocator.cpp (file contents):
Revision 1902 by tim, Thu Dec 2 05:04:20 2004 UTC vs.
Revision 1903 by tim, Thu Jan 6 00:16:07 2005 UTC

# Line 5 | Line 5
5  
6   #include "utils/simError.h"
7   #include "applications/simpleBuilder/MoLocator.hpp"
8 < #include "math/MatVec3.h"
8 > #include "types/AtomType.hpp"
9 > namespace oopse {
10 > MoLocator::MoLocator( MoleculeStamp* theStamp, ForceField* theFF){
11  
10 MoLocator::MoLocator( MoleculeStamp* theStamp, ForceFields* theFF){
11
12    myStamp = theStamp;
13    myFF = theFF;
14    nIntegrableObjects = myStamp->getNIntegrable();
15 <  calcRefCoords();
15 >  calcRef();
16   }
17  
18   void MoLocator::placeMol( const Vector3d& offset, const Vector3d& ort, Molecule* mol){
19 <  double newCoor[3];
20 <  double curRefCoor[3];
21 <  double zeroVector[3];
22 <   std::vector<StuntDouble*> myIntegrableObjects;
23 <  double rotMat[3][3];
19 >    Vector3d newCoor;
20 >    Vector3d curRefCoor;  
21 >    RotMat3x3d rotMat = latVec2RotMat(ort);
22    
23 <  zeroVector[0] = 0.0;
24 <  zeroVector[1] = 0.0;
25 <  zeroVector[2] = 0.0;
26 <  
27 <  latVec2RotMat(ort, rotMat);
28 <  
29 <  myIntegrableObjects = mol->getIntegrableObjects();
23 >    if(mol->getNIntegrableObjects() != nIntegrableObjects){
24 >        sprintf( painCave.errMsg,
25 >            "MoLocator error.\n"
26 >            "  The number of integrable objects of MoleculeStamp is not the same as  that of Molecule\n");
27 >        painCave.isFatal = 1;
28 >        simError();
29 >    }
30  
31 <  if(myIntegrableObjects.size() != nIntegrableObjects){
32 <      sprintf( painCave.errMsg,
33 <               "MoLocator error.\n"
34 <               "  The number of integrable objects of MoleculeStamp is not the same as  that of Molecule\n");
35 <          painCave.isFatal = 1;
38 <      simError();
31 >    Molecule::IntegrableObjectIterator ii;
32 >    StuntDouble* integrableObject;
33 >    int i;
34 >    for (integrableObject = mol->beginIntegrableObject(ii), i = 0; integrableObject != NULL;
35 >        integrableObject = mol->nextIntegrableObject(ii), ++i) {
36  
37 <  }
38 <    
42 <  for(int i=0; i<nIntegrableObjects; i++) {
37 >        newCoor = rotMat * refCoords[i];
38 >        newCoor += offset;
39  
40 <    //calculate the reference coordinate for integrable objects after rotation
41 <    curRefCoor[0] = refCoords[i][0];
46 <    curRefCoor[1] = refCoords[i][1];
47 <    curRefCoor[2] = refCoords[i][2];
48 <    
49 <    matVecMul3(rotMat, curRefCoor, newCoor);    
40 >        integrableObject->setPos( newCoor);
41 >        integrableObject->setVel(V3Zero);
42  
43 <    newCoor[0] +=  offset[0];
44 <    newCoor[1] +=  offset[1];
45 <    newCoor[2] +=  offset[2];
46 <
55 <    myIntegrableObjects[i]->setPos( newCoor);
56 <    myIntegrableObjects[i]->setVel(zeroVector);
57 <
58 <    if(myIntegrableObjects[i]->isDirectional()){
59 <      myIntegrableObjects[i]->setA(rotMat);
60 <      myIntegrableObjects[i]->setJ(zeroVector);  
43 >        if(integrableObject->isDirectional()){
44 >          integrableObject->setA(rotMat * integrableObject->getA());
45 >          integrableObject->setJ(V3Zero);  
46 >        }        
47      }
62  }
63
48   }
49  
50 < void MoLocator::calcRefCoords( void ){
50 > void MoLocator::calcRef( void ){
51    AtomStamp* currAtomStamp;
52    int nAtoms;
53    int nRigidBodies;
# Line 99 | Line 83 | void MoLocator::calcRefCoords( void ){
83        continue;
84      //get mass and the reference coordinate
85      else{
86 <      currAtomMass = myFF->getAtomTypeMass(currAtomStamp->getType());
86 >    
87        mass.push_back(currAtomMass);
88        coor.x() = currAtomStamp->getPosX();
89        coor.y() = currAtomStamp->getPosY();
# Line 117 | Line 101 | void MoLocator::calcRefCoords( void ){
101  
102      for(int j = 0; j < nAtomsInRb; j++){
103  
104 <      currAtomMass = myFF->getAtomTypeMass(currAtomStamp->getType());
104 >      currAtomMass = getAtomMass(currAtomStamp->getType(), myFF);
105        totMassInRb +=  currAtomMass;
106        
107        coor.x() += currAtomStamp->getPosX() * currAtomMass;
# Line 151 | Line 135 | void latVec2RotMat(const Vector3d& lv, double rotMat[3
135   }
136  
137  
154 void latVec2RotMat(const Vector3d& lv, double rotMat[3][3]){
138  
139 <  double theta, phi, psi;
140 <  
141 <  theta =acos(lv.z());
142 <  phi = atan2(lv.y(), lv.x());
143 <  psi = 0;
139 > double getAtomMass(const std::string& at, ForceField* myFF) {
140 >    double mass;
141 >    AtomType* atomType= myFF->getAtomType(at);
142 >    if (atomType != NULL) {
143 >        mass =     atomType->getMass();
144 >    } else {
145 >        mass = 0.0;
146 >        std::cerr << "Can not find AtomType: " << at << std::endl;
147 >    }
148 >    return mass;
149 > }
150  
151 <  rotMat[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi));
152 <  rotMat[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi));
153 <  rotMat[0][2] = sin(theta) * sin(psi);
154 <  
155 <  rotMat[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi));
156 <  rotMat[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi));
157 <  rotMat[1][2] = sin(theta) * cos(psi);
158 <  
159 <  rotMat[2][0] = sin(phi) * sin(theta);
160 <  rotMat[2][1] = -cos(phi) * sin(theta);
161 <  rotMat[2][2] = cos(theta);
151 > double getMolMass(MoleculeStamp *molStamp, ForceField *myFF) {
152 >    int nAtoms;
153 >    AtomStamp *currAtomStamp;
154 >    double totMass;
155 >
156 >    totMass = 0;
157 >    nAtoms = molStamp->getNAtoms();
158 >
159 >    for(size_t i = 0; i < nAtoms; i++) {
160 >        totMass += getAtomMass(currAtomStamp->getType(), myFF);
161 >        
162 >    }
163   }
164 + RotMat3x3d latVec2RotMat(const Vector3d& lv){
165  
166 +    double theta =acos(lv[2]);
167 +    double phi = atan2(lv[1], lv[0]);
168 +    double psi = 0;
169 +
170 +    return RotMat3x3d(phi, theta, psi);
171 +
172 + }
173 +
174 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines