For the calculation of the work function within the framework of the DFT, consult [1,2,3,4]. Reference [4] concerns a simplified (semi-) analytic approach, approximating the solid as a semi-infinite uniform electron gas (i.e. jellium) of charge density equal to the average charge density of the solid whose work function is to be calculated. The ab initio calculations employ slab geometries, thereby to maintain periodicity and the applicability of the methods that use periodic boundary condition (for instance, use of the plane-wave basis functions vitally rely on this boundary condition).
For the calculation of the work function for 0D systems (quantum dots and nano structures), consider the definition of the work function in [1,2,3,4], which is independent of the dimensionality of the system.
[1] CJ Fall et al., J. Phys. C 11, 2689 (1999).
Article Deriving accurate work functions from thin-slab calculations
[2] NE Singh-Muller, and N Marzari, Phys. Rev. B 80, 235407 (2009).
Article Surface energies, work functions, and surface relaxations of...
[3] S Kajita et al., J. Phys.: Conf. Ser. 29, 120 (2006).
Article Density functional calculation of work function using charge...
[4] MV Mamonov, and VV Prudnikov, Russ. Phys. J. 41, 1174 (1998).
Article Calculation of the electron work function at metal surfaces ...
Langreth, D.C., Dion, M., Rydberg, H., Schröder, E., Hyldgaard, P. and Lundqvist, B.I., 2005. Van der Waals density functional theory with applications. International journal of quantum chemistry, 101(5), pp.599-610.