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

OpenGL visualizer: Automatic particle sizes are incorrect for WCA interactions #4719

Closed
RiccardoFrenner opened this issue May 6, 2023 · 1 comment · Fixed by #4720
Closed

Comments

@RiccardoFrenner
Copy link
Contributor

When using WCA interactions and compiling Espresso without the LENNARD_JONES and with the WCA feature, the expression in this line evaluates to false since the radius will be 0.5. The reason for this is that the interaction does not have the lennard_jones attribute when not compiled with the feature.
However, if one compiles with LENNARD_JONES , it will have the attribute even if no LJ interaction is used. Thus the line above will set the radius to zero (since ia.lennard_jones.sigma is zero) and the issue will not appear.

This is a MWE:

import espressomd
import espressomd.visualization

system = espressomd.System(box_l=[20.0]*3)
system.time_step = 0.01
p0 = system.part.add(pos=[2.0, 2.0, 2.0], type=0)

# p0 will have a radius of 0.5 in visualization but should have 2.0
system.non_bonded_inter[0, 0].wca.set_params(
    epsilon=1.0, sigma=4.0)

visualizer = espressomd.visualization.openGLLive(
    system,
    particle_sizes="auto",
    window_size=[1024, 1024],
)

visualizer.screenshot("test.png")

I think one could just remove the radius == 0 check when there is a WCA interaction to make the above code work. But I am not sure if someone will have a problem if he has LJ and WCA interactions on the same particles.

@jngrad
Copy link
Member

jngrad commented May 8, 2023

My bad, I made a mistake when converting the try...except statement to an if...else chain.
The original code gave LJ precedence over WCA, so the fix has to set radius = 0.0 initially.

@kodiakhq kodiakhq bot closed this as completed in #4720 May 10, 2023
kodiakhq bot added a commit that referenced this issue May 10, 2023
Fixes #4719

Description of changes:
- extract the correct particle radius from the interaction list
jngrad pushed a commit to jngrad/espresso that referenced this issue Jul 13, 2023
Fixes espressomd#4719

Description of changes:
- extract the correct particle radius from the interaction list
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

Successfully merging a pull request may close this issue.

2 participants