-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Virtual sites coordinates folding breaks with periodic boundary conditions #4703
Comments
Not sure I understand the problem statement. With periodic boundary conditions, particle coordinates are folded when negative. The virtual site is initially at position What is unclear to me though, is why the image count wildly varies during integration: import espressomd
import espressomd.virtual_sites
vs_distance = 2
system = espressomd.System(box_l =3*[100])
system.cell_system.skin = 0.1
system.time_step = 0.01
system.min_global_cut = 1.5 * vs_distance
system.virtual_sites = espressomd.virtual_sites.VirtualSitesRelative()
real_part = system.part.add(pos=[10.,10.,vs_distance/2.], director=[0,0,1])
virt_part = system.part.add(pos=[10.,10.,-vs_distance/2.], virtual=True)
virt_part.vs_auto_relate_to(real_part)
print("pos unfolded:", system.part.all().pos.tolist())
print("pos folded: ", system.part.all().pos_folded.tolist())
print("image box: ", system.part.all().image_box.tolist())
print("distance: ", system.distance(real_part, virt_part))
print("system.integrator.run(0)")
system.integrator.run(0)
print("pos unfolded:", system.part.all().pos.tolist())
print("pos folded: ", system.part.all().pos_folded.tolist())
print("image box: ", system.part.all().image_box.tolist())
print("distance: ", system.distance(real_part, virt_part))
print("real_part.director = [0,0,-1]")
real_part.director = [0,0,-1]
print("system.integrator.run(0)")
system.integrator.run(0)
print("pos unfolded:", system.part.all().pos.tolist())
print("pos folded: ", system.part.all().pos_folded.tolist())
print("image box: ", system.part.all().image_box.tolist())
print("distance: ", system.distance(real_part, virt_part)) Output on the walberla branch and on the 4.2.1 bugfix release candidate:
This looks suspicious to me. Output on the python branch:
This looks much better. @RudolfWeeber @pkreissl do you have an opinion on this? |
regarding the -1 to 99 change: I know that the folded position comes out correctly, but I would like the unfolded position to remain -1. Are positions folded into the original box when I add particles to the system? |
The regression was introduced in 4.2.1, python and walberla by #4564. The |
I wrote a unit test in python to check corner cases in aec1756, but I've barely scratched the surface. It doesn't consider e.g. the case where the LE shear offset makes either one of the particles, or both particles, go through an image box in the shear direction after application of the offset (we would need to write 8 cases), or the case where particles are initially at [0, 0, 0] instead of [1e-7, 0, 0], i.e. to cover the case of the LE offset being automatically applied at particle creation (due to inconsistent folding rules with the regular particle folding mechanism). Fully testing all corner cases would require writing at least 32 cases per direction, with 20 lines per case. To check the folding code after the real particle director gets flipped, one would need to multiply that number by 4. I don't think it is feasible. The current unit test only has 8 cases for LEbc, but it is already quite hard to read. Also, when running the unit test with multiple MPI ranks, the image box values are different, and I'm not sure why. In addition to that, the behavior requested in the OP would require not storing the minimal distance between the real particle and virtual site, but rather storing the distance in unfolded coordinates. This leads to new issues:
Yet, the current code cannot stay, because the image box counter keeps increasing at every time step. |
the way I read this is that LEbc and virtual sites do not play nice together. Would it be too bad if the two features were mutually exclusive? |
@bindgens1 @RudolfWeeber do you have any plans for virtual sites + LEbc? |
@christophlohrmann resp. @bindgens1 could you please confirm the bugfix in branches |
@jngrad your commit fixes the flip bug and passes all my bacteria-tests |
The ghost communication code seems to be broken. The I've updated both branches with a bugfix. |
Fixes #4703 Description of changes: - bugfix: virtual sites relative are now properly folded again (the regression was introduced by #4564) - bugfix: uninitialized virtual sites now throw a runtime error instead of implicitly tracking the particle with pid=0 - write more thorough tests for virtual sites relative: integration through periodic boundaries, checkpointing
Fixes espressomd#4703 Description of changes: - bugfix: virtual sites relative are now properly folded again (the regression was introduced by espressomd#4564) - bugfix: uninitialized virtual sites now throw a runtime error instead of implicitly tracking the particle with pid=0 - write more thorough tests for virtual sites relative: integration through periodic boundaries, checkpointing
This has a similar feel to the virtual sites that teleported through the boxes in Simon K's issue #4604 from a while back.
The text was updated successfully, but these errors were encountered: