dmalhotra / pvfmm

A parallel kernel-independent FMM library for particle and volume potentials
http://pvfmm.org
GNU Lesser General Public License v3.0
52 stars 29 forks source link

Issue with Periodic Boundary Conditions #18

Open iostanin1 opened 2 days ago

iostanin1 commented 2 days ago

Hi, I try to test periodic boundary conditions for the case of Laplace kernel (gradient)

f = - n (1/4pir^2)

and two charges in the unit cell:

q1(0.25,0.5,0.5) q2(0.75,0.5,0.5)

I specify X-periodicity. For truly periodic cell I expect to see the zero forces. If periodic BCs in pvfmm imply just one replication of unit cell in every direction, I expect to see the forces

(-0.0354,0,0), (0.0354,0,0)

But what I actually see is

(-0.0127,0,0), (0.0127,0,0)

Which I do not know how to interpret. I tried to increase the multipole order up to 20, but the forces remain the same. Free-space forces for the same geometry are (-0.3183,0,0), (0.3183,0,0), which is correct.

Could you comment on this - am I missing something or there is an issue? How the periodic BCs in pvfmm are supposed to work?

Best, Igor Ostanin.

dmalhotra commented 1 day ago

PVFMM does not support X-periodicity, it only supports either free-space or fully periodicity (periodic in all 3 directions).

You may be using the option PVFMM_EXTENDED_BC and then using X-periodicity. That option is meant to be only used with STKFMM. With that option, PVFMM adds two images on either side (not just one replication that you assumed). The remaining far-field would be added by STKFMM.

Let me know if you have any further questions.

iostanin1 commented 1 day ago

Dear Dhairya,

I still do not understand the behavior of periodic BCs.

Consider the story with default Lapace Gradient kernel and two charges in the elementary box: at r1 = (0.25,0.5,0.5), r2 = (0.75,0.5,0.5). Let us control x component acting on the particle 1 (f1_x).

If PVFMM_EXTENDED_BC = OFF, and we specify bndry = pvfmm::Periodic, then:

1) If the far-field is accounted, then for the geometry above I should see f1_x = 0, because of the symmetry of the problem. If there is no far field, just 26 images on every side of the unit box, then the straightforward computations (26 image cells, 53 sources + 1 target, 44 cancel out, 9 do not) lead to f_x1 = -0.171355. However, PFVMM gives -0.148718.

If PVFMM_EXTENDED_BC = ON, bndry = pvfmm::boundarytype::PXYZ, pvfmm returns -0.168301, which is closer, but still notably different irrespectively of multipole order.

If we use bndry = pvfmm::boundarytype::PX, and as we know there is no far field adjustment, the correct answer for f1_x is -0.0353677, while PVFMM result is -0.0127324.

I've recently coupled pvfmm with particle dynamics code (https://bitbucket.org/mercurydpm/mercurydpm/branch/pvfmmCoupling) and tried to model motion of multiple masses in a periodic box using PVFMM, and what I see is immediate collapse of masses to the center of the cube, which makes sense for a finite cell but is clearly artificial for the periodic one. That makes me think that I still do not undersand something about using PBCs in PVFMM.