Algorithm for diffuse coeff implemented in py