def bond_constraints(system):
    """For a openmm system, map constrained atom pairs to distances."""
    # this is ok
    bonds = {}
    nc = system.getNumConstraints()
    for c in range(nc):
        prm = system.getConstraintParameters(c)
        if len(prm) == 3:
            ia, ib, dd = prm
            ids = (ia, ib) if ib > ia else (ib, ia)
            bonds[ids] = dd
    return bonds