check_convergence function

Checks the convergence according to the convergence threshold