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 1211 by gezelter, Wed Jan 23 16:38:22 2008 UTC vs.
Revision 1908 by gezelter, Fri Jul 19 21:25:45 2013 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   /**
# Line 53 | Line 54
54   #include "utils/MemoryUtils.hpp"
55   #include "utils/simError.h"
56  
57 < namespace oopse {
58 <  Molecule::Molecule(int stampId, int globalIndex, const std::string& molName)
59 <    : stampId_(stampId), globalIndex_(globalIndex), moleculeName_(molName) {
57 > namespace OpenMD {
58 >  Molecule::Molecule(int stampId, int globalIndex, const std::string& molName,
59 >                     int region) : stampId_(stampId),
60 >                                   globalIndex_(globalIndex),
61 >                                   moleculeName_(molName),
62 >                                   region_(region),
63 >                                   constrainTotalCharge_(false) {
64    }
65    
66    Molecule::~Molecule() {
# Line 64 | Line 69 | namespace oopse {
69      MemoryUtils::deletePointers(bonds_);
70      MemoryUtils::deletePointers(bends_);
71      MemoryUtils::deletePointers(torsions_);
72 +    MemoryUtils::deletePointers(inversions_);
73      MemoryUtils::deletePointers(rigidBodies_);
74      MemoryUtils::deletePointers(cutoffGroups_);
75      MemoryUtils::deletePointers(constraintPairs_);
76      MemoryUtils::deletePointers(constraintElems_);
77 +
78      // integrableObjects_ don't own the objects
79      integrableObjects_.clear();
80 +    fluctuatingCharges_.clear();
81      
82    }
83    
# Line 97 | Line 105 | namespace oopse {
105        torsions_.push_back(torsion);
106      }
107    }
108 +
109 +  void Molecule::addInversion(Inversion* inversion) {
110 +    if (std::find(inversions_.begin(), inversions_.end(), inversion) ==
111 +        inversions_.end()) {
112 +      inversions_.push_back(inversion);
113 +    }
114 +  }
115    
116    void Molecule::addRigidBody(RigidBody *rb) {
117      if (std::find(rigidBodies_.begin(), rigidBodies_.end(), rb) ==
# Line 129 | Line 144 | namespace oopse {
144    void Molecule::complete() {
145      
146      std::set<Atom*> rigidAtoms;
147 +    Atom* atom;
148 +    AtomIterator ai;
149      RigidBody* rb;
150 <    std::vector<RigidBody*>::iterator rbIter;
150 >    RigidBodyIterator rbIter;
151  
152 <    
152 >    // Get list of all the atoms that are part of rigid bodies
153 >
154      for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) {
155        rigidAtoms.insert(rb->getBeginAtomIter(), rb->getEndAtomIter());
156      }
157      
158 <    Atom* atom;
159 <    AtomIterator ai;
158 >    // add any atom that wasn't part of a rigid body to the list of integrableObjects
159 >
160      for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) {
161        
162 <      if (rigidAtoms.find(*ai) == rigidAtoms.end()) {
162 >      if (rigidAtoms.find(atom) == rigidAtoms.end()) {
163  
164          // If an atom does not belong to a rigid body, it is an
165          // integrable object
166  
167 <        integrableObjects_.push_back(*ai);
167 >        integrableObjects_.push_back(atom);
168        }
169      }
170      
171 <    //find all free atoms (which do not belong to rigid bodies)  
154 <    // performs the "difference" operation from set theory, the output
155 <    // range contains a copy of every element that is contained in
156 <    // [allAtoms.begin(), allAtoms.end()) and not contained in
157 <    // [rigidAtoms.begin(), rigidAtoms.end()).
158 <    //std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(),
159 <    //                        std::back_inserter(integrableObjects_));
171 >    // then add the rigid bodies themselves to the integrableObjects
172  
161    //if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) {
162    //    //Some atoms in rigidAtoms are not in allAtoms, something must be wrong
163    //    sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule");
164    //
165    //    painCave.isFatal = 1;
166    //    simError();        
167    //}
173      for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) {
174        integrableObjects_.push_back(rb);
175      }
176 <    //integrableObjects_.insert(integrableObjects_.end(), rigidBodies_.begin(), rigidBodies_.end());
176 >
177 >    // find the atoms that are fluctuating charges and add them to the
178 >    // fluctuatingCharges_ vector
179 >
180 >    for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) {
181 >      if ( atom->isFluctuatingCharge() )
182 >        fluctuatingCharges_.push_back( atom );      
183 >    }
184 >
185    }
186  
187    RealType Molecule::getMass() {
# Line 237 | Line 250 | namespace oopse {
250      Bond* bond;
251      Bend* bend;
252      Torsion* torsion;
253 +    Inversion* inversion;
254      Molecule::BondIterator bondIter;;
255      Molecule::BendIterator  bendIter;
256      Molecule::TorsionIterator  torsionIter;
257 +    Molecule::InversionIterator  inversionIter;
258  
259      RealType potential = 0.0;
260  
# Line 256 | Line 271 | namespace oopse {
271        potential += torsion->getPotential();
272      }
273      
274 +    for (inversion = beginInversion(inversionIter); torsion != NULL;
275 +         inversion =  nextInversion(inversionIter)) {
276 +      potential += inversion->getPotential();
277 +    }
278 +    
279      return potential;
280      
281    }
282    
283 +  void Molecule::addProperty(GenericData* genData) {
284 +    properties_.addProperty(genData);  
285 +  }
286 +
287 +  void Molecule::removeProperty(const std::string& propName) {
288 +    properties_.removeProperty(propName);  
289 +  }
290 +
291 +  void Molecule::clearProperties() {
292 +    properties_.clearProperties();
293 +  }
294 +
295 +  std::vector<std::string> Molecule::getPropertyNames() {
296 +    return properties_.getPropertyNames();  
297 +  }
298 +      
299 +  std::vector<GenericData*> Molecule::getProperties() {
300 +    return properties_.getProperties();
301 +  }
302 +
303 +  GenericData* Molecule::getPropertyByName(const std::string& propName) {
304 +    return properties_.getPropertyByName(propName);
305 +  }
306 +
307    std::ostream& operator <<(std::ostream& o, Molecule& mol) {
308      o << std::endl;
309      o << "Molecule " << mol.getGlobalIndex() << "has: " << std::endl;
# Line 267 | Line 311 | namespace oopse {
311      o << mol.getNBonds() << " bonds" << std::endl;
312      o << mol.getNBends() << " bends" << std::endl;
313      o << mol.getNTorsions() << " torsions" << std::endl;
314 +    o << mol.getNInversions() << " inversions" << std::endl;
315      o << mol.getNRigidBodies() << " rigid bodies" << std::endl;
316 <    o << mol.getNIntegrableObjects() << "integrable objects" << std::endl;
317 <    o << mol.getNCutoffGroups() << "cutoff groups" << std::endl;
318 <    o << mol.getNConstraintPairs() << "constraint pairs" << std::endl;
316 >    o << mol.getNIntegrableObjects() << " integrable objects" << std::endl;
317 >    o << mol.getNCutoffGroups() << " cutoff groups" << std::endl;
318 >    o << mol.getNConstraintPairs() << " constraint pairs" << std::endl;
319 >    o << mol.getNFluctuatingCharges() << " fluctuating charges" << std::endl;
320      return o;
321    }
322    
323 < }//end namespace oopse
323 > }//end namespace OpenMD

Comparing trunk/src/primitives/Molecule.cpp (property svn:keywords):
Revision 1211 by gezelter, Wed Jan 23 16:38:22 2008 UTC vs.
Revision 1908 by gezelter, Fri Jul 19 21:25:45 2013 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines