33 |
|
|
34 |
|
} |
35 |
|
else{ |
36 |
+ |
|
37 |
|
indexOfAllZConsMols = index->getIndexData(); |
38 |
+ |
|
39 |
+ |
//the maximum value of index is the last one(we sorted the index data in SimSetup.cpp) |
40 |
+ |
int maxIndex; |
41 |
+ |
int totalNumMol; |
42 |
+ |
|
43 |
+ |
maxIndex = indexOfAllZConsMols[indexOfAllZConsMols.size() - 1]; |
44 |
+ |
|
45 |
+ |
#ifndef IS_MPI |
46 |
+ |
totalNumMol = nMols; |
47 |
+ |
#else |
48 |
+ |
totalNumMol = mpiSim->getTotNmol(); |
49 |
+ |
#endif |
50 |
+ |
|
51 |
+ |
if(maxIndex > totalNumMol - 1){ |
52 |
+ |
sprintf( painCave.errMsg, |
53 |
+ |
"ZConstraint error: index is out of range\n"); |
54 |
+ |
painCave.isFatal = 1; |
55 |
+ |
simError(); |
56 |
+ |
|
57 |
+ |
} |
58 |
+ |
|
59 |
|
} |
60 |
|
|
61 |
|
} |
491 |
|
|
492 |
|
template<typename T> void ZConstraint<T>::resetZ() |
493 |
|
{ |
494 |
+ |
|
495 |
+ |
double pos[3]; |
496 |
|
double deltaZ; |
497 |
|
double mzOfZCons; //total sum of m*z of z-constrain molecules |
498 |
|
double mzOfUncons; //total sum of m*z of unconstrain molecuels; |
527 |
|
#endif |
528 |
|
|
529 |
|
zsys = (totalMZOfZCons + totalMZOfUncons) /totalMassOfUncons; |
530 |
< |
|
507 |
< |
cout << "current time: " << info->getTime() <<endl; |
530 |
> |
|
531 |
|
for(int i = 0; i < zconsMols.size(); i++){ |
532 |
|
|
533 |
|
zconsMols[i]->getCOM(COM); |
534 |
|
|
512 |
– |
cout << "global index: " << zconsMols[i]->getGlobalIndex() << "\tZ: " << COM[2] << "\t"; |
535 |
|
deltaZ = zsys + refZ[i] - COM[2]; |
514 |
– |
cout << "\tdistance: " << COM[2] +deltaZ - zsys; |
536 |
|
//update z coordinate |
537 |
|
zconsAtoms = zconsMols[i]->getMyAtoms(); |
538 |
|
for(int j =0; j < zconsMols[i]->getNAtoms(); j++){ |
539 |
< |
zconsAtoms[j]->setZ(zconsAtoms[j]->getZ() + deltaZ); |
539 |
> |
zconsAtoms[j]->getPos(pos); |
540 |
> |
pos[2] += deltaZ; |
541 |
> |
zconsAtoms[j]->setPos(pos); |
542 |
|
} |
543 |
|
|
544 |
|
//calculate z constrain force |
545 |
|
fz[i] = massOfZConsMols[i]* deltaZ / dt2; |
546 |
|
|
524 |
– |
cout << "\tforce: " << fz[i] << endl; |
547 |
|
} |
548 |
|
|
549 |
|
|