Computing the workfunction