espressomd / espresso

The ESPResSo package
https://espressomd.org
GNU General Public License v3.0
226 stars 183 forks source link

Store bonds on all partners #4390

Open RudolfWeeber opened 2 years ago

RudolfWeeber commented 2 years ago

Current situation

Currently, a pair bond between particles p1 and p2 or a 3- or 4-particle bond between p1, p2, p3(, p4) is only stored on p1.

Advantages:

Disadvantages:

Proposed change

Steps:

Proposed Bonds Python interface

Example

harmonic = HarmonicBonx(...)
angle_harmonic = AngleHarmonic(...)

p1 = system.part.add(...)
p2 = system.part.add(...)
p3 = system.part.add(...)

system.bonds[harmonic].add((p1,p2))
system.bonds[harmonic].add((p2,p3))

assert (p1,p2) in system.bonds[harmonic] 
assert (p2,p1) in system.bonds[harmonic]

system.bonds[angle_harmonic].add((p2,p1,p3)) # p2 at the tip of the angle
andreashaertel commented 2 years ago

My only concern would be the size of additionally needed memory, if it were too large - what, I think, is not the case. Apart from this concern, the proposal sounds reasonable.