diff --git a/BaseGrid.h b/BaseGrid.h index 716c6e335816f8c492824061ca4023dbc8d6eadb..1afc86928b8329eaaa55e5b00b449bf87faafa97 100644 --- a/BaseGrid.h +++ b/BaseGrid.h @@ -571,15 +571,19 @@ public: float v[2][2][2]; for (int iz = 0; iz < 2; iz++) { int jz = (iz + homeZ); - if (jz >= nz) jz = 0; + jz = (jz < 0) ? nz-1 : jz; + jz = (jz >= nz) ? 0 : jz; for (int iy = 0; iy < 2; iy++) { int jy = (iy + homeY); - if (jy >= ny) jy = 0; + jy = (jy < 0) ? ny-1 : jy; + jy = (jy >= ny) ? 0 : jy; for (int ix = 0; ix < 2; ix++) { int jx = (ix + homeX); - if (jx >= nx) jx = 0; + jx = (jx < 0) ? nx-1 : jx; + jx = (jx >= nx) ? 0 : jx; int ind = jz + jy*nz + jx*nz*ny; v[ix][iy][iz] = val[ind]; + // printf("%d %d %d: %d %f\n",ix,iy,iz,ind,val[ind]); looks OK } } } diff --git a/GrandBrownTown.cuh b/GrandBrownTown.cuh index 9ceb183132ed8cf686d770959439c31a99bf0722..671724a55f5417f023a73a57c582177c2c98690b 100644 --- a/GrandBrownTown.cuh +++ b/GrandBrownTown.cuh @@ -46,7 +46,8 @@ void updateKernel(Vector3* pos, Vector3* __restrict__ forceInternal, Vector3 forceExternal = Vector3(0.0f, 0.0f, pt.charge * electricField); // Compute PMF - ForceEnergy fe = pt.pmf->interpolateForceDLinearly(p); + // TODO: maybe make periodic and nonPeriodic versions of this kernel + ForceEnergy fe = pt.pmf->interpolateForceDLinearlyPeriodic(p); #ifndef FORCEGRIDOFF // Add a force defined via 3D FORCE maps (not 3D potential maps) @@ -70,6 +71,9 @@ void updateKernel(Vector3* pos, Vector3* __restrict__ forceInternal, // Update the particle's position using the calculated values for time, force, etc. float diffusion = pt.diffusion; Vector3 diffGrad = Vector3(0.0f); + // printf("force: %f %f %f %f %f %f\n", p.x, p.y, p.z, + // fe.f.x, fe.f.y, fe.f.z); + // // force.x, force.y, force.z); if (pt.diffusionGrid != NULL) { // printf("atom %d: pos: %f %f %f\n", idx, p.x, p.y, p.z);