--- trunk/OOPSE/libmdtools/AtomVisitor.cpp 2004/04/19 17:44:48 1119 +++ trunk/OOPSE/libmdtools/AtomVisitor.cpp 2004/04/22 03:29:30 1129 @@ -44,6 +44,7 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ double ox[3] = {0.0, 0.0, -0.0654}; double u[3] = {0, 0, 1}; double rotMatrix[3][3]; + double rotTrans[3][3]; AtomInfo* atomInfo; double pos[3]; double vel[3]; @@ -54,7 +55,7 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ bool haveAtomData; //if atom is not SSD atom, just skip it - if(!strcmp(datom->getType(), "SSD")) + if(strcmp(datom->getType(), "SSD")) return; data = datom->getProperty("ATOMDATA"); @@ -78,9 +79,12 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ datom->getPos(pos); datom->getQ(q); datom->getA(rotMatrix); + + // We need A^T to convert from body-fixed to space-fixed: + transposeMat3(rotMatrix, rotTrans); //center of mass of the water molecule - matVecMul3(rotMatrix, u, newVec); + matVecMul3(rotTrans, u, newVec); atomInfo = new AtomInfo; atomInfo->AtomType = "X"; atomInfo->pos[0] = pos[0]; @@ -93,7 +97,7 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ atomData->addAtomInfo(atomInfo); //oxygen - matVecMul3(rotMatrix, ox, newVec); + matVecMul3(rotTrans, ox, newVec); atomInfo = new AtomInfo; atomInfo->AtomType = "O"; atomInfo->pos[0] = pos[0] + newVec[0]; @@ -106,7 +110,7 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ //hydrogen1 - matVecMul3(rotMatrix, h1, newVec); + matVecMul3(rotTrans, h1, newVec); atomInfo = new AtomInfo; atomInfo->AtomType = "H"; atomInfo->pos[0] = pos[0] + newVec[0]; @@ -118,7 +122,7 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ atomData->addAtomInfo(atomInfo); //hydrogen2 - matVecMul3(rotMatrix, h2, newVec); + matVecMul3(rotTrans, h2, newVec); atomInfo = new AtomInfo; atomInfo->AtomType = "H"; atomInfo->pos[0] = pos[0] + newVec[0]; @@ -140,6 +144,27 @@ void SSDAtomVisitor::visit(DirectionalAtom* datom){ } +const string SSDAtomVisitor::toString(){ + char buffer[65535]; + string result; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); + result += buffer; + + sprintf(buffer , "Visitor Description: Convert SSD into 4 differnet atoms\n"); + result += buffer; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + return result; +} + +//----------------------------------------------------------------------------// + void DefaultAtomVisitor::visit(Atom* atom){ AtomData* atomData; AtomInfo* atomInfo; @@ -199,4 +224,23 @@ void DefaultAtomVisitor::visit(DirectionalAtom* datom) setVisited(datom); } - + + +const string DefaultAtomVisitor::toString(){ + char buffer[65535]; + string result; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); + result += buffer; + + sprintf(buffer , "Visitor Description: copy atom infomation into atom data\n"); + result += buffer; + + sprintf(buffer ,"------------------------------------------------------------------\n"); + result += buffer; + + return result; +}