Computation of van der Waals effects in layered materials