100 |
|
cutoffGroup = createCutoffGroup(ff, mol, currentCutoffGroupStamp); |
101 |
|
mol->addCutoffGroup(cutoffGroup); |
102 |
|
} |
103 |
+ |
|
104 |
+ |
//every free atom is a cutoff group |
105 |
+ |
std::set<Atom*> allAtoms; |
106 |
+ |
typename Molecule::AtomIterator ai; |
107 |
+ |
|
108 |
+ |
//add all atoms into allAtoms set |
109 |
+ |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
110 |
+ |
allAtoms.insert(atom); |
111 |
+ |
} |
112 |
+ |
|
113 |
+ |
typename Molecule::CutoffGroupIterator ci; |
114 |
+ |
CutoffGroup* cg; |
115 |
+ |
std::set<Atom*> cutoffAtoms; |
116 |
+ |
|
117 |
+ |
//add all of the atoms belong to cutoff groups into cutoffAtoms set |
118 |
+ |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
119 |
+ |
|
120 |
+ |
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
121 |
+ |
cutoffAtoms.insert(atom); |
122 |
+ |
} |
123 |
+ |
|
124 |
+ |
} |
125 |
+ |
|
126 |
+ |
//find all free atoms (which do not belong to cutoff groups) |
127 |
+ |
//performs the "difference" operation from set theory, the output range contains a copy of every |
128 |
+ |
//element that is contained in [allAtoms.begin(), allAtoms.end()) and not contained in |
129 |
+ |
//[cutoffAtoms.begin(), cutoffAtoms.end()). |
130 |
+ |
std::vector<Atom*> freeAtoms; |
131 |
+ |
std::set_difference(allAtoms.begin(), allAtoms.end(), cutoffAtoms.begin(), cutoffAtoms.end(), |
132 |
+ |
std::back_inserter(freeAtoms.end())); |
133 |
+ |
|
134 |
+ |
if (freeAtoms.size() != allAtoms.size() - cutoffAtoms.size()) { |
135 |
+ |
//Some atoms in rigidAtoms are not in allAtoms, something must be wrong |
136 |
+ |
sprintf(painCave.errMsg, "Atoms in cutoff groups are not in the atom list of the same molecule"); |
137 |
+ |
|
138 |
+ |
painCave.isFatal = 1; |
139 |
+ |
simError(); |
140 |
+ |
} |
141 |
+ |
|
142 |
+ |
//loop over the free atoms and then create one cutoff group for every single free atom |
143 |
+ |
std::vector<Atom*>::iterator fai; |
144 |
|
|
145 |
+ |
for (fai = freeAtoms.begin(); fai != freeAtoms.end(); ++fai) { |
146 |
+ |
createCutoffGroup(mol, *fai); |
147 |
+ |
mol->addCutoffGroup(cutoffGroup); |
148 |
+ |
} |
149 |
|
//create constraints |
150 |
|
|
151 |
|
//the construction of this molecule is finished |
257 |
|
} |
258 |
|
|
259 |
|
Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol, BendStamp* stamp) { |
260 |
< |
BendType* bendType; |
261 |
< |
Atom* atomA; |
217 |
< |
Atom* atomB; |
218 |
< |
Atom* atomC; |
260 |
> |
bool isGhostBend = false; |
261 |
> |
int ghostIndex; |
262 |
|
|
220 |
– |
//need to consider the ghost bend |
221 |
– |
atomA = mol->getAtomAt(stamp->getA()); |
222 |
– |
atomB = mol->getAtomAt(stamp->getB()); |
223 |
– |
atomC = mol->getAtomAt(stamp->getC()); |
224 |
– |
|
225 |
– |
assert( atomA && atomB && atomC); |
263 |
|
|
264 |
< |
bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType()); |
264 |
> |
// |
265 |
> |
if (stamp->haveExtras()){ |
266 |
> |
LinkedAssign* extras = currentBend->getExtras(); |
267 |
> |
LinkedAssign* currentExtra = extras; |
268 |
|
|
269 |
< |
if (bendType == NULL) { |
270 |
< |
sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", |
271 |
< |
atomA->getType().c_str(), |
272 |
< |
atomB->getType().c_str(), |
273 |
< |
atomC->getType().c_str()); |
269 |
> |
while (currentExtra != NULL){ |
270 |
> |
if (!strcmp(currentExtra->getlhs(), "ghostVectorSource")){ |
271 |
> |
switch (currentExtra->getType()){ |
272 |
> |
case 0: |
273 |
> |
ghostIndex = currentExtra->getInt(); |
274 |
> |
isGhostBend = true; |
275 |
> |
break; |
276 |
|
|
277 |
< |
painCave.isFatal = 1; |
278 |
< |
simError(); |
277 |
> |
default: |
278 |
> |
sprintf(painCave.errMsg, |
279 |
> |
"SimSetup Error: ghostVectorSource must be an int.\n"); |
280 |
> |
painCave.isFatal = 1; |
281 |
> |
simError(); |
282 |
> |
} |
283 |
> |
} else{ |
284 |
> |
sprintf(painCave.errMsg, |
285 |
> |
"SimSetup Error: unhandled bend assignment:\n"); |
286 |
> |
painCave.isFatal = 1; |
287 |
> |
simError(); |
288 |
> |
} |
289 |
> |
currentExtra = currentExtra->getNext(); |
290 |
> |
} |
291 |
> |
|
292 |
|
} |
293 |
|
|
294 |
< |
return new Bond(atomA, atomB, bendType); |
294 |
> |
if (isGhostBend) { |
295 |
|
|
296 |
+ |
int indexA = stamp->getA(); |
297 |
+ |
int indexB= stamp->getB(); |
298 |
+ |
|
299 |
+ |
assert(indexA != indexB); |
300 |
+ |
|
301 |
+ |
int normalIndex; |
302 |
+ |
if (indexA == ghostIndex) { |
303 |
+ |
normalIndex = indexB; |
304 |
+ |
} else if (indexB == ghostIndex) { |
305 |
+ |
normalIndex = indexA; |
306 |
+ |
} |
307 |
+ |
|
308 |
+ |
Atom* normalAtom = mol->getAtomAt(normalIndex) ; |
309 |
+ |
Atom* ghostAtom = mol->getAtomAt(ghostIndex); |
310 |
+ |
|
311 |
+ |
BendType* bendType = ff->getBendType(normalAtom->getType(), ghostAtom->getType(), "GHOST"); |
312 |
+ |
|
313 |
+ |
if (bendType == NULL) { |
314 |
+ |
sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", |
315 |
+ |
normalAtom->getType().c_str(), |
316 |
+ |
ghostAtom->getType().c_str(), |
317 |
+ |
"GHOST"); |
318 |
+ |
|
319 |
+ |
painCave.isFatal = 1; |
320 |
+ |
simError(); |
321 |
+ |
} |
322 |
+ |
|
323 |
+ |
return new GhostBend(normalAtom, ghostAtom, bendType); |
324 |
+ |
|
325 |
+ |
} else { |
326 |
+ |
|
327 |
+ |
Atom* atomA = mol->getAtomAt(stamp->getA()); |
328 |
+ |
Atom* atomB = mol->getAtomAt(stamp->getB()); |
329 |
+ |
Atom* atomC = mol->getAtomAt(stamp->getC()); |
330 |
+ |
|
331 |
+ |
assert( atomA && atomB && atomC); |
332 |
+ |
|
333 |
+ |
BendType* bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType()); |
334 |
+ |
|
335 |
+ |
if (bendType == NULL) { |
336 |
+ |
sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", |
337 |
+ |
atomA->getType().c_str(), |
338 |
+ |
atomB->getType().c_str(), |
339 |
+ |
atomC->getType().c_str()); |
340 |
+ |
|
341 |
+ |
painCave.isFatal = 1; |
342 |
+ |
simError(); |
343 |
+ |
} |
344 |
+ |
|
345 |
+ |
return new Bend(atomA, atomB, atomC, bendType); |
346 |
+ |
} |
347 |
|
} |
348 |
|
|
349 |
|
Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) { |
393 |
|
return cg; |
394 |
|
} |
395 |
|
|
396 |
+ |
CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule * mol, Atom* atom) { |
397 |
+ |
CutoffGroup* cg; |
398 |
+ |
cg = new CutoffGroup(); |
399 |
+ |
cg->addAtom(); |
400 |
+ |
return cg; |
401 |
+ |
} |
402 |
|
//Constraint* MoleculeCreator::createConstraint() { |
403 |
|
|
404 |
|
//} |