30 #include "ProxyMgr.decl.h" 49 #include "ComputeQMMgr.decl.h" 56 #define MIN_DEBUG_LEVEL 2 71 int average(
CompAtom *qtilde,
const HGArrayVector &q,
BigReal *lambda,
const int n,
const int m,
const HGArrayBigReal &imass,
const HGArrayBigReal &length2,
const HGArrayInt &ial,
const HGArrayInt &ibl,
const HGArrayVector &refab,
const BigReal tolf,
const int ntrial);
78 const BigReal tol2,
const int maxiter,
79 bool& done,
bool& consFailure);
80 #define MASS_EPSILON (1.0e-35) //a very small floating point number 84 #if NAMD_SeparateWaters != 0 95 #define IS_HYDROGEN_GROUP_WATER(hgs, mass) \ 96 ((hgs >= 3) && ((mass >= 14.0) && (mass <= 18.0))) 100 #ifdef TIMER_COLLECTION 101 const char *TimerSet::tlabel[TimerSet::NUMTIMERS] = {
122 settle_initialized = 0;
125 rattleListValid =
false;
126 rattleListValid_SOA =
false;
131 numGBISP1Arrived = 0;
132 numGBISP2Arrived = 0;
133 numGBISP3Arrived = 0;
134 phase1BoxClosedCalled =
false;
135 phase2BoxClosedCalled =
false;
136 phase3BoxClosedCalled =
false;
144 center = 0.5*(min+max);
149 aAwayDist = (max.x - min.x) * aAway;
156 bAwayDist = (max.y - min.y) * bAway;
163 cAwayDist = (max.z - min.z) * cAway;
168 migrationSuspended =
false;
169 allMigrationIn =
false;
170 marginViolations = 0;
176 flags.maxForceUsed = -1;
178 numAtoms = atom.size();
179 replacementForces = 0;
182 doPairlistCheck_newTolerance =
188 for (
int i = 0; i < numAtoms; ++i ) {
189 numFixedAtoms += ( atom[i].atomFixed ? 1 : 0 );
195 sizeCudaAtomList = 0;
198 #ifdef NODEAWARE_PROXY_SPANNINGTREE 207 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 215 sort_solvent_atoms();
219 buildRattleList_SOA();
220 rattleListValid_SOA =
true;
226 #if NAMD_SeparateWaters != 0 229 tempAtom.resize(numAtoms);
239 gridForceIdxChecked=
false;
244 void HomePatch::write_tip4_props() {
245 printf(
"Writing r_om and r_ohc: %f | %f\n", r_om, r_ohc);
248 void HomePatch::init_tip4() {
256 void ::HomePatch::init_swm4() {
278 sort_solvent_atoms();
289 #if NAMD_SeparateWaters != 0 302 { sequencer=sequencerPtr; }
306 { sequencer->
run(); }
308 void HomePatch::readPatchMap() {
313 patchMigrationCounter = numNeighbors
315 DebugM( 1,
"NumNeighbors for pid " <<
patchID<<
" is "<< numNeighbors <<
"\n");
317 for (n=0; n<numNeighbors; n++) {
318 realInfo[n].
destNodeID =
p->node(realInfo[n].destPatchID = nnPatchID[n]);
319 DebugM( 1,
" nnPatchID=" <<nnPatchID[n]<<
" nnNodeID="<< realInfo[n].destNodeID<<
"\n");
324 for (
int i=0; i<3; i++)
325 for (
int j=0; j<3; j++)
326 for (
int k=0; k<3; k++)
328 int pid =
p->pid(
p->index_a(
patchID)+i-1,
331 DebugM(5,
"ERROR, for patchID " <<
patchID <<
" I got neigh pid = " << pid <<
"\n");
334 ( (i-1) &&
p->periodic_a() ) ||
335 ( (j-1) &&
p->periodic_b() ) ||
336 ( (k-1) &&
p->periodic_c() ) )) {
337 mInfo[i][j][k] = NULL;
342 for (n = 0; n<numNeighbors; n++) {
343 if (pid == realInfo[n].destPatchID) {
344 mInfo[i][j][k] = &realInfo[n];
348 if (n == numNeighbors) {
349 DebugM(4,
"BAD News, I could not find PID " << pid <<
"\n");
354 DebugM(1,
"Patch("<<
patchID<<
") # of neighbors = " << numNeighbors <<
"\n");
360 #ifdef NODEAWARE_PROXY_SPANNINGTREE 362 #ifdef USE_NODEPATCHMGR 363 delete [] nodeChildren;
373 phase1BoxClosedCalled =
true;
382 }
else if (box == 6) {
384 }
else if (box == 7) {
386 }
else if (box == 8) {
387 phase2BoxClosedCalled =
true;
398 }
else if (box == 9) {
400 }
else if (box == 10) {
408 if ( replacementForces ) {
409 for (
int i = 0; i <
numAtoms; ++i ) {
410 if ( replacementForces[i].replace ) {
415 replacementForces = 0;
417 DebugM(1,
patchID <<
": " << CthSelf() <<
" awakening sequencer " 418 << sequencer->thread <<
"(" <<
patchID <<
") @" << CmiTimer() <<
"\n");
421 phase3BoxClosedCalled =
true;
426 if (numGBISP1Arrived == proxy.
size() &&
427 numGBISP2Arrived == proxy.
size() &&
428 numGBISP3Arrived == proxy.
size()) {
449 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 458 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 463 for ( ; *pe != n; ++pe );
469 #if USE_TOPOMAP && USE_SPANNING_TREE 471 int HomePatch::findSubroots(
int dim,
int* subroots,
int psize,
int* pidscopy){
474 int conesizes[6] = {0,0,0,0,0,0};
475 int conecounters[6] = {0,0,0,0,0,0};
476 int childcounter = 0;
479 for(
int i=0;i<psize;i++){
480 int cone = tmgr.getConeNumberForRank(pidscopy[i]);
481 cones[cone][conesizes[cone]++] = pidscopy[i];
484 while(childcounter<nChild){
485 for(
int i=0;i<6;i++){
486 if(conecounters[i]<conesizes[i]){
487 subroots[childcounter++] = cones[i][conecounters[i]++];
495 #endif // USE_TOPOMAP 499 int d1 = abs(*(
int *)a - CkMyPe());
500 int d2 = abs(*(
int *)b - CkMyPe());
512 CProxy_NodeProxyMgr pm(CkpvAccess(BOCclass_group).nodeProxyMgr);
520 #ifdef NODEAWARE_PROXY_SPANNINGTREE 521 void HomePatch::buildNodeAwareSpanningTree(
void){
522 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG) 523 DebugFileTrace *dft = DebugFileTrace::Object();
525 dft->writeTrace(
"HomePatch[%d] has %d proxy on proc[%d] node[%d]\n",
patchID, proxy.
size(), CkMyPe(), CkMyNode());
526 dft->writeTrace(
"Proxies are: ");
527 for(
int i=0; i<proxy.
size(); i++) dft->writeTrace(
"%d(%d), ", proxy[i], CkNodeOf(proxy[i]));
528 dft->writeTrace(
"\n");
539 ProxyMgr::buildSinglePatchNodeAwareSpanningTree(
patchID, proxy, ptnTree);
543 setupChildrenFromProxySpanningTree();
548 void HomePatch::setupChildrenFromProxySpanningTree(){
549 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 552 if(ptnTree.size()==0) {
556 #ifdef USE_NODEPATCHMGR 558 delete [] nodeChildren;
564 CmiAssert(rootnode->
peIDs[0] == CkMyPe());
568 int internalChild = rootnode->
numPes-1;
569 int externalChild = ptnTree.size()-1;
573 if(internalSlots==0) {
577 internalChild = (internalSlots>internalChild)?internalChild:internalSlots;
581 nChild = externalChild+internalChild;
586 child =
new int[nChild];
588 for(
int i=0; i<externalChild; i++) {
589 child[i] = ptnTree.item(i+1).peIDs[0];
591 for(
int i=externalChild, j=1; i<nChild; i++, j++) {
592 child[i] = rootnode->
peIDs[j];
595 #ifdef USE_NODEPATCHMGR 598 CProxy_NodeProxyMgr pm(CkpvAccess(BOCclass_group).nodeProxyMgr);
608 numNodeChild = externalChild;
609 if(internalChild) numNodeChild++;
610 delete [] nodeChildren;
611 nodeChildren =
new int[numNodeChild];
612 for(
int i=0; i<externalChild; i++) {
613 nodeChildren[i] = ptnTree.item(i+1).nodeID;
618 nodeChildren[numNodeChild-1] = rootnode->
nodeID;
621 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG) 622 DebugFileTrace *dft = DebugFileTrace::Object();
624 dft->writeTrace(
"HomePatch[%d] has %d children: ",
patchID, nChild);
625 for(
int i=0; i<nChild; i++)
626 dft->writeTrace(
"%d ", child[i]);
627 dft->writeTrace(
"\n");
633 #ifdef NODEAWARE_PROXY_SPANNINGTREE 638 ptnTree.resize(treesize);
639 int *pAllPes = msg->
allPes;
640 for(
int i=0; i<treesize; i++) {
642 delete [] oneNode->
peIDs;
644 oneNode->
nodeID = CkNodeOf(*pAllPes);
646 for(
int j=0; j<oneNode->
numPes; j++) {
647 oneNode->
peIDs[j] = *pAllPes;
652 setupChildrenFromProxySpanningTree();
658 if(ptnTree.size()==0)
return;
662 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG) 666 CmiAssert(CkMyPe() == msg->
allPes[0]);
675 #ifndef NODEAWARE_PROXY_SPANNINGTREE 682 for (i=0; i<n; i++) {
687 if (tree.
size() <= i)
break;
688 child[i-1] = tree[i];
692 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 702 if (tree.
size() == 0)
return;
705 msg->
node = CkMyPe();
714 #ifndef NODEAWARE_PROXY_SPANNINGTREE 718 int psize = proxy.
size();
719 if (psize == 0)
return;
721 int oldsize = oldtree.
size();
732 for ( pli = proxy.
begin(); pli != proxy.
end(); ++pli )
734 int oldindex = oldtree.
find(*pli);
735 if (oldindex != -1 && oldindex < psize) {
736 tree[oldindex] = *pli;
740 for ( pli = proxy.
begin(); pli != proxy.
end(); ++pli )
742 if (tree.
find(*pli) != -1)
continue;
744 while (tree[e] != -1) { e--;
if (e==-1) e = psize; }
747 while (tree[s] != -1) { s++;
if (s==psize+1) s = 1; }
753 if (oldsize==0 && nNonPatch) {
761 #if USE_TOPOMAP && USE_SPANNING_TREE 764 int *treecopy =
new int [psize];
776 for(i=0;i<psize;i++){
777 treecopy[i] = tree[i+1];
781 tmgr.sortRanksByHops(treecopy,nNonPatch);
782 tmgr.sortRanksByHops(treecopy+nNonPatch,
786 nChild = findSubroots(
proxySpanDim,subroots,psize,treecopy);
789 for(
int i=1;i<psize+1;i++){
791 for(
int j=0;j<nChild;j++)
792 if(tree[i]==subroots[j]){
796 if(isSubroot)
continue;
799 tmgr.sortIndexByHops(tree[i], subroots,
803 subtrees[idxes[j]][(subsizes[idxes[j]])++] = tree[i];
809 NAMD_bug(
"HomePatch BGL Spanning Tree error: Couldn't find subtree for leaf\n");
816 if (tree.
size() <= i)
break;
817 child[i-1] = tree[i];
825 CkPrintf(
"[%d] Spanning tree for %d with %d children %d nNonPatch %d\n", CkMyPe(),
patchID, psize, nNonPatch);
826 for (
int i=0; i<psize+1; i++) {
827 CkPrintf(
"%d ", tree[i]);
844 char *iszeroPtr = msg->
isZero;
850 for(
int i=0; i<msg->
flLen[k]; i++, rfPtr++, iszeroPtr++) {
851 if((*iszeroPtr)!=1) {
872 for ( ; f_i != f_e; ++f_i, ++
f ) *
f += *f_i;
888 int nf = msg->
flLen[k];
890 #pragma disjoint (*f_i, *f) 892 for (
int count = 0; count < nf; count++) {
894 f[count].x += f_i->
x;
895 f[count].y += f_i->
y;
896 f[count].z += f_i->
z;
919 ComputeQMMgr *mgrP = CProxy_ComputeQMMgr::ckLocalBranch(
920 CkpvAccess(BOCclass_group).computeQMMgr) ;
928 if ( subP != NULL ) {
941 for (
int qmIter=0; qmIter<numQMAtms; qmIter++) {
943 if (qmAtmIndx[qmIter] == subP->
newID) {
979 if (!patchMapRead) { readPatchMap(); }
980 if (numNeighbors && !
simParams->staticAtomAssignment) {
984 copy_updates_to_AOS();
997 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED) 1008 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) 1009 if ( doMigration ) {
1012 int * __restrict ao_SOA = patchDataSOA.
sortOrder;
1013 int * __restrict unsort_SOA = patchDataSOA.
unsortOrder;
1014 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || (defined(NAMD_MIC) && MIC_SORT_ATOMS != 0) 1020 int * __restrict atomFixed = patchDataSOA.
atomFixed;
1021 for (
int j=0; j<n; ++j ) {
1023 if ( atomFixed[j] ) ao_SOA[--k2] = j;
1024 else ao_SOA[k++] = j;
1029 for (
int j=0; j<n; ++j ) {
1039 for (
int i = 0; i < n; ++i) {
1041 printf(
"ao_SOA[%d] = %d\n", i, ao_SOA[i]);
1046 for (
int i = 0; i < n; ++i) {
1054 const BigReal ucenter_x = ucenter.
x;
1055 const BigReal ucenter_y = ucenter.
y;
1056 const BigReal ucenter_z = ucenter.
z;
1058 #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0) 1060 n_16 = (n + 15) & (~15);
1061 cudaAtomList.
resize(n_16);
1063 mic_position_t *atom_x = ((mic_position_t*)ac) + (0 * n_16);
1064 mic_position_t *atom_y = ((mic_position_t*)ac) + (1 * n_16);
1065 mic_position_t *atom_z = ((mic_position_t*)ac) + (2 * n_16);
1066 mic_position_t *atom_q = ((mic_position_t*)ac) + (3 * n_16);
1067 #elif defined(NAMD_AVXTILES) 1068 int n_avx = (n + 15) & (~15);
1069 cudaAtomList.
resize(n_avx);
1071 tiles.realloc(n, ac);
1073 if(doMigration) cudaAtomList.
resize(n);
1076 double * __restrict pos_x = patchDataSOA.
pos_x;
1077 double * __restrict pos_y = patchDataSOA.
pos_y;
1078 double * __restrict pos_z = patchDataSOA.
pos_z;
1079 float * __restrict charge = patchDataSOA.
charge;
1080 int * __restrict ao_SOA = patchDataSOA.
sortOrder;
1081 #ifndef NODEGROUP_FORCE_REGISTER 1083 for (
int k=0; k<n; ++k ) {
1084 #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0) 1086 atom_x[k] = pos_x[j] - ucenter_x;
1087 atom_y[k] = pos_y[j] - ucenter_y;
1088 atom_z[k] = pos_z[j] - ucenter_z;
1089 atom_q[k] = charge_scaling * charge[j];
1097 ac[k].
x = pos_x[j] - ucenter_x;
1098 ac[k].
y = pos_y[j] - ucenter_y;
1099 ac[k].
z = pos_z[j] - ucenter_z;
1104 ac[k].
q = charge_scaling * charge[j];
1108 if(!
simParams->CUDASOAintegrate || doMigration){
1109 for (
int k=0; k<n; ++k ) {
1110 #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0) 1112 atom_x[k] = pos_x[j] - ucenter_x;
1113 atom_y[k] = pos_y[j] - ucenter_y;
1114 atom_z[k] = pos_z[j] - ucenter_z;
1115 atom_q[k] = charge_scaling * charge[j];
1122 ac[k].
x = pos_x[j] - ucenter_x;
1123 ac[k].
y = pos_y[j] - ucenter_y;
1124 ac[k].
z = pos_z[j] - ucenter_z;
1129 ac[k].
q = charge_scaling * charge[j];
1136 doMigration = doMigration && numNeighbors;
1138 doMigration = doMigration || ! patchMapRead;
1140 doMigration = doMigration || doAtomUpdate;
1141 doAtomUpdate =
false;
1152 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP) 1164 const double * __restrict pos_x = patchDataSOA.
pos_x;
1165 const double * __restrict pos_y = patchDataSOA.
pos_y;
1166 const double * __restrict pos_z = patchDataSOA.
pos_z;
1167 const float * __restrict charge = patchDataSOA.
charge;
1168 const int * __restrict vdwType = patchDataSOA.
vdwType;
1170 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP) 1176 for (
int i=0; i < n; i++) {
1177 p_i[i].position.x = pos_x[i];
1178 p_i[i].position.y = pos_y[i];
1179 p_i[i].position.z = pos_z[i];
1180 p_i[i].charge = charge[i];
1181 p_i[i].vdwType = vdwType[i];
1183 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP) 1184 p_i[i].nonbondedGroupSize = nonbondedGroupSize[i];
1186 p_i[i].hydrogenGroupSize = hydrogenGroupSize[i];
1189 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) 1190 const int * __restrict sortOrder = patchDataSOA.
sortOrder;
1192 const int * __restrict
id = patchDataSOA.
id;
1193 #if defined(MEM_OPT_VERSION) 1194 const int * __restrict exclId = patchDataSOA.
exclId;
1195 const int * __restrict sigId = patchDataSOA.
sigId;
1197 const int * __restrict atomFixed = patchDataSOA.
atomFixed;
1198 const int * __restrict groupFixed = patchDataSOA.
groupFixed;
1201 #ifndef USE_NO_BITFIELDS 1203 #endif // USE_NO_BITFIELDS 1204 for (
int i=0; i < n; i++) {
1205 #ifndef USE_NO_BITFIELDS 1206 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) 1209 #if defined(MEM_OPT_VERSION) 1210 pExtCopy_i[i].
id =
id[i];
1211 pExtCopy_i[i].exclId = exclId[i];
1212 ASSERT(atomFixed[i] == 0 || atomFixed[i] == 1);
1213 ASSERT(groupFixed[i] == 0 || groupFixed[i] == 1);
1216 pExtCopy_i[i].sigId = (sigId[i] | atomFixedBit | groupFixedBit);
1218 ASSERT(atomFixed[i] == 0 || atomFixed[i] == 1);
1219 ASSERT(groupFixed[i] == 0 || groupFixed[i] == 1);
1222 pExtCopy_i[i].
id = (
id[i] | atomFixedBit | groupFixedBit);
1223 #endif // if defined(MEM_OPT_VERSION) 1225 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) 1226 pExt_i[i].sortOrder = sortOrder[i];
1228 pExt_i[i].id =
id[i];
1229 #if defined(MEM_OPT_VERSION) 1230 pExt_i[i].exclId = exclId[i];
1231 pExt_i[i].sigId = sigId[i];
1233 pExt_i[i].atomFixed = atomFixed[i];
1234 pExt_i[i].groupFixed = groupFixed[i];
1235 #endif // USE_NO_BITFIELDS 1244 const double * __restrict pos_x = patchDataSOA.
pos_x;
1245 const double * __restrict pos_y = patchDataSOA.
pos_y;
1246 const double * __restrict pos_z = patchDataSOA.
pos_z;
1247 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP) 1251 #ifndef NODEGROUP_FORCE_REGISTER 1253 for (
int i=0; i < n; i++) {
1254 p_i[i].position.x = pos_x[i];
1255 p_i[i].position.y = pos_y[i];
1256 p_i[i].position.z = pos_z[i];
1257 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP) 1258 p_i[i].nonbondedGroupSize = nonbondedGroupSize[i];
1262 if(!
simParams->CUDASOAintegrate || doMigration){
1263 for (
int i=0; i < n; i++) {
1264 p_i[i].position.x = pos_x[i];
1265 p_i[i].position.y = pos_y[i];
1266 p_i[i].position.z = pos_z[i];
1267 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP) 1268 p_i[i].nonbondedGroupSize = nonbondedGroupSize[i];
1273 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) 1274 const int * __restrict sortOrder = patchDataSOA.
sortOrder;
1275 #ifdef NODEGROUP_FORCE_REGISTER 1277 if(!
simParams->CUDASOAintegrate || doMigration){
1278 for (
int i=0; i < n; i++) {
1279 pExt_i[i].sortOrder = sortOrder[i];
1284 for (
int i=0; i < n; i++) {
1285 pExt_i[i].sortOrder = sortOrder[i];
1293 #ifdef NODEGROUP_FORCE_REGISTER 1309 numGBISP1Arrived = 0;
1310 phase1BoxClosedCalled =
false;
1311 numGBISP2Arrived = 0;
1312 phase2BoxClosedCalled =
false;
1313 numGBISP3Arrived = 0;
1314 phase3BoxClosedCalled =
false;
1315 if (doMigration || isNewProxyAdded)
1320 if (doMigration || isNewProxyAdded) {
1329 int pidsPreAllocated = 1;
1332 npid = proxy.
size();
1333 pids =
new int[npid];
1334 pidsPreAllocated = 0;
1336 int *pide = pids + proxy.
size();
1337 int patchNodesLast =
1339 for ( pli = proxy.
begin(); pli != proxy.
end(); ++pli )
1349 #ifdef NODEAWARE_PROXY_SPANNINGTREE 1350 #ifdef USE_NODEPATCHMGR 1351 npid = numNodeChild;
1352 pids = nodeChildren;
1359 pidsPreAllocated = 0;
1361 for (
int i=0; i<nChild; i++) pids[i] = child[i];
1368 int pdMsgPLLen =
p.
size();
1369 int pdMsgAvgPLLen = 0;
1379 pdMsgVLLen =
v.
size();
1386 if (
flags.
doGBIS && (doMigration || isNewProxyAdded)) {
1392 int lcpoTypeLen = 0;
1394 if (
flags.
doLCPO && (doMigration || isNewProxyAdded)) {
1399 int pdMsgPLExtLen = 0;
1400 if(doMigration || isNewProxyAdded) {
1404 int cudaAtomLen = 0;
1405 #if defined(NAMD_CUDA) || defined(NAMD_HIP) 1410 #if MIC_HANDCODE_FORCE_SOA_VS_AOS != 0 1413 cudaAtomLen = (
numAtoms + 15) & (~15);
1416 ProxyDataMsg *nmsg =
new (pdMsgPLLen, pdMsgAvgPLLen, pdMsgVLLen, intRadLen,
1422 nmsg->
plLen = pdMsgPLLen;
1434 nmsg->
vlLen = pdMsgVLLen;
1443 if (
flags.
doGBIS && (doMigration || isNewProxyAdded)) {
1444 for (
int i = 0; i <
numAtoms * 2; i++) {
1451 if (
flags.
doLCPO && (doMigration || isNewProxyAdded)) {
1452 for (
int i = 0; i <
numAtoms; i++) {
1458 if(doMigration || isNewProxyAdded){
1463 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) 1469 #if NAMD_SeparateWaters != 0 1471 nmsg->numWaterAtoms = numWaterAtoms;
1474 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK) 1475 nmsg->isFromImmMsgCall = 0;
1478 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG) 1479 DebugFileTrace *dft = DebugFileTrace::Object();
1481 dft->writeTrace(
"HP::posReady: for HomePatch[%d], sending proxy msg to: ",
patchID);
1482 for(
int i=0; i<npid; i++) {
1483 dft->writeTrace(
"%d ", pids[i]);
1485 dft->writeTrace(
"\n");
1489 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 1490 if (isProxyChanged || localphs == NULL)
1495 for (
int i=0; i<nphs; i++) {
1496 CmiDestoryPersistent(localphs[i]);
1500 localphs =
new PersistentHandle[npid];
1502 for (
int i=0; i<npid; i++) {
1503 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) 1505 localphs[i] = CmiCreateNodePersistent(pids[i], persist_size,
sizeof(envelope)+
sizeof(
ProxyDataMsg));
1508 localphs[i] = CmiCreatePersistent(pids[i], persist_size,
sizeof(envelope)+
sizeof(
ProxyDataMsg));
1512 CmiAssert(nphs == npid && localphs != NULL);
1513 CmiUsePersistentHandle(localphs, nphs);
1515 if(doMigration || isNewProxyAdded) {
1520 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 1521 CmiUsePersistentHandle(NULL, 0);
1523 isNewProxyAdded = 0;
1526 if(!pidsPreAllocated)
delete [] pids;
1527 DebugM(4,
"patchID("<<
patchID<<
") doing positions Ready\n");
1529 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY 1530 positionPtrBegin =
p.
begin();
1531 positionPtrEnd =
p.
end();
1558 fprintf(stderr,
"Patch %d atom IDS\n", this->
patchID);
1560 for(
int i = 0 ; i <
numAtoms; i++){
1561 fprintf(stderr,
"atom[%d] = %d %d %d\n", i, atom[i].
id,
1577 #ifdef NODEGROUP_FORCE_REGISTER 1582 if (n > MigrationCUDAKernel::kMaxAtomsPerPatch) {
1583 NAMD_die(
"Device migration does not currently support patches with greater than 2048 atoms.\n" 1584 "Please run with a smaller margin or without device migration.\n");
1594 size_t nbytes = patchDataSOA.
numBytes;
1596 #if defined(NAMD_CUDA) || defined(NAMD_HIP) 1606 void HomePatch::clearAtomMap() {
1621 const int numAtomAlloc = 2048;
1623 cudaAtomList.
reserve(numAtomAlloc);
1638 size_t nbytes = patchDataSOA.
numBytes;
1640 #if defined(NAMD_CUDA) || defined(NAMD_HIP) 1650 doMigration = doMigration || ! patchMapRead;
1652 doMigration = doMigration || doAtomUpdate;
1653 doAtomUpdate =
false;
1657 const bool updateAtomMap =
simParams->updateAtomMap;
1661 if (startup || updateAtomMap) {
1664 #ifndef USE_NO_BITFIELDS 1671 #ifndef USE_NO_BITFIELDS 1672 ASSERT(atomFixed == 0 || atomFixed == 1);
1673 ASSERT(groupFixed == 0 || groupFixed == 1);
1676 pExtCopy_i[i].
id = (
id | atomFixedBit | groupFixedBit);
1679 pExt_i[i].atomFixed = atomFixed;
1680 pExt_i[i].groupFixed = groupFixed;
1681 #endif // USE_NO_BITFIELDS 1688 p_i[i].
vdwType = atom[i].vdwType;
1692 p_i[i].partition = atom[i].partition;
1697 patchDataSOA.
id[i] = int(atom[i].
id);
1698 patchDataSOA.
atomFixed[i] = int(atom[i].atomFixed);
1699 patchDataSOA.
groupFixed[i] = int(atom[i].groupFixed);
1701 }
else if (updateAtomMap) {
1703 copy_atoms_to_SOA();
1708 #ifdef NODEGROUP_FORCE_REGISTER 1719 int pidsPreAllocated = 1;
1722 npid = proxy.
size();
1723 pids =
new int[npid];
1724 pidsPreAllocated = 0;
1726 int *pide = pids + proxy.
size();
1727 int patchNodesLast =
1729 for ( pli = proxy.
begin(); pli != proxy.
end(); ++pli )
1739 #ifdef NODEAWARE_PROXY_SPANNINGTREE 1740 #ifdef USE_NODEPATCHMGR 1741 npid = numNodeChild;
1742 pids = nodeChildren;
1749 pidsPreAllocated = 0;
1751 for (
int i=0; i<nChild; i++) pids[i] = child[i];
1758 int pdMsgPLLen =
p.
size();
1759 int pdMsgAvgPLLen = 0;
1767 int lcpoTypeLen = 0;
1769 int pdMsgPLExtLen = 0;
1770 if(doMigration || isNewProxyAdded) {
1774 int cudaAtomLen = 0;
1780 #if MIC_HANDCODE_FORCE_SOA_VS_AOS != 0 1783 cudaAtomLen = (
numAtoms + 15) & (~15);
1786 ProxyDataMsg *nmsg =
new (pdMsgPLLen, pdMsgAvgPLLen, pdMsgVLLen, intRadLen,
1792 nmsg->
plLen = pdMsgPLLen;
1799 nmsg->
vlLen = pdMsgVLLen;
1803 if(doMigration || isNewProxyAdded){
1808 #if defined(NAMD_CUDA) || defined(NAMD_MIC) 1814 #if NAMD_SeparateWaters != 0 1816 nmsg->numWaterAtoms = numWaterAtoms;
1819 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK) 1820 nmsg->isFromImmMsgCall = 0;
1823 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG) 1824 DebugFileTrace *dft = DebugFileTrace::Object();
1826 dft->writeTrace(
"HP::posReady: for HomePatch[%d], sending proxy msg to: ",
patchID);
1827 for(
int i=0; i<npid; i++) {
1828 dft->writeTrace(
"%d ", pids[i]);
1830 dft->writeTrace(
"\n");
1834 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 1835 if (isProxyChanged || localphs == NULL)
1838 for (
int i=0; i<nphs; i++) {
1839 CmiDestoryPersistent(localphs[i]);
1843 localphs =
new PersistentHandle[npid];
1845 for (
int i=0; i<npid; i++) {
1846 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) 1848 localphs[i] = CmiCreateNodePersistent(pids[i], persist_size,
sizeof(envelope)+
sizeof(
ProxyDataMsg));
1851 localphs[i] = CmiCreatePersistent(pids[i], persist_size,
sizeof(envelope)+
sizeof(
ProxyDataMsg));
1855 CmiAssert(nphs == npid && localphs != NULL);
1856 CmiUsePersistentHandle(localphs, nphs);
1858 if(doMigration || isNewProxyAdded) {
1863 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 1864 CmiUsePersistentHandle(NULL, 0);
1866 isNewProxyAdded = 0;
1869 if(!pidsPreAllocated)
delete [] pids;
1870 DebugM(4,
"patchID("<<
patchID<<
") doing positions Ready\n");
1872 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY 1873 positionPtrBegin =
p.
begin();
1874 positionPtrEnd =
p.
end();
1887 #endif // NODEGROUP_FORCE_REGISTER 1902 if (!patchMapRead) { readPatchMap(); }
1904 if (numNeighbors && !
simParams->staticAtomAssignment) {
1913 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED) 1922 #if defined(NAMD_CUDA) || defined(NAMD_MIC) || defined(NAMD_AVXTILES) || defined(NAMD_HIP) 1923 #ifdef NAMD_AVXTILES 1926 if ( doMigration ) {
1929 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_AVXTILES) || \ 1930 (defined(NAMD_MIC) && MIC_SORT_ATOMS != 0) 1931 int *ao =
new int[n];
1936 for (
int j=0; j<n; ++j ) {
1938 if ( a_i[j].atomFixed ) ao[--k2] = j;
1944 for (
int j=0; j<n; ++j ) {
1949 for (
int i=0; i<n; ++i ) {
1954 for (
int i = 0; i < n; ++i) {
1963 const BigReal ucenter_x = ucenter.
x;
1964 const BigReal ucenter_y = ucenter.
y;
1965 const BigReal ucenter_z = ucenter.
z;
1967 #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0) 1969 n_16 = (n + 15) & (~15);
1970 cudaAtomList.
resize(n_16);
1972 mic_position_t *atom_x = ((mic_position_t*)ac) + (0 * n_16);
1973 mic_position_t *atom_y = ((mic_position_t*)ac) + (1 * n_16);
1974 mic_position_t *atom_z = ((mic_position_t*)ac) + (2 * n_16);
1975 mic_position_t *atom_q = ((mic_position_t*)ac) + (3 * n_16);
1976 #elif defined(NAMD_AVXTILES) 1977 int n_avx = (n + 15) & (~15);
1978 cudaAtomList.
resize(n_avx);
1980 tiles.realloc(n, ac);
1986 reallocate_host<CudaAtom>(&cudaAtomList, &sizeCudaAtomList, n);
1991 for (
int k=0; k<n; ++k ) {
1992 #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0) 1994 atom_x[k] = a[j].
position.
x - ucenter_x;
1995 atom_y[k] = a[j].
position.
y - ucenter_y;
1996 atom_z[k] = a[j].
position.
z - ucenter_z;
1997 atom_q[k] = charge_scaling * a[j].
charge;
2003 ac[k].q = charge_scaling * a[j].
charge;
2006 #ifdef NAMD_AVXTILES 2010 for (
int k=n; k<n_avx; ++k ) {
2019 #ifdef NAMD_AVXTILES 2021 }
else doMigration = doMigration && numNeighbors;
2024 doMigration = doMigration && numNeighbors;
2026 doMigration = doMigration || ! patchMapRead;
2028 doMigration = doMigration || doAtomUpdate;
2029 doAtomUpdate =
false;
2040 #if ! (defined(NAMD_CUDA) || defined(NAMD_HIP)) 2041 #if defined(NAMD_AVXTILES) 2057 for ( i=0; i<n; ++i ) {
2072 numGBISP1Arrived = 0;
2073 phase1BoxClosedCalled =
false;
2074 numGBISP2Arrived = 0;
2075 phase2BoxClosedCalled =
false;
2076 numGBISP3Arrived = 0;
2077 phase3BoxClosedCalled =
false;
2078 if (doMigration || isNewProxyAdded)
2083 if (doMigration || isNewProxyAdded) {
2091 int pidsPreAllocated = 1;
2094 npid = proxy.
size();
2095 pids =
new int[npid];
2096 pidsPreAllocated = 0;
2098 int *pide = pids + proxy.
size();
2099 int patchNodesLast =
2101 for ( pli = proxy.
begin(); pli != proxy.
end(); ++pli )
2111 #ifdef NODEAWARE_PROXY_SPANNINGTREE 2112 #ifdef USE_NODEPATCHMGR 2113 npid = numNodeChild;
2114 pids = nodeChildren;
2121 pidsPreAllocated = 0;
2123 for (
int i=0; i<nChild; i++) pids[i] = child[i];
2130 int pdMsgPLLen =
p.
size();
2131 int pdMsgAvgPLLen = 0;
2138 pdMsgVLLen =
v.
size();
2143 if (
flags.
doGBIS && (doMigration || isNewProxyAdded)) {
2148 int lcpoTypeLen = 0;
2149 if (
flags.
doLCPO && (doMigration || isNewProxyAdded)) {
2153 int pdMsgPLExtLen = 0;
2154 if(doMigration || isNewProxyAdded) {
2158 int cudaAtomLen = 0;
2159 #if defined(NAMD_CUDA) || defined(NAMD_HIP) 2161 #elif defined(NAMD_AVXTILES) 2163 cudaAtomLen = (
numAtoms + 15) & (~15);
2164 #elif defined(NAMD_MIC) 2165 #if MIC_HANDCODE_FORCE_SOA_VS_AOS != 0 2168 cudaAtomLen = (
numAtoms + 15) & (~15);
2172 ProxyDataMsg *nmsg =
new (pdMsgPLLen, pdMsgAvgPLLen, pdMsgVLLen, intRadLen,
2178 nmsg->
plLen = pdMsgPLLen;
2188 nmsg->
vlLen = pdMsgVLLen;
2194 if (
flags.
doGBIS && (doMigration || isNewProxyAdded)) {
2195 for (
int i = 0; i <
numAtoms * 2; i++) {
2200 if (
flags.
doLCPO && (doMigration || isNewProxyAdded)) {
2201 for (
int i = 0; i <
numAtoms; i++) {
2207 if(doMigration || isNewProxyAdded){
2212 #if defined(NAMD_CUDA) || defined(NAMD_MIC) || defined(NAMD_AVXTILES) || defined(NAMD_HIP) 2213 #ifdef NAMD_AVXTILES 2223 #if NAMD_SeparateWaters != 0 2225 nmsg->numWaterAtoms = numWaterAtoms;
2228 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK) 2229 nmsg->isFromImmMsgCall = 0;
2232 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG) 2233 DebugFileTrace *dft = DebugFileTrace::Object();
2235 dft->writeTrace(
"HP::posReady: for HomePatch[%d], sending proxy msg to: ",
patchID);
2236 for(
int i=0; i<npid; i++) {
2237 dft->writeTrace(
"%d ", pids[i]);
2239 dft->writeTrace(
"\n");
2243 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 2244 if (isProxyChanged || localphs == NULL)
2249 for (
int i=0; i<nphs; i++) {
2250 CmiDestoryPersistent(localphs[i]);
2254 localphs =
new PersistentHandle[npid];
2256 for (
int i=0; i<npid; i++) {
2257 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) 2259 localphs[i] = CmiCreateNodePersistent(pids[i], persist_size,
sizeof(envelope)+
sizeof(
ProxyDataMsg));
2262 localphs[i] = CmiCreatePersistent(pids[i], persist_size,
sizeof(envelope)+
sizeof(
ProxyDataMsg));
2266 CmiAssert(nphs == npid && localphs != NULL);
2267 CmiUsePersistentHandle(localphs, nphs);
2269 if(doMigration || isNewProxyAdded) {
2274 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 2275 CmiUsePersistentHandle(NULL, 0);
2277 isNewProxyAdded = 0;
2280 if(!pidsPreAllocated)
delete [] pids;
2281 DebugM(4,
"patchID("<<
patchID<<
") doing positions Ready\n");
2283 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY 2284 positionPtrBegin =
p.
begin();
2285 positionPtrEnd =
p.
end();
2312 replacementForces =
f;
2318 for (
int i = 0; i <
numAtoms; ++i )
2320 f_saved[ftag][i] =
f[ftag][i];
2325 void HomePatch::sort_solvent_atoms() {
2326 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED) 2338 numSolventAtoms = 0;
2342 if (a[i].
isWater) numSolventAtoms++;
2345 numSoluteAtoms =
numAtoms - numSolventAtoms;
2356 atom.
swap(sortatom);
2359 numWaters = numSolventAtoms / 3;
2380 p->
maxAtoms = ((natoms + padding - 1) / padding) * padding;
2391 (numdoubles *
sizeof(double) + 9*
sizeof(
float) + 17*
sizeof(int));
2402 p->
buffer = (
unsigned char *) mybuffer;
2403 unsigned char *t = p->
buffer;
2404 p->
pos_x = (
double *) t;
2406 p->
pos_y = (
double *) t;
2408 p->
pos_z = (
double *) t;
2430 p->
sigId = (
int *) t;
2436 p->
vel_x = (
double *) t;
2438 p->
vel_y = (
double *) t;
2440 p->
vel_z = (
double *) t;
2450 p->
mass = (
float *) t;
2528 void HomePatch::copy_atoms_to_SOA() {
2532 size_t nbytes = patchDataSOA.
numBytes;
2534 #if defined(NAMD_CUDA) || defined(NAMD_HIP) 2545 patchDataSOA.
pos_x[i] = atom[i].position.x;
2546 patchDataSOA.
pos_y[i] = atom[i].position.y;
2547 patchDataSOA.
pos_z[i] = atom[i].position.z;
2548 patchDataSOA.
charge[i] = atom[i].charge;
2549 patchDataSOA.
vdwType[i] = int(atom[i].vdwType);
2558 patchDataSOA.
id[i] = int(atom[i].
id);
2559 #ifdef MEM_OPT_VERSION 2560 patchDataSOA.
exclId[i] = int(atom[i].exclId);
2561 patchDataSOA.
sigId[i] = int(atom[i].sigId);
2563 patchDataSOA.
atomFixed[i] = int(atom[i].atomFixed);
2564 patchDataSOA.
groupFixed[i] = int(atom[i].groupFixed);
2566 patchDataSOA.
vel_x[i] = atom[i].velocity.x;
2567 patchDataSOA.
vel_y[i] = atom[i].velocity.y;
2568 patchDataSOA.
vel_z[i] = atom[i].velocity.z;
2572 patchDataSOA.
mass[i] = atom[i].mass;
2574 patchDataSOA.
status[i] = atom[i].status;
2575 patchDataSOA.
transform_i[i] = atom[i].transform.i;
2576 patchDataSOA.
transform_j[i] = atom[i].transform.j;
2577 patchDataSOA.
transform_k[i] = atom[i].transform.k;
2583 calculate_derived_SOA();
2587 void HomePatch::calculate_derived_SOA() {
2590 patchDataSOA.
recipMass[i] = (atom[i].mass > 0 ? 1.f / atom[i].mass : 0);
2608 void HomePatch::copy_forces_to_SOA() {
2650 for (
int i = 0; i <
numAtoms; i++) {
2660 for (
int i = 0; i <
numAtoms; i++) {
2668 for (
int i = 0; i <
numAtoms; i++) {
2679 void HomePatch::copy_updates_to_AOS() {
2681 atom[i].velocity.x = patchDataSOA.
vel_x[i];
2682 atom[i].velocity.y = patchDataSOA.
vel_y[i];
2683 atom[i].velocity.z = patchDataSOA.
vel_z[i];
2684 atom[i].position.x = patchDataSOA.
pos_x[i];
2685 atom[i].position.y = patchDataSOA.
pos_y[i];
2686 atom[i].position.z = patchDataSOA.
pos_z[i];
2691 void HomePatch::copy_forces_to_AOS() {
2696 current_force[i].x = patchDataSOA.
f_slow_x[i];
2697 current_force[i].y = patchDataSOA.
f_slow_y[i];
2698 current_force[i].z = patchDataSOA.
f_slow_z[i];
2704 current_force[i].x = patchDataSOA.
f_nbond_x[i];
2705 current_force[i].y = patchDataSOA.
f_nbond_y[i];
2706 current_force[i].z = patchDataSOA.
f_nbond_z[i];
2712 current_force[i].x = patchDataSOA.
f_normal_x[i];
2713 current_force[i].y = patchDataSOA.
f_normal_y[i];
2714 current_force[i].z = patchDataSOA.
f_normal_z[i];
2721 void HomePatch::zero_global_forces_SOA() {
2727 #undef DEBUG_REDISTRIB_FORCE 2728 #undef DEBUG_REDISTRIB_FORCE_VERBOSE 2745 void HomePatch::redistrib_colinear_lp_force(
2749 BigReal distance = distance_f;
2754 distance *= r_jk_rlength;
2755 BigReal fdot = distance*(fi*r_jk)*r_jk_rlength*r_jk_rlength;
2756 const Vector fja = (1. + scale + distance)*fi - r_jk*fdot;
2757 const Vector fka = fi - fja;
2791 #define FIX_FOR_WATER 2792 void HomePatch::redistrib_relative_lp_force(
2795 Tensor *virial,
int midpt) {
2796 #ifdef DEBUG_REDISTRIB_FORCE 2798 foldnet = fi + fj + fk + fl;
2799 toldnet = cross(ri,fi) + cross(rj,fj) + cross(rk,fk) + cross(rl,fl);
2801 Vector fja(0), fka(0), fla(0);
2806 BigReal fdot = (fi*r) * invr2;
2813 s = rj - 0.5*(rk + rl);
2824 #if !defined(FIX_FOR_WATER) 2833 #if !defined(FIX_FOR_WATER) 2836 Vector ft = fi - fr - fp;
2846 fpdot = (fi*
p) / sqrt(p2);
2854 ft = cross(s,
v) * invs2;
2865 BigReal srdot = (s*r) * invs2;
2868 BigReal stdot = (s*t) * invs2;
2871 BigReal fact = rrdot*fpdot*invtt*invq;
2875 fja += fp*(1+srdot) + fq*stdot;
2877 ft = fq*(1+stdot) + fp*srdot;
2889 va +=
outer(fka,rk);
2890 va +=
outer(fla,rl);
2900 #ifdef DEBUG_REDISTRIB_FORCE 2901 #define TOL_REDISTRIB 1e-4 2903 fnewnet = fi + fj + fk + fl;
2904 tnewnet = cross(ri,fi) + cross(rj,fj) + cross(rk,fk) + cross(rl,fl);
2905 Vector fdiff = fnewnet - foldnet;
2906 Vector tdiff = tnewnet - toldnet;
2907 if (fdiff.
length2() > TOL_REDISTRIB*TOL_REDISTRIB) {
2908 printf(
"Error: force redistribution for water exceeded tolerance: " 2909 "fdiff=(%f, %f, %f)\n", fdiff.
x, fdiff.
y, fdiff.
z);
2911 if (tdiff.
length2() > TOL_REDISTRIB*TOL_REDISTRIB) {
2912 printf(
"Error: torque redistribution for water exceeded tolerance: " 2913 "tdiff=(%f, %f, %f)\n", tdiff.
x, tdiff.
y, tdiff.
z);
2918 void HomePatch::redistrib_ap_force(
Vector& fi,
Vector& fj) {
2923 fi = fi_old + fj_old;
2924 fj = fi_old + fj_old;
2936 void HomePatch::redistrib_lp_water_force(
2941 #ifdef DEBUG_REDISTRIB_FORCE 2945 Vector totforce, tottorque;
2946 totforce = f_ox + f_h1 + f_h2 + f_lp;
2947 tottorque = cross(f_ox, p_ox) + cross(f_h1, p_h1) + cross(f_h2, p_h2);
2950 tottorque += cross(f_lp, p_lp);
2956 Vector fad_ox(0), fad_h(0);
2959 Vector r_ox_lp = p_lp - p_ox;
2961 invlen2_r_ox_lp *= invlen2_r_ox_lp;
2962 BigReal rad_factor = (f_lp * r_ox_lp) * invlen2_r_ox_lp;
2963 Vector f_rad = r_ox_lp * rad_factor;
2968 Vector r_hcom_ox = p_ox - ( (p_h1 + p_h2) * 0.5 );
2982 Vector f_ang = f_lp - f_rad;
2986 BigReal invlen_r_hcom_ox = r_hcom_ox.rlength();
2987 BigReal oxcomp = (r_hcom_ox.length() - len_r_ox_lp) * invlen_r_hcom_ox;
2988 BigReal hydcomp = 0.5 * len_r_ox_lp * invlen_r_hcom_ox;
2990 fad_ox += (f_ang * oxcomp);
2991 fad_h += (f_ang * hydcomp);
2996 vir +=
outer(fad_h, p_h1);
2997 vir +=
outer(fad_h, p_h2);
2998 vir -=
outer(f_lp, p_lp);
3008 #ifdef DEBUG_REDISTRIB_FORCE 3010 Vector newforce, newtorque;
3011 newforce = f_ox + f_h1 + f_h2;
3012 newtorque = cross(f_ox, p_ox) + cross(f_h1, p_h1) + cross(f_h2, p_h2);
3013 Vector fdiff = newforce - totforce;
3014 Vector tdiff = newtorque - tottorque;
3016 if (error > 0.0001) {
3017 printf(
"Error: Force redistribution for water " 3018 "exceeded force tolerance: error=%f\n", error);
3020 #ifdef DEBUG_REDISTRIB_FORCE_VERBOSE 3021 printf(
"Error in net force: %f\n", error);
3025 if (error > 0.0001) {
3026 printf(
"Error: Force redistribution for water " 3027 "exceeded torque tolerance: error=%f\n", error);
3029 #ifdef DEBUG_REDISTRIB_FORCE_VERBOSE 3030 printf(
"Error in net torque: %f\n", error);
3053 void HomePatch::reposition_colinear_lonepair(
3057 BigReal distance = distance_f;
3061 if (r2 < 1e-10 || 100. < r2) {
3062 iout <<
iWARN <<
"Large/small distance between lonepair reference atoms: (" 3063 << rj <<
") (" << rk <<
")\n" <<
endi;
3065 ri = rj + (scale + distance*r_jk.
rlength())*r_jk;
3082 void HomePatch::reposition_relative_lonepair(
3086 if ( (rj-rk).length2() > 100. || (rj-rl).length2() > 100. ) {
3087 iout <<
iWARN <<
"Large distance between lonepair reference atoms: (" 3088 << rj <<
") (" << rk <<
") (" << rl <<
")\n" <<
endi;
3090 BigReal r, t,
p, cst, snt, csp, snp, invlen;
3093 if (distance >= 0) {
3119 ri.
x = rj.x + w.
x*a.
x + w.
y*b.
x + w.
z*c.
x;
3120 ri.
y = rj.y + w.
x*a.
y + w.
y*b.
y + w.
z*c.
y;
3121 ri.
z = rj.z + w.
x*a.
z + w.
y*b.
z + w.
z*c.
z;
3135 ri.
x = (mi * ri_old.
x + mj * rj_old.
x)/(mi + mj);
3136 ri.
y = (mi * ri_old.
y + mj * rj_old.
y)/(mi + mj);
3137 ri.
z = (mi * ri_old.
z + mj * rj_old.
z)/(mi + mj);
3143 void HomePatch::reposition_all_lonepairs(
void) {
3146 if (atom[i].mass < 0.01) {
3152 sprintf(errmsg,
"reposition lone pairs: " 3153 "no Lphost exists for LP %d\n", aid);
3161 sprintf(errmsg,
"reposition lone pairs: " 3162 "LP %d has some Lphost atom off patch\n", aid);
3167 reposition_colinear_lonepair(atom[i].position, atom[j.
index].position,
3171 reposition_relative_lonepair(atom[i].position, atom[j.
index].position,
3172 atom[k.
index].position, atom[l.
index].position,
3179 void HomePatch::reposition_all_alchpairs(
void) {
3183 for (
int i = 0; i <
numAtoms; i++) {
3185 alchPair_id = atom[i].id + numFepInitial;
3187 reposition_alchpair(atom[i].position, atom[j.
index].position, atom[i].mass, atom[j.
index].mass);
3197 pos[2] = pos[0] + (0.5 * (pos[3] + pos[4]) - pos[0]) * (r_om / r_ohc);
3201 vel[2] = (pos[2] - ref[2]) * invdt;
3219 pos[3] = pos[0] + (0.5 * (pos[1] + pos[2]) - pos[0]) * (r_om / r_ohc);
3224 vel[3] = (pos[3] - ref[3]) * invdt;
3231 void HomePatch::redistrib_lonepair_forces(
const int ftag,
Tensor *virial) {
3234 for (
int i = 0; i <
numAtoms; i++) {
3235 if (atom[i].mass < 0.01) {
3241 sprintf(errmsg,
"redistrib lone pair forces: " 3242 "no Lphost exists for LP %d\n", aid);
3250 sprintf(errmsg,
"redistrib lone pair forces: " 3251 "LP %d has some Lphost atom off patch\n", aid);
3256 redistrib_colinear_lp_force(f_mod[ftag][i], f_mod[ftag][j.
index],
3257 f_mod[ftag][k.
index], atom[i].position, atom[j.
index].position,
3262 redistrib_relative_lp_force(f_mod[ftag][i], f_mod[ftag][j.
index],
3264 atom[i].position, atom[j.
index].position,
3265 atom[k.
index].position, atom[l.
index].position, virial, midpt);
3271 void HomePatch::redistrib_alchpair_forces(
const int ftag) {
3278 for (
int i = 0; i <
numAtoms; i++) {
3280 alchPair_id = atom[i].id + numFepInitial;
3282 redistrib_ap_force(f_mod[ftag][i],f_mod[ftag][j.
index]);
3287 void HomePatch::redistrib_swm4_forces(
const int ftag,
Tensor *virial) {
3291 for (
int i = 0; i <
numAtoms; i++) {
3292 if (atom[i].mass < 0.01) {
3294 redistrib_lp_water_force(f_mod[ftag][i-2], f_mod[ftag][i+1],
3295 f_mod[ftag][i+2], f_mod[ftag][i],
3296 atom[i-2].position, atom[i+1].position,
3297 atom[i+2].position, atom[i].position, virial);
3302 void HomePatch::redistrib_tip4p_forces(
const int ftag,
Tensor* virial) {
3308 if (atom[i].mass < 0.01) {
3310 redistrib_lp_water_force(f_mod[ftag][i-3], f_mod[ftag][i-2],
3311 f_mod[ftag][i-1], f_mod[ftag][i],
3312 atom[i-3].position, atom[i-2].position,
3313 atom[i-1].position, atom[i].position, virial);
3321 const Force * __restrict force_arr,
3328 for (
int i = 0; i < num_atoms; ++i ) {
3329 if ( atom_arr[i].atomFixed ) {
3330 atom_arr[i].velocity = 0;
3332 BigReal dt_mass = dt * atom_arr[i].recipMass;
3333 atom_arr[i].velocity.x += force_arr[i].x * dt_mass;
3334 atom_arr[i].velocity.y += force_arr[i].y * dt_mass;
3335 atom_arr[i].velocity.z += force_arr[i].z * dt_mass;
3339 for (
int i = 0; i < num_atoms; ++i ) {
3340 BigReal dt_mass = dt * atom_arr[i].recipMass;
3341 atom_arr[i].velocity.x += force_arr[i].x * dt_mass;
3342 atom_arr[i].velocity.y += force_arr[i].y * dt_mass;
3343 atom_arr[i].velocity.z += force_arr[i].z * dt_mass;
3350 const Force * __restrict force_arr1,
3351 const Force * __restrict force_arr2,
3352 const Force * __restrict force_arr3,
3361 for (
int i = 0; i < num_atoms; ++i ) {
3362 if ( atom_arr[i].atomFixed ) {
3363 atom_arr[i].velocity = 0;
3365 BigReal rmass = atom_arr[i].recipMass;
3366 atom_arr[i].velocity.x += (force_arr1[i].x*dt1
3367 + force_arr2[i].x*dt2 + force_arr3[i].x*dt3) * rmass;
3368 atom_arr[i].velocity.y += (force_arr1[i].y*dt1
3369 + force_arr2[i].y*dt2 + force_arr3[i].y*dt3) * rmass;
3370 atom_arr[i].velocity.z += (force_arr1[i].z*dt1
3371 + force_arr2[i].z*dt2 + force_arr3[i].z*dt3) * rmass;
3375 for (
int i = 0; i < num_atoms; ++i ) {
3376 BigReal rmass = atom_arr[i].recipMass;
3377 atom_arr[i].velocity.x += (force_arr1[i].x*dt1
3378 + force_arr2[i].x*dt2 + force_arr3[i].x*dt3) * rmass;
3379 atom_arr[i].velocity.y += (force_arr1[i].y*dt1
3380 + force_arr2[i].y*dt2 + force_arr3[i].y*dt3) * rmass;
3381 atom_arr[i].velocity.z += (force_arr1[i].z*dt1
3382 + force_arr2[i].z*dt2 + force_arr3[i].z*dt3) * rmass;
3394 for (
int i = 0; i < num_atoms; ++i ) {
3395 if ( ! atom_arr[i].atomFixed ) {
3396 atom_arr[i].position.x += atom_arr[i].velocity.x * dt;
3397 atom_arr[i].position.y += atom_arr[i].velocity.y * dt;
3398 atom_arr[i].position.z += atom_arr[i].velocity.z * dt;
3402 for (
int i = 0; i < num_atoms; ++i ) {
3403 atom_arr[i].position.x += atom_arr[i].velocity.x * dt;
3404 atom_arr[i].position.y += atom_arr[i].velocity.y * dt;
3405 atom_arr[i].position.z += atom_arr[i].velocity.z * dt;
3416 const int fixedAtomsOn =
simParams->fixedAtomsOn;
3418 const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt;
3422 BigReal idz, zmin, delta_T, maxtime=timestep,v_Bond;
3428 double r_wall, r_wall_SQ, rab, rab_SQ, dr, mass_a, mass_b, mass_sum;
3429 Vector v_ab, vb_1, vp_1, vb_2, vp_2, new_vel_a, new_vel_b, new_pos_a, new_pos_b, *new_pos, *new_vel;
3430 double dot_v_r_1, dot_v_r_2;
3431 double vb_cm, dr_a, dr_b;
3437 nslabs =
simParams->pressureProfileSlabs;
3443 r_wall_SQ = r_wall*r_wall;
3446 if ( (0.05 < atom[i].mass) && ((atom[i].mass < 1.0)) ) {
3450 v_ab = atom[ib].position - atom[ia].position;
3451 rab_SQ = v_ab.
x*v_ab.
x + v_ab.
y*v_ab.
y + v_ab.
z*v_ab.
z;
3453 if (rab_SQ > r_wall_SQ) {
3455 if ( (rab > (2.0*r_wall)) && dieOnError ) {
3457 <<
"The drude is too far away from atom " 3458 << (atom[ia].id + 1) <<
" d = " << rab <<
"!\n" <<
endi;
3466 if ( fixedAtomsOn && atom[ia].atomFixed ) {
3467 if (atom[ib].atomFixed) {
3471 dot_v_r_2 = atom[ib].velocity.x*v_ab.
x 3472 + atom[ib].velocity.y*v_ab.
y + atom[ib].velocity.z*v_ab.
z;
3473 vb_2 = dot_v_r_2 * v_ab;
3474 vp_2 = atom[ib].velocity - vb_2;
3477 if(dot_v_r_2 == 0.0) {
3481 delta_T = dr/fabs(dot_v_r_2);
3482 if(delta_T > maxtime ) delta_T = maxtime;
3485 dot_v_r_2 = -dot_v_r_2*sqrt(kbt/atom[ib].mass)/fabs(dot_v_r_2);
3487 vb_2 = dot_v_r_2 * v_ab;
3489 new_vel_a = atom[ia].velocity;
3490 new_vel_b = vp_2 + vb_2;
3492 dr_b = -dr + delta_T*dot_v_r_2;
3494 new_pos_a = atom[ia].position;
3495 new_pos_b = atom[ib].position + dr_b*v_ab;
3499 mass_a = atom[ia].mass;
3500 mass_b = atom[ib].mass;
3501 mass_sum = mass_a+mass_b;
3503 dot_v_r_1 = atom[ia].velocity.x*v_ab.
x 3504 + atom[ia].velocity.y*v_ab.
y + atom[ia].velocity.z*v_ab.
z;
3505 vb_1 = dot_v_r_1 * v_ab;
3506 vp_1 = atom[ia].velocity - vb_1;
3508 dot_v_r_2 = atom[ib].velocity.x*v_ab.x
3509 + atom[ib].velocity.y*v_ab.y + atom[ib].velocity.z*v_ab.z;
3510 vb_2 = dot_v_r_2 * v_ab;
3511 vp_2 = atom[ib].velocity - vb_2;
3513 vb_cm = (mass_a*dot_v_r_1 + mass_b*dot_v_r_2)/mass_sum;
3520 if(dot_v_r_2 == dot_v_r_1) {
3524 delta_T = dr/fabs(dot_v_r_2 - dot_v_r_1);
3525 if(delta_T > maxtime ) delta_T = maxtime;
3529 v_Bond = sqrt(kbt/mass_b);
3532 dot_v_r_1 = -dot_v_r_1*v_Bond*mass_b/(fabs(dot_v_r_1)*mass_sum);
3533 dot_v_r_2 = -dot_v_r_2*v_Bond*mass_a/(fabs(dot_v_r_2)*mass_sum);
3535 dr_a = dr*mass_b/mass_sum + delta_T*dot_v_r_1;
3536 dr_b = -dr*mass_a/mass_sum + delta_T*dot_v_r_2;
3538 new_pos_a = atom[ia].position + dr_a*v_ab;
3539 new_pos_b = atom[ib].position + dr_b*v_ab;
3546 vb_1 = dot_v_r_1 * v_ab;
3547 vb_2 = dot_v_r_2 * v_ab;
3549 new_vel_a = vp_1 + vb_1;
3550 new_vel_b = vp_2 + vb_2;
3555 atom[ia].position = new_pos_a;
3556 atom[ib].position = new_pos_b;
3558 else if ( virial == 0 ) {
3559 atom[ia].velocity = new_vel_a;
3560 atom[ib].velocity = new_vel_b;
3563 for ( j = 0; j < 2; j++ ) {
3566 new_pos = &new_pos_a;
3567 new_vel = &new_vel_a;
3571 new_pos = &new_pos_b;
3572 new_vel = &new_vel_b;
3574 Force df = (*new_vel - atom[Idx].velocity) *
3575 ( atom[Idx].mass * invdt );
3578 atom[Idx].velocity = *new_vel;
3579 atom[Idx].position = *new_pos;
3585 int slab = (int)floor((z-zmin)*idz);
3586 if (slab < 0) slab += nslabs;
3587 else if (slab >= nslabs) slab -= nslabs;
3590 ppreduction->
item(ppoffset ) += vir.
xx;
3591 ppreduction->
item(ppoffset+1) += vir.
yy;
3592 ppreduction->
item(ppoffset+2) += vir.
zz;
3611 if ( dt && virial ) *virial += wc;
3617 #ifdef DEBUG_MINIMIZE 3619 printf(
"Step %d, patch %d: buildRattleList()\n",
3624 const int fixedAtomsOn =
simParams->fixedAtomsOn;
3625 const int useSettle =
simParams->useSettle;
3640 if ( ! settle_initialized ) {
3641 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
3643 if (atom[ig].rigidBondLength > 0) {
3653 if (atom[ig].mass < 0.5 || atom[ig+1].mass < 0.5) {
3660 atom[ig].rigidBondLength,
3661 atom[oatm].rigidBondLength,
3662 settle_mO, settle_mH,
3663 settle_mOrmT, settle_mHrmT, settle_ra,
3664 settle_rb, settle_rc, settle_rra);
3665 settle_initialized = 1;
3680 int posRattleParam = 0;
3687 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
3688 int hgs = atom[ig].hydrogenGroupSize;
3695 for (
int i = 0; i < hgs; ++i ) {
3696 ref[i] = atom[ig+i].position;
3697 rmass[i] = (atom[ig+i].mass > 0. ? 1. / atom[ig+i].mass : 0.);
3698 fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
3705 BigReal tmp = atom[ig].rigidBondLength;
3707 if (hgs != wathgsize) {
3709 sprintf(errmsg,
"Water molecule starting with atom %d contains %d atoms " 3710 "but the specified water model requires %d atoms.\n",
3711 atom[ig].
id+1, hgs, wathgsize);
3715 if (useSettle && !anyfixed) {
3720 if ( !(fixed[1] && fixed[2]) ) {
3721 dsq[icnt] = tmp * tmp;
3727 for (
int i = 1; i < hgs; ++i ) {
3728 if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
3729 if ( !(fixed[0] && fixed[i]) ) {
3730 dsq[icnt] = tmp * tmp;
3744 rattleListElem.
ig = ig;
3745 rattleListElem.
icnt = icnt;
3747 for (
int i = 0; i < icnt; ++i ) {
3751 rattleParamElem.
ia = a;
3752 rattleParamElem.
ib = b;
3753 rattleParamElem.
dsq = dsq[i];
3754 rattleParamElem.
rma = rmass[a];
3755 rattleParamElem.
rmb = rmass[b];
3759 for (
int i = icnt; i < 4; ++i ) {
3761 rattleParamElem.
ia = 0;
3762 rattleParamElem.
ib = 0;
3763 rattleParamElem.
dsq = 0;
3764 rattleParamElem.
rma = 0;
3765 rattleParamElem.
rmb = 0;
3769 for(
int i = 0; i < 4; ++i) {
3772 std::cout << std::endl;
3779 for (
int ig = 0; ig <
numAtoms; ++ig ) {
3780 Force df = (
velNew[ig] - atom[ig].velocity) * ( atom[ig].mass * invdt );
3784 atom[ig].velocity =
velNew[ig];
3794 return rattle1old(timestep, virial, ppreduction);
3802 const int fixedAtomsOn =
simParams->fixedAtomsOn;
3803 const int useSettle =
simParams->useSettle;
3805 const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt;
3816 for (
int j=0;j < n;j+=2) {
3819 for (
int i = 0; i < 3; ++i ) {
3820 ref[i] = atom[ig+i].position;
3821 pos[i] = atom[ig+i].position + atom[ig+i].velocity * dt;
3824 for (
int i = 0; i < 3; ++i ) {
3825 ref[i+3] = atom[ig+i].position;
3826 pos[i+3] = atom[ig+i].position + atom[ig+i].velocity * dt;
3829 settle_mOrmT, settle_mHrmT, settle_ra,
3830 settle_rb, settle_rc, settle_rra);
3833 for (
int i = 0; i < 3; ++i ) {
3834 velNew[ig+i] = (pos[i] - ref[i])*invdt;
3838 for (
int i = 0; i < 3; ++i ) {
3839 velNew[ig+i] = (pos[i+3] - ref[i+3])*invdt;
3847 for (
int i = 0; i < 3; ++i ) {
3848 ref[i] = atom[ig+i].position;
3849 pos[i] = atom[ig+i].position + atom[ig+i].velocity * dt;
3852 settle_mOrmT, settle_mHrmT, settle_ra,
3853 settle_rb, settle_rc, settle_rra);
3854 for (
int i = 0; i < 3; ++i ) {
3855 velNew[ig+i] = (pos[i] - ref[i])*invdt;
3873 int hgs = atom[ig].hydrogenGroupSize;
3874 for (
int i = 0; i < hgs; ++i ) {
3875 ref[i] = atom[ig+i].position;
3876 pos[i] = atom[ig+i].position;
3877 if (!(fixedAtomsOn && atom[ig+i].atomFixed)) {
3878 pos[i] += atom[ig+i].velocity * dt;
3908 tol2, maxiter, done, consFailure);
3921 for (
int i = 0; i < hgs; ++i ) {
3927 for (
int i = 0; i < hgs; ++i ) {
3928 velNew[ig+i] = (pos[i] - ref[i])*invdt;
3932 if ( consFailure ) {
3934 iout <<
iERROR <<
"Constraint failure in RATTLE algorithm for atom " 3935 << (atom[ig].id + 1) <<
"!\n" <<
endi;
3938 iout <<
iWARN <<
"Constraint failure in RATTLE algorithm for atom " 3939 << (atom[ig].id + 1) <<
"!\n" <<
endi;
3941 }
else if ( ! done ) {
3943 iout <<
iERROR <<
"Exceeded RATTLE iteration limit for atom " 3944 << (atom[ig].id + 1) <<
"!\n" <<
endi;
3947 iout <<
iWARN <<
"Exceeded RATTLE iteration limit for atom " 3948 << (atom[ig].id + 1) <<
"!\n" <<
endi;
3956 int hgs = atom[ig].hydrogenGroupSize;
3957 for (
int i = 0; i < hgs; ++i ) {
3958 velNew[ig+i] = atom[ig+i].velocity;
3959 posNew[ig+i] = atom[ig+i].position;
3964 for (
int ig = 0; ig <
numAtoms; ++ig )
3965 atom[ig].position =
posNew[ig];
3966 }
else if ( virial == 0 ) {
3967 for (
int ig = 0; ig <
numAtoms; ++ig )
3968 atom[ig].velocity =
velNew[ig];
3985 const int fixedAtomsOn =
simParams->fixedAtomsOn;
3986 const int useSettle =
simParams->useSettle;
3988 const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt;
3994 int ial[10], ibl[10];
4015 if ( ! settle_initialized ) {
4016 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
4018 if (atom[ig].rigidBondLength > 0) {
4028 if (atom[ig].mass < 0.5 || atom[ig+1].mass < 0.5) {
4035 atom[ig].rigidBondLength,
4036 atom[oatm].rigidBondLength,
4037 settle_mO, settle_mH,
4038 settle_mOrmT, settle_mHrmT, settle_ra,
4039 settle_rb, settle_rc, settle_rra);
4040 settle_initialized = 1;
4047 nslabs =
simParams->pressureProfileSlabs;
4052 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
4053 int hgs = atom[ig].hydrogenGroupSize;
4054 if ( hgs == 1 )
continue;
4057 for ( i = 0; i < hgs; ++i ) {
4058 ref[i] = atom[ig+i].position;
4059 pos[i] = atom[ig+i].position;
4060 vel[i] = atom[ig+i].velocity;
4061 rmass[i] = (atom[ig+i].mass > 0. ? 1. / atom[ig+i].mass : 0.);
4063 fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
4066 if ( fixed[i] ) { anyfixed = 1; rmass[i] = 0.; }
else pos[i] += vel[i] * dt;
4069 if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) {
4070 if (hgs != wathgsize) {
4072 sprintf(errmsg,
"Water molecule starting with atom %d contains %d atoms " 4073 "but the specified water model requires %d atoms.\n",
4074 atom[ig].
id+1, hgs, wathgsize);
4078 if (useSettle && !anyfixed) {
4089 settle1(ref+2, pos+2, vel+2, invdt,
4090 settle_mOrmT, settle_mHrmT, settle_ra,
4091 settle_rb, settle_rc, settle_rra);
4099 swm4_omrepos(ref, pos, vel, invdt);
4103 settle_mOrmT, settle_mHrmT, settle_ra,
4104 settle_rb, settle_rc, settle_rra);
4106 tip4_omrepos(ref, pos, vel, invdt);
4113 if ( invdt == 0 )
for ( i = 0; i < wathgsize; ++i ) {
4114 atom[ig+i].position = pos[i];
4115 }
else if ( virial == 0 )
for ( i = 0; i < wathgsize; ++i ) {
4116 atom[ig+i].velocity = vel[i];
4117 }
else for ( i = 0; i < wathgsize; ++i ) {
4118 Force df = (vel[i] - atom[ig+i].velocity) * ( atom[ig+i].mass * invdt );
4122 atom[ig+i].velocity = vel[i];
4129 int slab = (int)floor((z-zmin)*idz);
4130 if (slab < 0) slab += nslabs;
4131 else if (slab >= nslabs) slab -= nslabs;
4134 ppreduction->
item(ppoffset ) += vir.
xx;
4135 ppreduction->
item(ppoffset+1) += vir.
yy;
4136 ppreduction->
item(ppoffset+2) += vir.
zz;
4141 if ( !(fixed[1] && fixed[2]) ) {
4142 dsq[icnt] = tmp * tmp; ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
4145 for ( i = 1; i < hgs; ++i ) {
4146 if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
4147 if ( !(fixed[0] && fixed[i]) ) {
4148 dsq[icnt] = tmp * tmp; ial[icnt] = 0; ibl[icnt] = i; ++icnt;
4152 if ( icnt == 0 )
continue;
4153 for ( i = 0; i < icnt; ++i ) {
4154 refab[i] = ref[ial[i]] - ref[ibl[i]];
4156 for ( i = 0; i < hgs; ++i ) {
4161 for ( iter = 0; iter < maxiter; ++iter ) {
4165 for ( i = 0; i < icnt; ++i ) {
4166 int a = ial[i];
int b = ibl[i];
4167 Vector pab = pos[a] - pos[b];
4170 BigReal diffsq = rabsq - pabsq;
4171 if ( fabs(diffsq) > (rabsq * tol2) ) {
4174 if ( rpab < ( rabsq * 1.0e-6 ) ) {
4181 BigReal gab = diffsq / ( 2.0 * ( rma + rmb ) * rpab );
4185 if ( invdt != 0. ) {
4196 if ( consFailure ) {
4198 iout <<
iERROR <<
"Constraint failure in RATTLE algorithm for atom " 4199 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4202 iout <<
iWARN <<
"Constraint failure in RATTLE algorithm for atom " 4203 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4205 }
else if ( ! done ) {
4207 iout <<
iERROR <<
"Exceeded RATTLE iteration limit for atom " 4208 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4211 iout <<
iWARN <<
"Exceeded RATTLE iteration limit for atom " 4212 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4218 if ( invdt == 0 )
for ( i = 0; i < hgs; ++i ) {
4219 atom[ig+i].position = pos[i];
4220 }
else if ( virial == 0 )
for ( i = 0; i < hgs; ++i ) {
4221 atom[ig+i].velocity = vel[i] + rmass[i] * netdp[i];
4222 }
else for ( i = 0; i < hgs; ++i ) {
4223 Force df = netdp[i] * invdt;
4227 atom[ig+i].velocity = vel[i] + rmass[i] * netdp[i];
4232 int slab = (int)floor((z-zmin)*idz);
4233 if (slab < 0) slab += nslabs;
4234 else if (slab >= nslabs) slab -= nslabs;
4237 ppreduction->
item(ppoffset ) += vir.
xx;
4238 ppreduction->
item(ppoffset+1) += vir.
yy;
4239 ppreduction->
item(ppoffset+2) += vir.
zz;
4243 if ( dt && virial ) *virial += wc;
4253 const int fixedAtomsOn =
simParams->fixedAtomsOn;
4254 const int useSettle =
simParams->useSettle;
4262 int ial[10], ibl[10];
4275 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
4277 int hgs = atom[ig].hydrogenGroupSize;
4278 if ( hgs == 1 )
continue;
4281 for ( i = 0; i < hgs; ++i ) {
4282 ref[i] = atom[ig+i].position;
4283 vel[i] = atom[ig+i].velocity;
4284 rmass[i] = atom[ig+i].mass > 0. ? 1. / atom[ig+i].mass : 0.;
4285 fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
4286 if ( fixed[i] ) { anyfixed = 1; rmass[i] = 0.; }
4289 if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) {
4290 if (hgs != wathgsize) {
4291 NAMD_bug(
"Hydrogen group error caught in rattle2().");
4294 if (useSettle && !anyfixed) {
4303 settle2(atom[ig].mass, atom[ig+3].mass, ref+2, vel+2, dt, virial);
4310 settle2(atom[ig].mass, atom[ig+1].mass, ref, vel, dt, virial);
4315 for (i=0; i<hgs; i++) {
4316 atom[ig+i].velocity = vel[i];
4320 if ( !(fixed[1] && fixed[2]) ) {
4321 redmass[icnt] = 1. / (rmass[1] + rmass[2]);
4322 dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
4326 for ( i = 1; i < hgs; ++i ) {
4327 if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
4328 if ( !(fixed[0] && fixed[i]) ) {
4329 redmass[icnt] = 1. / (rmass[0] + rmass[i]);
4330 dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 0;
4331 ibl[icnt] = i; ++icnt;
4335 if ( icnt == 0 )
continue;
4337 for ( i = 0; i < icnt; ++i ) {
4338 refab[i] = ref[ial[i]] - ref[ibl[i]];
4342 for ( iter = 0; iter < maxiter; ++iter ) {
4344 for ( i = 0; i < icnt; ++i ) {
4345 int a = ial[i];
int b = ibl[i];
4346 Vector vab = vel[a] - vel[b];
4350 if ( (fabs(rvab) * dt * rabsqi) > tol ) {
4351 Vector dp = rab * (-rvab * redmass[i] * rabsqi);
4352 wc +=
outer(dp,rab);
4353 vel[a] += rmass[a] * dp;
4354 vel[b] -= rmass[b] * dp;
4363 NAMD_die(
"Exceeded maximum number of iterations in rattle2().");
4366 "Exceeded maximum number of iterations in rattle2().\n" <<
endi;
4370 for ( i = 0; i < hgs; ++i ) {
4371 atom[ig+i].velocity = vel[i];
4376 *virial += wc / ( 0.5 * dt );
4387 const int fixedAtomsOn =
simParams->fixedAtomsOn;
4388 const int useSettle =
simParams->useSettle;
4396 int ial[10], ibl[10];
4409 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
4411 int hgs = atom[ig].hydrogenGroupSize;
4412 if ( hgs == 1 )
continue;
4415 for ( i = 0; i < hgs; ++i ) {
4416 ref[i] = atom[ig+i].position;
4417 vel[i] = ( forces ? f1[ig+i] : atom[ig+i].velocity );
4419 fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
4420 if ( fixed[i] ) { anyfixed = 1; rmass[i] = 0.; }
4423 if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) {
4424 if (hgs != wathgsize) {
4425 NAMD_bug(
"Hydrogen group error caught in rattle2().");
4428 if (useSettle && !anyfixed) {
4437 settle2(1.0, 1.0, ref+2, vel+2, dt, virial);
4444 settle2(1.0, 1.0, ref, vel, dt, virial);
4449 for (i=0; i<hgs; i++) {
4450 ( forces ? f1[ig+i] : atom[ig+i].velocity ) = vel[i];
4454 if ( !(fixed[1] && fixed[2]) ) {
4455 redmass[icnt] = 1. / (rmass[1] + rmass[2]);
4456 dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
4460 for ( i = 1; i < hgs; ++i ) {
4461 if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
4462 if ( !(fixed[0] && fixed[i]) ) {
4463 redmass[icnt] = 1. / (rmass[0] + rmass[i]);
4464 dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 0;
4465 ibl[icnt] = i; ++icnt;
4469 if ( icnt == 0 )
continue;
4471 for ( i = 0; i < icnt; ++i ) {
4472 refab[i] = ref[ial[i]] - ref[ibl[i]];
4476 for ( iter = 0; iter < maxiter; ++iter ) {
4478 for ( i = 0; i < icnt; ++i ) {
4479 int a = ial[i];
int b = ibl[i];
4480 Vector vab = vel[a] - vel[b];
4484 if ( (fabs(rvab) * dt * rabsqi) > tol ) {
4485 Vector dp = rab * (-rvab * redmass[i] * rabsqi);
4486 wc +=
outer(dp,rab);
4487 vel[a] += rmass[a] * dp;
4488 vel[b] -= rmass[b] * dp;
4497 NAMD_die(
"Exceeded maximum number of iterations in rattle2().");
4500 "Exceeded maximum number of iterations in rattle2().\n" <<
endi;
4504 for ( i = 0; i < hgs; ++i ) {
4505 ( forces ? f1[ig+i] : atom[ig+i].velocity ) = vel[i];
4510 *virial += wc / ( 0.5 * dt );
4521 #ifdef DEBUG_MINIMIZE 4523 printf(
"Step %d, patch %d: buildRattleList_SOA()\n",
4532 const double * __restrict pos_x = patchDataSOA.
pos_x;
4533 const double * __restrict pos_y = patchDataSOA.
pos_y;
4534 const double * __restrict pos_z = patchDataSOA.
pos_z;
4535 const float * __restrict mass = patchDataSOA.
mass;
4536 const double * __restrict recipMass = patchDataSOA.
recipMass;
4537 const float * __restrict rigidBondLength = patchDataSOA.
rigidBondLength;
4541 const int fixedAtomsOn =
simParams->fixedAtomsOn;
4542 const int useSettle =
simParams->useSettle;
4553 if ( ! settle_initialized ) {
4554 for (
int ig = numSoluteAtoms;
4556 ig += hydrogenGroupSize[ig]) {
4558 if (rigidBondLength[ig] > 0) {
4568 if (mass[ig] < 0.5 || mass[ig+1] < 0.5) {
4575 rigidBondLength[ig],
4576 rigidBondLength[oatm],
4577 settle_mO, settle_mH,
4578 settle_mOrmT, settle_mHrmT, settle_ra,
4579 settle_rb, settle_rc, settle_rra);
4580 settle_initialized = 1;
4594 for (
int ig = 0; ig < numSoluteAtoms; ig += hydrogenGroupSize[ig]) {
4595 int hgs = hydrogenGroupSize[ig];
4597 NAMD_bug(
"Hydrogen group size 0. Exiting to avoid infinite loop\n.");
4598 }
else if ( hgs == 1 ) {
4605 BigReal tmp = rigidBondLength[ig];
4607 dsq[icnt] = tmp * tmp;
4612 for (
int i = 1; i < hgs; ++i ) {
4613 if ( ( tmp = rigidBondLength[ig+i] ) > 0 ) {
4614 dsq[icnt] = tmp * tmp;
4627 rattleListElem.
ig = ig;
4628 rattleListElem.
icnt = icnt;
4630 for (
int i = 0; i < icnt; ++i ) {
4634 rattleParamElem.
ia = a;
4635 rattleParamElem.
ib = b;
4636 rattleParamElem.
dsq = dsq[i];
4637 rattleParamElem.
rma = recipMass[ig+a];
4638 rattleParamElem.
rmb = recipMass[ig+b];
4642 for (
int i = icnt; i < 4; ++i )
4645 rattleParamElem.
ia = 0;
4646 rattleParamElem.
ib = 0;
4647 rattleParamElem.
dsq = 0;
4648 rattleParamElem.
rma = 0;
4649 rattleParamElem.
rmb = 0;
4671 double * __restrict pos_x = patchDataSOA.
pos_x;
4672 double * __restrict pos_y = patchDataSOA.
pos_y;
4673 double * __restrict pos_z = patchDataSOA.
pos_z;
4674 double * __restrict vel_x = patchDataSOA.
vel_x;
4675 double * __restrict vel_y = patchDataSOA.
vel_y;
4676 double * __restrict vel_z = patchDataSOA.
vel_z;
4677 double * __restrict posNew_x = patchDataSOA.
posNew_x;
4678 double * __restrict posNew_y = patchDataSOA.
posNew_y;
4679 double * __restrict posNew_z = patchDataSOA.
posNew_z;
4680 double * __restrict velNew_x = patchDataSOA.
velNew_x;
4681 double * __restrict velNew_y = patchDataSOA.
velNew_y;
4682 double * __restrict velNew_z = patchDataSOA.
velNew_z;
4684 #ifdef __INTEL_COMPILER 4685 __assume_aligned(pos_x,64);
4686 __assume_aligned(pos_y,64);
4687 __assume_aligned(pos_z,64);
4688 __assume_aligned(vel_x,64);
4689 __assume_aligned(vel_y,64);
4690 __assume_aligned(vel_z,64);
4691 __assume_aligned(posNew_x,64);
4692 __assume_aligned(posNew_y,64);
4693 __assume_aligned(posNew_z,64);
4694 __assume_aligned(velNew_x,64);
4695 __assume_aligned(velNew_y,64);
4696 __assume_aligned(velNew_z,64);
4697 __assume_aligned(hydrogenGroupSize,64);
4700 const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt;
4707 posNew_x[i] = pos_x[i] + vel_x[i] * dt;
4708 posNew_y[i] = pos_y[i] + vel_y[i] * dt;
4709 posNew_z[i] = pos_z[i] + vel_z[i] * dt;
4715 if (numSolventAtoms > 0) {
4716 int n = numSoluteAtoms;
4718 &posNew_x[n], &posNew_y[n], &posNew_z[n],
4720 settle_mOrmT, settle_mHrmT, settle_ra,
4721 settle_rb, settle_rc, settle_rra);
4731 &pos_x[ig], &pos_y[ig], &pos_z[ig],
4732 &posNew_x[ig], &posNew_y[ig], &posNew_z[ig],
4740 &pos_x[ig], &pos_y[ig], &pos_z[ig],
4741 &posNew_x[ig], &posNew_y[ig], &posNew_z[ig],
4747 &pos_x[ig], &pos_y[ig], &pos_z[ig],
4748 &posNew_x[ig], &posNew_y[ig], &posNew_z[ig],
4749 tol2, maxiter, done, consFailure);
4754 &pos_x[ig], &pos_y[ig], &pos_z[ig],
4755 &posNew_x[ig], &posNew_y[ig], &posNew_z[ig],
4763 if ( consFailure ) {
4765 iout <<
iERROR <<
"Constraint failure in RATTLE algorithm for atom " 4766 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4769 iout <<
iWARN <<
"Constraint failure in RATTLE algorithm for atom " 4770 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4772 }
else if ( ! done ) {
4774 iout <<
iERROR <<
"Exceeded RATTLE iteration limit for atom " 4775 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4778 iout <<
iWARN <<
"Exceeded RATTLE iteration limit for atom " 4779 << (atom[ig].id + 1) <<
"!\n" <<
endi;
4787 velNew_x[i] = (posNew_x[i] - pos_x[i]) * invdt;
4788 velNew_y[i] = (posNew_y[i] - pos_y[i]) * invdt;
4789 velNew_z[i] = (posNew_z[i] - pos_z[i]) * invdt;
4795 for (
int j=0; j < numNoconst; j++) {
4797 posNew_x[ig] = pos_x[ig];
4798 posNew_y[ig] = pos_y[ig];
4799 posNew_z[ig] = pos_z[ig];
4800 velNew_x[ig] = vel_x[ig];
4801 velNew_y[ig] = vel_y[ig];
4802 velNew_z[ig] = vel_z[ig];
4806 for (
int ig = 0; ig <
numAtoms; ++ig ) {
4807 pos_x[ig] = posNew_x[ig];
4808 pos_y[ig] = posNew_y[ig];
4809 pos_z[ig] = posNew_z[ig];
4812 else if ( virial == 0 ) {
4813 for (
int ig = 0; ig <
numAtoms; ++ig ) {
4814 vel_x[ig] = velNew_x[ig];
4815 vel_y[ig] = velNew_y[ig];
4816 vel_z[ig] = velNew_z[ig];
4820 const float * __restrict mass = patchDataSOA.
mass;
4821 double * __restrict f_normal_x = patchDataSOA.
f_normal_x;
4822 double * __restrict f_normal_y = patchDataSOA.
f_normal_y;
4823 double * __restrict f_normal_z = patchDataSOA.
f_normal_z;
4824 #ifdef __INTEL_COMPILER 4825 __assume_aligned(mass,64);
4826 __assume_aligned(f_normal_x,64);
4827 __assume_aligned(f_normal_y,64);
4828 __assume_aligned(f_normal_z,64);
4831 for (
int ig = 0; ig <
numAtoms; ig++) {
4832 BigReal df_x = (velNew_x[ig] - vel_x[ig]) * ( mass[ig] * invdt );
4833 BigReal df_y = (velNew_y[ig] - vel_y[ig]) * ( mass[ig] * invdt );
4834 BigReal df_z = (velNew_z[ig] - vel_z[ig]) * ( mass[ig] * invdt );
4835 f_normal_x[ig] += df_x;
4836 f_normal_y[ig] += df_y;
4837 f_normal_z[ig] += df_z;
4838 vir.
xx += df_x * pos_x[ig];
4839 vir.
xy += df_x * pos_y[ig];
4840 vir.
xz += df_x * pos_z[ig];
4841 vir.
yx += df_y * pos_x[ig];
4842 vir.
yy += df_y * pos_y[ig];
4843 vir.
yz += df_y * pos_z[ig];
4844 vir.
zx += df_z * pos_x[ig];
4845 vir.
zy += df_z * pos_y[ig];
4846 vir.
zz += df_z * pos_z[ig];
4849 for (
int ig = 0; ig <
numAtoms; ig++) {
4850 vel_x[ig] = velNew_x[ig];
4851 vel_y[ig] = velNew_y[ig];
4852 vel_z[ig] = velNew_z[ig];
4868 DebugM(2,
"loweAndersenVelocities\n");
4872 for (
int i = 0; i <
numAtoms; ++i) {
4875 v[i].position = atom[i].velocity;
4876 v[i].charge = atom[i].mass;
4878 DebugM(2,
"loweAndersenVelocities\n");
4883 DebugM(2,
"loweAndersenFinish\n");
4894 for (
int i = 0; i <
numAtoms; i++) {
4906 for (
int i = 0; i <
numAtoms; i++) {
4909 intRad[2*i+0] = rad - offset;
4910 intRad[2*i+1] = screen*(rad - offset);
4927 for (
int i = 0; i <
numAtoms; i++) {
4929 rhoi = rhoi0+coulomb_radius_offset;
4955 BigReal fij, expkappa, Dij, dEdai, dedasum;
4956 BigReal rhoi, rhoi0, psii, nbetapsi;
4957 BigReal gammapsi2, tanhi, daidr;
4958 for (
int i = 0; i <
numAtoms; i++) {
4962 expkappa = exp(-kappa*fij);
4963 Dij = epsilon_p_i - expkappa*epsilon_s_i;
4965 dEdai = -0.5*
COULOMB*atom[i].charge*atom[i].charge
4966 *(kappa*epsilon_s_i*expkappa-Dij/fij)/
bornRad[i];
4971 rhoi = rhoi0+coulomb_radius_offset;
4973 nbetapsi = -beta*psii;
4974 gammapsi2 = gamma*psii*psii;
4975 tanhi = tanh(psii*(delta+nbetapsi+gammapsi2));
4977 * (delta+nbetapsi+nbetapsi+gammapsi2+gammapsi2+gammapsi2);
4988 if (proxy.
size() > 0) {
4989 CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
4990 for (
int i = 0; i < proxy.
size(); i++) {
4991 int node = proxy[i];
5000 cp[node].recvData(msg);
5008 if (proxy.
size() > 0) {
5009 CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
5012 for (
int i = 0; i < proxy.
size(); i++) {
5013 int node = proxy[i];
5023 cp[node].recvData(msg);
5032 for (
int i = 0; i < msg->
psiSumLen; ++i ) {
5039 if (phase1BoxClosedCalled ==
true &&
5040 numGBISP1Arrived==proxy.
size() ) {
5047 numGBISP1Arrived == proxy.
size() &&
5048 numGBISP2Arrived == proxy.
size() &&
5049 numGBISP3Arrived == proxy.
size()) {
5060 for (
int i = 0; i < msg->
dEdaSumLen; ++i ) {
5067 if (phase2BoxClosedCalled ==
true &&
5068 numGBISP2Arrived==proxy.
size() ) {
5075 numGBISP1Arrived == proxy.
size() &&
5076 numGBISP2Arrived == proxy.
size() &&
5077 numGBISP3Arrived == proxy.
size()) {
5107 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
5108 int hgs = atom[ig].hydrogenGroupSize;
5109 if ( hgs == 1 )
continue;
5110 for ( i = 0; i < hgs; ++i ) {
5111 ref[i] = atom[ig+i].position;
5112 rmass[i] = 1. / atom[ig+i].mass;
5113 fixed[i] = (
simParams->fixedAtomsOn && atom[ig+i].atomFixed );
5114 if ( fixed[i] ) rmass[i] = 0.;
5119 if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) {
5121 NAMD_die(
"Hydrogen group error caught in mollyAverage(). It's a bug!\n");
5123 if ( !(fixed[1] && fixed[2]) ) {
5124 dsq[icnt] = tmp * tmp; ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
5127 for ( i = 1; i < hgs; ++i ) {
5128 if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
5129 if ( !(fixed[0] && fixed[i]) ) {
5130 dsq[icnt] = tmp * tmp; ial[icnt] = 0; ibl[icnt] = i; ++icnt;
5134 if ( icnt == 0 )
continue;
5136 molly_lambda.
resize(numLambdas);
5137 lambda = &(molly_lambda[numLambdas - icnt]);
5138 for ( i = 0; i < icnt; ++i ) {
5139 refab[i] = ref[ial[i]] - ref[ibl[i]];
5142 iter=
average(avg,ref,lambda,hgs,icnt,rmass,dsq,ial,ibl,refab,tol,maxiter);
5143 if ( iter == maxiter ) {
5144 iout <<
iWARN <<
"Exceeded maximum number of iterations in mollyAverage().\n"<<
endi;
5175 for (
int ig = 0; ig <
numAtoms; ig += atom[ig].hydrogenGroupSize ) {
5176 int hgs = atom[ig].hydrogenGroupSize;
5177 if (hgs == 1 )
continue;
5178 for ( i = 0; i < hgs; ++i ) {
5179 ref[i] = atom[ig+i].position;
5181 rmass[i] = 1. / atom[ig+i].mass;
5182 fixed[i] = (
simParams->fixedAtomsOn && atom[ig+i].atomFixed );
5183 if ( fixed[i] ) rmass[i] = 0.;
5187 if ( atom[ig].rigidBondLength > 0 ) {
5189 NAMD_die(
"Hydrogen group error caught in mollyMollify(). It's a bug!\n");
5191 if ( !(fixed[1] && fixed[2]) ) {
5192 ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
5195 for ( i = 1; i < hgs; ++i ) {
5196 if ( atom[ig+i].rigidBondLength > 0 ) {
5197 if ( !(fixed[0] && fixed[i]) ) {
5198 ial[icnt] = 0; ibl[icnt] = i; ++icnt;
5203 if ( icnt == 0 )
continue;
5204 lambda = &(molly_lambda[numLambdas]);
5206 for ( i = 0; i < icnt; ++i ) {
5207 refab[i] = ref[ial[i]] - ref[ibl[i]];
5210 mollify(avg,ref,lambda,force,hgs,icnt,rmass,ial,ibl,refab);
5212 for ( i = 0; i < hgs; ++i ) {
5223 checkpoint_atom.
copy(atom);
5227 #if NAMD_SeparateWaters != 0 5228 checkpoint_numWaterAtoms = numWaterAtoms;
5235 atom.
copy(checkpoint_atom);
5239 doAtomUpdate =
true;
5247 sort_solvent_atoms();
5248 copy_atoms_to_SOA();
5258 #if NAMD_SeparateWaters != 0 5259 numWaterAtoms = checkpoint_numWaterAtoms;
5266 const int remote =
simParams->scriptIntArg1;
5267 const char *key =
simParams->scriptStringArg1;
5274 NAMD_die(
"Unable to free checkpoint, requested key was never stored.");
5284 NAMD_die(
"Unable to load checkpoint, requested key was never stored.");
5296 msg->
replica = CmiMyPartition();
5303 const int remote =
simParams->scriptIntArg1;
5304 const char *key =
simParams->scriptStringArg1;
5306 NAMD_bug(
"HomePatch::recvCheckpointLoad called during checkpointFree.");
5308 if ( msg->
replica != remote ) {
5309 NAMD_bug(
"HomePatch::recvCheckpointLoad message from wrong replica.");
5313 strcpy(newmsg->
key,key);
5317 newmsg->
pe = CkMyPe();
5318 newmsg->
replica = CmiMyPartition();
5330 doAtomUpdate =
true;
5335 sort_solvent_atoms();
5336 copy_atoms_to_SOA();
5366 CkpvAccess(_qd)->process();
5398 CkpvAccess(_qd)->process();
5410 CkpvAccess(_qd)->process();
5411 doAtomUpdate =
true;
5417 sort_solvent_atoms();
5418 copy_atoms_to_SOA();
5441 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED) 5465 doPairlistCheck_newTolerance *= (1. -
simParams->pairlistShrink);
5466 doPairlistCheck_lattice =
lattice;
5469 for ( i=0; i<n; ++i ) { psave_i[i] = p_i[i]; }
5476 Lattice &lattice_old = doPairlistCheck_lattice;
5479 Vector center_delta = center_cur - center_old;
5483 for ( i=0; i<2; ++i ) {
5484 for (
int j=0; j<2; ++j ) {
5485 for (
int k=0; k<2; ++k ) {
5488 corner_delta -= center_delta;
5490 if ( cd > max_cd ) max_cd = cd;
5494 max_cd = sqrt(max_cd);
5499 for ( i=0; i<n; ++i ) {
5502 p_delta -= center_delta;
5504 if ( pd > max_pd ) max_pd = pd;
5506 max_pd = sqrt(max_pd);
5508 BigReal max_tol = max_pd + max_cd;
5514 if ( max_tol > ( (1. -
simParams->pairlistTrigger) *
5515 doPairlistCheck_newTolerance ) ) {
5518 doPairlistCheck_newTolerance *= (1. +
simParams->pairlistGrow);
5521 if ( max_tol > doPairlistCheck_newTolerance ) {
5524 doPairlistCheck_newTolerance = max_tol / (1. -
simParams->pairlistTrigger);
5545 double * __restrict pos_x = patchDataSOA.
pos_x;
5546 double * __restrict pos_y = patchDataSOA.
pos_y;
5547 double * __restrict pos_z = patchDataSOA.
pos_z;
5553 const int hgs = hydrogenGroupSize[j];
5556 if ( ngs > 5 ) ngs = 5;
5561 for ( i = 1; i < ngs; ++i ) {
5562 nonbondedGroupSize[j+i] = 0;
5566 BigReal r2 = dx * dx + dy * dy + dz * dz;
5567 if ( r2 > hgcut )
break;
5568 else if ( r2 > maxrad2 ) maxrad2 = r2;
5570 nonbondedGroupSize[j] = i;
5571 for ( ; i < hgs; ++i ) {
5572 nonbondedGroupSize[j+i] = 1;
5578 NAMD_bug(
"hydrogenGroupSize is zero in HomePatch::doGroupSizeCheck");
5601 while ( p_i != p_e ) {
5605 if ( ngs > 5 ) ngs = 5;
5610 for ( i = 1; i < ngs; ++i ) {
5615 BigReal r2 = dx * dx + dy * dy + dz * dz;
5616 if ( r2 > hgcut )
break;
5617 else if ( r2 > maxrad2 ) maxrad2 = r2;
5620 for ( ; i < hgs; ++i ) {
5627 NAMD_bug(
"hydrogenGroupSize is zero in HomePatch::doGroupSizeCheck");
5649 if ( ( aAwayDist*sysdima < minSize*0.9999 ) ||
5650 ( bAwayDist*sysdimb < minSize*0.9999 ) ||
5651 ( cAwayDist*sysdimc < minSize*0.9999 ) ) {
5653 NAMD_die(
"Periodic cell has become too small for original patch grid!\n" 5654 "Possible solutions are to restart from a recent checkpoint,\n" 5655 "increase margin, or disable useFlexibleCell for liquid simulation.");
5660 BigReal margina = 0.5 * ( aAwayDist - cutoff / sysdima );
5661 BigReal marginb = 0.5 * ( bAwayDist - cutoff / sysdimb );
5662 BigReal marginc = 0.5 * ( cAwayDist - cutoff / sysdimc );
5664 if ( (margina < -0.0001) || (marginb < -0.0001) || (marginc < -0.0001) ) {
5665 NAMD_die(
"Periodic cell has become too small for original patch grid!\n" 5666 "There are probably many margin violations already reported.\n" 5667 "Possible solutions are to restart from a recent checkpoint,\n" 5668 "increase margin, or disable useFlexibleCell for liquid simulation.");
5678 int xdev, ydev, zdev;
5679 int problemCount = 0;
5681 double * __restrict pos_x = patchDataSOA.
pos_x;
5682 double * __restrict pos_y = patchDataSOA.
pos_y;
5683 double * __restrict pos_z = patchDataSOA.
pos_z;
5685 Vector pos(pos_x[i],pos_y[i],pos_z[i]);
5690 if (s.
x < minx) xdev = 0;
5691 else if (maxx <= s.
x) xdev = 2;
5694 if (s.
y < miny) ydev = 0;
5695 else if (maxy <= s.
y) ydev = 2;
5698 if (s.
z < minz) zdev = 0;
5699 else if (maxz <= s.
z) zdev = 2;
5702 if (mInfo[xdev][ydev][zdev]) {
5731 if ( ( aAwayDist*sysdima < minSize*0.9999 ) ||
5732 ( bAwayDist*sysdimb < minSize*0.9999 ) ||
5733 ( cAwayDist*sysdimc < minSize*0.9999 ) ) {
5735 NAMD_die(
"Periodic cell has become too small for original patch grid!\n" 5736 "Possible solutions are to restart from a recent checkpoint,\n" 5737 "increase margin, or disable useFlexibleCell for liquid simulation.");
5742 BigReal margina = 0.5 * ( aAwayDist - cutoff / sysdima );
5743 BigReal marginb = 0.5 * ( bAwayDist - cutoff / sysdimb );
5744 BigReal marginc = 0.5 * ( cAwayDist - cutoff / sysdimc );
5746 if ( (margina < -0.0001) || (marginb < -0.0001) || (marginc < -0.0001) ) {
5747 NAMD_die(
"Periodic cell has become too small for original patch grid!\n" 5748 "There are probably many margin violations already reported.\n" 5749 "Possible solutions are to restart from a recent checkpoint,\n" 5750 "increase margin, or disable useFlexibleCell for liquid simulation.");
5760 int xdev, ydev, zdev;
5761 int problemCount = 0;
5765 for ( ; p_i != p_e; ++p_i ) {
5770 if (s.
x < minx) xdev = 0;
5771 else if (maxx <= s.
x) xdev = 2;
5774 if (s.
y < miny) ydev = 0;
5775 else if (maxy <= s.
y) ydev = 2;
5778 if (s.
z < minz) zdev = 0;
5779 else if (maxz <= s.
z) zdev = 2;
5782 if (mInfo[xdev][ydev][zdev]) {
5800 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED) 5809 for (i=0; i<numNeighbors; i++) {
5825 int xdev, ydev, zdev;
5832 #if NAMD_SeparateWaters != 0 5834 int numLostWaterAtoms = 0;
5837 while ( atom_i != atom_e ) {
5854 j+=(atom_i+j)->hydrogenGroupSize ) {
5855 pos += (atom_i+j)->position;
5870 if (s.
x < minx) xdev = 0;
5871 else if (maxx <= s.
x) xdev = 2;
5874 if (s.
y < miny) ydev = 0;
5875 else if (maxy <= s.
y) ydev = 2;
5878 if (s.
z < minz) zdev = 0;
5879 else if (maxz <= s.
z) zdev = 2;
5884 if (mInfo[xdev][ydev][zdev]) {
5889 DebugM(3,
"Migrating atom " << atom_i->
id <<
" from patch " 5896 #if NAMD_SeparateWaters != 0 5904 int atomIndex = atom_i - atom_first;
5905 if (atomIndex < numWaterAtoms)
5906 numLostWaterAtoms++;
5914 if ( delnum ) { *(atom_i-delnum) = *atom_i; }
5922 #if NAMD_SeparateWaters != 0 5923 numWaterAtoms -= numLostWaterAtoms;
5928 DebugM(4,
"numAtoms " <<
numAtoms <<
" deleted " << delnum <<
"\n");
5929 atom.
del(delpos,delnum);
5942 DebugM(1,
"Draining migration buffer ("<<i<<
","<<
numMlBuf<<
")\n");
5949 if (!allMigrationIn) {
5950 DebugM(3,
"All Migrations NOT in, we are suspending patch "<<
patchID<<
"\n");
5951 migrationSuspended =
true;
5953 migrationSuspended =
false;
5955 allMigrationIn =
false;
5972 #if NAMD_SeparateWaters != 0 5991 for (mi = migrationList.
begin(); mi != migrationList.
end(); mi++) {
5992 DebugM(1,
"Migrating atom " << mi->
id <<
" to patch " 6000 j+=(mi+j)->hydrogenGroupSize ) {
6001 pos += (mi+j)->position;
6025 #endif // if (NAMD_SeparateWaters != 0) 6031 DebugM(3,
"Counter on " <<
patchID <<
" = " << patchMigrationCounter <<
"\n");
6032 if (!--patchMigrationCounter) {
6038 sort_solvent_atoms();
6039 copy_atoms_to_SOA();
6047 DebugM(3,
"All Migrations are in for patch "<<
patchID<<
"\n");
6048 allMigrationIn =
true;
6049 patchMigrationCounter = numNeighbors;
6050 if (migrationSuspended) {
6052 migrationSuspended =
false;
6066 #if NAMD_SeparateWaters != 0 6071 void HomePatch::separateAtoms() {
6083 if (atom.
size() < 0)
return;
6096 int nonWaterIndex = 0;
6103 if (IS_HYDROGEN_GROUP_WATER(hgs, mass)) {
6106 if (waterIndex != i) {
6107 atom[waterIndex ] = atom[i ];
6108 atom[waterIndex + 1] = atom[i + 1];
6109 atom[waterIndex + 2] = atom[i + 2];
6110 if (wathgsize > 3) atom[waterIndex + 3] = atom[i + 3];
6111 if (wathgsize > 4) atom[waterIndex + 4] = atom[i + 4];
6115 waterIndex += wathgsize;
6121 for (
int j = 0; j < hgs; j++)
6122 tempAtom[nonWaterIndex + j] = atom[i + j];
6124 nonWaterIndex += hgs;
6136 for (i = 0; i < nonWaterIndex; i++)
6137 atom[waterIndex + i] = tempAtom[i];
6140 numWaterAtoms = waterIndex;
6153 if (al.
size() <= 0)
return;
6155 const int orig_atomSize = atom.
size();
6156 const int orig_alSize = al.
size();
6159 atom.
resize(orig_atomSize + orig_alSize);
6162 #if 0 // version where non-waters are moved to scratch first 6184 const int orig_atom_numNonWaters = orig_atomSize - numWaterAtoms;
6185 tempAtom.resize(orig_atom_numNonWaters + al.
size());
6186 for (
int i = 0; i < orig_atom_numNonWaters; i++)
6187 tempAtom[i] = atom[numWaterAtoms + i];
6191 int atom_waterIndex = numWaterAtoms;
6192 int atom_nonWaterIndex = orig_atom_numNonWaters;
6194 while (i < orig_alSize) {
6199 NAMD_bug(
"HomePatch::mergeAtomList() not updated for migration groups!");
6203 if (IS_HYDROGEN_GROUP_WATER(hgs, mass)) {
6208 al[i].position =
lattice.
nearest(al[i].position, center, &(al[i].transform));
6209 Transform mother_transform = al[i].transform;
6214 al[i+1].transform = mother_transform;
6219 al[i+2].transform = mother_transform;
6222 atom[atom_waterIndex ] = al[i ];
6223 atom[atom_waterIndex + 1] = al[i + 1];
6224 atom[atom_waterIndex + 2] = al[i + 2];
6226 atom_waterIndex += 3;
6234 al[i].position =
lattice.
nearest(al[i].position, center, &(al[i].transform));
6235 Transform mother_transform = al[i].transform;
6238 for (
int j = 1; j < hgs; j++) {
6241 al[i+j].transform = mother_transform;
6245 for (
int j = 0; j < hgs; j++)
6246 tempAtom[atom_nonWaterIndex + j] = al[i + j];
6248 atom_nonWaterIndex += hgs;
6255 for (
int i = 0; i < atom_nonWaterIndex; i++)
6256 atom[atom_waterIndex + i] = tempAtom[i];
6259 numWaterAtoms = atom_waterIndex;
6283 int al_numWaterAtoms = 0;
6285 while (i < orig_alSize) {
6291 if (IS_HYDROGEN_GROUP_WATER(hgs, mass)) {
6292 al_numWaterAtoms += wathgsize;
6300 if (al_numWaterAtoms > 0) {
6301 for (i = orig_atomSize - 1; i >= numWaterAtoms; i--) {
6302 atom[i + al_numWaterAtoms] = atom[i];
6309 int atom_waterIndex = numWaterAtoms;
6310 int atom_nonWaterIndex = orig_atomSize + al_numWaterAtoms;
6312 while (i < orig_alSize) {
6317 NAMD_bug(
"HomePatch::mergeAtomList() not updated for migration groups!");
6321 if (IS_HYDROGEN_GROUP_WATER(hgs, mass)) {
6326 al[i].position =
lattice.
nearest(al[i].position, center, &(al[i].transform));
6327 Transform mother_transform = al[i].transform;
6332 al[i+1].transform = mother_transform;
6337 al[i+2].transform = mother_transform;
6340 atom[atom_waterIndex ] = al[i ];
6341 atom[atom_waterIndex + 1] = al[i + 1];
6342 atom[atom_waterIndex + 2] = al[i + 2];
6344 if (wathgsize > 3) atom[atom_waterIndex + 3] = al[i + 3];
6346 atom_waterIndex += wathgsize;
6354 al[i].position =
lattice.
nearest(al[i].position, center, &(al[i].transform));
6355 Transform mother_transform = al[i].transform;
6358 for (
int j = 1; j < hgs; j++) {
6361 al[i+j].transform = mother_transform;
6365 for (
int j = 0; j < hgs; j++)
6366 atom[atom_nonWaterIndex + j] = al[i + j];
6368 atom_nonWaterIndex += hgs;
6375 numWaterAtoms = atom_waterIndex;
6396 for (j=ii;j<i;j++) sum -= a[i][j]*b[j];
6400 for (i=n-1;i>=0;i--) {
6402 for (j=i+1;j<n;j++) sum -= a[i][j]*b[j];
6412 double big,dum,sum,temp;
6418 if ((temp=fabs(a[i][j])) > big) big=temp;
6419 if (big == 0.0)
NAMD_die(
"Singular matrix in routine ludcmp\n");
6425 for (k=0;k<i;k++) sum -= a[i][k]*a[k][j];
6432 sum -= a[i][k]*a[k][j];
6434 if ( (dum=vv[i]*fabs(sum)) >= big) {
6449 if (a[j][j] == 0.0) a[j][j]=
TINY;
6452 for (i=j+1;i<n;i++) a[i][j] *= dum;
6463 gqij[i][ial[i]]=2.0*refab[i];
6464 gqij[i][ibl[i]]=-gqij[i][ial[i]];
6470 int average(
CompAtom *qtilde,
const HGArrayVector &q,
BigReal *lambda,
const int n,
const int m,
const HGArrayBigReal &imass,
const HGArrayBigReal &length2,
const HGArrayInt &ial,
const HGArrayInt &ibl,
const HGArrayVector &refab,
const BigReal tolf,
const int ntrial) {
6508 G_q(refab,grhs,n,m,ial,ibl);
6509 for (k=1;k<=ntrial;k++) {
6518 multiplier = lambda[i];
6521 auxrhs[i][j]=multiplier*imass[j]*grhs[i][j];
6527 tmp[j]+=auxrhs[i][j];
6537 for ( i = 0; i < m; i++ ) {
6548 G_q(avgab,glhs,n,m,ial,ibl);
6552 iout<<
iINFO << glhs[i*n+0] <<
" " << glhs[i*n+1] <<
" " << glhs[i*n+2] << std::endl<<
endi;
6557 for (j=0; j<n; j++) {
6558 for (i=0; i<m;i++) {
6559 grhs2[i][j] = grhs[i][j]*imass[j];
6568 for (k1=0;k1<n;k1++) {
6569 fjac[i][j] += glhs[i][k1]*grhs2[j][k1];
6597 gij[i]=avgab[i]*avgab[i]-length2[i];
6602 for(i=0;i<m-1;i++) {
6615 for (i=0;i<m;i++) errf += fabs(fvec[i]);
6622 for (i=0;i<m;i++) p[i] = -fvec[i];
6636 <<
" " << lambda[1] <<
" " << lambda[2] << std::endl<<
endi;
6639 if (errx <= tolx)
break;
6646 iout<<
iINFO <<
"LAMBDA:" << lambda[0] <<
" " << lambda[1] <<
" " << lambda[2] << std::endl<<
endi;
6656 Vector zero(0.0,0.0,0.0);
6667 tmpforce[i]=imass[i]*force[i];
6673 for ( i = 0; i < m; i++ ) {
6677 G_q(avgab,glhs,n,m,ial,ibl);
6678 G_q(refab,grhs,n,m,ial,ibl);
6680 for (j=0; j<n; j++) {
6681 for (i=0; i<m;i++) {
6682 grhs2[i][j] = grhs[i][j]*imass[j];
6692 fjac[j][i] += glhs[i][k]*grhs2[j][k];
6703 aux[i]+=grhs[i][j]*tmpforce[j];
6713 y[j] += aux[i]*glhs[i][j];
6722 tmpforce2[i]=imass[i]*y[i];
6731 Vector tmpf = 2.0*lambda[j]*(tmpforce2[ial[j]]-tmpforce2[ibl[j]]);
6732 tmpforce[ial[j]] += tmpf;
6733 tmpforce[ibl[j]] -= tmpf;
6738 force[i]=tmpforce[i]+y[i];
void PatchDataSOA_set_buffer(PatchDataSOA *p, void *mybuffer)
void depositMigration(MigrateAtomsMsg *)
void copy(ResizeArray< Elem > &ra)
void recvCheckpointLoad(CheckpointAtomsMsg *msg)
template void settle1_SIMD< 1 >(const Vector *ref, Vector *pos, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
#define NAMD_EVENT_STOP(eon, id)
std::ostream & iINFO(std::ostream &s)
Data * clientOpen(int count=1)
int numNodesWithPatches(void)
void minimize_rattle2(const BigReal, Tensor *virial, bool forces=false)
void settle1_SOA(const double *__restrict ref_x, const double *__restrict ref_y, const double *__restrict ref_z, double *__restrict pos_x, double *__restrict pos_y, double *__restrict pos_z, int numWaters, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
void positionsReady_SOA(int doMigration=0)
NAMD_HOST_DEVICE Vector c() const
void registerProxy(RegisterProxyMsg *)
OwnerBox< Patch, Results > forceBox
static ProxyMgr * Object()
NAMD_HOST_DEVICE Position reverse_transform(Position data, const Transform &t) const
SortedArray< LSSSubsDat > & lssSubs(ComputeQMMgr *mgr)
int flLen[Results::maxNumForces]
BigReal max_a(int pid) const
const int * get_qmAtmIndx()
static BigReal dielectric_1
static void partition(int *order, const FullAtom *atoms, int begin, int end)
static PatchMap * Object()
void sendProxies(int pid, int *list, int n)
void registerIDsFullAtom(const FullAtom *begin, const FullAtom *end)
NAMD_HOST_DEVICE Tensor outer(const Vector &v1, const Vector &v2)
CompAtom * velocityPtrEnd
int32 numhosts
Either 2 or 3 host atoms, depending on LP type.
#define NAMD_SeparateWaters
DMK - Atom Separation (water vs. non-water)
SimParameters * simParameters
void addForceToMomentum(FullAtom *__restrict atom_arr, const Force *__restrict force_arr, const BigReal dt, int num_atoms) __attribute__((__noinline__))
void sendNodeAwareSpanningTree(ProxyNodeAwareSpanningTreeMsg *)
int rattle1(const BigReal, Tensor *virial, SubmitReduction *)
MigrationList migrationList
void rattle2(const BigReal, Tensor *virial)
void recvNodeAwareSpanningTree(ProxyNodeAwareSpanningTreeMsg *msg)
NAMD_HOST_DEVICE Position unscale(ScaledPosition s) const
void gbisComputeAfterP2()
void MSHAKEIterate(const int icnt, const RattleParam *rattleParam, const BigReal *refx, const BigReal *refy, const BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, const BigReal tol2, const int maxiter, bool &done, bool &consFailure)
void sendExchangeReq(int pid, int src)
std::ostream & endi(std::ostream &s)
CompAtom * avgPositionPtrEnd
void receiveResults(ProxyResultVarsizeMsg *msg)
char const *const NamdProfileEventStr[]
ExchangeAtomsMsg * exchange_msg
int32 maxAtoms
max number of atoms available, multiple of MAXFACTOR
#define PROXY_DATA_PRIORITY
std::ostream & iWARN(std::ostream &s)
virtual void boxClosed(int)
BigReal HGMatrixBigReal[MAXHGS][MAXHGS]
CompAtom * avgPositionList
void loweAndersenVelocities()
float * langScalVelBBK2
derived from langevinParam
void sortAtomsForCUDA(int *order, const FullAtom *atoms, int nfree, int n)
int add(const Elem &elem)
void recvCheckpointReq(int task, const char *key, int replica, int pe)
void exchangeCheckpoint(int scriptTask, int &bpc)
template void settle1_SIMD< 2 >(const Vector *ref, Vector *pos, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
Molecule stores the structural information for the system.
void positionsReady(int doMigration=0)
int32 * migrationGroupSize
int settle2(BigReal mO, BigReal mH, const Vector *pos, Vector *vel, BigReal dt, Tensor *virial)
std::vector< RattleList > rattleList
void patchLoad(PatchID id, int nAtoms, int timestep)
void setall(const Elem &elem)
void sendCheckpointAck(int pid, int dst, int dstpe)
static ProxyNodeAwareSpanningTreeMsg * getANewMsg(PatchID pid, NodeID nid, proxyTreeNode *tree, int size)
int berendsenPressure_count
void reorder(Elem *a, int n)
void settle1init(BigReal pmO, BigReal pmH, BigReal hhdist, BigReal ohdist, BigReal &mO, BigReal &mH, BigReal &mOrmT, BigReal &mHrmT, BigReal &ra, BigReal &rb, BigReal &rc, BigReal &rra)
initialize cached water properties
void doGroupSizeCheck_SOA()
void positionsReady_GPU(int doMigration=0, int startup=0)
int32 * hydrogenGroupSize
size_t numBytes
number of bytes allocated for soa_buffer
constexpr int getWaterModelGroupSize(const WaterModel &watmodel)
int rattle1_SOA(const BigReal, Tensor *virial, SubmitReduction *)
void updateAtomCount(const int n, const int reallocate)
BigReal HGArrayBigReal[MAXHGS]
float * gaussrand_x
fill with Gaussian distributed random numbers
int const * getLcpoParamType()
#define NAMD_EVENT_START(eon, id)
#define NAMD_GROUP_FIXED_MASK
void LINCS(const int icnt, const RattleParam *rattleParam, const BigReal *refx, const BigReal *refy, const BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, const BigReal tol2, const int maxiter, bool &done, bool &consFailure)
static int compDistance(const void *a, const void *b)
void unregisterProxy(UnregisterProxyMsg *)
NAMD_HOST_DEVICE BigReal length(void) const
NAMD_HOST_DEVICE Position apply_transform(Position data, const Transform &t) const
void NAMD_bug(const char *err_msg)
ResizeArray< FullAtom > atoms
template void rattlePair< 1 >(const RattleParam *rattleParam, const BigReal *refx, const BigReal *refy, const BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, bool &consFailure)
int oneAwayNeighbors(int pid, PatchID *neighbor_ids=0)
void mollify(CompAtom *qtilde, const HGArrayVector &q0, const BigReal *lambda, HGArrayVector &force, const int n, const int m, const HGArrayBigReal &imass, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab)
zVector HGMatrixVector[MAXHGS][MAXHGS]
BigReal min_c(int pid) const
std::map< std::string, checkpoint_t * > checkpoints
int numaway_c(void) const
double * vel_x
Jim recommends double precision velocity.
void submitLoadStats(int timestep)
void mollyMollify(Tensor *virial)
int rattle1old(const BigReal, Tensor *virial, SubmitReduction *)
NAMD_HOST_DEVICE ScaledPosition scale(Position p) const
void clientClose(int count=1)
void recvSpanningTree(int *t, int n)
LocalID localID(AtomID id)
NAMD_HOST_DEVICE BigReal length2(void) const
void replaceForces(ExtForce *f)
std::vector< int > settleList
#define NAMD_ATOM_FIXED_MASK
const_iterator const_begin(void) const
PatchID getPatchID() const
void sendMigrationMsgs(PatchID, MigrationInfo *, int)
int numaway_a(void) const
const Real * get_qmAtomGroup() const
NAMD_HOST_DEVICE Vector a_r() const
NAMD_HOST_DEVICE Vector b_r() const
void gbisComputeAfterP1()
NAMD_HOST_DEVICE Position nearest(Position data, ScaledPosition ref) const
void NAMD_die(const char *err_msg)
void sendNodeAwareSpanningTree()
void lubksb(HGMatrixBigReal &a, int n, HGArrayInt &indx, HGArrayBigReal &b)
static LdbCoordinator * Object()
BigReal min_a(int pid) const
CompAtom * avgPositionPtrBegin
NAMD_HOST_DEVICE Vector c_r() const
int berendsenPressure_count
static AtomMap * Object()
void sortAtomsForCUDA_SOA(int *__restrict order, int *__restrict unorder, const double *__restrict ax, const double *__restrict ay, const double *__restrict az, int nfree, int n)
NAMD_HOST_DEVICE Vector b() const
MigrateAtomsMsg * msgbuf[PatchMap::MaxOneAway]
int hardWallDrude(const BigReal, Tensor *virial, SubmitReduction *)
void saveForce(const int ftag=Results::normal)
void setGBISIntrinsicRadii()
std::vector< Vector > posNew
void buildRattleList_SOA()
int berendsenPressure_count
std::vector< RattleParam > rattleParam
void sendProxyData(ProxyDataMsg *, int, int *)
void sendSpanningTree(ProxySpanningTreeMsg *)
void sendCheckpointLoad(CheckpointAtomsMsg *msg, int dst, int dstpe)
double * recipMass
derived from mass
int settle1(const Vector *ref, Vector *pos, Vector *vel, BigReal invdt, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
optimized settle1 algorithm, reuses water properties as much as possible
void ludcmp(HGMatrixBigReal &a, int n, HGArrayInt &indx, BigReal *d)
void sendProxyList(int pid, int *plist, int size)
#define NAMD_EVENT_START_EX(eon, id, str)
BigReal max_b(int pid) const
void sendProxyAll(ProxyDataMsg *, int, int *)
ForceList * forceList[Results::maxNumForces]
void G_q(const HGArrayVector &refab, HGMatrixVector &gqij, const int n, const int m, const HGArrayInt &ial, const HGArrayInt &ibl)
Elem * find(const Elem &elem)
OwnerBox< Patch, GBReal > dEdaSumBox
int find(const Elem &e) const
static float MassToRadius(Mass mi)
int flLen[Results::maxNumForces]
void del(int index, int num=1)
int numaway_b(void) const
static float MassToScreen(Mass mi)
void recvExchangeReq(int req)
CompAtomExt * positionExtList
void buildSpanningTree(void)
BigReal max_c(int pid) const
int numPatchesOnNode(int node)
void PatchDataSOA_initialize(PatchDataSOA *p)
BigReal pairlistTolerance
std::vector< Vector > velNew
void receiveResult(ProxyGBISP1ResultMsg *msg)
Lphost * get_lphost(int atomid) const
void rattleN(const int icnt, const RattleParam *rattleParam, const BigReal *refx, const BigReal *refy, const BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, const BigReal tol2, const int maxiter, bool &done, bool &consFailure)
void MSHAKE_CUDA(int *, const int size, const RattleParam *rattleParam, BigReal *refx, BigReal *refy, BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, const BigReal tol2, const int maxiter, bool &done, bool &consFailure)
std::ostream & iERROR(std::ostream &s)
#define SET_PRIORITY(MSG, SEQ, PRIO)
void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end)
zVector HGArrayVector[MAXHGS]
void registerPatch(int patchID, int numPes, int *pes)
size_t PatchDataSOA_set_size(PatchDataSOA *p, int natoms, int padding)
void addForceToMomentum3(FullAtom *__restrict atom_arr, const Force *__restrict force_arr1, const Force *__restrict force_arr2, const Force *__restrict force_arr3, const BigReal dt1, const BigReal dt2, const BigReal dt3, int num_atoms) __attribute__((__noinline__))
void addVelocityToPosition(FullAtom *__restrict atom_arr, const BigReal dt, int num_atoms) __attribute__((__noinline__))
std::vector< int > noconstList
ForceList f[Results::maxNumForces]
float * langScalRandBBK2
from langevinParam and recipMass
NAMD_HOST_DEVICE BigReal rlength(void) const
#define GB2_PROXY_DATA_PRIORITY
void swap(ResizeArray< Elem > &ra)
NAMD_HOST_DEVICE Vector a() const
void loweAndersenFinish()
int32 * nonbondedGroupSize
BigReal min_b(int pid) const
void addRattleForce(const BigReal invdt, Tensor &wc)
NAMD_HOST_DEVICE Vector unit(void) const
void sendCheckpointStore(CheckpointAtomsMsg *msg, int dst, int dstpe)
void positionsReady(int n=0, int startup=1)
NAMD_HOST_DEVICE Vector origin() const
void sendCheckpointReq(int pid, int remote, const char *key, int task)
void useSequencer(Sequencer *sequencerPtr)
static PatchMgr * Object()
OwnerBox< Patch, GBReal > psiSumBox
#define GB3_PROXY_DATA_PRIORITY
void sendExchangeMsg(ExchangeAtomsMsg *msg, int dst, int dstpe)
void recvCheckpointStore(CheckpointAtomsMsg *msg)
void recvExchangeMsg(ExchangeAtomsMsg *msg)
double * velNew_x
temp storage for rigid bond constraints
int average(CompAtom *qtilde, const HGArrayVector &q, BigReal *lambda, const int n, const int m, const HGArrayBigReal &imass, const HGArrayBigReal &length2, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab, const BigReal tolf, const int ntrial)
#define PATCH_PRIORITY(PID)
CompAtom * velocityPtrBegin
int32 numAtoms
number of atoms
void exchangeAtoms(int scriptTask)