ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/primitives/Molecule.cpp
(Generate patch)

Comparing trunk/src/primitives/Molecule.cpp (file contents):
Revision 2052 by gezelter, Fri Jan 9 19:06:35 2015 UTC vs.
Revision 2071 by gezelter, Sat Mar 7 21:41:51 2015 UTC

# Line 53 | Line 53
53   #include "primitives/Molecule.hpp"
54   #include "utils/MemoryUtils.hpp"
55   #include "utils/simError.h"
56 < #include "utils/ElementsTable.hpp"
56 > #include "utils/StringUtils.hpp"
57  
58   namespace OpenMD {
59    Molecule::Molecule(int stampId, int globalIndex, const std::string& molName,
60 <                     int region) : stampId_(stampId),
60 >                     int region) :
61                                     globalIndex_(globalIndex),
62 <                                   moleculeName_(molName),
63 <                                   region_(region),
62 >                                   stampId_(stampId),
63 >                                   region_(region),
64 >                                   moleculeName_(molName),
65                                     constrainTotalCharge_(false) {
66    }
67    
# Line 196 | Line 197 | namespace OpenMD {
197        // get the chain of base types for this atom type:
198        std::vector<AtomType*> ayb = at->allYourBase();
199        // use the last type in the chain of base types for the name:
200 <      std::string bn = ayb[ayb.size()-1]->getName();
200 >      std::string bn = UpperCase(ayb[ayb.size()-1]->getName());
201  
202 <      int obanum = etab.GetAtomicNum(bn.c_str());
203 <      if (obanum != 0) {
203 <        RealType eneg = etab.GetElectroNeg(obanum);
204 <        if (eneg > 3.01) {
202 >        if (bn.compare("O")==0 || bn.compare("N")==0
203 >            || bn.compare("F")==0)
204            hBondAcceptors_.push_back( atom );
205 <        }
207 <      }
205 >      
206      }
209
210    // find electronegative atoms that are either bonded to hydrogens or are
211    // present in the same rigid bodies:
207      
208 +    // find electronegative atoms that are either bonded to
209 +    // hydrogens or are present in the same rigid bodies:
210 +    
211      for (bond = beginBond(bi); bond != NULL; bond = nextBond(bi)) {
212        Atom* atom1 = bond->getAtomA();
213        Atom* atom2 = bond->getAtomB();
# Line 219 | Line 217 | namespace OpenMD {
217        std::vector<AtomType*> ayb1 = at1->allYourBase();
218        std::vector<AtomType*> ayb2 = at2->allYourBase();
219        // use the last type in the chain of base types for the name:
220 <      std::string bn1 = ayb1[ayb1.size()-1]->getName();
221 <      std::string bn2 = ayb2[ayb2.size()-1]->getName();
222 <      int obanum1 = etab.GetAtomicNum(bn1.c_str());
223 <      int obanum2 = etab.GetAtomicNum(bn2.c_str());
224 <
225 <      if (obanum1 == 1) {              
226 <        if (obanum2 != 0) {
227 <          RealType eneg = etab.GetElectroNeg(obanum2);
228 <          if (eneg > 3.01) {
229 <            HBondDonor* donor = new HBondDonor();
232 <            donor->donorAtom = atom2;
233 <            donor->donatedHydrogen = atom1;
234 <            hBondDonors_.push_back( donor );
235 <          }
236 <        }
237 <      }
238 <      if (obanum2 == 1) {
239 <        if (obanum1 != 0) {
240 <          RealType eneg = etab.GetElectroNeg(obanum1);
241 <          if (eneg > 3.01) {
242 <            HBondDonor* donor = new HBondDonor();
243 <            donor->donorAtom = atom1;
244 <            donor->donatedHydrogen = atom2;
245 <            hBondDonors_.push_back( donor );
246 <          }
220 >      std::string bn1 = UpperCase(ayb1[ayb1.size()-1]->getName());
221 >      std::string bn2 = UpperCase(ayb2[ayb2.size()-1]->getName());
222 >      
223 >      if (bn1.compare("H")==0) {
224 >        if (bn2.compare("O")==0 || bn2.compare("N")==0
225 >            || bn2.compare("F")==0) {
226 >          HBondDonor* donor = new HBondDonor();
227 >          donor->donorAtom = atom2;
228 >          donor->donatedHydrogen = atom1;
229 >          hBondDonors_.push_back( donor );
230          }
231        }
232 +      if (bn2.compare("H")==0) {
233 +        if (bn1.compare("O")==0 || bn1.compare("N")==0
234 +            || bn1.compare("F")==0) {
235 +          HBondDonor* donor = new HBondDonor();
236 +          donor->donorAtom = atom1;
237 +          donor->donatedHydrogen = atom2;
238 +            hBondDonors_.push_back( donor );
239 +        }
240 +      }
241      }
242 <
243 <    for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) {
244 <      for(atom1 = rb->beginAtom(ai); atom1 != NULL; atom1 = rb->nextAtom(ai)) {
242 >    
243 >    for (rb = beginRigidBody(rbIter); rb != NULL;
244 >         rb = nextRigidBody(rbIter)) {
245 >      for(atom1 = rb->beginAtom(ai); atom1 != NULL;
246 >          atom1 = rb->nextAtom(ai)) {
247          AtomType* at1 = atom1->getAtomType();
248          // get the chain of base types for this atom type:
249          std::vector<AtomType*> ayb1 = at1->allYourBase();
250          // use the last type in the chain of base types for the name:
251 <        std::string bn1 = ayb1[ayb1.size()-1]->getName();
252 <        int obanum1 = etab.GetAtomicNum(bn1.c_str());
253 <        if (obanum1 != 0) {
254 <          RealType eneg = etab.GetElectroNeg(obanum1);
255 <          if (eneg > 3.01) {
256 <            for(atom2 = rb->beginAtom(aj); atom2 != NULL;
257 <                atom2 = rb->nextAtom(aj)) {
258 <              AtomType* at2 = atom2->getAtomType();
259 <              // get the chain of base types for this atom type:              
260 <              std::vector<AtomType*> ayb2 = at2->allYourBase();
261 <              // use the last type in the chain of base types for the name:
262 <              std::string bn2 = ayb2[ayb2.size()-1]->getName();
263 <              int obanum2 = etab.GetAtomicNum(bn2.c_str());
264 <              if (obanum2 == 1) {
265 <                HBondDonor* donor = new HBondDonor();
266 <                donor->donorAtom = atom1;
273 <                donor->donatedHydrogen = atom2;
274 <                hBondDonors_.push_back( donor );
275 <              }
251 >        std::string bn1 = UpperCase(ayb1[ayb1.size()-1]->getName());
252 >        
253 >        if (bn1.compare("O")==0 || bn1.compare("N")==0
254 >            || bn1.compare("F")==0) {
255 >          for(atom2 = rb->beginAtom(aj); atom2 != NULL;
256 >              atom2 = rb->nextAtom(aj)) {
257 >            AtomType* at2 = atom2->getAtomType();
258 >            // get the chain of base types for this atom type:              
259 >            std::vector<AtomType*> ayb2 = at2->allYourBase();
260 >            // use the last type in the chain of base types for the name:
261 >            std::string bn2 = UpperCase(ayb2[ayb2.size()-1]->getName());
262 >            if (bn2.compare("H")==0) {              
263 >              HBondDonor* donor = new HBondDonor();
264 >              donor->donorAtom = atom1;
265 >              donor->donatedHydrogen = atom2;
266 >              hBondDonors_.push_back( donor );
267              }
268            }
269          }
270        }
271 <    }          
271 >    }
272    }
273 <
273 >  
274    RealType Molecule::getMass() {
275      StuntDouble* sd;
276      std::vector<StuntDouble*>::iterator i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines