def subs_potentials(A,B,tol):
    """Difference between two sets of data of the same length
    Args:
        A/B: the arrays (2D)
        tol: the tolerence of the difference
    Returns:
        C: a new aaray (2D)
    """

    C = A
    for i in range(len(A)):
        C[i,0] = A[i,0]
        if abs(A[i,1] - B[i,1]) <= tol:
            C[i,1] = 0
        else:
            C[i,1] = A[i,1] - B[i,1]

    return C