Ultrafast demagnetization in bulk versus thin films: an ab initio study