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, 24107 (2008). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
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 |
|
/** |
55 |
|
#include "utils/simError.h" |
56 |
|
|
57 |
|
namespace OpenMD { |
58 |
< |
Molecule::Molecule(int stampId, int globalIndex, const std::string& molName) |
59 |
< |
: stampId_(stampId), globalIndex_(globalIndex), moleculeName_(molName) { |
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() { |
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 |
|
|
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) |
162 |
< |
// performs the "difference" operation from set theory, the output |
163 |
< |
// range contains a copy of every element that is contained in |
164 |
< |
// [allAtoms.begin(), allAtoms.end()) and not contained in |
165 |
< |
// [rigidAtoms.begin(), rigidAtoms.end()). |
166 |
< |
//std::set_difference(allAtoms.begin(), allAtoms.end(), rigidAtoms.begin(), rigidAtoms.end(), |
167 |
< |
// std::back_inserter(integrableObjects_)); |
171 |
> |
// then add the rigid bodies themselves to the integrableObjects |
172 |
|
|
169 |
– |
//if (integrableObjects_.size() != allAtoms.size() - rigidAtoms.size()) { |
170 |
– |
// //Some atoms in rigidAtoms are not in allAtoms, something must be wrong |
171 |
– |
// sprintf(painCave.errMsg, "Atoms in rigidbody are not in the atom list of the same molecule"); |
172 |
– |
// |
173 |
– |
// painCave.isFatal = 1; |
174 |
– |
// simError(); |
175 |
– |
//} |
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() { |
304 |
|
return properties_.getPropertyByName(propName); |
305 |
|
} |
306 |
|
|
302 |
– |
|
303 |
– |
|
304 |
– |
|
307 |
|
std::ostream& operator <<(std::ostream& o, Molecule& mol) { |
308 |
|
o << std::endl; |
309 |
|
o << "Molecule " << mol.getGlobalIndex() << "has: " << 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 |
|
|