Skip to content
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 glitch through the box #4604

Closed
Koppeprojects opened this issue Nov 7, 2022 · 4 comments
Closed

Virtual sites glitch through the box #4604

Koppeprojects opened this issue Nov 7, 2022 · 4 comments

Comments

@Koppeprojects
Copy link

The virtual particles displace themselves to the neighboring periodic box images. But the folded positions are still correct.

import numpy as np
import espressomd
import espressomd.virtual_sites as evs

system = espressomd.System(box_l=3 * [5])
system.time_step = 0.01
system.cell_system.skin = 0.4e-6
system.virtual_sites = evs.VirtualSitesRelative(have_quaternion=True)
center_part = system.part.add(
    pos=3 * [2.5],
    rotation=[False, True, False],
    fix=[True, True, True],
    gamma=1,
    gamma_rot=1
)

pos_virt = np.array(center_part.pos) + [1, 0, 0]
virtual_partcl = system.part.add(pos=pos_virt, director=[1, 0, 0], virtual=True)
virtual_partcl.vs_auto_relate_to(center_part)

system.thermostat.set_brownian(
    kT=1,
    gamma=1,
    seed=42,
    act_on_virtual=False,
)
system.integrator.set_brownian_dynamics()

positions = []
positionsfolded = []
for _ in range(100):
    system.integrator.run(100)
    positions.append(virtual_partcl.pos)
    positionsfolded.append(virtual_partcl.pos_folded)
distancefolded = np.linalg.norm(center_part.pos - np.array(positionsfolded), axis=1)
np.testing.assert_allclose(distancefolded, 1)

distance = np.linalg.norm(center_part.pos - np.array(positions), axis=1)
np.testing.assert_allclose(distance, 1)
@Koppeprojects
Copy link
Author

For me I found a solution. I changed line 122 in the file VirtualSitesRelative.cpp from

fold_position(shift, image_shift, box_geo); 

to

fold_position(p.pos, image_shift, box_geo);

@jngrad
Copy link
Member

jngrad commented Nov 7, 2022

Thank you for this bug report. As I understand it, this bug was introduced in 4.3-dev. A bugfix was proposed in #4564 and merged into the walberla branch, which in turn will be merged in the python branch in a few weeks.

@RudolfWeeber
Copy link
Contributor

Simon, could you please check that this is indeed fixed in the Walberla branch?

@Koppeprojects
Copy link
Author

It is fixed, the minimal script runs smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants