12 #include "cp_state_ctrl/CP_State_GSpacePlane.h"
15 #include "CPcharmParaInfoGrp.h"
18 #include "src_piny_physics_v1.0/include/class_defs/Interface_ctrl.h"
19 #include "PhysScratchCache.h"
27 #include "src_piny_physics_v1.0/include/class_defs/piny_constants.h"
28 #include "src_piny_physics_v1.0/include/class_defs/ATOM_OPERATIONS/class_atomintegrate.h"
29 #include "src_piny_physics_v1.0/include/class_defs/ATOM_OPERATIONS/class_atomoutput.h"
30 #include "src_piny_physics_v1.0/include/class_defs/CP_OPERATIONS/class_cprspaceion.h"
34 extern CkVec <CProxy_PIBeadAtoms> UPIBeadAtomsProxy;
35 extern CkVec <IntMap2on2> GSImaptable;
36 extern CkVec <CProxy_EnergyGroup> UegroupProxy;
38 extern CkVec <CProxy_CP_State_GSpacePlane> UgSpacePlaneProxy;
39 extern CkVec <CProxy_GSpaceDriver> UgSpaceDriverProxy;
40 extern CkVec <CProxy_AtomsCache> UatomsCacheProxy;
41 extern CkVec <CProxy_AtomsCompute> UatomsComputeProxy;
42 extern CkVec <CProxy_EnergyGroup> UegroupProxy;
43 extern CkVec <CProxy_StructFactCache> UsfCacheProxy;
44 extern CkVec <CProxy_eesCache> UeesCacheProxy;
45 extern CProxy_TemperController temperControllerProxy;
47 extern CProxy_PhysScratchCache pScratchProxy;
66 AtomsCompute::AtomsCompute(
int n,
int n_nl,
int len_nhc_,
int iextended_on_,
int cp_min_opt_,
67 int cp_wave_opt_,
int isokin_opt_,
double kT_,
Atom* a,
AtomNHC *aNHC,
int nChareAtoms_,
68 UberCollection _thisInstance) : natm(n), natm_nl(n_nl), len_nhc(len_nhc_), iextended_on(iextended_on_), cp_min_opt(cp_min_opt_), cp_wave_opt(cp_wave_opt_), isokin_opt(isokin_opt_), kT(kT_), nChareAtoms(nChareAtoms_), thisInstance(_thisInstance)
84 atomsCMrecv=atomsPIMDXrecv=
false;
85 temperScreenFile = (UatomsCacheProxy[thisInstance.proxyOffset].ckLocalBranch())->temperScreenFile;
89 numPIMDBeads = config.UberImax;
90 PIBeadIndex = thisInstance.idxU.x;
91 TemperIndex = thisInstance.idxU.z;
92 atoms =
new Atom[natm];
94 AtomsCache *ag = UatomsCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
97 fastAtoms.q =
new double[natm];
98 fastAtoms.x =
new double[natm];
99 fastAtoms.y =
new double[natm];
100 fastAtoms.z =
new double[natm];
101 fastAtoms.fx =
new double[natm];
102 fastAtoms.fy =
new double[natm];
103 fastAtoms.fz =
new double[natm];
104 fastAtoms.fxu =
new double[natm];
105 fastAtoms.fyu =
new double[natm];
106 fastAtoms.fzu =
new double[natm];
107 for(
int i=0;i<natm;i++){
108 fastAtoms.x[i] = a[i].x;
109 fastAtoms.y[i] = a[i].y;
110 fastAtoms.z[i] = a[i].z;
111 fastAtoms.fx[i] = a[i].fx;
112 fastAtoms.fy[i] = a[i].fy;
113 fastAtoms.fz[i] = a[i].fz;
115 iteration = &(ag->iteration);
117 CmiMemcpy(atoms, a, natm *
sizeof(
Atom));
118 for(
int i=0;i<natm;i++){atomsNHC[i].Init(&aNHC[i]);}
119 ftot = (
double *)fftw_malloc((3*natm+2)*
sizeof(double));
122 if(iextended_on==1 && cp_min_opt==0){
130 double *qq = fastAtoms.q;
131 for(
int i=0;i<natm;i++){qq[i]=atoms[i].q;}
136 int nproc = nChareAtoms;
137 int div = (natm / nproc);
138 int rem = (natm % nproc);
141 for(
int myid=0;myid<nproc;myid++){
143 if(myid< rem){natmNow++;}
144 if(natmNow>0){nAtmMsgRecv++;}
151 massPIMDScal = (
double *)fftw_malloc(numPIMDBeads*
sizeof(
double));
170 delete [] fastAtoms.q;
171 delete [] fastAtoms.x;
172 delete [] fastAtoms.y;
173 delete [] fastAtoms.z;
174 delete [] fastAtoms.fx;
175 delete [] fastAtoms.fy;
176 delete [] fastAtoms.fz;
177 delete [] fastAtoms.fxu;
178 delete [] fastAtoms.fyu;
179 delete [] fastAtoms.fzu;
180 fftw_free(PIMD_CM_Atoms.x);
181 fftw_free(PIMD_CM_Atoms.y);
182 fftw_free(PIMD_CM_Atoms.z);
202 const int offset=thisInstance.getPO();
203 amBeadRoot = (CkMyPe()==GSImaptable[offset].get(0,0));
204 amZerothBead = (thisInstance.idxU.x==0);
209 CkArrayID *atomsArrayids=
new CkArrayID[numPIMDBeads];
210 CkArrayIndex **elems =
new CkArrayIndex*[numPIMDBeads];
211 CkArrayIndex **elemsAll =
new CkArrayIndex*[numPIMDBeads];
212 int *naelems =
new int[numPIMDBeads];
213 int *naelemsAll =
new int[numPIMDBeads];
214 for(
int i=0;i<numPIMDBeads;i++){
215 elems[i]=
new CkArrayIndex1D[1];
216 elemsAll[i]=
new CkArrayIndex1D[nChareAtoms];
219 naelemsAll[i]=nChareAtoms;
221 int offset=instance.calcPO();
222 elems[i][0]=CkArrayIndex1D(0);
223 for(
int j=0;j<nChareAtoms;j++)
224 elemsAll[i][j]=CkArrayIndex1D(j);
225 atomsArrayids[i]=UatomsComputeProxy[offset].ckGetArrayID();
229 proxyAllBeads=CProxySection_AtomsCompute(numPIMDBeads, atomsArrayids, elemsAll, naelemsAll);
231 delete [] naelemsAll;
232 for(
int i=0;i<numPIMDBeads;i++){
delete [] elems[i];
delete [] elemsAll[i];}
234 delete [] atomsArrayids;
252 #ifdef _CP_DEBUG_ATMS_
253 CkPrintf(
"{%d}[%d] AtomsCompute::recvContribute count %d\n ", thisInstance.proxyOffset, thisIndex, handleForcesCount);
259 int myid = thisIndex;
260 contribMsg[handleForcesCount++]=msg;
261 EnergyGroup *eg = UegroupProxy[thisInstance.proxyOffset].ckLocalBranch();
265 double *ftot = (
double *) msg->getData();
267 double pot_ewd_rs_loc = ftot[3*natm];
268 double potPerdCorrLoc = ftot[3*natm+1];
273 eg->estruct.eewald_real = pot_ewd_rs_loc;
276 #ifdef _CP_DEBUG_ATMS_EXIT_
277 if(myid==0){CkExit();}
279 if(handleForcesCount==2)
296 #ifdef _CP_DEBUG_ATMS_
297 CkPrintf(
"{%d}[%d] AtomsCompute::recvContributeForces count %d\n ", thisInstance.proxyOffset, thisIndex, handleForcesCount);
301 int myid = thisIndex;
302 contribMsg[handleForcesCount++]=msg;
304 #ifdef _CP_DEBUG_ATMS_EXIT_
305 if(myid==0){CkExit();}
308 if(handleForcesCount==2)
319 #ifdef _CP_DEBUG_ATMS_
320 CkPrintf(
"{%d}[%d] AtomsCompute::handleForces \n ", thisInstance.proxyOffset, thisIndex);
323 AtomsCache *ag = UatomsCacheProxy[thisInstance.proxyOffset].ckLocalBranch();
324 int iteration = ag->iteration;
330 EnergyGroup *eg = UegroupProxy[thisInstance.proxyOffset].ckLocalBranch();
334 double *ftot0 = (
double *) contribMsg[0]->getData();
335 double *ftot1 = (
double *) contribMsg[1]->getData();
339 for(i=0,j=0;i<natm;i++,j+=3){
340 atoms[i].fx = ftot0[j] + ftot1[j];
341 atoms[i].fy = ftot0[j+1] + ftot1[j+1];
342 atoms[i].fz = ftot0[j+2] + ftot1[j+2];
343 #ifdef _CP_DEBUG_ATMS_
346 CkPrintf(
"AtomCompute handleForces forces %d %.5g,%.5g,%.5g\n",i, atoms[i].fx, atoms[i].fy, atoms[i].fz);
349 fmag += atoms[i].fx * atoms[i].fx + atoms[i].fy * atoms[i].fy + atoms[i].fz * atoms[i].fz;
352 fmag /= (double)(3*natm);
354 eg->estruct.fmag_atm = fmag;
355 delete contribMsg[0];
356 delete contribMsg[1];
358 #ifdef _CP_DEBUG_PSI_OFF_
359 double omega = (0.0241888/15.0);
360 double omega2 = omega*omega;
363 px =
new double *[natm];
364 for(i =0;i<natm;i++){
365 px[i] =
new double[npts];
366 for(j=0;j<npts;j++){px[i][j]=0.0;}
376 atoms[i].fx = -omega2*atoms[i].x*atoms[i].m;
377 atoms[i].fy = -omega2*atoms[i].y*atoms[i].m;;
378 atoms[i].fz = -omega2*atoms[i].z*atoms[i].m;;
385 #ifdef _GLENN_CHECK_FORCES
386 FILE *fp = fopen(
"forces.save",
"w");
388 fprintf(fp,
"%.12g %.12g %.12g\n",atoms[i].fx,atoms[i].fy,atoms[i].fz);
422 #ifdef _CP_DEBUG_ATMS_
423 CkPrintf(
"GJM_DBG: Before atom integrate %d : %d\n",thisIndex,natm);
428 int mybead = thisInstance.idxU.x+1;
429 int myid = thisIndex;
431 EnergyGroup *eg = UegroupProxy[thisInstance.proxyOffset].ckLocalBranch();
439 int div = (natm / nChareAtoms);
440 int rem = (natm % nChareAtoms);
441 int natmStr = div*myid;
443 if(myid>=rem){natmStr += rem;}
444 if(myid< rem){natmStr += myid;}
445 if(myid< rem){natmNow++;}
446 int natmEnd = natmNow+natmStr;
451 double eKinetic_loc = 0.0;
452 double eKineticNhc_loc = 0.0;
453 double potNhc_loc = 0.0;
454 double potPIMDChain_loc = 0.0;
461 #ifdef _CP_DEBUG_PSI_OFF_
462 if(nChareAtoms>1 && numPIMDBeads>1){
463 CkPrintf(
"Harmonic oscillator debug test currently broken for PIMD\n");
464 CkPrintf(
"Need a reduction over beads of the chain energy\n");
467 double omega = (0.0241888/15.0);
468 double omega2 = omega*omega;
472 sigma = 1.0/sqrt(kT*atoms[0].m*omega2);
474 sigma = 1.0/sqrt(2.0*atoms[0].m*omega);
477 double dx = 6.0*sigma/(double)npts;
478 for(
int i=natmStr;i<natmEnd;i++){
479 int i1 = (atoms[i].x+3.0*sigma)/dx;
480 int i2 = (atoms[i].y+3.0*sigma)/dx;
481 int i3 = (atoms[i].z+3.0*sigma)/dx;
482 i1 = (i1 >= 0 ? i1 : 0);
483 i2 = (i2 >= 0 ? i2 : 0);
484 i3 = (i3 >= 0 ? i3 : 0);
485 i1 = (i1 < npts ? i1 : npts-1);
486 i2 = (i2 < npts ? i2 : npts-1);
487 i3 = (i3 < npts ? i3 : npts-1);
493 if(((*iteration+1) % 1000)==0){
494 for(
int i=natmStr;i<natmEnd;i++){
496 sprintf(fname,
"atmtest.dat.%d",i);
497 double anorm = sqrt(2.0/(sigma*sigma*acos(-1.0)));
498 FILE *fp = fopen(fname,
"w");
499 for(
int j =1;j<npts-1;j++){
500 double x = ((double)(2*j+1))*0.5*dx - 3.0*sigma;
501 double ans = anorm*exp(-0.5*x*x/(sigma*sigma));
502 double cnt = 3.0*((double)(*iteration+1));
503 fprintf(fp,
"%g %g %g\n",x,(px[i][j]*anorm/cnt),ans);
509 double pot_harm = 0.0;
510 for(
int i=natmStr;i<natmEnd;i++){
511 pot_harm += (atoms[i].m*omega2*(atoms[i].x*atoms[i].x+
512 atoms[i].y*atoms[i].y+
513 atoms[i].z*atoms[i].z));
524 if(numPIMDBeads>1 && cp_min_opt==0 && cp_wave_opt==0 && natmNow>0){
525 switchPIMDBeadForceMass(mybead,natmStr,natmEnd,&potPIMDChain_loc);
531 #ifndef _CP_DEBUG_SCALC_ONLY_
532 ATOMINTEGRATE::ctrl_atom_integrate(*iteration,natm,len_nhc,cp_min_opt,
533 cp_wave_opt,iextended_on,atoms,atomsNHC,myid,
534 &eKinetic_loc,&eKineticNhc_loc,&potNhc_loc,&iwrite_atm,
535 myoutput_on,natmNow,natmStr,natmEnd,mybead);
541 if(numPIMDBeads>1 && cp_min_opt==0 && cp_wave_opt==0 && natmNow>0){
542 unswitchPIMDMass(mybead,natmStr,natmEnd);
548 #ifdef _CP_DEBUG_PSI_OFF_
551 etot_atm = eKinetic_loc+eKineticNhc_loc+potNhc_loc+pot_harm+potPIMDChain_loc;
552 CkPrintf(
"iteration %d : tot class energy %.12g on %d\n",*iteration,etot_atm,myid);
554 etot_atm = eKineticNhc_loc+potNhc_loc;
555 CkPrintf(
"iteration %d : tot class energy %.12g %.12g on %d\n",*iteration,etot_atm,
556 (eKinetic_loc+pot_harm),myid);
566 if(cp_wave_opt==0 && cp_min_opt==0){
568 sendAtoms(eKinetic_loc,eKineticNhc_loc,potNhc_loc,potPIMDChain_loc,natmNow,natmStr,natmEnd);
577 eg->estruct.eKinetic_atm = 0.0;
578 eg->estruct.eKineticNhc_atm = 0.0;
579 eg->estruct.potNhc_atm = 0.0;
580 eg->estruct.potPIMDChain = 0.0;
586 CkCallback cb(CkIndex_AtomsCompute::atomsDone(NULL), CkArrayIndex1D(0), UatomsComputeProxy[thisInstance.proxyOffset]);
587 contribute(
sizeof(
int),&i,CkReduction::sum_int,cb);
604 #ifdef _CP_DEBUG_ATMS_
605 CkPrintf(
"{%d}[%d] AtomsCompute::startRealSpaceForces\n ", thisInstance.proxyOffset, thisIndex);
610 int myid = thisIndex;
611 int nproc = nChareAtoms;
621 #ifndef _CP_DEBUG_PSI_OFF_
622 #ifndef _CP_DEBUG_SCALC_ONLY_
623 CPRSPACEION::CP_getionforce(natm,&fastAtoms,myid,nproc,&pot_ewd_rs,&vself,&vbgr,&potPerdCorr, pScratchProxy.ckLocalBranch()->psscratch);
630 #ifdef _CP_DEBUG_ATMS_
631 CkPrintf(
"GJM_DBG: calling contribute atm forces %d\n",myid);
635 UatomsCacheProxy[thisInstance.proxyOffset].contributeforces();
637 double *ftot =
new double[(3*natm+2)];
638 for(
int i=0,j=0; i<natm; i++,j+=3){
639 ftot[j] = fastAtoms.fx[i];
640 ftot[j+1] = fastAtoms.fy[i];
641 ftot[j+2] = fastAtoms.fz[i];
643 ftot[3*natm] =pot_ewd_rs;
644 ftot[3*natm+1]=potPerdCorr;
645 CkCallback cb(CkIndex_AtomsCompute::recvContribute(NULL), UatomsComputeProxy[thisInstance.proxyOffset]);
646 contribute((3*natm+2)*
sizeof(
double),ftot,CkReduction::sum_double,cb);
661 EnergyGroup *eg = UegroupProxy[thisInstance.proxyOffset].ckLocalBranch();
664 double eKinetic = eg->estruct.eKinetic_atm;
665 double eKineticNhc = eg->estruct.eKineticNhc_atm;
666 double fmag = eg->estruct.fmag_atm;
667 double pot_ewd_rs_now = eg->estruct.eewald_real;
668 double potNhc = eg->estruct.potNhc_atm;
669 double free_atm = 3*((double)natm);
670 int iperd = sim->iperd;
674 fprintf(temperScreenFile,
"Iter [%d] EWALD_REAL = %5.8lf\n", *iteration, pot_ewd_rs_now);
675 fprintf(temperScreenFile,
"Iter [%d] EWALD_SELF = %5.8lf\n",*iteration, vself);
676 fprintf(temperScreenFile,
"Iter [%d] EWALD_BGR = %5.8lf\n",*iteration, vbgr);
678 fprintf(temperScreenFile,
"Iter [%d] EWALD_Perd = %5.8lf\n",*iteration, potPerdCorr);
681 fprintf(temperScreenFile,
"Iter [%d] ATM_COUL = %5.8lf\n",*iteration, pot_ewd_rs_now);
684 fprintf(temperScreenFile,
"Iter [%d] atm eKin = %5.8lf\n",*iteration, eKinetic);
685 fprintf(temperScreenFile,
"Iter [%d] atm Temp = %5.8lf\n",*iteration, (2.0*eKinetic*BOLTZ/free_atm));
686 fprintf(temperScreenFile,
"Iter [%d] atm fmag = %5.8lf\n",*iteration, fmag);
690 free_Nhc = free_atm*((double)len_nhc);
692 free_Nhc = free_atm*((double)(len_nhc-1));
694 fprintf(temperScreenFile,
"Iter [%d] atm eKinNhc = %5.8lf\n",*iteration, eKineticNhc);
695 fprintf(temperScreenFile,
"Iter [%d] atm TempNHC = %5.8lf\n",*iteration, (2.0*eKineticNhc*BOLTZ/free_Nhc));
696 fprintf(temperScreenFile,
"Iter [%d] atm potNHC = %5.8lf\n",*iteration, potNhc);
699 fprintf(temperScreenFile,
"Iter [%d] atm fmag = %5.8lf\n",*iteration, fmag);
718 for(
int atomI=0;atomI<natm;atomI++){
719 msg->x[atomI]=atoms[atomI].fx;
720 msg->y[atomI]=atoms[atomI].fy;
721 msg->z[atomI]=atoms[atomI].fz;
723 msg->index=PIBeadIndex;
724 UPIBeadAtomsProxy[thisInstance.proxyOffset].accept_PIMD_Fx(msg);
743 for(
int atomI=0;atomI<natm;atomI++){
744 msg->x[atomI]=atoms[atomI].fx;
745 msg->y[atomI]=atoms[atomI].fy;
746 msg->z[atomI]=atoms[atomI].fz;
749 for(
int atomI=0;atomI<natm;atomI++){
750 msg->x[(atomI+ioff)]=atoms[atomI].x;
751 msg->y[(atomI+ioff)]=atoms[atomI].y;
752 msg->z[(atomI+ioff)]=atoms[atomI].z;
754 msg->index=PIBeadIndex;
755 UPIBeadAtomsProxy[thisInstance.proxyOffset].accept_PIMD_Fx_and_x(msg);
781 double potPIMDChain_loc,
int natmNow,
int natmStr,
int natmEnd){
786 int nsize = 9*natmNow+4;
788 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
789 *(
int*)CkPriorityPtr(msg) = config.sfpriority-10;
791 double *atmData = msg->data;
793 msg->natmStr = natmStr;
794 msg->natmEnd = natmEnd;
799 for(
int i=natmStr,j=0;i<natmEnd;i++,j+=9){
800 atmData[(j) ]=atoms[i].x;
801 atmData[(j+1)]=atoms[i].y;
802 atmData[(j+2)]=atoms[i].z;
803 atmData[(j+3)]=atoms[i].xold;
804 atmData[(j+4)]=atoms[i].yold;
805 atmData[(j+5)]=atoms[i].zold;
806 atmData[(j+6)]=atoms[i].vxold;
807 atmData[(j+7)]=atoms[i].vyold;
808 atmData[(j+8)]=atoms[i].vzold;
814 atmData[(nsize-4)] = potPIMDChain_loc;
815 atmData[(nsize-3)] = eKinetic_loc;
816 atmData[(nsize-2)] = eKineticNhc_loc;
817 atmData[(nsize-1)] = potNhc_loc;
825 UatomsComputeProxy[thisInstance.proxyOffset].acceptAtoms(msg);
844 int nsize = 9*natm+4;
846 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
847 *(
int*)CkPriorityPtr(msg) = config.sfpriority-10;
849 double *atmData = msg->data;
857 for(
int i=0,j=0;i<natm;i++,j+=9){
858 atmData[(j) ]=atoms[i].x;
859 atmData[(j+1)]=atoms[i].y;
860 atmData[(j+2)]=atoms[i].z;
861 atmData[(j+3)]=atoms[i].xold;
862 atmData[(j+4)]=atoms[i].yold;
863 atmData[(j+5)]=atoms[i].zold;
864 atmData[(j+6)]=atoms[i].vxold;
865 atmData[(j+7)]=atoms[i].vyold;
866 atmData[(j+8)]=atoms[i].vzold;
868 EnergyGroup *eg = UegroupProxy[thisInstance.proxyOffset].ckLocalBranch();
869 atmData[nsize-4]=eg->estruct.eKinetic_atm;
870 atmData[nsize-3]=eg->estruct.eKineticNhc_atm;
871 atmData[nsize-2]=eg->estruct.potNhc_atm;
872 atmData[nsize-1]=eg->estruct.potPIMDChain;
880 UatomsCacheProxy[thisInstance.proxyOffset].acceptAtoms(msg);
899 double *atmData = msg->data;
900 int nsize = msg->nsize;
901 int natmStr = msg->natmStr;
902 int natmEnd = msg->natmEnd;
908 for(
int i=natmStr,j=0;i<natmEnd;i++,j+=9){
909 atoms[i].xu = atmData[(j) ];
910 atoms[i].yu = atmData[(j+1)];
911 atoms[i].zu = atmData[(j+2)];
912 atoms[i].xold = atmData[(j+3)];
913 atoms[i].yold = atmData[(j+4)];
914 atoms[i].zold = atmData[(j+5)];
915 atoms[i].vxold = atmData[(j+6)];
916 atoms[i].vyold = atmData[(j+7)];
917 atoms[i].vzold = atmData[(j+8)];
920 for(
int i=natmStr,j=0;i<natmEnd;i++,j+=9){
921 atoms[i].x = atmData[(j) ];
922 atoms[i].y = atmData[(j+1)];
923 atoms[i].z = atmData[(j+2)];
924 atoms[i].xold = atmData[(j+3)];
925 atoms[i].yold = atmData[(j+4)];
926 atoms[i].zold = atmData[(j+5)];
927 atoms[i].vxold = atmData[(j+6)];
928 atoms[i].vyold = atmData[(j+7)];
929 atoms[i].vzold = atmData[(j+8)];
932 #ifdef _CP_DEBUG_ATMS_
935 for(
int i=natmStr,j=0;i<natmEnd;i++,j+=9){
937 CkPrintf(
"AtomCompute acceptAtoms[%d] updated to %.5g,%.5g,%.5g from %.5g,%.5g,%.5g\n",i, atoms[i].x, atoms[i].y, atoms[i].z, atoms[i].xold, atoms[i].yold, atoms[i].zold);
952 potPIMDChain+= atmData[(nsize-4)];
953 eKinetic += atmData[(nsize-3)];
954 eKineticNhc += atmData[(nsize-2)];
955 potNhc += atmData[(nsize-1)];
965 if(countAtm==nAtmMsgRecv){
971 EnergyGroup *eg = UegroupProxy[thisInstance.proxyOffset].ckLocalBranch();
972 eg->estruct.eKinetic_atm = eKinetic;
973 eg->estruct.eKineticNhc_atm = eKineticNhc;
974 eg->estruct.potNhc_atm = potNhc;
975 eg->estruct.potPIMDChain = potPIMDChain;
985 int output_on = config.atmOutput;
986 if(output_on==1 && *iteration<=config.maxIter-1){
989 int myid = thisIndex;
990 ATOMOUTPUT::ctrl_piny_output(*iteration,natm,len_nhc,pi_beads,myid,atoms,atomsNHC,
991 &iwrite_atm,output_on,TemperIndex,PIBeadIndex);
992 if(myid==0 && iwrite_atm>0){
993 fprintf(temperScreenFile,
"-----------------------------------\n");
994 fprintf(temperScreenFile,
"Writing atoms to disk at time %d\n",*iteration);
995 fprintf(temperScreenFile,
"-----------------------------------\n");
1006 if(amBeadRoot && amZerothBead){
1008 for(
int atomI=0;atomI<natm;atomI++){
1009 msg->x[atomI]=atoms[atomI].xu;
1010 msg->y[atomI]=atoms[atomI].yu;
1011 msg->z[atomI]=atoms[atomI].zu;
1014 proxyAllBeads.accept_PIMD_CM(msg);
1019 CkCallback cb(CkIndex_AtomsCompute::atomsDone(NULL), CkArrayIndex1D(0), UatomsComputeProxy[thisInstance.proxyOffset]);
1020 contribute(
sizeof(
int),&i,CkReduction::sum_int,cb);
1029 void AtomsCompute::atomsDone(CkReductionMsg *msg)
1034 if(cp_wave_opt==0 && cp_min_opt==0)
1037 UatomsCacheProxy[thisInstance.proxyOffset].atomsDone();
1045 void AtomsCompute::accept_PIMD_CM(
AtomXYZMsg *msg){
1048 for(
int atomnum=0; atomnum<natm; atomnum++){
1049 atoms[atomnum].xcm = msg->x[atomnum];
1050 atoms[atomnum].ycm = msg->y[atomnum];
1051 atoms[atomnum].zcm = msg->z[atomnum];
1058 #ifdef _CP_DEBUG_ATMS_
1059 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_CM contributing to atomsDone atomsPIMDXrecv is %d iteration %d\n ", thisInstance.proxyOffset, thisIndex, atomsPIMDXrecv, *iteration);
1062 CkCallback cb(CkIndex_AtomsCompute::atomsDone(NULL), CkArrayIndex1D(0), UatomsComputeProxy[thisInstance.proxyOffset]);
1063 contribute(
sizeof(
int),&i,CkReduction::sum_int,cb);
1064 atomsCMrecv=atomsPIMDXrecv=
false;
1066 #ifdef _CP_DEBUG_ATMS_
1067 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_CM warning! atomsPIMDXrecv is %d iteration %d\n ", thisInstance.proxyOffset, thisIndex, atomsPIMDXrecv, *iteration);
1083 for(
int atomnum=0;atomnum<natm;atomnum++){
1084 UPIBeadAtomsProxy[thisInstance.proxyOffset][atomnum].accept_PIMD_u(
1085 atoms[atomnum].xu,atoms[atomnum].yu,atoms[atomnum].zu, PIBeadIndex);
1099 atoms[atomI].fxu =_fxu;
1100 atoms[atomI].fyu =_fyu;
1101 atoms[atomI].fzu =_fzu;
1104 #ifdef _CP_DEBUG_ATMS_
1105 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_fu (%d of %d) iteration %d %d %.5g %.5g %.5g\n",
1106 thisInstance.proxyOffset, thisIndex,acceptCountfu, natm, *iteration, atomI, _fxu, _fyu, _fzu);
1108 if(acceptCountfu==natm){
1124 double _xu,
double _yu,
double _zu,
int atomI){
1127 atoms[atomI].fxu =_fxu;
1128 atoms[atomI].fyu =_fyu;
1129 atoms[atomI].fzu =_fzu;
1131 atoms[atomI].xu =_xu;
1132 atoms[atomI].yu =_yu;
1133 atoms[atomI].zu =_zu;
1136 #ifdef _CP_DEBUG_ATMS_
1137 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_fu (%d of %d) iteration %d %d %.5g %.5g %.5g\n",
1138 thisInstance.proxyOffset, thisIndex,acceptCountfu, natm, *iteration, atomI, _fxu, _fyu, _fzu);
1140 if(acceptCountfu==natm){
1164 fastAtoms.x[atomI]=_x;
1165 fastAtoms.y[atomI]=_y;
1166 fastAtoms.z[atomI]=_z;
1170 if(acceptCountX==natm){
1172 atomsPIMDXrecv=
true;
1175 #ifdef _CP_DEBUG_ATMS_
1176 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_x contributing to atomsDone atomsCMrecv is %d iteration %d\n ", thisInstance.proxyOffset, thisIndex, atomsCMrecv, *iteration);
1178 CkCallback cb(CkIndex_AtomsCompute::atomsDone(NULL), CkArrayIndex1D(0), UatomsComputeProxy[thisInstance.proxyOffset]);
1180 contribute(
sizeof(
int),&i,CkReduction::sum_int,cb);
1181 atomsCMrecv=atomsPIMDXrecv=
false;
1183 #ifdef _CP_DEBUG_ATMS_
1184 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_x warning! atomsCMrecv is %d iteration %d\n", thisInstance.proxyOffset, thisIndex, atomsCMrecv, *iteration);
1202 for(
int atomnum=0;atomnum<natm;atomnum++){
1203 UPIBeadAtomsProxy[thisInstance.proxyOffset][atomnum].accept_PIMD_x(atoms[atomnum].x,atoms[atomnum].y,atoms[atomnum].z,
1211 void AtomsCompute::acceptNewTemperature(
double temp)
1216 contribute(
sizeof(
int), &i, CkReduction::sum_int,
1217 CkCallback(CkIndex_InstanceController::atomsDoneNewTemp(NULL),CkArrayIndex1D(thisInstance.proxyOffset),
instControllerProxy), thisInstance.proxyOffset);
1229 #ifdef _CP_DEBUG_ATMS_
1230 CkPrintf(
"{%d}[%d] AtomsCompute::accept_PIMD_u iteration %d\n", thisInstance.proxyOffset, thisIndex, *iteration);
1232 atoms[atomI].xu =_xu;
1233 atoms[atomI].yu =_yu;
1234 atoms[atomI].zu =_zu;
1237 if(acceptCountu==natm){
1246 #include "Atoms.def.h"
void outputAtmEnergy()
= Atom energy output
holds the UberIndex and the offset for proxies
void recvContributeForces(CkReductionMsg *)
recvContributeForces Every Array member has all the forces at present.
void accept_PIMD_Fu_and_u(double _fxu, double _fyu, double _fzu, double _xu, double _yu, double _zu, int atomI)
= is broadcast to us
Accepts reduction of forces from AtomsCache, integrates forces to produce new coordinates, distributes new coordinates to AtomsCache.
CProxy_InstanceController instControllerProxy
void send_PIMD_Fx_and_x()
void acceptAtoms(AtomMsg *)
Take packed message of a chunk of the atoms with updated positions.
void startRealSpaceForces()
trigger force computation based on real forces available in each processor's chare then contribute to...
Add type declarations for simulationConstants class (readonly vars) and once class for each type of o...
Author: Eric J Bohm Date Created: June 4th, 2006.
void accept_PIMD_u(double _ux, double _uy, double _uz, int atomI)
= done during initialization in 1st iteration
void recvContribute(CkReductionMsg *)
recvContribute Every Array member is sent all the forces at present.
~AtomsCompute()
Destructor.
void integrateAtoms()
Integrate atoms.
void send_PIMD_x()
= done during initialization in 1st iteration
void sendAtoms(double, double, double, double, int, int, int)
This thing is sending its updated atoms to all elements.
void accept_PIMD_Fu(double _fxu, double _fyu, double _fzu, int atomI)
= is broadcast to us
void accept_PIMD_x(double _x, double _y, double _z, int atomI)
void init()
= Bead root is the 0th element.
void bcastAtomsToAtomCache()
For dynamics we have to update all the caches with the new coordinates.