def bond_fpair
import bend-prot@0.1.0.0/bonded.bend as Bondedimport Base
import bend-prot@0.1.0.0/geom.bend as G
266# Bond forces: F = -2k(d-r0) * unit(pa-pb) on a, opposite on b; zero for
267# coincident or missing atoms. Per-atom loop over flat bonds.
268def bond_fpair(+d: G.Vec3, +d2: F32, +k: F32, +r0: F32) -> G.Vec3 & G.Vec3:
269 +r = F32.sqrt(d2)
270 +mag = Bool.pick(F32, F32.is_eq(d2, 0.0), 0.0, (((0.0 - (2.0 * k : F32) : F32) * (r - r0 : F32) : F32) / r : F32))
271 +fa = G.Vec3.scale(mag, d)
272 (fa, G.Vec3.neg(fa))