14 #include "PIBeadAtoms.h"
16 extern CkVec <CProxy_AtomsCompute> UatomsComputeProxy;
23 PIBeadAtoms::PIBeadAtoms(
UberCollection _thisInstance,
int _numBeads,
int _natm) :thisInstance(_thisInstance),
24 numBeads(_numBeads), natm (_natm)
30 x=
new double[numBeads];
31 y=
new double[numBeads];
32 z=
new double[numBeads];
33 xu=
new double[numBeads];
34 yu=
new double[numBeads];
35 zu=
new double[numBeads];
36 fx=
new double[numBeads];
37 fy=
new double[numBeads];
38 fz=
new double[numBeads];
39 fxu=
new double[numBeads];
40 fyu=
new double[numBeads];
41 fzu=
new double[numBeads];
43 rat1 =
new double[numBeads];
44 rat2 =
new double[numBeads];
45 veig =
new double[numBeads];
53 for(
int ip=2;ip<=numBeads;ip++){
55 rat1[ip1] = ((double)(ip1))/((
double)(ip));
56 rat2[ip1] = 1.0/((double)(ip));
57 veig[ip1] = ((double)(ip))/((
double)(ip1));
76 void PIBeadAtoms::accept_PIMD_Fx(
AtomXYZMsg *msg)
79 fx[msg->index]=msg->x[thisIndex];
80 fy[msg->index]=msg->y[thisIndex];
81 fz[msg->index]=msg->z[thisIndex];
88 if(acceptCount_Fx==numBeads){
92 for(
int bead=0;bead<numBeads; bead++){
94 int proxyOffset=instance.setPO();
99 UatomsComputeProxy[proxyOffset].accept_PIMD_Fu(fxu[bead], fyu[bead], fzu[bead], thisIndex);
115 fx[msg->index]=msg->x[thisIndex];
116 fy[msg->index]=msg->y[thisIndex];
117 fz[msg->index]=msg->z[thisIndex];
118 x[msg->index]=msg->x[(thisIndex+natm)];
119 y[msg->index]=msg->y[(thisIndex+natm)];
120 z[msg->index]=msg->z[(thisIndex+natm)];
129 if(acceptCount_Fx==numBeads){
134 for(
int bead=0;bead<numBeads; bead++){
135 instance.idxU.x=bead;
136 int proxyOffset=instance.setPO();
141 UatomsComputeProxy[proxyOffset].accept_PIMD_Fu_and_u(fxu[bead], fyu[bead], fzu[bead],xu[bead], yu[bead], zu[bead], thisIndex);
153 void PIBeadAtoms::accept_PIMD_u(
double _xu,
double _yu,
double _zu,
int PIBeadIndex)
163 if(acceptCount_u==numBeads){
167 for(
int bead=0;bead<numBeads; bead++){
168 instance.idxU.x=bead;
169 int proxyOffset=instance.setPO();
172 UatomsComputeProxy[proxyOffset].accept_PIMD_x(x[bead], y[bead], z[bead], thisIndex);
185 void PIBeadAtoms::accept_PIMD_x(
double _x,
double _y,
double _z,
int PIBeadIndex )
195 if(acceptCount_x==numBeads){
199 for(
int bead=0;bead<numBeads; bead++){
200 instance.idxU.x=bead;
201 int proxyOffset=instance.setPO();
204 UatomsComputeProxy[proxyOffset].accept_PIMD_u(xu[bead],yu[bead],zu[bead], thisIndex);
217 void PIBeadAtoms::compute_PIMD_Fu()
223 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@@@\n");
224 CkPrintf(
"The number of beads must be >=0\n");
225 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@@@\n");
232 fxu[0] = 0.0; fyu[0] = 0.0; fzu[0] = 0.0;
233 for(
int ip=0;ip<numBeads;ip++){
234 fxu[0] += fx[ip]; fyu[0] += fy[ip]; fzu[0] += fz[ip];
236 fxu[1] = fx[1]; fyu[1] = fy[1]; fzu[1] = fz[1];
237 for(
int ip=1;ip<numBeads-1;ip++){
239 fxu[ip1] = fx[ip1] + rat1[ip]*fxu[ip];
240 fyu[ip1] = fy[ip1] + rat1[ip]*fyu[ip];
241 fzu[ip1] = fz[ip1] + rat1[ip]*fzu[ip];
244 fxu[0] = fx[0]; fyu[0] = fy[0]; fzu[0] = fz[0];
257 void PIBeadAtoms::compute_PIMD_u()
263 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@@@\n");
264 CkPrintf(
"The number of beads must be >=0\n");
265 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@@@\n");
272 xu[0] = x[0]; yu[0] = y[0]; zu[0] = z[0];
273 for(
int ip=1;ip<numBeads-1;ip++){
275 double xstar = rat1[ip]*x[ip1] + rat2[ip]*x[0];
276 double ystar = rat1[ip]*y[ip1] + rat2[ip]*y[0];
277 double zstar = rat1[ip]*z[ip1] + rat2[ip]*z[0];
278 xu[ip] = x[ip] - xstar;
279 yu[ip] = y[ip] - ystar;
280 zu[ip] = z[ip] - zstar;
283 xu[ip] = x[ip] - x[0];
284 yu[ip] = y[ip] - y[0];
285 zu[ip] = z[ip] - z[0];
287 xu[0] = x[0]; yu[0] = y[0]; zu[0] = z[0];
300 void PIBeadAtoms::compute_PIMD_x()
306 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@@@\n");
307 CkPrintf(
"The number of beads must be >=0\n");
308 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@@@\n");
316 x[0] = xu[0]; y[0] = yu[0]; z[0] = zu[0];
318 x[ip] = xu[ip] + x[0]; y[ip] = yu[ip] + y[0]; z[ip] = zu[ip] + z[0];
319 for(
int ip=numBeads-2;ip>=1;ip--){
321 double xadd = rat1[ip]*x[ip1]+xu[0]*rat2[ip];
322 double yadd = rat1[ip]*y[ip1]+yu[0]*rat2[ip];
323 double zadd = rat1[ip]*z[ip1]+zu[0]*rat2[ip];
324 x[ip] = xu[ip] + xadd;
325 y[ip] = yu[ip] + yadd;
326 z[ip] = zu[ip] + zadd;
329 x[0] = xu[0]; y[0] = yu[0]; z[0] = zu[0];
348 CkPrintf(
"\n/////////////////////////////////\n");
349 for(
int i =0;i<numBeads;i++){
350 CkPrintf(
"x[%d]: %g %g %g\n",i,x[i],y[i],z[i]);
352 CkPrintf(
"/////////////////////////////////\n\n");
369 CkPrintf(
"\n/////////////////////////////////\n");
370 for(
int i =0;i<numBeads;i++){
371 CkPrintf(
"u[%d]: %g %g %g\n",i,xu[i],yu[i],zu[i]);
373 CkPrintf(
"/////////////////////////////////\n\n");
390 for(
int i =0;i<numBeads;i++){
391 xu[i] = 0.0; yu[i] = 0.0; zu[i] = 0.0;;
408 for(
int i =0;i<numBeads;i++){
409 fxu[i] = 0.0; fyu[i] = 0.0; fzu[i] = 0.0;;
427 for(
int i =0;i<numBeads;i++){
428 x[i] = 0.0; y[i] = 0.0; z[i] = 0.0;;
447 int ip1 = numBeads-1;
449 ep = ( (x[ip]-x[ip1])*(x[ip]-x[ip1])
450 +(y[ip]-y[ip1])*(y[ip]-y[ip1])
451 +(z[ip]-z[ip1])*(z[ip]-z[ip1])
453 for(
int ip=1;ip<numBeads;ip++){
455 ep += ( (x[ip]-x[ip1])*(x[ip]-x[ip1])
456 +(y[ip]-y[ip1])*(y[ip]-y[ip1])
457 +(z[ip]-z[ip1])*(z[ip]-z[ip1])
460 CkPrintf(
"\n/////////////////////////////////\n");
461 CkPrintf(
"x energy %.10g\n",ep);
462 CkPrintf(
"/////////////////////////////////\n");
480 for(
int ip =1;ip<numBeads;ip++){
481 double fk = veig[ip];
482 ep += fk*(xu[ip]*xu[ip]
487 CkPrintf(
"\n/////////////////////////////////\n");
488 CkPrintf(
"u energy %.10g\n",ep);
489 CkPrintf(
"/////////////////////////////////\n");
507 printf(
"\n/////////////////////////////////\n");
512 double delta = 1.e-05;
513 for(
int ip =0;ip<numBeads;ip++){
538 printf(
"fu[%d]: %.10g %.10g : %.10g %.10g : %.10g %.10g\n",
539 ip,fxu[ip],0.5*(potmx-potpx)/delta,
540 fyu[ip],0.5*(potmy-potpy)/delta,
541 fzu[ip],0.5*(potmz-potpz)/delta);
544 printf(
"/////////////////////////////////\n");
563 for(
int ip =0;ip<numBeads;ip++){
564 pot += fk*(x[ip]*x[ip]
576 #include "PIBeadAtoms.def.h"
holds the UberIndex and the offset for proxies
Accepts reduction of forces from AtomsCache, integrates forces to produce new coordinates, distributes new coordinates to AtomsCache.
void output_PIMD_x()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void zero_PIMD_u()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void zero_PIMD_x()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void output_PIMD_u()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void energy_PIMD_x()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void accept_PIMD_Fx_and_x(AtomXYZMsg *msg)
void energy_PIMD_u()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void checkUforce()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void zero_PIMD_fu()
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...
void modelpot_PIMD_x(double *)
useful for debugging /////////////////////////////////////////////////////////////////////////// ////...