| 56 |
|
|
| 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() { |
| 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 |
|
|
| 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) |
| 163 |
< |
// performs the "difference" operation from set theory, the output |
| 164 |
< |
// range contains a copy of every element that is contained in |
| 165 |
< |
// [allAtoms.begin(), allAtoms.end()) and not contained in |
| 166 |
< |
// [rigidAtoms.begin(), rigidAtoms.end()). |
| 167 |
< |
//std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(), |
| 168 |
< |
// std::back_inserter(integrableObjects_)); |
| 168 |
> |
// then add the rigid bodies themselves to the integrableObjects |
| 169 |
|
|
| 170 |
– |
//if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) { |
| 171 |
– |
// //Some atoms in rigidAtoms are not in allAtoms, something must be wrong |
| 172 |
– |
// sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule"); |
| 173 |
– |
// |
| 174 |
– |
// painCave.isFatal = 1; |
| 175 |
– |
// simError(); |
| 176 |
– |
//} |
| 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() { |
| 301 |
|
return properties_.getPropertyByName(propName); |
| 302 |
|
} |
| 303 |
|
|
| 303 |
– |
|
| 304 |
– |
|
| 305 |
– |
|
| 304 |
|
std::ostream& operator <<(std::ostream& o, Molecule& mol) { |
| 305 |
|
o << std::endl; |
| 306 |
|
o << "Molecule " << mol.getGlobalIndex() << "has: " << 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 |
|
|