You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The python interface currently allows overwriting bond objects. This is undefined behavior when a bond is overwritten by a bond of a different type. For example, when replacing a 2-center bond by a 3- or 4-center bond, the list of partners in the BondView is not updated and the force calculation will access span elements out of bounds. This bug can be fixed without impacting the collision detection feature (see #4225).
MWE:
importespressomd.interactionssystem=espressomd.System(box_l=[20.0, 20.0, 20.0])
p1, p2, p3, p4=system.part.add(pos=[[1, 0, 0], [0, 0, 0], [0, 1, 0], [1, 1, 0]])
system.time_step=0.01system.cell_system.skin=0.4system.bonded_inter[0] =espressomd.interactions.HarmonicBond(k=0.5, r_0=1.1)
p1.add_bond((system.bonded_inter[0], p2))
print(p1.bonds)
system.integrator.run(0, recalc_forces=True)
system.bonded_inter[0] =espressomd.interactions.Dihedral(mult=3, bend=5.2, phase=3.)
print(p1.bonds) # issue: there is only one bonded partner, but Dihedral needs 3 partnerssystem.integrator.run(0, recalc_forces=True) # segfault: access out of bounds
We can make the c++ bond classes hashable and use that as key for the bond.
That would also have the added benefit that if someone restores particles with bonds that are defined differently in the current system, we can catch it.
The angle bonding collision detection mode is the only remaining feature depending on consecutive bond numbering, afaik. It can probably be removed, though.
Fixes#4225Fixes#4377Fixes#4169
Description of changes:
- Bonded interactions are now stored as ScriptInterface objects, are immutable and can be removed
- It is no longer possible to overwrite a bond object by a different type of bond (avoids segmentation faults)
The python interface currently allows overwriting bond objects. This is undefined behavior when a bond is overwritten by a bond of a different type. For example, when replacing a 2-center bond by a 3- or 4-center bond, the list of partners in the
BondView
is not updated and the force calculation will access span elements out of bounds. This bug can be fixed without impacting the collision detection feature (see #4225).MWE:
Output in a debug build:
The text was updated successfully, but these errors were encountered: