--- branches/new_design/OOPSE-2.0/src/brains/MoleculeCreator.cpp 2004/11/23 22:50:17 1773 +++ branches/new_design/OOPSE-2.0/src/brains/MoleculeCreator.cpp 2004/11/23 23:12:23 1774 @@ -257,32 +257,93 @@ Bend* MoleculeCreator::createBend(ForceField* ff, Mole } Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol, BendStamp* stamp) { - BendType* bendType; - Atom* atomA; - Atom* atomB; - Atom* atomC; - - //need to consider the ghost bend - atomA = mol->getAtomAt(stamp->getA()); - atomB = mol->getAtomAt(stamp->getB()); - atomC = mol->getAtomAt(stamp->getC()); + bool isGhostBend = false; + int ghostIndex; - assert( atomA && atomB && atomC); - bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType()); + // + if (stamp->haveExtras()){ + LinkedAssign* extras = currentBend->getExtras(); + LinkedAssign* currentExtra = extras; - if (bendType == NULL) { - sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", - atomA->getType().c_str(), - atomB->getType().c_str(), - atomC->getType().c_str()); + while (currentExtra != NULL){ + if (!strcmp(currentExtra->getlhs(), "ghostVectorSource")){ + switch (currentExtra->getType()){ + case 0: + ghostIndex = currentExtra->getInt(); + isGhostBend = true; + break; - painCave.isFatal = 1; - simError(); + default: + sprintf(painCave.errMsg, + "SimSetup Error: ghostVectorSource must be an int.\n"); + painCave.isFatal = 1; + simError(); + } + } else{ + sprintf(painCave.errMsg, + "SimSetup Error: unhandled bend assignment:\n"); + painCave.isFatal = 1; + simError(); + } + currentExtra = currentExtra->getNext(); + } + } - return new Bond(atomA, atomB, bendType); + if (isGhostBend) { + int indexA = stamp->getA(); + int indexB= stamp->getB(); + + assert(indexA != indexB); + + int normalIndex; + if (indexA == ghostIndex) { + normalIndex = indexB; + } else if (indexB == ghostIndex) { + normalIndex = indexA; + } + + Atom* normalAtom = mol->getAtomAt(normalIndex) ; + Atom* ghostAtom = mol->getAtomAt(ghostIndex); + + BendType* bendType = ff->getBendType(normalAtom->getType(), ghostAtom->getType(), "GHOST"); + + if (bendType == NULL) { + sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", + normalAtom->getType().c_str(), + ghostAtom->getType().c_str(), + "GHOST"); + + painCave.isFatal = 1; + simError(); + } + + return new GhostBend(normalAtom, ghostAtom, bendType); + + } else { + + Atom* atomA = mol->getAtomAt(stamp->getA()); + Atom* atomB = mol->getAtomAt(stamp->getB()); + Atom* atomC = mol->getAtomAt(stamp->getC()); + + assert( atomA && atomB && atomC); + + BendType* bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType()); + + if (bendType == NULL) { + sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", + atomA->getType().c_str(), + atomB->getType().c_str(), + atomC->getType().c_str()); + + painCave.isFatal = 1; + simError(); + } + + return new Bend(atomA, atomB, atomC, bendType); + } } Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) {