| 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. |
| 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 |
|
/** |
| 54 |
|
#include "utils/MemoryUtils.hpp" |
| 55 |
|
#include "utils/simError.h" |
| 56 |
|
|
| 57 |
< |
namespace oopse { |
| 57 |
> |
namespace OpenMD { |
| 58 |
|
Molecule::Molecule(int stampId, int globalIndex, const std::string& molName) |
| 59 |
< |
: stampId_(stampId), globalIndex_(globalIndex), moleculeName_(molName) { |
| 59 |
> |
: stampId_(stampId), globalIndex_(globalIndex), moleculeName_(molName), |
| 60 |
> |
constrainTotalCharge_(false) { |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
Molecule::~Molecule() { |
| 66 |
|
MemoryUtils::deletePointers(bonds_); |
| 67 |
|
MemoryUtils::deletePointers(bends_); |
| 68 |
|
MemoryUtils::deletePointers(torsions_); |
| 69 |
+ |
MemoryUtils::deletePointers(inversions_); |
| 70 |
|
MemoryUtils::deletePointers(rigidBodies_); |
| 71 |
|
MemoryUtils::deletePointers(cutoffGroups_); |
| 72 |
|
MemoryUtils::deletePointers(constraintPairs_); |
| 73 |
|
MemoryUtils::deletePointers(constraintElems_); |
| 74 |
+ |
|
| 75 |
|
// integrableObjects_ don't own the objects |
| 76 |
|
integrableObjects_.clear(); |
| 77 |
+ |
fluctuatingCharges_.clear(); |
| 78 |
|
|
| 79 |
|
} |
| 80 |
|
|
| 102 |
|
torsions_.push_back(torsion); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
+ |
|
| 106 |
+ |
void Molecule::addInversion(Inversion* inversion) { |
| 107 |
+ |
if (std::find(inversions_.begin(), inversions_.end(), inversion) == |
| 108 |
+ |
inversions_.end()) { |
| 109 |
+ |
inversions_.push_back(inversion); |
| 110 |
+ |
} |
| 111 |
+ |
} |
| 112 |
|
|
| 113 |
|
void Molecule::addRigidBody(RigidBody *rb) { |
| 114 |
|
if (std::find(rigidBodies_.begin(), rigidBodies_.end(), rb) == |
| 141 |
|
void Molecule::complete() { |
| 142 |
|
|
| 143 |
|
std::set<Atom*> rigidAtoms; |
| 144 |
+ |
Atom* atom; |
| 145 |
+ |
AtomIterator ai; |
| 146 |
|
RigidBody* rb; |
| 147 |
< |
std::vector<RigidBody*>::iterator rbIter; |
| 147 |
> |
RigidBodyIterator rbIter; |
| 148 |
|
|
| 149 |
< |
|
| 149 |
> |
// Get list of all the atoms that are part of rigid bodies |
| 150 |
> |
|
| 151 |
|
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { |
| 152 |
|
rigidAtoms.insert(rb->getBeginAtomIter(), rb->getEndAtomIter()); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
< |
Atom* atom; |
| 156 |
< |
AtomIterator ai; |
| 155 |
> |
// add any atom that wasn't part of a rigid body to the list of integrableObjects |
| 156 |
> |
|
| 157 |
|
for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { |
| 158 |
|
|
| 159 |
< |
if (rigidAtoms.find(*ai) == rigidAtoms.end()) { |
| 159 |
> |
if (rigidAtoms.find(atom) == rigidAtoms.end()) { |
| 160 |
|
|
| 161 |
|
// If an atom does not belong to a rigid body, it is an |
| 162 |
|
// integrable object |
| 163 |
|
|
| 164 |
< |
integrableObjects_.push_back(*ai); |
| 164 |
> |
integrableObjects_.push_back(atom); |
| 165 |
|
} |
| 166 |
|
} |
| 167 |
|
|
| 168 |
< |
//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_)); |
| 168 |
> |
// then add the rigid bodies themselves to the integrableObjects |
| 169 |
|
|
| 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 |
– |
//} |
| 170 |
|
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) { |
| 171 |
|
integrableObjects_.push_back(rb); |
| 172 |
|
} |
| 173 |
< |
//integrableObjects_.insert(integrableObjects_.end(), rigidBodies_.begin(), rigidBodies_.end()); |
| 173 |
> |
|
| 174 |
> |
// find the atoms that are fluctuating charges and add them to the |
| 175 |
> |
// fluctuatingCharges_ vector |
| 176 |
> |
|
| 177 |
> |
for (atom = beginAtom(ai); atom != NULL; atom = nextAtom(ai)) { |
| 178 |
> |
if ( atom->isFluctuatingCharge() ) |
| 179 |
> |
fluctuatingCharges_.push_back( atom ); |
| 180 |
> |
} |
| 181 |
> |
|
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
RealType Molecule::getMass() { |
| 247 |
|
Bond* bond; |
| 248 |
|
Bend* bend; |
| 249 |
|
Torsion* torsion; |
| 250 |
+ |
Inversion* inversion; |
| 251 |
|
Molecule::BondIterator bondIter;; |
| 252 |
|
Molecule::BendIterator bendIter; |
| 253 |
|
Molecule::TorsionIterator torsionIter; |
| 254 |
+ |
Molecule::InversionIterator inversionIter; |
| 255 |
|
|
| 256 |
|
RealType potential = 0.0; |
| 257 |
|
|
| 268 |
|
potential += torsion->getPotential(); |
| 269 |
|
} |
| 270 |
|
|
| 271 |
+ |
for (inversion = beginInversion(inversionIter); torsion != NULL; |
| 272 |
+ |
inversion = nextInversion(inversionIter)) { |
| 273 |
+ |
potential += inversion->getPotential(); |
| 274 |
+ |
} |
| 275 |
+ |
|
| 276 |
|
return potential; |
| 277 |
|
|
| 278 |
|
} |
| 279 |
|
|
| 280 |
+ |
void Molecule::addProperty(GenericData* genData) { |
| 281 |
+ |
properties_.addProperty(genData); |
| 282 |
+ |
} |
| 283 |
+ |
|
| 284 |
+ |
void Molecule::removeProperty(const std::string& propName) { |
| 285 |
+ |
properties_.removeProperty(propName); |
| 286 |
+ |
} |
| 287 |
+ |
|
| 288 |
+ |
void Molecule::clearProperties() { |
| 289 |
+ |
properties_.clearProperties(); |
| 290 |
+ |
} |
| 291 |
+ |
|
| 292 |
+ |
std::vector<std::string> Molecule::getPropertyNames() { |
| 293 |
+ |
return properties_.getPropertyNames(); |
| 294 |
+ |
} |
| 295 |
+ |
|
| 296 |
+ |
std::vector<GenericData*> Molecule::getProperties() { |
| 297 |
+ |
return properties_.getProperties(); |
| 298 |
+ |
} |
| 299 |
+ |
|
| 300 |
+ |
GenericData* Molecule::getPropertyByName(const std::string& propName) { |
| 301 |
+ |
return properties_.getPropertyByName(propName); |
| 302 |
+ |
} |
| 303 |
+ |
|
| 304 |
|
std::ostream& operator <<(std::ostream& o, Molecule& mol) { |
| 305 |
|
o << std::endl; |
| 306 |
|
o << "Molecule " << mol.getGlobalIndex() << "has: " << std::endl; |
| 308 |
|
o << mol.getNBonds() << " bonds" << std::endl; |
| 309 |
|
o << mol.getNBends() << " bends" << std::endl; |
| 310 |
|
o << mol.getNTorsions() << " torsions" << std::endl; |
| 311 |
+ |
o << mol.getNInversions() << " inversions" << std::endl; |
| 312 |
|
o << mol.getNRigidBodies() << " rigid bodies" << std::endl; |
| 313 |
< |
o << mol.getNIntegrableObjects() << "integrable objects" << std::endl; |
| 314 |
< |
o << mol.getNCutoffGroups() << "cutoff groups" << std::endl; |
| 315 |
< |
o << mol.getNConstraintPairs() << "constraint pairs" << std::endl; |
| 313 |
> |
o << mol.getNIntegrableObjects() << " integrable objects" << std::endl; |
| 314 |
> |
o << mol.getNCutoffGroups() << " cutoff groups" << std::endl; |
| 315 |
> |
o << mol.getNConstraintPairs() << " constraint pairs" << std::endl; |
| 316 |
> |
o << mol.getNFluctuatingCharges() << " fluctuating charges" << std::endl; |
| 317 |
|
return o; |
| 318 |
|
} |
| 319 |
|
|
| 320 |
< |
}//end namespace oopse |
| 320 |
> |
}//end namespace OpenMD |