--- trunk/src/primitives/Molecule.cpp 2015/01/09 19:06:35 2052 +++ trunk/src/primitives/Molecule.cpp 2015/03/07 21:41:51 2071 @@ -53,14 +53,15 @@ #include "primitives/Molecule.hpp" #include "utils/MemoryUtils.hpp" #include "utils/simError.h" -#include "utils/ElementsTable.hpp" +#include "utils/StringUtils.hpp" namespace OpenMD { Molecule::Molecule(int stampId, int globalIndex, const std::string& molName, - int region) : stampId_(stampId), + int region) : globalIndex_(globalIndex), - moleculeName_(molName), - region_(region), + stampId_(stampId), + region_(region), + moleculeName_(molName), constrainTotalCharge_(false) { } @@ -196,20 +197,17 @@ namespace OpenMD { // get the chain of base types for this atom type: std::vector ayb = at->allYourBase(); // use the last type in the chain of base types for the name: - std::string bn = ayb[ayb.size()-1]->getName(); + std::string bn = UpperCase(ayb[ayb.size()-1]->getName()); - int obanum = etab.GetAtomicNum(bn.c_str()); - if (obanum != 0) { - RealType eneg = etab.GetElectroNeg(obanum); - if (eneg > 3.01) { + if (bn.compare("O")==0 || bn.compare("N")==0 + || bn.compare("F")==0) hBondAcceptors_.push_back( atom ); - } - } + } - - // find electronegative atoms that are either bonded to hydrogens or are - // present in the same rigid bodies: + // find electronegative atoms that are either bonded to + // hydrogens or are present in the same rigid bodies: + for (bond = beginBond(bi); bond != NULL; bond = nextBond(bi)) { Atom* atom1 = bond->getAtomA(); Atom* atom2 = bond->getAtomB(); @@ -219,67 +217,60 @@ namespace OpenMD { std::vector ayb1 = at1->allYourBase(); std::vector ayb2 = at2->allYourBase(); // use the last type in the chain of base types for the name: - std::string bn1 = ayb1[ayb1.size()-1]->getName(); - std::string bn2 = ayb2[ayb2.size()-1]->getName(); - int obanum1 = etab.GetAtomicNum(bn1.c_str()); - int obanum2 = etab.GetAtomicNum(bn2.c_str()); - - if (obanum1 == 1) { - if (obanum2 != 0) { - RealType eneg = etab.GetElectroNeg(obanum2); - if (eneg > 3.01) { - HBondDonor* donor = new HBondDonor(); - donor->donorAtom = atom2; - donor->donatedHydrogen = atom1; - hBondDonors_.push_back( donor ); - } - } - } - if (obanum2 == 1) { - if (obanum1 != 0) { - RealType eneg = etab.GetElectroNeg(obanum1); - if (eneg > 3.01) { - HBondDonor* donor = new HBondDonor(); - donor->donorAtom = atom1; - donor->donatedHydrogen = atom2; - hBondDonors_.push_back( donor ); - } + std::string bn1 = UpperCase(ayb1[ayb1.size()-1]->getName()); + std::string bn2 = UpperCase(ayb2[ayb2.size()-1]->getName()); + + if (bn1.compare("H")==0) { + if (bn2.compare("O")==0 || bn2.compare("N")==0 + || bn2.compare("F")==0) { + HBondDonor* donor = new HBondDonor(); + donor->donorAtom = atom2; + donor->donatedHydrogen = atom1; + hBondDonors_.push_back( donor ); } } + if (bn2.compare("H")==0) { + if (bn1.compare("O")==0 || bn1.compare("N")==0 + || bn1.compare("F")==0) { + HBondDonor* donor = new HBondDonor(); + donor->donorAtom = atom1; + donor->donatedHydrogen = atom2; + hBondDonors_.push_back( donor ); + } + } } - - for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { - for(atom1 = rb->beginAtom(ai); atom1 != NULL; atom1 = rb->nextAtom(ai)) { + + for (rb = beginRigidBody(rbIter); rb != NULL; + rb = nextRigidBody(rbIter)) { + for(atom1 = rb->beginAtom(ai); atom1 != NULL; + atom1 = rb->nextAtom(ai)) { AtomType* at1 = atom1->getAtomType(); // get the chain of base types for this atom type: std::vector ayb1 = at1->allYourBase(); // use the last type in the chain of base types for the name: - std::string bn1 = ayb1[ayb1.size()-1]->getName(); - int obanum1 = etab.GetAtomicNum(bn1.c_str()); - if (obanum1 != 0) { - RealType eneg = etab.GetElectroNeg(obanum1); - if (eneg > 3.01) { - for(atom2 = rb->beginAtom(aj); atom2 != NULL; - atom2 = rb->nextAtom(aj)) { - AtomType* at2 = atom2->getAtomType(); - // get the chain of base types for this atom type: - std::vector ayb2 = at2->allYourBase(); - // use the last type in the chain of base types for the name: - std::string bn2 = ayb2[ayb2.size()-1]->getName(); - int obanum2 = etab.GetAtomicNum(bn2.c_str()); - if (obanum2 == 1) { - HBondDonor* donor = new HBondDonor(); - donor->donorAtom = atom1; - donor->donatedHydrogen = atom2; - hBondDonors_.push_back( donor ); - } + std::string bn1 = UpperCase(ayb1[ayb1.size()-1]->getName()); + + if (bn1.compare("O")==0 || bn1.compare("N")==0 + || bn1.compare("F")==0) { + for(atom2 = rb->beginAtom(aj); atom2 != NULL; + atom2 = rb->nextAtom(aj)) { + AtomType* at2 = atom2->getAtomType(); + // get the chain of base types for this atom type: + std::vector ayb2 = at2->allYourBase(); + // use the last type in the chain of base types for the name: + std::string bn2 = UpperCase(ayb2[ayb2.size()-1]->getName()); + if (bn2.compare("H")==0) { + HBondDonor* donor = new HBondDonor(); + donor->donorAtom = atom1; + donor->donatedHydrogen = atom2; + hBondDonors_.push_back( donor ); } } } } - } + } } - + RealType Molecule::getMass() { StuntDouble* sd; std::vector::iterator i;