void updateCOM() { DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_; bool needsVel = false; if (data.getStorageLayout() & DataStorage::dslVelocity) needsVel = true; if (cutoffAtomList.size() == 1) { data.position[localIndex_] = cutoffAtomList[0]->getPos(); if (needsVel) data.velocity[localIndex_] = cutoffAtomList[0]->getVel(); } else { std::vector<Atom *>::iterator i; Atom * atom; RealType totalMass = getMass(); data.position[localIndex_] = V3Zero; if (needsVel) data.velocity[localIndex_] = V3Zero; for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { data.position[localIndex_] += atom->getMass() * atom->getPos(); if (needsVel) data.velocity[localIndex_] += atom->getMass() * atom->getVel(); } data.position[localIndex_] /= totalMass; if (needsVel) data.velocity[localIndex_] /= totalMass; } }
RealType getMass() { if (!haveTotalMass) { totalMass = 0.0; std::vector<Atom *>::iterator i; for(Atom* atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { RealType mass = atom->getMass(); totalMass += mass; } haveTotalMass = true; } return totalMass; }
Angle Residue::getTorsionPhi() const { Angle result(0.0); if (hasTorsionPhi()) { const Residue* previous = getPrevious(RTTI::getDefault<Residue>()); if (previous != 0) { const Atom* C = 0; const Atom* N = 0; const Atom* CA = 0; AtomConstIterator it; for (it = beginAtom(); +it; ++it) { if (it->getName() == "C") C = &*it; if (it->getName() == "CA") CA = &*it; if (it->getName() == "N") N = &*it; } const Atom* last_C = 0; for (it = previous->beginAtom(); +it; ++it) { if (it->getName() == "C") { last_C = &*it; break; } } if ((N != 0) && (C != 0) && (CA != 0) && (last_C != 0)) { result = calculateTorsionAngle(*last_C, *N, *CA, *C); } else { Log.error() << "Atoms not found:" << last_C << "/" << N << "/" << CA << "/" << C << " in residue " << getFullName() << " " << getID() << endl; } } else { Log.error() << "No previous residue!" << endl; } } return result; }
Angle Residue::getTorsionPsi() const { Angle result(0.0); if (hasTorsionPsi()) { const Residue* next = getNext(RTTI::getDefault<Residue>()); if (next != 0) { const Atom* C = 0; const Atom* N = 0; const Atom* CA = 0; AtomConstIterator it; for (it = beginAtom(); +it; ++it) { if (it->getName() == "C") C = &*it; if (it->getName() == "CA") CA = &*it; if (it->getName() == "N") N = &*it; } const Atom* next_N = 0; for (it = next->beginAtom(); +it; ++it) { if (it->getName() == "N") { next_N = &*it; break; } } if ((N != 0) && (C != 0) && (CA != 0) && (next_N != 0)) { result = calculateTorsionAngle(*N, *CA, *C, *next_N); } else { Log.error() << "Atoms not found:" << N << "/" << CA << "/" << C << "/" << next_N << " in residue " << getFullName() << " " << getID() << endl; } } else { Log.error() << "No next residue!" << endl; } } return result; }