Rafael Nadal ground out a three-set victory over Tomas Berdych to end the Czech's hopes of reaching the semi-finals at the ATP World Tour Finals.