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

Comparing trunk/OOPSE-2.0/src/applications/simpleBuilder/MoLocator.cpp (file contents):
Revision 1681 by tim, Thu Oct 28 22:26:32 2004 UTC vs.
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC

# Line 1 | Line 1
1 + /*
2 + * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + *
4 + * The University of Notre Dame grants you ("Licensee") a
5 + * non-exclusive, royalty free, license to use, modify and
6 + * redistribute this software in source and binary code form, provided
7 + * that the following conditions are met:
8 + *
9 + * 1. Acknowledgement of the program authors must be made in any
10 + *    publication of scientific results based in part on use of the
11 + *    program.  An acceptable form of acknowledgement is citation of
12 + *    the article in which the program was described (Matthew
13 + *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + *    Parallel Simulation Engine for Molecular Dynamics,"
16 + *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + *
18 + * 2. Redistributions of source code must retain the above copyright
19 + *    notice, this list of conditions and the following disclaimer.
20 + *
21 + * 3. Redistributions in binary form must reproduce the above copyright
22 + *    notice, this list of conditions and the following disclaimer in the
23 + *    documentation and/or other materials provided with the
24 + *    distribution.
25 + *
26 + * This software is provided "AS IS," without a warranty of any
27 + * kind. All express or implied conditions, representations and
28 + * warranties, including any implied warranty of merchantability,
29 + * fitness for a particular purpose or non-infringement, are hereby
30 + * excluded.  The University of Notre Dame and its licensors shall not
31 + * be liable for any damages suffered by licensee as a result of
32 + * using, modifying or distributing the software or its
33 + * derivatives. In no event will the University of Notre Dame or its
34 + * licensors be liable for any lost revenue, profit or data, or for
35 + * direct, indirect, special, consequential, incidental or punitive
36 + * damages, however caused and regardless of the theory of liability,
37 + * arising out of the use of or inability to use software, even if the
38 + * University of Notre Dame has been advised of the possibility of
39 + * such damages.
40 + */
41 +
42   #include <iostream>
43  
44   #include <cstdlib>
# Line 5 | Line 46
46  
47   #include "utils/simError.h"
48   #include "applications/simpleBuilder/MoLocator.hpp"
49 < #include "math/MatVec3.h"
49 > #include "types/AtomType.hpp"
50 > namespace oopse {
51 > MoLocator::MoLocator( MoleculeStamp* theStamp, ForceField* theFF){
52  
10 MoLocator::MoLocator( MoleculeStamp* theStamp, ForceFields* theFF){
11
53    myStamp = theStamp;
54    myFF = theFF;
55    nIntegrableObjects = myStamp->getNIntegrable();
56 <  calcRefCoords();
56 >  calcRef();
57   }
58  
59   void MoLocator::placeMol( const Vector3d& offset, const Vector3d& ort, Molecule* mol){
60 <  double newCoor[3];
61 <  double curRefCoor[3];
62 <  double zeroVector[3];
22 <  vector<StuntDouble*> myIntegrableObjects;
23 <  double rotMat[3][3];
60 >    Vector3d newCoor;
61 >    Vector3d curRefCoor;  
62 >    RotMat3x3d rotMat = latVec2RotMat(ort);
63    
64 <  zeroVector[0] = 0.0;
65 <  zeroVector[1] = 0.0;
66 <  zeroVector[2] = 0.0;
67 <  
68 <  latVec2RotMat(ort, rotMat);
69 <  
70 <  myIntegrableObjects = mol->getIntegrableObjects();
64 >    if(mol->getNIntegrableObjects() != nIntegrableObjects){
65 >        sprintf( painCave.errMsg,
66 >            "MoLocator error.\n"
67 >            "  The number of integrable objects of MoleculeStamp is not the same as  that of Molecule\n");
68 >        painCave.isFatal = 1;
69 >        simError();
70 >    }
71  
72 <  if(myIntegrableObjects.size() != nIntegrableObjects){
73 <      sprintf( painCave.errMsg,
74 <               "MoLocator error.\n"
75 <               "  The number of integrable objects of MoleculeStamp is not the same as  that of Molecule\n");
76 <          painCave.isFatal = 1;
38 <      simError();
72 >    Molecule::IntegrableObjectIterator ii;
73 >    StuntDouble* integrableObject;
74 >    int i;
75 >    for (integrableObject = mol->beginIntegrableObject(ii), i = 0; integrableObject != NULL;
76 >        integrableObject = mol->nextIntegrableObject(ii), ++i) {
77  
78 <  }
79 <    
42 <  for(int i=0; i<nIntegrableObjects; i++) {
78 >        newCoor = rotMat * refCoords[i];
79 >        newCoor += offset;
80  
81 <    //calculate the reference coordinate for integrable objects after rotation
82 <    curRefCoor[0] = refCoords[i][0];
46 <    curRefCoor[1] = refCoords[i][1];
47 <    curRefCoor[2] = refCoords[i][2];
48 <    
49 <    matVecMul3(rotMat, curRefCoor, newCoor);    
81 >        integrableObject->setPos( newCoor);
82 >        integrableObject->setVel(V3Zero);
83  
84 <    newCoor[0] +=  offset[0];
85 <    newCoor[1] +=  offset[1];
86 <    newCoor[2] +=  offset[2];
87 <
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);  
84 >        if(integrableObject->isDirectional()){
85 >          integrableObject->setA(rotMat * integrableObject->getA());
86 >          integrableObject->setJ(V3Zero);  
87 >        }        
88      }
62  }
63
89   }
90  
91 < void MoLocator::calcRefCoords( void ){
91 > void MoLocator::calcRef( void ){
92    AtomStamp* currAtomStamp;
93    int nAtoms;
94    int nRigidBodies;
95 <  vector<double> mass;
95 >   std::vector<double> mass;
96    Vector3d coor;
97    Vector3d refMolCom;  
98    int nAtomsInRb;
# Line 99 | Line 124 | void MoLocator::calcRefCoords( void ){
124        continue;
125      //get mass and the reference coordinate
126      else{
127 <      currAtomMass = myFF->getAtomTypeMass(currAtomStamp->getType());
127 >    
128        mass.push_back(currAtomMass);
129        coor.x() = currAtomStamp->getPosX();
130        coor.y() = currAtomStamp->getPosY();
# Line 117 | Line 142 | void MoLocator::calcRefCoords( void ){
142  
143      for(int j = 0; j < nAtomsInRb; j++){
144  
145 <      currAtomMass = myFF->getAtomTypeMass(currAtomStamp->getType());
145 >      currAtomMass = getAtomMass(currAtomStamp->getType(), myFF);
146        totMassInRb +=  currAtomMass;
147        
148        coor.x() += currAtomStamp->getPosX() * currAtomMass;
# Line 151 | Line 176 | void latVec2RotMat(const Vector3d& lv, double rotMat[3
176   }
177  
178  
154 void latVec2RotMat(const Vector3d& lv, double rotMat[3][3]){
179  
180 <  double theta, phi, psi;
181 <  
182 <  theta =acos(lv.z());
183 <  phi = atan2(lv.y(), lv.x());
184 <  psi = 0;
180 > double getAtomMass(const std::string& at, ForceField* myFF) {
181 >    double mass;
182 >    AtomType* atomType= myFF->getAtomType(at);
183 >    if (atomType != NULL) {
184 >        mass =     atomType->getMass();
185 >    } else {
186 >        mass = 0.0;
187 >        std::cerr << "Can not find AtomType: " << at << std::endl;
188 >    }
189 >    return mass;
190 > }
191  
192 <  rotMat[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi));
193 <  rotMat[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi));
194 <  rotMat[0][2] = sin(theta) * sin(psi);
195 <  
196 <  rotMat[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi));
197 <  rotMat[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi));
198 <  rotMat[1][2] = sin(theta) * cos(psi);
199 <  
200 <  rotMat[2][0] = sin(phi) * sin(theta);
201 <  rotMat[2][1] = -cos(phi) * sin(theta);
172 <  rotMat[2][2] = cos(theta);
192 > double getMolMass(MoleculeStamp *molStamp, ForceField *myFF) {
193 >    int nAtoms;
194 >    double totMass = 0;
195 >    nAtoms = molStamp->getNAtoms();
196 >
197 >    for(size_t i = 0; i < nAtoms; i++) {
198 >        AtomStamp *currAtomStamp = molStamp->getAtom(i);
199 >        totMass += getAtomMass(currAtomStamp->getType(), myFF);        
200 >    }
201 >    return totMass;
202   }
203 + RotMat3x3d latVec2RotMat(const Vector3d& lv){
204  
205 +    double theta =acos(lv[2]);
206 +    double phi = atan2(lv[1], lv[0]);
207 +    double psi = 0;
208 +
209 +    return RotMat3x3d(phi, theta, psi);
210 +
211 + }
212 + }
213 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines